diff --git a/builtinModules/homeConfigurations.nix b/builtinModules/homeConfigurations.nix index f120916..4bf8f2c 100644 --- a/builtinModules/homeConfigurations.nix +++ b/builtinModules/homeConfigurations.nix @@ -8,7 +8,7 @@ let inherit (lib) foldl mapAttrsToList mkOption mkIf recursiveUpdate; inherit (lib.types) attrs lazyAttrsOf; inherit (flakelight) selectAttr; - inherit (flakelight.types) optFunctionTo; + inherit (flakelight.types) optCallWith; isHome = x: x ? activationPackage; @@ -29,14 +29,12 @@ let ); configs = mapAttrs - (name: f: - let val = f moduleArgs; in - if isHome val then val else mkHome name val) + (name: cfg: if isHome cfg then cfg else mkHome name cfg) config.homeConfigurations; in { options.homeConfigurations = mkOption { - type = lazyAttrsOf (optFunctionTo attrs); + type = lazyAttrsOf (optCallWith moduleArgs attrs); default = { }; }; diff --git a/builtinModules/nixosConfigurations.nix b/builtinModules/nixosConfigurations.nix index 30b4bb6..96746cf 100644 --- a/builtinModules/nixosConfigurations.nix +++ b/builtinModules/nixosConfigurations.nix @@ -8,7 +8,7 @@ let inherit (lib) foldl mapAttrsToList mkIf mkOption recursiveUpdate; inherit (lib.types) attrs lazyAttrsOf; inherit (flakelight) selectAttr; - inherit (flakelight.types) optFunctionTo; + inherit (flakelight.types) optCallWith; # Avoid checking if toplevel is a derivation as it causes the nixos modules # to be evaluated. @@ -23,14 +23,12 @@ let }); configs = mapAttrs - (hostname: f: - let val = f moduleArgs; in - if isNixos val then val else mkNixos hostname val) + (hostname: cfg: if isNixos cfg then cfg else mkNixos hostname cfg) config.nixosConfigurations; in { options.nixosConfigurations = mkOption { - type = lazyAttrsOf (optFunctionTo attrs); + type = lazyAttrsOf (optCallWith moduleArgs attrs); default = { }; }; diff --git a/default.nix b/default.nix index 7df750a..d2a7995 100644 --- a/default.nix +++ b/default.nix @@ -92,6 +92,9 @@ let optFunctionTo = elemType: coercedTo elemType (x: _: x) (functionTo elemType); + + optCallWith = args: elemType: coercedTo (functionTo elemType) (x: x args) + elemType; }; supportedSystem = { lib, stdenv, ... }: