diff --git a/nix/eval-machine-info.nix b/nix/eval-machine-info.nix index 503b4c25d..085452cd4 100644 --- a/nix/eval-machine-info.nix +++ b/nix/eval-machine-info.nix @@ -39,13 +39,42 @@ rec { # Get the configuration of this machine from each network # expression, attaching _file attributes so the NixOS module # system can give sensible error messages. + modules = concatMap (n: optional (hasAttr machineName n) { imports = [(getAttr machineName n)]; inherit (n) _file; }) networks; - in - { name = machineName; - value = import { + + machineConfs = + concatMap (n: optional (hasAttr machineName n) + (getAttr machineName n)) + networks; + + nameToPath = attrs: name: { + prefix = name; + path = attrs."${name}"; + }; + + attrsetToPaths = attrset: map (nameToPath attrset) + (builtins.attrNames attrset); + + importSources = + (concatMap (module: + if (!builtins.isFunction module + && builtins.hasAttr "deployment" module) + && (builtins.hasAttr "nix_path" module.deployment) + then attrsetToPaths module.deployment.nix_path + else []) + machineConfs) ++ builtins.nixPath; + + __nixPath = importSources; + + machineImport = builtins.scopedImport { + inherit __nixPath; + }; + in { + name = machineName; + value = machineImport { modules = modules ++ defaults ++ diff --git a/nix/options.nix b/nix/options.nix index 0866c3ab8..117b44a7b 100644 --- a/nix/options.nix +++ b/nix/options.nix @@ -103,6 +103,13 @@ in ''; }; + deployment.nix_path = mkOption { + default = {}; + type = types.attrsOf types.str; + description = '' + ''; + }; + deployment.hasFastConnection = mkOption { default = false; type = types.bool;