diff options
Diffstat (limited to 'lib/trivial.nix')
-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 6cdc869b300b..62906339e605 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -85,6 +85,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: { }) |