diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2018-11-20 09:39:20 +0000 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2018-11-24 10:36:57 +0000 |
commit | 79b94624686bdf43a0518d6be7d5ad0e0274c0d8 (patch) | |
tree | 484beffa4143fc772ca7085686116bdc6ec5e83a /pkgs/development/go-modules | |
parent | 2219e2578e73751eba538c416902a27ee4cd0ac9 (diff) |
go_1_11: fix cross compilation
Diffstat (limited to 'pkgs/development/go-modules')
-rw-r--r-- | pkgs/development/go-modules/generic/default.nix | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index deebba5cfec8..6af5f72f2b73 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -1,5 +1,5 @@ { go, govers, lib, fetchgit, fetchhg, fetchbzr, rsync -, removeReferencesTo, fetchFromGitHub }: +, removeReferencesTo, fetchFromGitHub, stdenv }: { name, buildInputs ? [], nativeBuildInputs ? [], passthru ? {}, preFixup ? "" , shellHook ? "" @@ -80,7 +80,9 @@ go.stdenv.mkDerivation ( inherit name; nativeBuildInputs = [ removeReferencesTo go ] ++ (lib.optional (!dontRenameImports) govers) ++ nativeBuildInputs; - buildInputs = [ go ] ++ buildInputs; + buildInputs = buildInputs; + + inherit (go) GOOS GOARCH; configurePhase = args.configurePhase or '' runHook preConfigure @@ -167,7 +169,18 @@ go.stdenv.mkDerivation ( export NIX_BUILD_CORES=1 fi getGoDirs "" | xargs -n1 -P $NIX_BUILD_CORES bash -c 'buildGoDir install "$@"' -- - + '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + # normalize cross-compiled builds w.r.t. native builds + ( + dir=$NIX_BUILD_TOP/go/bin/${go.GOOS}_${go.GOARCH} + if [[ -n "$(shopt -s nullglob; echo $dir/*)" ]]; then + mv $dir/* $dir/.. + fi + if [[ -d $dir ]]; then + rmdir $dir + fi + ) + '' + '' runHook postBuild ''; |