Merge pull request #176380 from hercules-ci/simplify-mkDerivation
Simplify `mkDerivation`
This commit is contained in:
commit
a4af21c0d8
1 changed files with 11 additions and 15 deletions
|
@ -10,14 +10,8 @@ let
|
||||||
inherit (stdenv) hostPlatform;
|
inherit (stdenv) hostPlatform;
|
||||||
};
|
};
|
||||||
|
|
||||||
makeOverlayable = mkDerivationSimple:
|
|
||||||
fnOrAttrs:
|
|
||||||
if builtins.isFunction fnOrAttrs
|
|
||||||
then makeDerivationExtensible mkDerivationSimple fnOrAttrs
|
|
||||||
else makeDerivationExtensibleConst mkDerivationSimple fnOrAttrs;
|
|
||||||
|
|
||||||
# Based off lib.makeExtensible, with modifications:
|
# Based off lib.makeExtensible, with modifications:
|
||||||
makeDerivationExtensible = mkDerivationSimple: rattrs:
|
makeDerivationExtensible = rattrs:
|
||||||
let
|
let
|
||||||
# NOTE: The following is a hint that will be printed by the Nix cli when
|
# NOTE: The following is a hint that will be printed by the Nix cli when
|
||||||
# encountering an infinite recursion. It must not be formatted into
|
# encountering an infinite recursion. It must not be formatted into
|
||||||
|
@ -48,14 +42,14 @@ let
|
||||||
f0 self super
|
f0 self super
|
||||||
else x;
|
else x;
|
||||||
in
|
in
|
||||||
makeDerivationExtensible mkDerivationSimple
|
makeDerivationExtensible
|
||||||
(self: let super = rattrs self; in super // f self super))
|
(self: let super = rattrs self; in super // f self super))
|
||||||
args;
|
args;
|
||||||
in finalPackage;
|
in finalPackage;
|
||||||
|
|
||||||
# makeDerivationExtensibleConst == makeDerivationExtensible (_: attrs),
|
# makeDerivationExtensibleConst == makeDerivationExtensible (_: attrs),
|
||||||
# but pre-evaluated for a slight improvement in performance.
|
# but pre-evaluated for a slight improvement in performance.
|
||||||
makeDerivationExtensibleConst = mkDerivationSimple: attrs:
|
makeDerivationExtensibleConst = attrs:
|
||||||
mkDerivationSimple
|
mkDerivationSimple
|
||||||
(f0:
|
(f0:
|
||||||
let
|
let
|
||||||
|
@ -67,12 +61,10 @@ let
|
||||||
f0 self super
|
f0 self super
|
||||||
else x;
|
else x;
|
||||||
in
|
in
|
||||||
makeDerivationExtensible mkDerivationSimple (self: attrs // f self attrs))
|
makeDerivationExtensible (self: attrs // f self attrs))
|
||||||
attrs;
|
attrs;
|
||||||
|
|
||||||
in
|
mkDerivationSimple = overrideAttrs:
|
||||||
|
|
||||||
makeOverlayable (overrideAttrs:
|
|
||||||
|
|
||||||
|
|
||||||
# `mkDerivation` wraps the builtin `derivation` function to
|
# `mkDerivation` wraps the builtin `derivation` function to
|
||||||
|
@ -485,6 +477,10 @@ lib.extendDerivation
|
||||||
# should be made available to Nix expressions using the
|
# should be made available to Nix expressions using the
|
||||||
# derivation (e.g., in assertions).
|
# derivation (e.g., in assertions).
|
||||||
passthru)
|
passthru)
|
||||||
(derivation derivationArg)
|
(derivation derivationArg);
|
||||||
|
|
||||||
)
|
in
|
||||||
|
fnOrAttrs:
|
||||||
|
if builtins.isFunction fnOrAttrs
|
||||||
|
then makeDerivationExtensible fnOrAttrs
|
||||||
|
else makeDerivationExtensibleConst fnOrAttrs
|
||||||
|
|
Loading…
Reference in a new issue