@@ -80,6 +80,15 @@ rec {
8080 # argument, but it's nice this way if several uses of `extends` are cascaded.
8181 extends = f: rattrs: self: let super = rattrs self; in super // f self super;
8282
83+ # Compose two extending functions of the type expected by 'extends'
84+ # into one where changes made in the first are available in the
85+ # 'super' of the second
86+ composeExtensions =
87+ f: g: self: super:
88+ let fApplied = f self super;
89+ super' = super // fApplied;
90+ in fApplied // g self super';
91+
8392 # Create an overridable, recursive attribute set. For example:
8493 #
8594 # nix-repl> obj = makeExtensible (self: { })