confctl 1.0.0 → 2.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.
- checksums.yaml +4 -4
- data/.editorconfig +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +18 -1
- data/README.md +3 -9
- data/confctl.gemspec +14 -14
- data/docs/carrier.md +138 -0
- data/lib/confctl/cli/app.rb +3 -0
- data/lib/confctl/cli/cluster.rb +73 -44
- data/lib/confctl/cli/configuration.rb +7 -2
- data/lib/confctl/cli/gen_data.rb +19 -1
- data/lib/confctl/cli/generation.rb +5 -3
- data/lib/confctl/generation/host_list.rb +3 -3
- data/lib/confctl/git_repo_mirror.rb +2 -2
- data/lib/confctl/machine.rb +101 -11
- data/lib/confctl/machine_control.rb +7 -0
- data/lib/confctl/machine_list.rb +14 -1
- data/lib/confctl/machine_status.rb +51 -4
- data/lib/confctl/nix.rb +28 -5
- data/lib/confctl/swpins/specs/git.rb +1 -1
- data/lib/confctl/version.rb +1 -1
- data/man/man8/confctl-options.nix.8 +165 -1
- data/man/man8/confctl-options.nix.8.md +165 -1
- data/man/man8/confctl.8 +21 -1
- data/man/man8/confctl.8.md +16 -1
- data/nix/evaluator.nix +18 -7
- data/nix/lib/default.nix +64 -17
- data/nix/lib/machine/default.nix +14 -11
- data/nix/lib/machine/info.nix +3 -3
- data/nix/modules/cluster/default.nix +142 -3
- data/nix/modules/confctl/carrier/base.nix +35 -0
- data/nix/modules/confctl/carrier/carrier-env.rb +81 -0
- data/nix/modules/confctl/carrier/netboot/build-netboot-server.rb +803 -0
- data/nix/modules/confctl/carrier/netboot/nixos.nix +185 -0
- data/nix/modules/system-list.nix +8 -0
- metadata +12 -7
- data/.ruby-version +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
# confctl-options.nix 8 2024-
|
1
|
+
# confctl-options.nix 8 2024-05-07 master
|
2
2
|
|
3
3
|
## NAME
|
4
4
|
`confctl-options.nix` - confctl configuration documentation
|
@@ -601,6 +601,22 @@ the deployment configuration directory, i.e. `cluster/<machine-name>/module.nix`
|
|
601
601
|
|
602
602
|
*Declared by:* `<confctl/nix/modules/cluster>`
|
603
603
|
|
604
|
+
`cluster.<name>.buildAttribute`
|
605
|
+
Path to the attribute in machine system config that should be built
|
606
|
+
|
607
|
+
For example, `[ "system" "build" "toplevel" ]` will select attribute
|
608
|
+
`config.system.build.toplevel`.
|
609
|
+
|
610
|
+
*Type:* list of string
|
611
|
+
|
612
|
+
*Default:* `[
|
613
|
+
"system"
|
614
|
+
"build"
|
615
|
+
"toplevel"
|
616
|
+
]`
|
617
|
+
|
618
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
619
|
+
|
604
620
|
`cluster.<name>.buildGenerations.max`
|
605
621
|
The maximum number of build generations to be kept on the build
|
606
622
|
machine.
|
@@ -634,6 +650,151 @@ the deployment configuration directory, i.e. `cluster/<machine-name>/module.nix`
|
|
634
650
|
|
635
651
|
*Declared by:* `<confctl/nix/modules/cluster>`
|
636
652
|
|
653
|
+
`cluster.<name>.carrier.enable`
|
654
|
+
Whether to enable This machine is a carrier for other machines.
|
655
|
+
|
656
|
+
*Type:* boolean
|
657
|
+
|
658
|
+
*Default:* `false`
|
659
|
+
|
660
|
+
*Example:* `true`
|
661
|
+
|
662
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
663
|
+
|
664
|
+
`cluster.<name>.carrier.machines`
|
665
|
+
List of carried machines
|
666
|
+
|
667
|
+
*Type:* list of (submodule)
|
668
|
+
|
669
|
+
*Default:* `[ ]`
|
670
|
+
|
671
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
672
|
+
|
673
|
+
`cluster.<name>.carrier.machines.*.alias`
|
674
|
+
Alias for carried machine name
|
675
|
+
|
676
|
+
*Type:* null or string
|
677
|
+
|
678
|
+
*Default:* `null`
|
679
|
+
|
680
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
681
|
+
|
682
|
+
`cluster.<name>.carrier.machines.*.buildAttribute`
|
683
|
+
Path to the attribute in machine system config that should be built
|
684
|
+
|
685
|
+
For example, `[ "system" "build" "toplevel" ]` will select attribute
|
686
|
+
`config.system.build.toplevel`.
|
687
|
+
|
688
|
+
*Type:* list of string
|
689
|
+
|
690
|
+
*Default:* `[
|
691
|
+
"system"
|
692
|
+
"build"
|
693
|
+
"toplevel"
|
694
|
+
]`
|
695
|
+
|
696
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
697
|
+
|
698
|
+
`cluster.<name>.carrier.machines.*.buildGenerations.max`
|
699
|
+
The maximum number of build generations to be kept on the build
|
700
|
+
machine.
|
701
|
+
|
702
|
+
*Type:* null or signed integer
|
703
|
+
|
704
|
+
*Default:* `null`
|
705
|
+
|
706
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
707
|
+
|
708
|
+
`cluster.<name>.carrier.machines.*.buildGenerations.maxAge`
|
709
|
+
Delete build generations older than
|
710
|
+
`cluster.<name>.carrier.machines.*.buildGenerations.maxAge`
|
711
|
+
seconds from the build machine. Old generations are deleted even
|
712
|
+
if `cluster.<name>.carrier.machines.*.buildGenerations.max` is
|
713
|
+
not reached.
|
714
|
+
|
715
|
+
*Type:* null or signed integer
|
716
|
+
|
717
|
+
*Default:* `null`
|
718
|
+
|
719
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
720
|
+
|
721
|
+
`cluster.<name>.carrier.machines.*.buildGenerations.min`
|
722
|
+
The minimum number of build generations to be kept on the build
|
723
|
+
machine.
|
724
|
+
|
725
|
+
*Type:* null or signed integer
|
726
|
+
|
727
|
+
*Default:* `null`
|
728
|
+
|
729
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
730
|
+
|
731
|
+
`cluster.<name>.carrier.machines.*.extraModules`
|
732
|
+
A list of additional NixOS modules to be imported for this machine
|
733
|
+
|
734
|
+
*Type:* list of path
|
735
|
+
|
736
|
+
*Default:* `[ ]`
|
737
|
+
|
738
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
739
|
+
|
740
|
+
`cluster.<name>.carrier.machines.*.hostGenerations.max`
|
741
|
+
The maximum number of generations to be kept on the machine.
|
742
|
+
|
743
|
+
*Type:* null or signed integer
|
744
|
+
|
745
|
+
*Default:* `null`
|
746
|
+
|
747
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
748
|
+
|
749
|
+
`cluster.<name>.carrier.machines.*.hostGenerations.maxAge`
|
750
|
+
Delete generations older than
|
751
|
+
`cluster.<name>.carrier.machines.*.hostGenerations.maxAge`
|
752
|
+
seconds from the machine. Old generations are deleted even
|
753
|
+
if `cluster.<name>.carrier.machines.*.hostGenerations.max` is
|
754
|
+
not reached.
|
755
|
+
|
756
|
+
*Type:* null or signed integer
|
757
|
+
|
758
|
+
*Default:* `null`
|
759
|
+
|
760
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
761
|
+
|
762
|
+
`cluster.<name>.carrier.machines.*.hostGenerations.min`
|
763
|
+
The minimum number of generations to be kept on the machine.
|
764
|
+
|
765
|
+
*Type:* null or signed integer
|
766
|
+
|
767
|
+
*Default:* `null`
|
768
|
+
|
769
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
770
|
+
|
771
|
+
`cluster.<name>.carrier.machines.*.labels`
|
772
|
+
Optional user-defined labels to classify the machine
|
773
|
+
|
774
|
+
*Type:* attribute set
|
775
|
+
|
776
|
+
*Default:* `{ }`
|
777
|
+
|
778
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
779
|
+
|
780
|
+
`cluster.<name>.carrier.machines.*.machine`
|
781
|
+
Machine name
|
782
|
+
|
783
|
+
*Type:* string
|
784
|
+
|
785
|
+
*Default:* `null`
|
786
|
+
|
787
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
788
|
+
|
789
|
+
`cluster.<name>.carrier.machines.*.tags`
|
790
|
+
Optional user-defined tags to classify the machine
|
791
|
+
|
792
|
+
*Type:* list of string
|
793
|
+
|
794
|
+
*Default:* `[ ]`
|
795
|
+
|
796
|
+
*Declared by:* `<confctl/nix/modules/cluster>`
|
797
|
+
|
637
798
|
`cluster.<name>.healthChecks.builderCommands`
|
638
799
|
Check commands run on the build machine
|
639
800
|
|
@@ -1034,6 +1195,9 @@ the deployment configuration directory, i.e. `cluster/<machine-name>/module.nix`
|
|
1034
1195
|
|
1035
1196
|
`cluster.<name>.host.target`
|
1036
1197
|
Address/host to which the configuration is deployed to
|
1198
|
+
|
1199
|
+
Set to null if the machine is not deployable, e.g. when it is only used
|
1200
|
+
as a carried machine.
|
1037
1201
|
|
1038
1202
|
*Type:* null or string
|
1039
1203
|
|
data/man/man8/confctl.8
CHANGED
@@ -113,6 +113,10 @@ generations can be managed using \fB\fCconfctl generation\fR command family.
|
|
113
113
|
\fB\fC\-j\fR, \fB\fC\-\-max\-jobs\fR \fInumber\fP
|
114
114
|
Maximum number of build jobs, passed to \fB\fCnix\-build\fR\&. See man
|
115
115
|
.BR nix-build (1).
|
116
|
+
.PP
|
117
|
+
\fB\fC\-\-cores\fR \fInumber\fP
|
118
|
+
Number of CPU cores to use, passed to \fB\fCnix\-build\fR\&. See man
|
119
|
+
.BR nix-build (1).
|
116
120
|
.TP
|
117
121
|
\fB\fCconfctl deploy\fR [\fIoptions\fP] [\fImachine\-pattern\fP [\fB\fCboot\fR|\fB\fCswitch\fR|\fB\fCtest\fR|\fB\fCdry\-activate\fR]]
|
118
122
|
Deploy either a new or an existing build generation to matching machines.
|
@@ -177,6 +181,10 @@ the target machine. The default action is \fB\fCswitch\fR\&.
|
|
177
181
|
\fB\fC\-j\fR, \fB\fC\-\-max\-jobs\fR \fInumber\fP
|
178
182
|
Maximum number of build jobs, passed to \fB\fCnix\-build\fR\&. See man
|
179
183
|
.BR nix-build (1).
|
184
|
+
.PP
|
185
|
+
\fB\fC\-\-cores\fR \fInumber\fP
|
186
|
+
Number of CPU cores to use, passed to \fB\fCnix\-build\fR\&. See man
|
187
|
+
.BR nix-build (1).
|
180
188
|
.PP
|
181
189
|
\fB\fC\-\-no\-health\-checks\fR
|
182
190
|
Do not run configured health checks. Health checks are run by default
|
@@ -226,6 +234,10 @@ Probe managed machines and determine their status.
|
|
226
234
|
\fB\fC\-j\fR, \fB\fC\-\-max\-jobs\fR \fInumber\fP
|
227
235
|
Maximum number of build jobs, passed to \fB\fCnix\-build\fR\&. See man
|
228
236
|
.BR nix-build (1).
|
237
|
+
.PP
|
238
|
+
\fB\fC\-\-cores\fR \fInumber\fP
|
239
|
+
Number of CPU cores to use, passed to \fB\fCnix\-build\fR\&. See man
|
240
|
+
.BR nix-build (1).
|
229
241
|
.TP
|
230
242
|
\fB\fCconfctl changelog\fR [\fIoptions\fP] [\fImachine\-pattern\fP [\fIsw\-pattern\fP]]
|
231
243
|
Show differences in deployed and configured software pins. For git software
|
@@ -270,6 +282,10 @@ itself, it works only on software pins.
|
|
270
282
|
\fB\fC\-j\fR, \fB\fC\-\-max\-jobs\fR \fInumber\fP
|
271
283
|
Maximum number of build jobs, passed to \fB\fCnix\-build\fR\&. See man
|
272
284
|
.BR nix-build (1).
|
285
|
+
.PP
|
286
|
+
\fB\fC\-\-cores\fR \fInumber\fP
|
287
|
+
Number of CPU cores to use, passed to \fB\fCnix\-build\fR\&. See man
|
288
|
+
.BR nix-build (1).
|
273
289
|
.TP
|
274
290
|
\fB\fCconfctl diff\fR [\fIoptions\fP] [\fImachine\-pattern\fP [\fIsw\-pattern\fP]]
|
275
291
|
Show differences in deployed and configured software pins. For git software
|
@@ -308,6 +324,10 @@ itself, it works only on software pins.
|
|
308
324
|
\fB\fC\-j\fR, \fB\fC\-\-max\-jobs\fR \fInumber\fP
|
309
325
|
Maximum number of build jobs, passed to \fB\fCnix\-build\fR\&. See man
|
310
326
|
.BR nix-build (1).
|
327
|
+
.PP
|
328
|
+
\fB\fC\-\-cores\fR \fInumber\fP
|
329
|
+
Number of CPU cores to use, passed to \fB\fCnix\-build\fR\&. See man
|
330
|
+
.BR nix-build (1).
|
311
331
|
.TP
|
312
332
|
\fB\fCconfctl test\-connection\fR [\fIoptions\fP] [\fImachine\-pattern\fP]
|
313
333
|
Try to open a SSH connection to the selected machines. This command can be
|
@@ -656,5 +676,5 @@ Report bugs to \[la]https://github.com/vpsfreecz/confctl/issues\[ra]\&.
|
|
656
676
|
.SH ABOUT
|
657
677
|
.PP
|
658
678
|
\fB\fCconfctl\fR was originally developed for the purposes of
|
659
|
-
vpsFree.cz \[la]https://vpsfree.org\[ra] and its cluster
|
679
|
+
vpsFree.cz \[la]https://vpsfree.org\[ra] and its cluster
|
660
680
|
configuration \[la]https://github.com/vpsfreecz/vpsfree-cz-configuration\[ra]\&.
|
data/man/man8/confctl.8.md
CHANGED
@@ -113,6 +113,9 @@ information.
|
|
113
113
|
`-j`, `--max-jobs` *number*
|
114
114
|
Maximum number of build jobs, passed to `nix-build`. See man nix-build(1).
|
115
115
|
|
116
|
+
`--cores` *number*
|
117
|
+
Number of CPU cores to use, passed to `nix-build`. See man nix-build(1).
|
118
|
+
|
116
119
|
`confctl deploy` [*options*] [*machine-pattern* [`boot`|`switch`|`test`|`dry-activate`]]
|
117
120
|
Deploy either a new or an existing build generation to matching machines.
|
118
121
|
|
@@ -176,6 +179,9 @@ information.
|
|
176
179
|
`-j`, `--max-jobs` *number*
|
177
180
|
Maximum number of build jobs, passed to `nix-build`. See man nix-build(1).
|
178
181
|
|
182
|
+
`--cores` *number*
|
183
|
+
Number of CPU cores to use, passed to `nix-build`. See man nix-build(1).
|
184
|
+
|
179
185
|
`--no-health-checks`
|
180
186
|
Do not run configured health checks. Health checks are run by default
|
181
187
|
when *switch-action* is `switch`, `test` or `boot` with `--reboot`.
|
@@ -224,6 +230,9 @@ information.
|
|
224
230
|
`-j`, `--max-jobs` *number*
|
225
231
|
Maximum number of build jobs, passed to `nix-build`. See man nix-build(1).
|
226
232
|
|
233
|
+
`--cores` *number*
|
234
|
+
Number of CPU cores to use, passed to `nix-build`. See man nix-build(1).
|
235
|
+
|
227
236
|
`confctl changelog` [*options*] [*machine-pattern* [*sw-pattern*]]
|
228
237
|
Show differences in deployed and configured software pins. For git software
|
229
238
|
pins, it's a git log.
|
@@ -267,6 +276,9 @@ information.
|
|
267
276
|
`-j`, `--max-jobs` *number*
|
268
277
|
Maximum number of build jobs, passed to `nix-build`. See man nix-build(1).
|
269
278
|
|
279
|
+
`--cores` *number*
|
280
|
+
Number of CPU cores to use, passed to `nix-build`. See man nix-build(1).
|
281
|
+
|
270
282
|
`confctl diff` [*options*] [*machine-pattern* [*sw-pattern*]]
|
271
283
|
Show differences in deployed and configured software pins. For git software
|
272
284
|
pins, it's a git diff.
|
@@ -304,6 +316,9 @@ information.
|
|
304
316
|
`-j`, `--max-jobs` *number*
|
305
317
|
Maximum number of build jobs, passed to `nix-build`. See man nix-build(1).
|
306
318
|
|
319
|
+
`--cores` *number*
|
320
|
+
Number of CPU cores to use, passed to `nix-build`. See man nix-build(1).
|
321
|
+
|
307
322
|
`confctl test-connection` [*options*] [*machine-pattern*]
|
308
323
|
Try to open a SSH connection to the selected machines. This command can be
|
309
324
|
used to confirm SSH host keys of the selected machines.
|
@@ -650,5 +665,5 @@ Report bugs to https://github.com/vpsfreecz/confctl/issues.
|
|
650
665
|
|
651
666
|
## ABOUT
|
652
667
|
`confctl` was originally developed for the purposes of
|
653
|
-
[vpsFree.cz](https://vpsfree.org) and its cluster
|
668
|
+
[vpsFree.cz](https://vpsfree.org) and its cluster
|
654
669
|
[configuration](https://github.com/vpsfreecz/vpsfree-cz-configuration).
|
data/nix/evaluator.nix
CHANGED
@@ -18,8 +18,8 @@ let
|
|
18
18
|
nameValuePairs = builtins.map (m: {
|
19
19
|
name = m.name;
|
20
20
|
value = {
|
21
|
-
inherit (m) name;
|
22
|
-
}
|
21
|
+
inherit (m) name alias clusterName carrier metaConfig;
|
22
|
+
};
|
23
23
|
}) machines;
|
24
24
|
|
25
25
|
machinesAttrs = builtins.listToAttrs nameValuePairs;
|
@@ -53,7 +53,7 @@ let
|
|
53
53
|
import ./lib/swpins/eval.nix {
|
54
54
|
inherit (arg) confDir;
|
55
55
|
name = m.name;
|
56
|
-
channels = m.
|
56
|
+
channels = m.metaConfig.swpins.channels;
|
57
57
|
pkgs = corePkgs.pkgs;
|
58
58
|
lib = corePkgs.lib;
|
59
59
|
};
|
@@ -70,17 +70,28 @@ let
|
|
70
70
|
value = buildToplevel fullMachinesAttrs.${host};
|
71
71
|
}) arg.machines);
|
72
72
|
|
73
|
-
buildToplevel =
|
73
|
+
buildToplevel = machine:
|
74
|
+
let
|
75
|
+
machineConfig = (evalMachine machine).config;
|
76
|
+
|
77
|
+
buildAttr = coreLib.attrByPath machine.build.attribute null machineConfig;
|
78
|
+
|
79
|
+
result =
|
80
|
+
if isNull buildAttr then
|
81
|
+
abort "Attribute 'config.${coreLib.concatStringsSep "." machine.build.attribute}' not found on machine ${machine.name}"
|
82
|
+
else
|
83
|
+
buildAttr;
|
84
|
+
in result;
|
74
85
|
|
75
|
-
evalMachine =
|
86
|
+
evalMachine = machine:
|
76
87
|
let
|
77
88
|
importPath = {
|
78
89
|
nixos = <nixpkgs/nixos/lib/eval-config.nix>;
|
79
90
|
vpsadminos = <vpsadminos/os/default.nix>;
|
80
91
|
};
|
81
92
|
|
82
|
-
evalConfig = import importPath.${
|
83
|
-
modules = [
|
93
|
+
evalConfig = import importPath.${machine.metaConfig.spin} {
|
94
|
+
modules = machine.extraModules ++ [ machine.build.toplevel ];
|
84
95
|
};
|
85
96
|
in evalConfig;
|
86
97
|
|
data/nix/lib/default.nix
CHANGED
@@ -1,29 +1,74 @@
|
|
1
1
|
{ confDir, coreLib, corePkgs }:
|
2
2
|
with coreLib;
|
3
3
|
let
|
4
|
-
machine = import ./machine { inherit confDir corePkgs coreLib
|
4
|
+
machine = import ./machine { inherit confDir corePkgs coreLib findMetaConfig; };
|
5
5
|
|
6
|
-
|
6
|
+
findMetaConfig =
|
7
7
|
{ cluster, name }:
|
8
8
|
cluster.${name};
|
9
9
|
|
10
10
|
makeMachine =
|
11
|
-
{ name,
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
{ name, metaConfig, carrier ? null, alias ? null, clusterName ? null, extraModules ? [], buildAttribute ? null }:
|
12
|
+
let
|
13
|
+
ensuredClusterName = if isNull clusterName then name else clusterName;
|
14
|
+
in {
|
15
|
+
inherit name alias metaConfig carrier extraModules;
|
16
|
+
clusterName = ensuredClusterName;
|
17
|
+
|
18
|
+
build = {
|
19
|
+
attribute = if isNull buildAttribute then metaConfig.buildAttribute else buildAttribute;
|
20
|
+
toplevel = buildConfig { name = ensuredClusterName; inherit metaConfig; };
|
21
|
+
};
|
15
22
|
};
|
16
23
|
|
17
24
|
buildConfig =
|
18
|
-
{ name,
|
19
|
-
if !
|
25
|
+
{ name, metaConfig }:
|
26
|
+
if !metaConfig.managed then
|
20
27
|
null
|
21
|
-
else if
|
22
|
-
machine.nixos { inherit name
|
23
|
-
else if
|
24
|
-
machine.vpsadminos { inherit name
|
28
|
+
else if metaConfig.spin == "nixos" then
|
29
|
+
machine.nixos { inherit name metaConfig; }
|
30
|
+
else if metaConfig.spin == "vpsadminos" then
|
31
|
+
machine.vpsadminos { inherit name metaConfig; }
|
25
32
|
else
|
26
33
|
null;
|
34
|
+
|
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);
|
41
|
+
|
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;
|
62
|
+
|
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" ]);
|
27
72
|
in rec {
|
28
73
|
inherit corePkgs coreLib;
|
29
74
|
|
@@ -35,20 +80,22 @@ in rec {
|
|
35
80
|
mkNetUdevRule name mac
|
36
81
|
) rs);
|
37
82
|
|
38
|
-
inherit
|
83
|
+
inherit findMetaConfig;
|
39
84
|
|
40
85
|
# Return all configured machines in a list
|
41
86
|
getClusterMachines = cluster:
|
42
|
-
|
43
|
-
|
44
|
-
|
87
|
+
let
|
88
|
+
machineAttrs = mapAttrs (name: metaConfig:
|
89
|
+
makeMachine { inherit name metaConfig; }
|
90
|
+
) cluster;
|
91
|
+
in expandCarriers machineAttrs;
|
45
92
|
|
46
93
|
# Get IP version addresses from all machines in a cluster
|
47
94
|
getAllAddressesOf = cluster: v:
|
48
95
|
let
|
49
96
|
machines = getClusterMachines cluster;
|
50
97
|
addresses = flatten (map (machine:
|
51
|
-
map (addr: machine // addr) machine.
|
98
|
+
map (addr: machine // addr) machine.metaConfig.addresses.${"v${toString v}"}
|
52
99
|
) machines);
|
53
100
|
in addresses;
|
54
101
|
|
data/nix/lib/machine/default.nix
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
{ confDir, corePkgs, coreLib,
|
1
|
+
{ confDir, corePkgs, coreLib, findMetaConfig }:
|
2
2
|
let
|
3
3
|
swpinsFor =
|
4
|
-
{ name,
|
4
|
+
{ name, metaConfig }:
|
5
5
|
import ../swpins/eval.nix {
|
6
6
|
inherit confDir name;
|
7
|
-
channels =
|
7
|
+
channels = metaConfig.swpins.channels;
|
8
8
|
pkgs = corePkgs;
|
9
9
|
lib = coreLib;
|
10
10
|
};
|
11
11
|
|
12
12
|
makeModuleArgs =
|
13
|
-
{
|
13
|
+
{ metaConfig, swpins, spin, name }@args: {
|
14
14
|
swpins = swpins.evaluated;
|
15
15
|
swpinsInfo = swpins.infos;
|
16
|
-
confMachine = import ./info.nix (args // { inherit
|
16
|
+
confMachine = import ./info.nix (args // { inherit findMetaConfig; });
|
17
17
|
};
|
18
18
|
|
19
19
|
makeImports = spin: extraImports: [
|
@@ -34,18 +34,20 @@ let
|
|
34
34
|
lib.mkIf (confMachine.host != null) (lib.mkDefault confMachine.host.fullDomain);
|
35
35
|
})
|
36
36
|
] ++ (import ../../modules/module-list.nix).${spin}
|
37
|
+
++ (import ../../modules/system-list.nix).${spin}
|
37
38
|
++ (import "${toString confDir}/modules/module-list.nix").${spin}
|
38
39
|
++ (import "${toString confDir}/cluster/module-list.nix")
|
39
40
|
++ extraImports;
|
40
41
|
in rec {
|
41
|
-
nixos = { name,
|
42
|
+
nixos = { name, metaConfig }:
|
42
43
|
let
|
43
|
-
swpins = swpinsFor { inherit name
|
44
|
+
swpins = swpinsFor { inherit name metaConfig; };
|
44
45
|
in
|
45
46
|
{ config, pkgs, ... }@args:
|
46
47
|
{
|
47
48
|
_module.args = makeModuleArgs {
|
48
|
-
|
49
|
+
metaConfig = config;
|
50
|
+
inherit swpins;
|
49
51
|
spin = "nixos";
|
50
52
|
inherit name;
|
51
53
|
};
|
@@ -55,14 +57,15 @@ in rec {
|
|
55
57
|
];
|
56
58
|
};
|
57
59
|
|
58
|
-
vpsadminos = { name,
|
60
|
+
vpsadminos = { name, metaConfig }:
|
59
61
|
let
|
60
|
-
swpins = swpinsFor { inherit name
|
62
|
+
swpins = swpinsFor { inherit name metaConfig; };
|
61
63
|
in
|
62
64
|
{ config, pkgs, ... }@args:
|
63
65
|
{
|
64
66
|
_module.args = makeModuleArgs {
|
65
|
-
|
67
|
+
metaConfig = config;
|
68
|
+
inherit swpins;
|
66
69
|
spin = "vpsadminos";
|
67
70
|
inherit name;
|
68
71
|
};
|
data/nix/lib/machine/info.nix
CHANGED