lib: make extensible
This allows the lib fixed point to be extended with
myLib = lib.extend (self: super: {
foo = "foo";
})
With this it's possible to have the new modified lib attrset available to all
modules when using evalModules
myLib.evalModules {
modules = [ ({ lib, ... }: {
options.bar = lib.mkOption {
default = lib.foo;
};
}) ];
}
=> { config = { bar = "foo"; ... }; options = ...; }
This commit is contained in:
parent
95ece9efe5
commit
e1dee4efcb
@ -5,9 +5,11 @@
|
||||
*/
|
||||
let
|
||||
|
||||
callLibs = file: import file { inherit lib; };
|
||||
inherit (import ./fixed-points.nix {}) makeExtensible;
|
||||
|
||||
lib = rec {
|
||||
lib = makeExtensible (self: let
|
||||
callLibs = file: import file { lib = self; };
|
||||
in with self; {
|
||||
|
||||
# often used, or depending on very little
|
||||
trivial = callLibs ./trivial.nix;
|
||||
@ -128,5 +130,5 @@ let
|
||||
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
||||
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
||||
prepareDerivationArgs nixType imap overridableDelayableArgs;
|
||||
};
|
||||
});
|
||||
in lib
|
||||
|
||||
@ -59,7 +59,7 @@ rec {
|
||||
};
|
||||
};
|
||||
|
||||
closed = closeModules (modules ++ [ internalModule ]) ({ inherit config options; lib = import ./.; } // specialArgs);
|
||||
closed = closeModules (modules ++ [ internalModule ]) ({ inherit config options lib; } // specialArgs);
|
||||
|
||||
options = mergeModules prefix (reverseList (filterModules (specialArgs.modulesPath or "") closed));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user