From b13cb5461433ccf7ae1a2e8d2691c3111441e984 Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Sat, 6 Jun 2015 22:38:08 +0000 Subject: [PATCH] Bring an importable modulesPath back from the dead, in the only way I know --- lib/modules.nix | 8 ++++++-- nixos/lib/eval-config.nix | 1 + nixos/modules/misc/extra-arguments.nix | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index dcede0c46c63..3561dd0d1d30 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -17,6 +17,10 @@ rec { evalModules) and the less declarative the module set is. */ evalModules = { modules , prefix ? [] + , # This should only be used for special arguments that need to be evaluated + # when resolving module structure (like in imports). For everything else, + # there's _module.args. + specialArgs ? {} , # This would be remove in the future, Prefer _module.args option instead. args ? {} , # This would be remove in the future, Prefer _module.check option instead. @@ -51,7 +55,7 @@ rec { }; }; - closed = closeModules (modules ++ [ internalModule ]) { inherit config options; lib = import ./.; }; + closed = closeModules (modules ++ [ internalModule ]) (specialArgs // { inherit config options; lib = import ./.; }); # Note: the list of modules is reversed to maintain backward # compatibility with the old module system. Not sure if this is @@ -118,7 +122,7 @@ rec { config = removeAttrs m ["key" "_file" "require" "imports"]; }; - applyIfFunction = f: arg@{ config, options, lib }: if isFunction f then + applyIfFunction = f: arg@{ config, options, lib, ... }: if isFunction f then let # Module arguments are resolved in a strict manner when attribute set # deconstruction is used. As the arguments are now defined with the diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index adacbd0863e3..97cb85a957f6 100644 --- a/nixos/lib/eval-config.nix +++ b/nixos/lib/eval-config.nix @@ -47,6 +47,7 @@ in rec { inherit prefix check; modules = modules ++ extraModules ++ baseModules ++ [ pkgsModule ]; args = extraArgs; + specialArgs = { modulesPath = ../modules; }; }) config options; # These are the extra arguments passed to every module. In diff --git a/nixos/modules/misc/extra-arguments.nix b/nixos/modules/misc/extra-arguments.nix index c2c8903546d5..ff2ff7cd4322 100644 --- a/nixos/modules/misc/extra-arguments.nix +++ b/nixos/modules/misc/extra-arguments.nix @@ -2,8 +2,6 @@ { _module.args = { - modulesPath = ../.; - pkgs_i686 = import ../../lib/nixpkgs.nix { system = "i686-linux"; config.allowUnfree = true;