diff --git a/nix/eval-machine-info.nix b/nix/eval-machine-info.nix index 47d2458bb..5caab91a0 100644 --- a/nix/eval-machine-info.nix +++ b/nix/eval-machine-info.nix @@ -12,48 +12,38 @@ let flakeExpr = flake.outputs.nixopsConfigurations.default or { }; - nixpkgsBoot = toString ; # this will be replaced on install by nixops' nixpkgs input - libBoot = import "${nixpkgsBoot}/lib"; + nixpkgsBoot = ; # this will be replaced on install by nixops' nixpkgs input + libOf = nixpkgs: import /${nixpkgs}/lib; + libBoot = libOf nixpkgsBoot; - evalModules = lib: modules: lib.evalModules { + evalMod = lib: mod: lib.evalModules { specialArgs = args // { inherit lib system; }; - modules = modules ++ networkExprs ++ [ - flakeExpr + modules = networkExprs ++ [ + ./net.nix mod flakeExpr { - options.nixpkgs = lib.mkOption { - type = lib.types.path; - description = "Path to the nixpkgs instance used to buld the machines."; - defaultText = lib.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own."; - default = flake.inputs.nixpkgs or nixpkgsBoot; - }; + nixpkgs = lib.mkDefault flake.inputs.nixpkgs or nixpkgsBoot; + network.nodeExtraArgs = { inherit uuid deploymentName; }; + defaults.environment.checkConfigurationOptions = lib.mkOverride 900 checkConfigurationOptions; } ]; }; - inherit ((evalModules libBoot [{ - _module.freeformType = with libBoot.types;attrsOf anything; - }]).config) nixpkgs; - + inherit ((evalMod libBoot { _module.check = false; }).config) nixpkgs; pkgs = nixpkgs.legacyPackages.${system} or (import nixpkgs { inherit system; }); - lib = nixpkgs.lib or pkgs.lib or (builtins.tryEval (import "${nixpkgs}/lib")).value or libBoot; + lib = nixpkgs.lib or pkgs.lib or (builtins.tryEval (libOf nixpkgs)).value or libBoot; in rec { inherit nixpkgs; - net = evalModules lib [ - ./net.nix - ({ config, ... }: { - resources.imports = pluginResourceModules ++ [ deploymentInfoModule ]; - network.resourcesDefaults = resourceModuleArgs_ rec{ - inherit (config) nodes resources; - machines = nodes; - }; - network.nodeExtraArgs = { inherit uuid deploymentName; }; - defaults.environment.checkConfigurationOptions = lib.mkOverride 900 checkConfigurationOptions; - # Make NixOps's deployment.* options available. - defaults.imports = pluginOptions ++ [ deploymentInfoModule ]; - }) - ]; + net = evalMod lib ({ config, ... }: { + resources.imports = pluginResourceModules ++ [ deploymentInfoModule ]; + network.resourcesDefaults = resourceModuleArgs_ rec{ + inherit (config) nodes resources; + machines = nodes; + }; + # Make NixOps's deployment.* options available. + defaults.imports = pluginOptions ++ [ deploymentInfoModule ]; + }); # for backward compatibility network = lib.mapAttrs (n: v: [v]) net.config; diff --git a/nix/net.nix b/nix/net.nix index a93c146a7..c1365b1fa 100644 --- a/nix/net.nix +++ b/nix/net.nix @@ -14,6 +14,11 @@ let in { options = { + nixpkgs = lib.mkOption { + type = types.path; + description = "Path to the nixpkgs instance used to buld the machines."; + defaultText = lib.literalDocBook "The 'nixpkgs' input to either the provided flake or nixops' own."; + }; network = { enableRollback = lib.mkEnableOption "network wide rollback"; description = mkOption {