Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

buildGoPackage: keep string context (#63680)

In Nix, each string has a context that it carries of where it
originated. Some functions like filterAttrs modify the context of its
args when doing comparisons. That is important because we use the
string context of “name” to get where a derivation was defined. This
causes some builtins like unsafeGetAttrPos to report incorrectly that
the string was set in lib/attrsets.nix and reporting that as the
source file. Using removeAttrs avoids this problem.

Fixes #63679

(cherry picked from commit 1f46aaab1b679b4db0b78b3ee16c0978f0bf66aa)
The web list of packages shows the current stable branch, so we needed
to backport this to fix that effect soonish. The change itself seems
very safe; only one rebuild is detected: `common-updater-scripts`

authored by

Matthew Bauer and committed by
Vladimír Čunát
d7752fc0 f49d8bef

+2 -4
+2 -4
pkgs/development/go-packages/generic/default.nix
··· 35 35 # IE: programs coupled with the compiler 36 36 , allowGoReference ? false 37 37 38 - , meta ? {}, ... } @ args': 38 + , meta ? {}, ... } @ args: 39 39 40 40 41 41 with builtins; 42 42 43 43 let 44 - args = lib.filterAttrs (name: _: name != "extraSrcs") args'; 45 - 46 44 removeReferences = [ ] ++ lib.optional (!allowGoReference) go; 47 45 48 46 removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; ··· 75 73 goPath = if goDeps != null then importGodeps { depsFile = goDeps; } ++ extraSrcs 76 74 else extraSrcs; 77 75 package = go.stdenv.mkDerivation ( 78 - (builtins.removeAttrs args [ "goPackageAliases" "disabled" ]) // { 76 + (builtins.removeAttrs args [ "goPackageAliases" "disabled" "extraSrcs"]) // { 79 77 80 78 nativeBuildInputs = [ removeReferencesTo go ] 81 79 ++ (lib.optional (!dontRenameImports) govers) ++ nativeBuildInputs;