nix: simplify build of gomobile

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-08-05 16:06:56 +02:00
parent 0319854e83
commit 2161192e76
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 7 additions and 24 deletions

View File

@ -36,33 +36,18 @@ in buildGoPackage rec {
--replace \
'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
"tmpdir = filepath.Join(os.Getenv(\"NIX_BUILD_TOP\"), \"work\")"
echo "Creating $dev"
mkdir -p $dev/src/$goPackagePath
echo "Copying from $src"
cp -a $src/. $dev/src/$goPackagePath
'';
preBuild = ''
mkdir $NIX_BUILD_TOP/gomobile-work $NIX_BUILD_TOP/work
'';
postInstall =
let
inherit (stdenv.lib) makeBinPath makeLibraryPath;
in ''
mkdir -p $out $bin/lib
ln -s ${ncurses5}/lib/libncursesw.so.5 $bin/lib/libtinfo.so.5
${if isDarwin then ''
wrapProgram $bin/bin/gomobile \
--prefix "PATH" : "${makeBinPath [ xcodeWrapper ]}" \
--prefix "LD_LIBRARY_PATH" : "${makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
'' else ''
wrapProgram $bin/bin/gomobile \
--prefix "LD_LIBRARY_PATH" : "${makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
''}
$bin/bin/gomobile init
# Necessary for GOPATH when using gomobile.
postInstall = ''
echo "Creating $out"
mkdir -p $out/src/$goPackagePath
echo "Copying from $src"
cp -a $src/. $out/src/$goPackagePath
'';
src = fetchgit {
@ -71,8 +56,6 @@ in buildGoPackage rec {
url = "https://go.googlesource.com/mobile";
};
outputs = [ "bin" "dev" "out" ];
meta = with stdenv.lib; {
description = "A tool for building and running mobile apps written in Go.";
longDescription = "Gomobile is a tool for building and running mobile apps written in Go.";

View File

@ -45,7 +45,7 @@ in buildGoPackage {
mkdir ${NIX_GOWORKDIR}
export GO111MODULE=off
export GOPATH=${gomobile.dev}:$GOPATH
export GOPATH=${gomobile.out}:$GOPATH
export NIX_GOWORKDIR=${NIX_GOWORKDIR}
'' + optionalString (platform == "android") ''