From d7752fc0ebf9d49dc47c70ce4e674df024a82cfa Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 22 Jun 2019 22:07:26 -0400 Subject: [PATCH] buildGoPackage: keep string context (#63680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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` --- pkgs/development/go-packages/generic/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/development/go-packages/generic/default.nix b/pkgs/development/go-packages/generic/default.nix index eb45f446dc9d..8e016fadface 100644 --- a/pkgs/development/go-packages/generic/default.nix +++ b/pkgs/development/go-packages/generic/default.nix @@ -35,14 +35,12 @@ # IE: programs coupled with the compiler , allowGoReference ? false -, meta ? {}, ... } @ args': +, meta ? {}, ... } @ args: with builtins; let - args = lib.filterAttrs (name: _: name != "extraSrcs") args'; - removeReferences = [ ] ++ lib.optional (!allowGoReference) go; removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; @@ -75,7 +73,7 @@ let goPath = if goDeps != null then importGodeps { depsFile = goDeps; } ++ extraSrcs else extraSrcs; package = go.stdenv.mkDerivation ( - (builtins.removeAttrs args [ "goPackageAliases" "disabled" ]) // { + (builtins.removeAttrs args [ "goPackageAliases" "disabled" "extraSrcs"]) // { nativeBuildInputs = [ removeReferencesTo go ] ++ (lib.optional (!dontRenameImports) govers) ++ nativeBuildInputs;