mkDerivation: support __functor functions and clean up (#411760)

This commit is contained in:
Philip Taron 2025-05-30 12:57:00 -07:00 committed by GitHub
commit 802d3df5e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 26 deletions

View file

@ -2,7 +2,6 @@
collectd.overrideAttrs (oldAttrs: {
pname = "libcollectdclient";
inherit (collectd) version;
buildInputs = [ ];
configureFlags = (oldAttrs.configureFlags or [ ]) ++ [

View file

@ -439,6 +439,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
(superDarwin.binutils-unwrapped.override { enableManpages = false; }).overrideAttrs
(old: {
version = "boot";
__intentionallyOverridingVersion = true; # to avoid a warning suggesting to provide src
passthru = (old.passthru or { }) // {
isFromBootstrapFiles = true;
};

View file

@ -36,6 +36,7 @@ let
remove
splitString
subtractLists
toFunction
unique
zipAttrsWith
;
@ -61,12 +62,7 @@ let
Most arguments are also passed through to the underlying call of [`builtins.derivation`](https://nixos.org/manual/nix/stable/language/derivations).
:::
*/
mkDerivation =
fnOrAttrs:
if builtins.isFunction fnOrAttrs then
makeDerivationExtensible fnOrAttrs
else
makeDerivationExtensibleConst fnOrAttrs;
mkDerivation = fnOrAttrs: makeDerivationExtensible (toFunction fnOrAttrs);
checkMeta = import ./check-meta.nix {
inherit lib config;
@ -99,6 +95,10 @@ let
thisOverlay = overlay final prev;
warnForBadVersionOverride = (
thisOverlay ? version
&& prev ? version
# We could check that the version is actually distinct, but that
# would probably just delay the inevitable, or preserve tech debt.
# && prev.version != thisOverlay.version
&& !(thisOverlay ? src)
&& !(thisOverlay.__intentionallyOverridingVersion or false)
);
@ -135,25 +135,6 @@ let
in
finalPackage;
#makeDerivationExtensibleConst = attrs: makeDerivationExtensible (_: attrs);
# but pre-evaluated for a slight improvement in performance.
makeDerivationExtensibleConst =
attrs:
mkDerivationSimple (
f0:
let
f =
self: super:
let
x = f0 super;
in
if builtins.isFunction x then f0 self super else x;
in
makeDerivationExtensible (
self: attrs // (if builtins.isFunction f0 || f0 ? __functor then f self attrs else f0)
)
) attrs;
knownHardeningFlags = [
"bindnow"
"format"

View file

@ -15911,6 +15911,7 @@ with pkgs;
polyml = polyml.overrideAttrs {
pname = "polyml-for-isabelle";
version = "2025";
__intentionallyOverridingVersion = true; # avoid a warning, no src override
configureFlags = [
"--enable-intinf-as-int"
"--with-gmp"