Skip to content

Commit 9c534fe

Browse files
committed
eval-machine-info: move net.nix import in 1st module evaluation
1 parent 5182ff4 commit 9c534fe

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

nix/eval-machine-info.nix

+20-30
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,38 @@
1212
let
1313
flakeExpr = flake.outputs.nixopsConfigurations.default or { };
1414

15-
nixpkgsBoot = toString <nixpkgs> ; # this will be replaced on install by nixops' nixpkgs input
16-
libBoot = import "${nixpkgsBoot}/lib";
15+
nixpkgsBoot = <nixpkgs> ; # this will be replaced on install by nixops' nixpkgs input
16+
libOf = nixpkgs: import /${nixpkgs}/lib;
17+
libBoot = libOf nixpkgsBoot;
1718

18-
evalModules = lib: modules: lib.evalModules {
19+
evalMod = lib: mod: lib.evalModules {
1920
specialArgs = args // { inherit lib system; };
20-
modules = modules ++ networkExprs ++ [
21-
flakeExpr
21+
modules = networkExprs ++ [
22+
./net.nix mod flakeExpr
2223
{
23-
options.nixpkgs = lib.mkOption {
24-
type = lib.types.path;
25-
description = "Path to the nixpkgs instance used to buld the machines.";
26-
defaultText = lib.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own.";
27-
default = flake.inputs.nixpkgs or nixpkgsBoot;
28-
};
24+
nixpkgs = lib.mkDefault flake.inputs.nixpkgs or nixpkgsBoot;
25+
network.nodeExtraArgs = { inherit uuid deploymentName; };
26+
defaults.environment.checkConfigurationOptions = lib.mkOverride 900 checkConfigurationOptions;
2927
}
3028
];
3129
};
3230

33-
inherit ((evalModules libBoot [{
34-
_module.freeformType = with libBoot.types;attrsOf anything;
35-
}]).config) nixpkgs;
36-
31+
inherit ((evalMod libBoot { _module.check = false; }).config) nixpkgs;
3732
pkgs = nixpkgs.legacyPackages.${system} or (import nixpkgs { inherit system; });
38-
lib = nixpkgs.lib or pkgs.lib or (builtins.tryEval (import "${nixpkgs}/lib")).value or libBoot;
33+
lib = nixpkgs.lib or pkgs.lib or (builtins.tryEval (libOf nixpkgs)).value or libBoot;
3934

4035
in rec {
4136
inherit nixpkgs;
4237

43-
net = evalModules lib [
44-
./net.nix
45-
({ config, ... }: {
46-
resources.imports = pluginResourceModules ++ [ deploymentInfoModule ];
47-
network.resourcesDefaults = resourceModuleArgs_ rec{
48-
inherit (config) nodes resources;
49-
machines = nodes;
50-
};
51-
network.nodeExtraArgs = { inherit uuid deploymentName; };
52-
defaults.environment.checkConfigurationOptions = lib.mkOverride 900 checkConfigurationOptions;
53-
# Make NixOps's deployment.* options available.
54-
defaults.imports = pluginOptions ++ [ deploymentInfoModule ];
55-
})
56-
];
38+
net = evalMod lib ({ config, ... }: {
39+
resources.imports = pluginResourceModules ++ [ deploymentInfoModule ];
40+
network.resourcesDefaults = resourceModuleArgs_ rec{
41+
inherit (config) nodes resources;
42+
machines = nodes;
43+
};
44+
# Make NixOps's deployment.* options available.
45+
defaults.imports = pluginOptions ++ [ deploymentInfoModule ];
46+
});
5747

5848
# for backward compatibility
5949
network = lib.mapAttrs (n: v: [v]) net.config;

nix/net.nix

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ let
1414
in
1515
{
1616
options = {
17+
nixpkgs = lib.mkOption {
18+
type = types.path;
19+
description = "Path to the nixpkgs instance used to buld the machines.";
20+
defaultText = lib.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own.";
21+
};
1722
network = {
1823
enableRollback = lib.mkEnableOption "network wide rollback";
1924
description = mkOption {

0 commit comments

Comments
 (0)