|
17 | 17 | flake = builtins.getFlake flakeUri; |
18 | 18 | flakeExpr = (builtins.tryEval flake.outputs.nixopsConfigurations.default).value or { }; |
19 | 19 |
|
20 | | - nixpkgs1 = <nixpkgs>; # this will be replaced on install by nixops' nixpkgs input |
21 | | - lib = import "${nixpkgs1}/lib"; |
| 20 | + nixpkgsBoot = <nixpkgs> ; # this will be replaced on install by nixops' nixpkgs input |
| 21 | + libBoot = import "${nixpkgsBoot}/lib"; |
22 | 22 |
|
23 | | - inherit (lib) mkOption types; |
24 | | - |
25 | | - stage1Eval = lib.evalModules { |
| 23 | + evalBoot = libBoot.evalModules { |
26 | 24 | specialArgs = args; |
27 | 25 | modules = [ |
28 | | - (lib.mkRemovedOptionModule [ "require" ] "Use the imports option instead.") |
29 | 26 | { |
30 | | - options.nixpkgs = mkOption { |
31 | | - type = types.path; |
| 27 | + options.nixpkgs = libBoot.mkOption { |
| 28 | + type = libBoot.types.path; |
32 | 29 | description = "Path to the nixpkgs instance used to buld the machines."; |
33 | | - defaultText = lib.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own."; |
34 | | - default = (builtins.tryEval flake.inputs.nixpkgs).value or nixpkgs1; |
| 30 | + defaultText = libBoot.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own."; |
| 31 | + default = (builtins.tryEval flake.inputs.nixpkgs).value or nixpkgsBoot; |
35 | 32 | }; |
36 | | - config._module.freeformType = with types;attrsOf anything; |
| 33 | + config._module.freeformType = with libBoot.types;attrsOf anything; |
37 | 34 | } |
38 | 35 | flakeExpr |
39 | 36 | ] ++ networkExprs; |
40 | 37 | }; |
41 | 38 |
|
42 | | - inherit (stage1Eval.config) nixpkgs; |
| 39 | + inherit (evalBoot.config) nixpkgs; |
43 | 40 |
|
44 | 41 | pkgs = nixpkgs.legacyPackages.${system} or import nixpkgs { inherit system; }; |
| 42 | + lib = nixpkgs.lib or pkgs.lib or libBoot; |
| 43 | + inherit (lib) mkOption types removeAttrs; |
45 | 44 |
|
46 | 45 | in |
47 | 46 | rec { |
48 | 47 |
|
49 | | - network = (stage1Eval.extendModules { |
| 48 | + network = (evalBoot.extendModules { |
50 | 49 | modules = [ |
51 | | - ({ config, ... }: { |
| 50 | + ({ config, options, ... }: { |
52 | 51 | options = { |
53 | 52 | network = { |
54 | 53 | enableRollback = lib.mkEnableOption "network wide rollback"; |
@@ -107,27 +106,26 @@ rec { |
107 | 106 | }); |
108 | 107 | }; |
109 | 108 | defaults = mkOption { |
110 | | - type = with types; |
111 | | - # TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448 |
112 | | - listOf (lib.mkOptionType { |
113 | | - name = "submodule"; |
114 | | - inherit (submodule { }) check; |
115 | | - merge = lib.options.mergeOneOption; |
116 | | - description = "NixOS modules"; |
117 | | - }); |
| 109 | + type = with types;listOf anything; |
118 | 110 | default = [ ]; |
119 | 111 | description = '' |
120 | 112 | Extra NixOS options to add to all nodes. |
121 | 113 | ''; |
122 | 114 | }; |
123 | 115 | }; |
124 | | - config.nodes = removeAttrs config [ "network" "defaults" "resources" "nodes" "nixpkgs" ]; |
| 116 | + config = let |
| 117 | + nodes = removeAttrs config (builtins.attrNames options); |
| 118 | + in mkIf ({} != nodes) { #TODO: actual warning/assert module impl. |
| 119 | + nodes = lib.warn "Please use the actual nodes.* option instead of assigning machines to the config's top level" nodes; |
| 120 | + }; |
125 | 121 | }) |
126 | 122 | ]; |
127 | 123 | }).config; |
128 | 124 |
|
129 | 125 | inherit (network) defaults resources nodes; |
130 | 126 |
|
| 127 | + networks = [ network ]; # for backward compatibility |
| 128 | + |
131 | 129 | inherit nixpkgs; |
132 | 130 |
|
133 | 131 | importedPluginNixExprs = map |
|
0 commit comments