diff options
author | Silvan Mosberger <infinisil@icloud.com> | 2018-04-06 18:51:10 +0200 |
---|---|---|
committer | John Ericson <Ericson2314@yahoo.com> | 2018-04-07 13:21:49 -0400 |
commit | e1dee4efcbffc72260025078bf8297a3b732509c (patch) | |
tree | 567b274abbd1dc708037ea7f9933bce98671167b /lib/default.nix | |
parent | 95ece9efe5104522ed024e3858d46f17bc6aaf16 (diff) |
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 = ...; }
Diffstat (limited to 'lib/default.nix')
-rw-r--r-- | lib/default.nix | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/default.nix b/lib/default.nix index cbe0a0ba21b59..59b3d2159daaf 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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 |