From 315a3525ceca8f442d419114233b98cd5bd57cb1 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:50:24 -0500 Subject: [PATCH] applyPatches: reorganize name handling, and fix meta.position --- .../trivial-builders/default.nix | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index 3051885345ae..88e4ef6dbe88 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -1007,16 +1007,6 @@ rec { finalAttrs: { src, - name ? - ( - if builtins.typeOf src == "path" then - baseNameOf src - else if builtins.isAttrs src && builtins.hasAttr "name" src then - src.name - else - throw "applyPatches: please supply a `name` argument because a default name can only be computed when the `src` is a path or is an attribute set with a `name` attribute." - ) - + "-patched", ... }@args: assert lib.assertMsg ( @@ -1039,9 +1029,23 @@ rec { ); in { - inherit - name - ; + name = + args.name or ( + if builtins.isPath src then + baseNameOf src + "-patched" + else if builtins.isAttrs src && (src ? name) then + let + srcName = builtins.parseDrvName src; + in + "${srcName.name}-patched${lib.optionalString (srcName.version != "") "-${srcName.version}"}" + else + throw "applyPatches: please supply a `name` argument because a default name can only be computed when the `src` is a path or is an attribute set with a `name` attribute." + ); + + # Manually setting `name` can mess up positioning. + # This should fix it. + pos = builtins.unsafeGetAttrPos "src" args; + preferLocalBuild = true; allowSubstitutes = false;