-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathflake-edit.nix
More file actions
81 lines (75 loc) · 1.85 KB
/
flake-edit.nix
File metadata and controls
81 lines (75 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{
lib,
pkgs,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.flake-edit;
configFormat = pkgs.formats.toml { };
settingsFile =
let
settings = lib.filterAttrsRecursive (_n: v: v != null && v != [ ] && v != { }) cfg.settings;
in
if settings != { } then configFormat.generate "flake-edit.toml" settings else null;
in
{
meta = {
maintainers = [ "a-kenji" ];
};
imports = [
(mkFormatterModule {
name = "flake-edit";
args = [
"--non-interactive"
];
includes = [ "flake.nix" ];
})
];
options.programs.flake-edit = {
settings = {
follow = {
ignore = lib.mkOption {
description = ''
List of inputs to ignore when following.
Supports simple names ("systems") or full paths ("crane.nixpkgs").
'';
type = lib.types.listOf lib.types.str;
default = [ ];
example = [
"systems"
"crane.flake-utils"
];
};
aliases = lib.mkOption {
description = ''
Mapping of canonical input names to alternative names.
Allows nested inputs like "nixpkgs-lib" to follow "nixpkgs".
'';
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
default = { };
example = {
nixpkgs = [ "nixpkgs-lib" ];
};
};
};
};
noLock = lib.mkOption {
description = "Skip updating the lockfile after editing flake.nix";
type = lib.types.bool;
default = false;
};
};
config = lib.mkIf cfg.enable {
settings.formatter.flake-edit = {
options =
(lib.optionals (settingsFile != null) [
"--config"
(toString settingsFile)
])
++ (lib.optional cfg.noLock "--no-lock")
++ [ "follow" ];
};
};
}