From 79b94624686bdf43a0518d6be7d5ad0e0274c0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 20 Nov 2018 09:39:20 +0000 Subject: go_1_11: fix cross compilation --- pkgs/development/go-modules/generic/default.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'pkgs/development/go-modules') 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 ''; -- cgit v1.2.3