summary refs log tree commit diff
path: root/pkgs/development/go-modules
diff options
context:
space:
mode:
authorzowoq <59103226+zowoq@users.noreply.github.com>2020-10-29 13:27:20 +1000
committerzowoq <59103226+zowoq@users.noreply.github.com>2020-11-18 08:13:34 +1000
commit4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758 (patch)
tree4396c755e36915f45cb5f2171bbf37e6c0fbcb19 /pkgs/development/go-modules
parent9f035ff85724eb495efd341f9be3ceae7aa4f85e (diff)
downloadnixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar.gz
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar.bz2
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar.lz
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar.xz
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.tar.zst
nixpkgs-4e9f7bbf8573d07f7b0c87d97c026cd4aad5a758.zip
buildGo{Package,Module}: set trimpath in GOFLAGS
Also drop removeReferencesTo

`-trimpath` removes all file system paths from the compiled executable,
this should improve reproducibility.
Diffstat (limited to 'pkgs/development/go-modules')
-rw-r--r--pkgs/development/go-modules/generic/default.nix14
1 files changed, 3 insertions, 11 deletions
diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix
index 7180ab7bf96..3714a1f6f0f 100644
--- a/pkgs/development/go-modules/generic/default.nix
+++ b/pkgs/development/go-modules/generic/default.nix
@@ -1,4 +1,4 @@
-{ go, cacert, git, lib, removeReferencesTo, stdenv, vend }:
+{ go, cacert, git, lib, stdenv, vend }:
 
 { name ? "${args'.pname}-${args'.version}"
 , src
@@ -43,10 +43,6 @@ with builtins;
 let
   args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "disabled" ];
 
-  removeReferences = [ ] ++ lib.optional (!allowGoReference) go;
-
-  removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
-
   go-modules = if vendorSha256 != null then go.stdenv.mkDerivation (let modArgs = {
 
     name = "${name}-go-modules";
@@ -121,12 +117,12 @@ let
   ) // overrideModAttrs modArgs) else "";
 
   package = go.stdenv.mkDerivation (args // {
-    nativeBuildInputs = [ removeReferencesTo go ] ++ nativeBuildInputs;
+    nativeBuildInputs = [ go ] ++ nativeBuildInputs;
 
     inherit (go) GOOS GOARCH;
 
     GO111MODULE = "on";
-    GOFLAGS = "-mod=vendor";
+    GOFLAGS = [ "-mod=vendor" ] ++ lib.optionals (!allowGoReference) [ "-trimpath" ];
 
     configurePhase = args.configurePhase or ''
       runHook preConfigure
@@ -229,10 +225,6 @@ let
       runHook postInstall
     '';
 
-    preFixup = (args.preFixup or "") + ''
-      find $out/{bin,libexec,lib} -type f 2>/dev/null | xargs -r ${removeExpr removeReferences} || true
-    '';
-
     strictDeps = true;
 
     disallowedReferences = lib.optional (!allowGoReference) go;