From a53a1857373df4c33fe63ef0536b450ca33e0fb2 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 19 May 2026 21:13:11 -0400 Subject: [PATCH 1/2] stdenv.mkDerivation: inline call to `toExtension` --- pkgs/stdenv/generic/make-derivation.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index e1680f07cfa4..0fb4717631c2 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -32,6 +32,7 @@ let isBool isDerivation isInt + isFunction isList isPath isString @@ -46,7 +47,6 @@ let seq splitString subtractLists - toExtension toFunction typeOf unique @@ -112,7 +112,21 @@ let final: let prev = rattrs final; - thisOverlay = toExtension f0 final prev; + # inlined version of toExtension + thisOverlay = + if isFunction f0 then + let + fPrev = f0 prev; + in + if isFunction fPrev then + # f is (final: prev: { ... }) + f0 final prev + else + # f is (prev: { ... }) + fPrev + else + # f is not a function; probably { ... } + f0; pos = unsafeGetAttrPos "version" thisOverlay; in warnIf From a351d833a2058662cf662ddbdd66401683703896 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 19 May 2026 21:16:57 -0400 Subject: [PATCH 2/2] stdenv.mkDerivation: move pos thunk inside another thunk --- pkgs/stdenv/generic/make-derivation.nix | 40 ++++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 0fb4717631c2..99b09e2f8083 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -127,7 +127,6 @@ let else # f is not a function; probably { ... } f0; - pos = unsafeGetAttrPos "version" thisOverlay; in warnIf ( @@ -140,26 +139,31 @@ let && !(thisOverlay ? src) && !(thisOverlay.__intentionallyOverridingVersion or false) ) - '' - ${ - args.name or "${args.pname or ""}-${args.version or ""}" - } was overridden with `version` but not `src` at ${pos.file or ""}:${ - toString pos.line or "" - }:${toString pos.column or ""}. + ( + let + pos = unsafeGetAttrPos "version" thisOverlay; + in + '' + ${ + args.name or "${args.pname or ""}-${args.version or ""}" + } was overridden with `version` but not `src` at ${pos.file or ""}:${ + toString pos.line or "" + }:${toString pos.column or ""}. - This is most likely not what you want. In order to properly change the version of a package, override - both the `version` and `src` attributes: + This is most likely not what you want. In order to properly change the version of a package, override + both the `version` and `src` attributes: - hello.overrideAttrs (oldAttrs: rec { - version = "1.0.0"; - src = pkgs.fetchurl { - url = "mirror://gnu/hello/hello-''${version}.tar.gz"; - hash = "..."; - }; - }) + hello.overrideAttrs (oldAttrs: rec { + version = "1.0.0"; + src = pkgs.fetchurl { + url = "mirror://gnu/hello/hello-''${version}.tar.gz"; + hash = "..."; + }; + }) - (To silence this warning, set `__intentionallyOverridingVersion = true` in your `overrideAttrs` call.) - '' + (To silence this warning, set `__intentionallyOverridingVersion = true` in your `overrideAttrs` call.) + '' + ) (prev // (removeAttrs thisOverlay [ "__intentionallyOverridingVersion" ])) );