diff options
author | Shea Levy <shea@shealevy.com> | 2017-04-11 11:16:29 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2017-04-11 11:16:29 -0400 |
commit | 52f998a2cee9ffd37794c35ffb71805536d3c6bf (patch) | |
tree | a9037678f5ecc6b2b23b2c28fa7f7a0fa3f0df51 /lib | |
parent | 58771c482c9ec51755c7b6e19630c27e83009e14 (diff) | |
parent | 0a15af2ed170b30636a264b6b535a9327effddc5 (diff) | |
download | nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar.gz nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar.bz2 nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar.lz nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar.xz nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.tar.zst nixlib-52f998a2cee9ffd37794c35ffb71805536d3c6bf.zip |
Merge branch 'composeExtensions'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/trivial.nix | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix index 40499b2b5092..acbd687dd98f 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -80,6 +80,15 @@ rec { # argument, but it's nice this way if several uses of `extends` are cascaded. extends = f: rattrs: self: let super = rattrs self; in super // f self super; + # Compose two extending functions of the type expected by 'extends' + # into one where changes made in the first are available in the + # 'super' of the second + composeExtensions = + f: g: self: super: + let fApplied = f self super; + super' = super // fApplied; + in fApplied // g self super'; + # Create an overridable, recursive attribute set. For example: # # nix-repl> obj = makeExtensible (self: { }) |