summary refs log tree commit diff
path: root/lib/customisation.nix
diff options
context:
space:
mode:
authorJohn Ericson <mail@JohnEricson.me>2018-08-20 13:09:15 -0400
committerGitHub <noreply@github.com>2018-08-20 13:09:15 -0400
commit3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095 (patch)
tree6a24a3399dd0aff40e616b428ee084f82ed936fd /lib/customisation.nix
parentf8f6ab3e8293e823954490a0e9d48e3933c1e326 (diff)
downloadnixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar.gz
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar.bz2
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar.lz
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar.xz
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.tar.zst
nixpkgs-3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095.zip
lib: Use lib.fixed-points.extends to avoid repetition
Another attempt after my sloppy https://github.com/NixOS/nixpkgs/commit/48ccdf322d9e7a68d0caf5833511ee3e53ec7d3a.

@Infinisil, thanks again, reverted in https://github.com/NixOS/nixpkgs/commit/4794aa5de233b5bf2d1c3245946379699d023467 and explained my mistakes in https://github.com/NixOS/nixpkgs/commit/48ccdf322d9e7a68d0caf5833511ee3e53ec7d3a#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.
Diffstat (limited to 'lib/customisation.nix')
-rw-r--r--lib/customisation.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 48028042890..0107ed33d9e 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -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;