From 5e347175022ba2da7f7b4dfb436ba55a3ac798b2 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Sun, 26 Apr 2026 16:16:46 -0400 Subject: [PATCH] stdenv.mkDerivation: inline function calls --- pkgs/stdenv/generic/make-derivation.nix | 74 ++++++++++++------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 2a8361efe328..4bb75a46fbf2 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -96,48 +96,44 @@ let overrideAttrs = f0: makeDerivationExtensible ( - ( - overlay: f: final: - let - prev = f final; - thisOverlay = overlay final prev; - pos = builtins.unsafeGetAttrPos "version" thisOverlay; - in - lib.warnIf - ( - prev ? src - && 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) - ) - '' - ${ - 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 ""}. + final: + let + prev = rattrs final; + thisOverlay = lib.toExtension f0 final prev; + pos = builtins.unsafeGetAttrPos "version" thisOverlay; + in + lib.warnIf + ( + prev ? src + && 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) + ) + '' + ${ + 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.) - '' - (prev // (removeAttrs thisOverlay [ "__intentionallyOverridingVersion" ])) - ) - (lib.toExtension f0) - rattrs + (To silence this warning, set `__intentionallyOverridingVersion = true` in your `overrideAttrs` call.) + '' + (prev // (removeAttrs thisOverlay [ "__intentionallyOverridingVersion" ])) ); finalPackage = mkDerivationSimple overrideAttrs args;