buildGo{Package,Module}: set trimpath in GOFLAGS
Also drop removeReferencesTo `-trimpath` removes all file system paths from the compiled executable, this should improve reproducibility.
This commit is contained in:
parent
9f035ff857
commit
4e9f7bbf85
@ -1,4 +1,4 @@
|
|||||||
{ go, cacert, git, lib, removeReferencesTo, stdenv, vend }:
|
{ go, cacert, git, lib, stdenv, vend }:
|
||||||
|
|
||||||
{ name ? "${args'.pname}-${args'.version}"
|
{ name ? "${args'.pname}-${args'.version}"
|
||||||
, src
|
, src
|
||||||
@ -43,10 +43,6 @@ with builtins;
|
|||||||
let
|
let
|
||||||
args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "disabled" ];
|
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 = {
|
go-modules = if vendorSha256 != null then go.stdenv.mkDerivation (let modArgs = {
|
||||||
|
|
||||||
name = "${name}-go-modules";
|
name = "${name}-go-modules";
|
||||||
@ -121,12 +117,12 @@ let
|
|||||||
) // overrideModAttrs modArgs) else "";
|
) // overrideModAttrs modArgs) else "";
|
||||||
|
|
||||||
package = go.stdenv.mkDerivation (args // {
|
package = go.stdenv.mkDerivation (args // {
|
||||||
nativeBuildInputs = [ removeReferencesTo go ] ++ nativeBuildInputs;
|
nativeBuildInputs = [ go ] ++ nativeBuildInputs;
|
||||||
|
|
||||||
inherit (go) GOOS GOARCH;
|
inherit (go) GOOS GOARCH;
|
||||||
|
|
||||||
GO111MODULE = "on";
|
GO111MODULE = "on";
|
||||||
GOFLAGS = "-mod=vendor";
|
GOFLAGS = [ "-mod=vendor" ] ++ lib.optionals (!allowGoReference) [ "-trimpath" ];
|
||||||
|
|
||||||
configurePhase = args.configurePhase or ''
|
configurePhase = args.configurePhase or ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
@ -229,10 +225,6 @@ let
|
|||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = (args.preFixup or "") + ''
|
|
||||||
find $out/{bin,libexec,lib} -type f 2>/dev/null | xargs -r ${removeExpr removeReferences} || true
|
|
||||||
'';
|
|
||||||
|
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
disallowedReferences = lib.optional (!allowGoReference) go;
|
disallowedReferences = lib.optional (!allowGoReference) go;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ go, govers, lib, fetchgit, fetchhg, fetchbzr, rsync
|
{ go, govers, lib, fetchgit, fetchhg, fetchbzr, rsync
|
||||||
, removeReferencesTo, fetchFromGitHub, stdenv }:
|
, fetchFromGitHub, stdenv }:
|
||||||
|
|
||||||
{ buildInputs ? []
|
{ buildInputs ? []
|
||||||
, nativeBuildInputs ? []
|
, nativeBuildInputs ? []
|
||||||
@ -44,10 +44,6 @@
|
|||||||
with builtins;
|
with builtins;
|
||||||
|
|
||||||
let
|
let
|
||||||
removeReferences = [ ] ++ lib.optional (!allowGoReference) go;
|
|
||||||
|
|
||||||
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
|
|
||||||
|
|
||||||
dep2src = goDep:
|
dep2src = goDep:
|
||||||
{
|
{
|
||||||
inherit (goDep) goPackagePath;
|
inherit (goDep) goPackagePath;
|
||||||
@ -78,7 +74,7 @@ let
|
|||||||
package = stdenv.mkDerivation (
|
package = stdenv.mkDerivation (
|
||||||
(builtins.removeAttrs args [ "goPackageAliases" "disabled" "extraSrcs"]) // {
|
(builtins.removeAttrs args [ "goPackageAliases" "disabled" "extraSrcs"]) // {
|
||||||
|
|
||||||
nativeBuildInputs = [ removeReferencesTo go ]
|
nativeBuildInputs = [ go ]
|
||||||
++ (lib.optional (!dontRenameImports) govers) ++ nativeBuildInputs;
|
++ (lib.optional (!dontRenameImports) govers) ++ nativeBuildInputs;
|
||||||
buildInputs = buildInputs;
|
buildInputs = buildInputs;
|
||||||
|
|
||||||
@ -88,6 +84,7 @@ let
|
|||||||
GOHOSTOS = go.GOHOSTOS or null;
|
GOHOSTOS = go.GOHOSTOS or null;
|
||||||
|
|
||||||
GO111MODULE = "off";
|
GO111MODULE = "off";
|
||||||
|
GOFLAGS = lib.optionals (!allowGoReference) [ "-trimpath" ];
|
||||||
|
|
||||||
GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
|
GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
|
||||||
|
|
||||||
@ -225,10 +222,6 @@ let
|
|||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = preFixup + ''
|
|
||||||
find $out/{bin,libexec,lib} -type f 2>/dev/null | xargs -r ${removeExpr removeReferences} || true
|
|
||||||
'';
|
|
||||||
|
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user