diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-03-31 11:25:44 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-05-06 18:29:04 +0200 |
commit | 1f4a58ef038184eaf4757e96ec1f09b08a01c8ab (patch) | |
tree | a289f8945255857516d66602f9f9c5e49c7237ed /lib/modules.nix | |
parent | 06ca78663c912eb62075ad4aea1f24c7f35cb0c3 (diff) | |
download | nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar.gz nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar.bz2 nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar.lz nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar.xz nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.tar.zst nixpkgs-1f4a58ef038184eaf4757e96ec1f09b08a01c8ab.zip |
lib/modules.nix: Refactor: extract applyModuleArgs
Diffstat (limited to 'lib/modules.nix')
-rw-r--r-- | lib/modules.nix | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 3b64afddaf5..9377c2e1e9d 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -364,7 +364,7 @@ let # Like unifyModuleSyntax, but also imports paths and calls functions if necessary loadModule = args: fallbackFile: fallbackKey: m: if isFunction m then - unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgsIfFunction fallbackKey m args) + unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgs fallbackKey m args) else if isAttrs m then if m._type or "module" == "module" then unifyModuleSyntax fallbackFile fallbackKey m @@ -514,7 +514,10 @@ let class = m.class or null; }; - applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then + applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }: + if isFunction f then applyModuleArgs key f args else f; + + applyModuleArgs = key: f: args@{ config, options, lib, ... }: let # Module arguments are resolved in a strict manner when attribute set # deconstruction is used. As the arguments are now defined with the @@ -538,9 +541,7 @@ let # context on the explicit arguments of "args" too. This update # operator is used to make the "args@{ ... }: with args.lib;" notation # works. - in f (args // extraArgs) - else - f; + in f (args // extraArgs); /* Merge a list of modules. This will recurse over the option declarations in all modules, combining them into a single set. |