confctl 2.2.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/.git-hooks/pre_commit/nixfmt.rb +13 -0
  3. data/.github/workflows/rspec.yml +64 -0
  4. data/.github/workflows/rubocop.yml +27 -0
  5. data/.github/workflows/tests.yml +139 -0
  6. data/.gitignore +12 -7
  7. data/.overcommit.yml +2 -0
  8. data/.rspec +1 -0
  9. data/.rubocop.yml +8 -1
  10. data/AGENTS.md +42 -0
  11. data/CHANGELOG.md +57 -0
  12. data/Gemfile +3 -2
  13. data/Gemfile.lock +198 -0
  14. data/README.md +166 -58
  15. data/Rakefile +5 -0
  16. data/confctl.gemspec +20 -2
  17. data/docs/carrier.md +3 -3
  18. data/docs/flake-inputs.md +159 -0
  19. data/docs/swpins-to-flakes.md +325 -0
  20. data/example/cluster/module-list.nix +2 -1
  21. data/example/cluster/nixos-machine/config.nix +12 -2
  22. data/example/cluster/nixos-machine/hardware.nix +6 -1
  23. data/example/cluster/vpsadminos-container/config.nix +6 -1
  24. data/example/cluster/vpsadminos-container/module.nix +4 -1
  25. data/example/cluster/vpsadminos-machine/config.nix +6 -1
  26. data/example/cluster/vpsadminos-machine/hardware.nix +6 -1
  27. data/example/cluster/vpsadminos-machine/module.nix +5 -2
  28. data/example/cluster/vpsfreecz-vps/config.nix +6 -1
  29. data/example/cluster/vpsfreecz-vps/module.nix +4 -1
  30. data/example/configs/swpins.nix +8 -3
  31. data/example/environments/base.nix +6 -1
  32. data/example/swpins/core.json +35 -0
  33. data/example-flake/.gitignore +2 -0
  34. data/example-flake/README.md +38 -0
  35. data/example-flake/cluster/cluster.nix +5 -0
  36. data/example-flake/cluster/module-list.nix +4 -0
  37. data/example-flake/cluster/nested/nixos-machine/config.nix +25 -0
  38. data/example-flake/cluster/nested/nixos-machine/hardware.nix +9 -0
  39. data/example-flake/cluster/nested/nixos-machine/module.nix +8 -0
  40. data/example-flake/cluster/nixos-machine/config.nix +25 -0
  41. data/example-flake/cluster/nixos-machine/hardware.nix +9 -0
  42. data/example-flake/cluster/nixos-machine/module.nix +8 -0
  43. data/example-flake/cluster/vpsadminos-container/config.nix +28 -0
  44. data/example-flake/cluster/vpsadminos-container/module.nix +8 -0
  45. data/example-flake/cluster/vpsadminos-machine/config.nix +27 -0
  46. data/example-flake/cluster/vpsadminos-machine/hardware.nix +9 -0
  47. data/example-flake/cluster/vpsadminos-machine/module.nix +8 -0
  48. data/example-flake/cluster/vpsfreecz-vps/config.nix +31 -0
  49. data/example-flake/cluster/vpsfreecz-vps/module.nix +8 -0
  50. data/example-flake/configs/confctl.nix +10 -0
  51. data/example-flake/data/default.nix +5 -0
  52. data/example-flake/data/ssh-keys.nix +7 -0
  53. data/example-flake/environments/base.nix +18 -0
  54. data/example-flake/flake.lock +75 -0
  55. data/example-flake/flake.nix +36 -0
  56. data/example-flake/modules/module-list.nix +13 -0
  57. data/example-flake/shell.nix +11 -0
  58. data/flake.lock +159 -0
  59. data/flake.nix +189 -0
  60. data/gemset.nix +1022 -0
  61. data/lib/confctl/cli/app.rb +145 -0
  62. data/lib/confctl/cli/attr_filters.rb +1 -1
  63. data/lib/confctl/cli/cluster.rb +681 -108
  64. data/lib/confctl/cli/command.rb +24 -2
  65. data/lib/confctl/cli/configuration.rb +171 -106
  66. data/lib/confctl/cli/generation.rb +65 -1
  67. data/lib/confctl/cli/inputs/channels.rb +190 -0
  68. data/lib/confctl/cli/inputs/machines.rb +83 -0
  69. data/lib/confctl/cli/inputs/root.rb +101 -0
  70. data/lib/confctl/cli/inputs.rb +5 -0
  71. data/lib/confctl/cli/log_view.rb +21 -10
  72. data/lib/confctl/cli/migrate/swpins_to_flakes.rb +866 -0
  73. data/lib/confctl/cli/migrate.rb +5 -0
  74. data/lib/confctl/cli/output_formatter.rb +5 -7
  75. data/lib/confctl/cli/swpins/base.rb +9 -0
  76. data/lib/confctl/cli/swpins/channel.rb +2 -5
  77. data/lib/confctl/cli/swpins/cluster.rb +2 -5
  78. data/lib/confctl/cli/swpins/core.rb +2 -5
  79. data/lib/confctl/config_type.rb +7 -0
  80. data/lib/confctl/flake_lock.rb +78 -0
  81. data/lib/confctl/flake_lock_diff.rb +36 -0
  82. data/lib/confctl/generation/build.rb +131 -24
  83. data/lib/confctl/generation/build_list.rb +4 -3
  84. data/lib/confctl/generation/unified.rb +14 -1
  85. data/lib/confctl/git_repo_mirror.rb +2 -2
  86. data/lib/confctl/health_checks/run_command.rb +3 -2
  87. data/lib/confctl/health_checks/systemd/properties.rb +1 -1
  88. data/lib/confctl/health_checks/systemd/property_list.rb +2 -2
  89. data/lib/confctl/inputs/commit_message.rb +125 -0
  90. data/lib/confctl/inputs/git_commit.rb +17 -0
  91. data/lib/confctl/inputs/nix_output_guard.rb +37 -0
  92. data/lib/confctl/inputs/setter.rb +179 -0
  93. data/lib/confctl/inputs/updater.rb +76 -0
  94. data/lib/confctl/inputs.rb +5 -0
  95. data/lib/confctl/inputs_info.rb +50 -0
  96. data/lib/confctl/line_buffer.rb +1 -1
  97. data/lib/confctl/machine.rb +18 -3
  98. data/lib/confctl/machine_control.rb +8 -2
  99. data/lib/confctl/machine_list.rb +2 -2
  100. data/lib/confctl/machine_status.rb +63 -20
  101. data/lib/confctl/nix/args.rb +48 -0
  102. data/lib/confctl/nix.rb +30 -437
  103. data/lib/confctl/nix_build_flake.rb +95 -0
  104. data/lib/confctl/nix_copy.rb +14 -2
  105. data/lib/confctl/nix_flake.rb +449 -0
  106. data/lib/confctl/nix_format.rb +3 -3
  107. data/lib/confctl/nix_legacy.rb +467 -0
  108. data/lib/confctl/swpins/change_set.rb +29 -3
  109. data/lib/confctl/swpins/specs/base.rb +2 -2
  110. data/lib/confctl/ui.rb +19 -0
  111. data/lib/confctl/version.rb +1 -1
  112. data/man/index.html +11 -0
  113. data/man/man8/confctl-options.nix.8.html +113 -0
  114. data/man/man8/confctl.8 +152 -21
  115. data/man/man8/confctl.8.html +355 -0
  116. data/man/man8/confctl.8.md +148 -17
  117. data/man/style.css +301 -0
  118. data/nix/evaluator.nix +94 -69
  119. data/nix/flake/mk-confctl-devshell.nix +85 -0
  120. data/nix/flake/mk-confctl-outputs.nix +522 -0
  121. data/nix/flake/mk-config-devshell.nix +168 -0
  122. data/nix/lib/default.nix +118 -65
  123. data/nix/lib/machine/default.nix +65 -45
  124. data/nix/lib/machine/info.nix +16 -5
  125. data/nix/lib/swpins/eval.nix +42 -29
  126. data/nix/lib/swpins/options.nix +6 -2
  127. data/nix/machines.nix +23 -15
  128. data/nix/modules/cluster/default.nix +104 -41
  129. data/nix/modules/confctl/carrier/base.nix +11 -4
  130. data/nix/modules/confctl/carrier/carrier-env.rb +2 -2
  131. data/nix/modules/confctl/carrier/netboot/build-netboot-server.rb +50 -16
  132. data/nix/modules/confctl/carrier/netboot/nixos.nix +56 -24
  133. data/nix/modules/confctl/configuration-info.nix +17 -0
  134. data/nix/modules/confctl/generations.nix +2 -2
  135. data/nix/modules/confctl/host.nix +13 -0
  136. data/nix/modules/confctl/inputs-info.nix +21 -0
  137. data/nix/modules/confctl/kexec-netboot/default.nix +13 -6
  138. data/nix/modules/confctl/kexec-netboot/kexec-netboot.8.adoc +3 -0
  139. data/nix/modules/confctl/kexec-netboot/kexec-netboot.rb +25 -16
  140. data/nix/modules/confctl/nix.nix +31 -1
  141. data/nix/modules/confctl/swpins.nix +13 -6
  142. data/nix/modules/module-list.nix +4 -2
  143. data/nix/modules/system-list.nix +4 -1
  144. data/nix/package.nix +37 -0
  145. data/shell.nix +39 -8
  146. data/skills/confctl-configuration-update/SKILL.md +228 -0
  147. data/skills/confctl-configuration-update/agents/openai.yaml +4 -0
  148. data/skills/confctl-release/SKILL.md +102 -0
  149. data/skills/confctl-release/agents/openai.yaml +4 -0
  150. data/spec/confctl/cli/cluster_health_check_spec.rb +43 -0
  151. data/spec/confctl/cli/cluster_skip_current_deploy_spec.rb +157 -0
  152. data/spec/confctl/cli/cluster_status_flake_spec.rb +83 -0
  153. data/spec/confctl/cli/inputs_set_output_spec.rb +70 -0
  154. data/spec/confctl/configuration_spec.rb +45 -0
  155. data/spec/confctl/inputs_spec.rb +104 -0
  156. data/spec/confctl/machine_control_spec.rb +112 -0
  157. data/spec/confctl/machine_list_spec.rb +47 -0
  158. data/spec/confctl/nix_flake_spec.rb +41 -0
  159. data/spec/confctl/swpins_spec.rb +106 -0
  160. data/spec/generation/build_modes_spec.rb +132 -0
  161. data/spec/inputs/commit_message_spec.rb +205 -0
  162. data/spec/inputs/nix_cached_fallback_spec.rb +50 -0
  163. data/spec/inputs/nix_output_guard_spec.rb +45 -0
  164. data/spec/spec_helper.rb +12 -0
  165. data/spec/support/cli_helper.rb +57 -0
  166. data/test-runner.sh +7 -0
  167. data/tests/all-tests.nix +30 -0
  168. data/tests/make-test.nix +15 -0
  169. data/tests/runner/extensions/confctl_helpers.rb +238 -0
  170. data/tests/runner/extensions/hostfwd_ports.rb +41 -0
  171. data/tests/suite/auto_rollback.nix +344 -0
  172. data/tests/suite/carrier/deploy.nix +751 -0
  173. data/tests/suite/carrier/netboot.nix +849 -0
  174. data/tests/suite/deploy/base.nix +806 -0
  175. data/tests/suite/deploy/flakes.nix +1 -0
  176. data/tests/suite/deploy/swpins.nix +1 -0
  177. metadata +104 -4
  178. data/nix/modules/confctl/overlays.nix +0 -15
data/nix/lib/default.nix CHANGED
@@ -1,23 +1,50 @@
1
- { confDir, coreLib, corePkgs }:
1
+ {
2
+ confDir,
3
+ coreLib,
4
+ corePkgs,
5
+ }:
2
6
  with coreLib;
3
7
  let
4
- machine = import ./machine { inherit confDir corePkgs coreLib findMetaConfig; };
8
+ machine = import ./machine {
9
+ inherit
10
+ confDir
11
+ corePkgs
12
+ coreLib
13
+ findMetaConfig
14
+ ;
15
+ };
5
16
 
6
- findMetaConfig =
7
- { cluster, name }:
8
- cluster.${name};
17
+ findMetaConfig = { cluster, name }: cluster.${name};
9
18
 
10
19
  makeMachine =
11
- { name, metaConfig, carrier ? null, alias ? null, clusterName ? null, extraModules ? [], buildAttribute ? null }:
20
+ {
21
+ name,
22
+ metaConfig,
23
+ carrier ? null,
24
+ alias ? null,
25
+ clusterName ? null,
26
+ extraModules ? [ ],
27
+ buildAttribute ? null,
28
+ }:
12
29
  let
13
30
  ensuredClusterName = if isNull clusterName then name else clusterName;
14
- in {
15
- inherit name alias metaConfig carrier extraModules;
31
+ in
32
+ {
33
+ inherit
34
+ name
35
+ alias
36
+ metaConfig
37
+ carrier
38
+ extraModules
39
+ ;
16
40
  clusterName = ensuredClusterName;
17
41
 
18
42
  build = {
19
43
  attribute = if isNull buildAttribute then metaConfig.buildAttribute else buildAttribute;
20
- toplevel = buildConfig { name = ensuredClusterName; inherit metaConfig; };
44
+ toplevel = buildConfig {
45
+ name = ensuredClusterName;
46
+ inherit metaConfig;
47
+ };
21
48
  };
22
49
  };
23
50
 
@@ -32,75 +59,105 @@ let
32
59
  else
33
60
  null;
34
61
 
35
- expandCarriers = machineAttrs: flatten (mapAttrsToList (name: m:
36
- if m.metaConfig.carrier.enable then
37
- [ m ] ++ (expandCarrier machineAttrs m)
38
- else
39
- m
40
- ) machineAttrs);
62
+ expandCarriers =
63
+ machineAttrs:
64
+ flatten (
65
+ mapAttrsToList (
66
+ name: m: if m.metaConfig.carrier.enable then [ m ] ++ (expandCarrier machineAttrs m) else m
67
+ ) machineAttrs
68
+ );
41
69
 
42
- expandCarrier = machineAttrs: carrierMachine: map (cm:
43
- makeMachine {
44
- name = "${carrierMachine.name}#${if isNull cm.alias then cm.machine else cm.alias}";
45
- alias = cm.alias;
46
- clusterName = cm.machine;
47
- carrier = carrierMachine.name;
48
- extraModules = cm.extraModules;
49
- buildAttribute = cm.buildAttribute;
50
- metaConfig = coreLib.updateManyAttrsByPath ([
51
- {
52
- path = [ "labels" ];
53
- update = old: old // cm.labels;
54
- }
55
- {
56
- path = [ "tags" ];
57
- update = old: old ++ cm.tags;
58
- }
59
- ] ++ (generationUpdates cm)) machineAttrs.${cm.machine}.metaConfig;
60
- }
61
- ) carrierMachine.metaConfig.carrier.machines;
70
+ expandCarrier =
71
+ machineAttrs: carrierMachine:
72
+ map (
73
+ cm:
74
+ makeMachine {
75
+ name = "${carrierMachine.name}#${if isNull cm.alias then cm.machine else cm.alias}";
76
+ alias = cm.alias;
77
+ clusterName = cm.machine;
78
+ carrier = carrierMachine.name;
79
+ extraModules = cm.extraModules;
80
+ buildAttribute = cm.buildAttribute;
81
+ metaConfig = coreLib.updateManyAttrsByPath (
82
+ [
83
+ {
84
+ path = [ "labels" ];
85
+ update = old: old // cm.labels;
86
+ }
87
+ {
88
+ path = [ "tags" ];
89
+ update = old: old ++ cm.tags;
90
+ }
91
+ ]
92
+ ++ (generationUpdates cm)
93
+ ) machineAttrs.${cm.machine}.metaConfig;
94
+ }
95
+ ) carrierMachine.metaConfig.carrier.machines;
62
96
 
63
- generationUpdates = cm:
64
- flatten (map (generations:
65
- map (attr: {
66
- path = [ generations attr ];
67
- update = old:
68
- let v = cm.${generations}.${attr};
69
- in if isNull v then old else v;
70
- }) [ "min" "max" "maxAge" ]
71
- ) [ "buildGenerations" "hostGenerations" ]);
72
- in rec {
97
+ generationUpdates =
98
+ cm:
99
+ flatten (
100
+ map
101
+ (
102
+ generations:
103
+ map
104
+ (attr: {
105
+ path = [
106
+ generations
107
+ attr
108
+ ];
109
+ update =
110
+ old:
111
+ let
112
+ v = cm.${generations}.${attr};
113
+ in
114
+ if isNull v then old else v;
115
+ })
116
+ [
117
+ "min"
118
+ "max"
119
+ "maxAge"
120
+ ]
121
+ )
122
+ [
123
+ "buildGenerations"
124
+ "hostGenerations"
125
+ ]
126
+ );
127
+ in
128
+ rec {
73
129
  inherit corePkgs coreLib;
74
130
 
75
131
  mkNetUdevRule = name: mac: ''
76
- ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", KERNEL=="eth*", ATTR{address}=="${mac}", NAME="${name}"
132
+ ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", KERNEL=="eth*", ATTR{address}=="${mac}", NAME="${name}"
77
133
  '';
78
134
 
79
- mkNetUdevRules = rs: concatStringsSep "\n" (mapAttrsToList (name: mac:
80
- mkNetUdevRule name mac
81
- ) rs);
135
+ mkNetUdevRules = rs: concatStringsSep "\n" (mapAttrsToList (name: mac: mkNetUdevRule name mac) rs);
82
136
 
83
137
  inherit findMetaConfig;
84
138
 
85
139
  # Return all configured machines in a list
86
- getClusterMachines = cluster:
140
+ getClusterMachines =
141
+ cluster:
87
142
  let
88
- machineAttrs = mapAttrs (name: metaConfig:
89
- makeMachine { inherit name metaConfig; }
90
- ) cluster;
91
- in expandCarriers machineAttrs;
143
+ machineAttrs = mapAttrs (name: metaConfig: makeMachine { inherit name metaConfig; }) cluster;
144
+ in
145
+ expandCarriers machineAttrs;
92
146
 
93
147
  # Get IP version addresses from all machines in a cluster
94
- getAllAddressesOf = cluster: v:
148
+ getAllAddressesOf =
149
+ cluster: v:
95
150
  let
96
151
  machines = getClusterMachines cluster;
97
- addresses = flatten (map (machine:
98
- map (addr: machine // addr) machine.metaConfig.addresses.${"v${toString v}"}
99
- ) machines);
100
- in addresses;
152
+ addresses = flatten (
153
+ map (machine: map (addr: machine // addr) machine.metaConfig.addresses.${"v${toString v}"}) machines
154
+ );
155
+ in
156
+ addresses;
101
157
 
102
158
  mkOptions = {
103
- addresses = v:
159
+ addresses =
160
+ v:
104
161
  { config, ... }:
105
162
  {
106
163
  options = {
@@ -117,11 +174,7 @@ in rec {
117
174
  string = mkOption {
118
175
  type = types.nullOr types.str;
119
176
  default = null;
120
- apply = v:
121
- if isNull v then
122
- "${config.address}/${toString config.prefix}"
123
- else
124
- v;
177
+ apply = v: if isNull v then "${config.address}/${toString config.prefix}" else v;
125
178
  description = "Address with prefix as string";
126
179
  };
127
180
  };
@@ -1,4 +1,9 @@
1
- { confDir, corePkgs, coreLib, findMetaConfig }:
1
+ {
2
+ confDir,
3
+ corePkgs,
4
+ coreLib,
5
+ findMetaConfig,
6
+ }:
2
7
  let
3
8
  swpinsFor =
4
9
  { name, metaConfig }:
@@ -10,68 +15,83 @@ let
10
15
  };
11
16
 
12
17
  makeModuleArgs =
13
- { metaConfig, swpins, spin, name }@args: {
18
+ {
19
+ metaConfig,
20
+ swpins,
21
+ spin,
22
+ name,
23
+ }@args:
24
+ {
14
25
  swpins = swpins.evaluated;
15
26
  swpinsInfo = swpins.infos;
16
27
  confMachine = import ./info.nix (args // { inherit findMetaConfig; });
17
28
  };
18
29
 
19
- makeImports = spin: extraImports: [
20
- ({ config, pkgs, lib, confMachine, ... }:
21
- {
22
- _file = "confctl/nix/lib/machine/default.nix";
23
-
24
- _module.args = {
25
- inherit confDir;
26
- confLib = import ../../lib { inherit confDir coreLib corePkgs; };
27
- confData = import "${toString confDir}/data/default.nix" { inherit lib; };
28
- };
30
+ makeImports =
31
+ spin: extraImports:
32
+ [
33
+ (
34
+ {
35
+ config,
36
+ pkgs,
37
+ lib,
38
+ confMachine,
39
+ ...
40
+ }:
41
+ {
42
+ _file = "confctl/nix/lib/machine/default.nix";
29
43
 
30
- networking.hostName =
31
- lib.mkIf (confMachine.host != null && confMachine.host.name != null) (lib.mkDefault confMachine.host.name);
44
+ _module.args = {
45
+ inherit confDir;
46
+ confLib = import ../../lib { inherit confDir coreLib corePkgs; };
47
+ confData = import "${toString confDir}/data/default.nix" { inherit lib; };
48
+ };
32
49
 
33
- networking.domain =
34
- lib.mkIf (confMachine.host != null) (lib.mkDefault confMachine.host.fullDomain);
35
- })
36
- ] ++ (import ../../modules/module-list.nix).${spin}
50
+ }
51
+ )
52
+ ]
53
+ ++ (import ../../modules/module-list.nix).${spin}
37
54
  ++ (import ../../modules/system-list.nix).${spin}
38
55
  ++ (import "${toString confDir}/modules/module-list.nix").${spin}
39
56
  ++ (import "${toString confDir}/cluster/module-list.nix")
40
57
  ++ extraImports;
41
- in rec {
42
- nixos = { name, metaConfig }:
58
+ in
59
+ rec {
60
+ nixos =
61
+ { name, metaConfig }:
43
62
  let
44
63
  swpins = swpinsFor { inherit name metaConfig; };
45
64
  in
46
- { config, pkgs, ... }@args:
47
- {
48
- _module.args = makeModuleArgs {
49
- metaConfig = config;
50
- inherit swpins;
51
- spin = "nixos";
52
- inherit name;
53
- };
54
-
55
- imports = makeImports "nixos" [
56
- "${toString confDir}/cluster/${name}/config.nix"
57
- ];
65
+ { config, pkgs, ... }@args:
66
+ {
67
+ _module.args = makeModuleArgs {
68
+ metaConfig = config;
69
+ inherit swpins;
70
+ spin = "nixos";
71
+ inherit name;
58
72
  };
59
73
 
60
- vpsadminos = { name, metaConfig }:
74
+ imports = makeImports "nixos" [
75
+ "${toString confDir}/cluster/${name}/config.nix"
76
+ ];
77
+ };
78
+
79
+ vpsadminos =
80
+ { name, metaConfig }:
61
81
  let
62
82
  swpins = swpinsFor { inherit name metaConfig; };
63
83
  in
64
- { config, pkgs, ... }@args:
65
- {
66
- _module.args = makeModuleArgs {
67
- metaConfig = config;
68
- inherit swpins;
69
- spin = "vpsadminos";
70
- inherit name;
71
- };
72
-
73
- imports = makeImports "vpsadminos" [
74
- "${toString confDir}/cluster/${name}/config.nix"
75
- ];
84
+ { config, pkgs, ... }@args:
85
+ {
86
+ _module.args = makeModuleArgs {
87
+ metaConfig = config;
88
+ inherit swpins;
89
+ spin = "vpsadminos";
90
+ inherit name;
76
91
  };
92
+
93
+ imports = makeImports "vpsadminos" [
94
+ "${toString confDir}/cluster/${name}/config.nix"
95
+ ];
96
+ };
77
97
  }
@@ -1,5 +1,16 @@
1
- { metaConfig, spin, name, findMetaConfig, ... }:
2
- ({ inherit name; } // findMetaConfig {
3
- inherit (metaConfig) cluster;
4
- inherit name;
5
- })
1
+ {
2
+ metaConfig,
3
+ spin,
4
+ name,
5
+ findMetaConfig,
6
+ ...
7
+ }:
8
+ (
9
+ {
10
+ inherit name;
11
+ }
12
+ // findMetaConfig {
13
+ inherit (metaConfig) cluster;
14
+ inherit name;
15
+ }
16
+ )
@@ -1,4 +1,11 @@
1
- { confDir, name, dir ? "cluster", channels, pkgs, lib }:
1
+ {
2
+ confDir,
3
+ name,
4
+ dir ? "cluster",
5
+ channels,
6
+ pkgs,
7
+ lib,
8
+ }:
2
9
  let
3
10
  pinFileName = builtins.replaceStrings [ "/" ] [ ":" ] name;
4
11
 
@@ -6,11 +13,7 @@ let
6
13
 
7
14
  pinFileJson = builtins.readFile pinFilePath;
8
15
 
9
- pinFileSpecs =
10
- if builtins.pathExists pinFilePath then
11
- builtins.fromJSON pinFileJson
12
- else
13
- {};
16
+ pinFileSpecs = if builtins.pathExists pinFilePath then builtins.fromJSON pinFileJson else { };
14
17
 
15
18
  pinFileSwpins = lib.mapAttrs (k: v: swpin v) pinFileSpecs;
16
19
 
@@ -24,47 +27,57 @@ let
24
27
 
25
28
  allChannelSwpins = map channelSwpins channels;
26
29
 
27
- allSwpins = (lib.foldl (a: b: a // b) {} allChannelSwpins) // pinFileSwpins;
30
+ allSwpins = (lib.foldl (a: b: a // b) { } allChannelSwpins) // pinFileSwpins;
28
31
 
29
- swpin = { fetcher, ... }:
30
- fetchers.${fetcher.type} fetcher.options;
32
+ swpin = { fetcher, ... }: fetchers.${fetcher.type} fetcher.options;
31
33
 
32
34
  fetchers = rec {
33
- directory = opts:
34
- opts.path;
35
+ directory = opts: opts.path;
35
36
 
36
- git = opts:
37
+ git =
38
+ opts:
37
39
  let
38
- filter = lib.filterAttrs (k: v: builtins.elem k [
39
- "url" "rev" "sha256" "fetchSubmodules"
40
- ]);
41
- in pkgs.fetchgit (filter opts);
40
+ filter = lib.filterAttrs (
41
+ k: v:
42
+ builtins.elem k [
43
+ "url"
44
+ "rev"
45
+ "sha256"
46
+ "fetchSubmodules"
47
+ ]
48
+ );
49
+ in
50
+ if opts ? path && builtins.pathExists opts.path then
51
+ builtins.storePath opts.path
52
+ else
53
+ pkgs.fetchgit (filter opts);
42
54
 
43
- zip = opts:
44
- pkgs.fetchzip opts;
55
+ zip = opts: pkgs.fetchzip opts;
45
56
 
46
- git-rev = opts:
57
+ git-rev =
58
+ opts:
47
59
  let
48
60
  repo = fetchers.${opts.wrapped_fetcher.type} opts.wrapped_fetcher.options;
49
61
  shortRev = lib.substring 0 9 (opts.rev);
50
62
  in
51
- pkgs.runCommand "git-${shortRev}" {} ''
52
- cp -a ${repo} $out
53
- chmod 700 $out
54
- echo "${opts.rev}" > $out/.git-revision
55
- echo ".git.${shortRev}" > $out/.version-suffix
56
- '';
63
+ pkgs.runCommand "git-${shortRev}" { } ''
64
+ cp -a ${repo} $out
65
+ chmod 700 $out
66
+ echo "${opts.rev}" > $out/.git-revision
67
+ echo ".git.${shortRev}" > $out/.version-suffix
68
+ '';
57
69
  };
58
70
 
59
- pinFileInfos = lib.mapAttrs (k: v: v.info or {}) pinFileSpecs;
71
+ pinFileInfos = lib.mapAttrs (k: v: v.info or { }) pinFileSpecs;
60
72
 
61
- channelInfos = chan: lib.mapAttrs (k: v: v.info or {}) (channelSpecs chan);
73
+ channelInfos = chan: lib.mapAttrs (k: v: v.info or { }) (channelSpecs chan);
62
74
 
63
75
  allChannelInfos = map channelInfos channels;
64
76
 
65
- allInfos = (lib.foldl (a: b: a // b) {} allChannelInfos) // pinFileInfos;
77
+ allInfos = (lib.foldl (a: b: a // b) { } allChannelInfos) // pinFileInfos;
66
78
 
67
- in {
79
+ in
80
+ {
68
81
  evaluated = allSwpins;
69
82
 
70
83
  infos = allInfos;
@@ -6,7 +6,11 @@ rec {
6
6
  {
7
7
  options = {
8
8
  type = mkOption {
9
- type = types.enum [ "directory" "git" "git-rev" ];
9
+ type = types.enum [
10
+ "directory"
11
+ "git"
12
+ "git-rev"
13
+ ];
10
14
  default = "git";
11
15
  };
12
16
 
@@ -82,7 +86,7 @@ rec {
82
86
 
83
87
  interval = mkOption {
84
88
  type = types.int;
85
- default = 60*60;
89
+ default = 60 * 60;
86
90
  description = ''
87
91
  Number of seconds from the last update to trigger the next
88
92
  auto-update, if auto-update is enabled.
data/nix/machines.nix CHANGED
@@ -1,31 +1,39 @@
1
- { confDir, corePkgs, coreLib }:
1
+ {
2
+ confDir,
3
+ corePkgs,
4
+ coreLib,
5
+ }:
2
6
  let
3
7
  confLib = import ./lib { inherit confDir coreLib corePkgs; };
4
8
 
5
9
  userModules = "${toString confDir}/modules/cluster/default.nix";
6
10
 
7
11
  baseModules = [
8
- ({ ... }:
9
- {
10
- _module.args = {
11
- pkgs = corePkgs;
12
- inherit confLib;
13
- swpins = {};
14
- swpinsInfo = {};
15
- confMachine = null;
16
- };
17
- })
12
+ (
13
+ { ... }:
14
+ {
15
+ _module.args = {
16
+ pkgs = corePkgs;
17
+ inherit confLib;
18
+ swpins = { };
19
+ swpinsInfo = { };
20
+ confMachine = null;
21
+ };
22
+ }
23
+ )
18
24
 
19
25
  ./modules/cluster
20
- ] ++ (import "${toString confDir}/cluster/module-list.nix")
21
- ++ (coreLib.optional (builtins.pathExists userModules) userModules);
26
+ ]
27
+ ++ (import "${toString confDir}/cluster/module-list.nix")
28
+ ++ (coreLib.optional (builtins.pathExists userModules) userModules);
22
29
 
23
30
  evalConfig = corePkgs.lib.evalModules {
24
- prefix = [];
31
+ prefix = [ ];
25
32
  modules = baseModules;
26
33
  };
27
34
 
28
35
  cluster = evalConfig.config.cluster;
29
36
 
30
37
  allMachines = confLib.getClusterMachines cluster;
31
- in allMachines
38
+ in
39
+ allMachines