stdenv.mkDerivation: simplify overrideAttrs with extends and toOverlay
This commit is contained in:
parent
11c20cd390
commit
30809ccecd
@ -67,26 +67,8 @@ let
|
||||
# ^^^^
|
||||
|
||||
overrideAttrs = f0:
|
||||
let
|
||||
f = self: super:
|
||||
# Convert f0 to an overlay. Legacy is:
|
||||
# overrideAttrs (super: {})
|
||||
# We want to introduce self. We follow the convention of overlays:
|
||||
# overrideAttrs (self: super: {})
|
||||
# Which means the first parameter can be either self or super.
|
||||
# This is surprising, but far better than the confusion that would
|
||||
# arise from flipping an overlay's parameters in some cases.
|
||||
let x = f0 super;
|
||||
in
|
||||
if builtins.isFunction x
|
||||
then
|
||||
# Can't reuse `x`, because `self` comes first.
|
||||
# Looks inefficient, but `f0 super` was a cheap thunk.
|
||||
f0 self super
|
||||
else x;
|
||||
in
|
||||
makeDerivationExtensible
|
||||
(self: let super = rattrs self; in super // (if builtins.isFunction f0 || f0?__functor then f self super else f0));
|
||||
makeDerivationExtensible
|
||||
(lib.extends (lib.toExtension f0) rattrs);
|
||||
|
||||
finalPackage =
|
||||
mkDerivationSimple overrideAttrs args;
|
||||
|
Loading…
Reference in New Issue
Block a user