From c3b35f21f78a3d23aaf40b70fe8865598ddc6729 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Wed, 11 Nov 2020 10:36:19 +0800 Subject: lib: Add composeManyExtensions --- lib/fixed-points.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/fixed-points.nix') diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix index 968930526a6..f998bc74e1d 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: { }) -- cgit 1.4.1