Skip to content

Commit dae4d87

Browse files
committed
Incorporating @roberth 's suggestions
1 parent a914e16 commit dae4d87

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

doc/release-notes/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Release 2.0
1515
- Separate state backends for storing state.
1616

1717
- Major code cleanups.
18-
- Now network specification files can import other files via ``imports`` and ``requires`` is no longer supported.
18+
19+
- Now the network specification is using the module system from ``nixpkgs.lib``
20+
- Now network specification files can import other files via ``imports``.
1921
- We have a ``nodes.*`` option where we put every NixOS configuration for the configured nodes. We suggest to use it instead of defining nodes in the top level.
2022

2123
- Removed NixOS Options

nix/eval-machine-info.nix

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,37 @@ let
1717
flake = builtins.getFlake flakeUri;
1818
flakeExpr = (builtins.tryEval flake.outputs.nixopsConfigurations.default).value or { };
1919

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";
2222

23-
inherit (lib) mkOption types;
24-
25-
stage1Eval = lib.evalModules {
23+
evalBoot = libBoot.evalModules {
2624
specialArgs = args;
2725
modules = [
28-
(lib.mkRemovedOptionModule [ "require" ] "Use the imports option instead.")
2926
{
30-
options.nixpkgs = mkOption {
31-
type = types.path;
27+
options.nixpkgs = libBoot.mkOption {
28+
type = libBoot.types.path;
3229
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;
3532
};
36-
config._module.freeformType = with types;attrsOf anything;
33+
config._module.freeformType = with libBoot.types;attrsOf anything;
3734
}
3835
flakeExpr
3936
] ++ networkExprs;
4037
};
4138

42-
inherit (stage1Eval.config) nixpkgs;
39+
inherit (evalBoot.config) nixpkgs;
4340

4441
pkgs = nixpkgs.legacyPackages.${system} or import nixpkgs { inherit system; };
42+
lib = nixpkgs.lib or pkgs.lib or libBoot;
43+
inherit (lib) mkOption types removeAttrs;
4544

4645
in
4746
rec {
4847

49-
network = (stage1Eval.extendModules {
48+
network = (evalBoot.extendModules {
5049
modules = [
51-
({ config, ... }: {
50+
({ config, options, ... }: {
5251
options = {
5352
network = {
5453
enableRollback = lib.mkEnableOption "network wide rollback";
@@ -107,27 +106,26 @@ rec {
107106
});
108107
};
109108
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;
118110
default = [ ];
119111
description = ''
120112
Extra NixOS options to add to all nodes.
121113
'';
122114
};
123115
};
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+
};
125121
})
126122
];
127123
}).config;
128124

129125
inherit (network) defaults resources nodes;
130126

127+
networks = [ network ]; # for backward compatibility
128+
131129
inherit nixpkgs;
132130

133131
importedPluginNixExprs = map

0 commit comments

Comments
 (0)