summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-04-14 19:08:20 +0200
committerVladimír Čunát <vcunat@gmail.com>2017-04-14 19:08:59 +0200
commit4aec96b379d3f1b89128297b0943253d6961cf94 (patch)
treebae26b8f66fa14c858f20ae409594e4abe7bc9b9 /lib/trivial.nix
parenteb750f9a7b22620a9bafc1ff3c498e062b3bd5b2 (diff)
parent6617c8bd87e185ece1762c22ed4521adebd7c65b (diff)
downloadnixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar.gz
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar.bz2
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar.lz
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar.xz
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.tar.zst
nixpkgs-4aec96b379d3f1b89128297b0943253d6961cf94.zip
Merge the two "same" merges
This only takes the state from the second parent.
The purpose is that when this commit depends on the failed one,
simply merging this commit is a safe way to fix the problems.  Details:
https://github.com/NixOS/nixpkgs/commit/24444513fb5#commitcomment-21767916
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 40499b2b509..acbd687dd98 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: { })