Skip to content

Commit

Permalink
lib: Use lib.fixed-points.extends to avoid repetition
Browse files Browse the repository at this point in the history
Another attempt after my sloppy 48ccdf3.

@infinisil, thanks again, reverted in 4794aa5 and explained my mistakes in 48ccdf3#commitcomment-29678643. I start with their work and provide this proof of this commit's correctness:
```nix
(lib.fixedPoints.extends (lib.flip g) f) # now
((f: rattrs: self: let super = rattrs self; in super // f self super) (lib.flip g) f) # inline extends
(self: let super = f self; in super // (lib.flip g) self super) # beta reduce
(self: let super = f self; in super // g super self)  # beta reduce
(self_: let super = f self_; in super // g super self_)  # alpha rename
(self_: let super = f self_; in super // g super self_) # original, same
```

Eventually we might harmonize `overrideScope`'s `g` parameter with the general pattern, but I leave that breaking change as a separate step. Best not to refactor and break at once, and at least the abstractions make the oddity clearer.
  • Loading branch information
John Ericson committed Aug 20, 2018
1 parent f8f6ab3 commit 3cf4354
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/customisation.nix
Expand Up @@ -195,9 +195,10 @@ rec {
let self = f self // {
newScope = scope: newScope (self // scope);
callPackage = self.newScope {};
# TODO(@Ericson2314): Haromonize argument order of `g` with everything else
overrideScope = g:
makeScope newScope
(self_: let super = f self_; in super // g super self_);
(lib.fixedPoints.extends (lib.flip g) f);
packages = f;
};
in self;
Expand Down

0 comments on commit 3cf4354

Please sign in to comment.