Skip to content

Commit

Permalink
eval-machine-info: move net.nix import in 1st module evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
pasqui23 committed Feb 4, 2023
1 parent 5182ff4 commit 9c534fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
50 changes: 20 additions & 30 deletions nix/eval-machine-info.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,38 @@
let
flakeExpr = flake.outputs.nixopsConfigurations.default or { };

nixpkgsBoot = toString <nixpkgs> ; # this will be replaced on install by nixops' nixpkgs input
libBoot = import "${nixpkgsBoot}/lib";
nixpkgsBoot = <nixpkgs> ; # 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;
Expand Down
5 changes: 5 additions & 0 deletions nix/net.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9c534fe

Please sign in to comment.