about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-04-11 11:16:29 -0400
committerShea Levy <shea@shealevy.com>2017-04-11 11:16:29 -0400
commit52f998a2cee9ffd37794c35ffb71805536d3c6bf (patch)
treea9037678f5ecc6b2b23b2c28fa7f7a0fa3f0df51 /lib
parent58771c482c9ec51755c7b6e19630c27e83009e14 (diff)
parent0a15af2ed170b30636a264b6b535a9327effddc5 (diff)
downloadnixlib-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.nix9
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: { })