summaryrefslogtreecommitdiffstats
path: root/lib/fixed-points.nix
diff options
context:
space:
mode:
authorJoe Hermaszewski <git@monoid.al>2020-11-11 10:36:19 +0800
committerPeter Simons <simons@cryp.to>2020-11-13 21:37:57 +0100
commitc3b35f21f78a3d23aaf40b70fe8865598ddc6729 (patch)
treecb243bc900a386be28cb73dd437f8f7aaa44cc97 /lib/fixed-points.nix
parentbacdeffd804c1da6700d2ab424cf2b74ca7e5355 (diff)
lib: Add composeManyExtensions
Diffstat (limited to 'lib/fixed-points.nix')
-rw-r--r--lib/fixed-points.nix11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index 968930526a63..f998bc74e1db 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -1,4 +1,4 @@
-{ ... }:
+{ lib, ... }:
rec {
# Compute the fixed point of the given function `f`, which is usually an
# attribute set that expects its final, non-recursive representation as an
@@ -77,6 +77,15 @@ rec {
super' = super // fApplied;
in fApplied // g self super';
+ # Compose several extending functions of the type expected by 'extends' into
+ # one where changes made in preceding functions are made available to
+ # subsequent ones.
+ #
+ # composeManyExtensions : [packageSet -> packageSet -> packageSet] -> packageSet -> packageSet -> packageSet
+ # ^final ^prev ^overrides ^final ^prev ^overrides
+ composeManyExtensions =
+ lib.foldr (x: y: composeExtensions x y) (self: super: {});
+
# Create an overridable, recursive attribute set. For example:
#
# nix-repl> obj = makeExtensible (self: { })