Skip to content

Commit

Permalink
nix: simplify build of gomobile
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sokołowski <jakub@status.im>
  • Loading branch information
jakubgs committed Aug 6, 2020
1 parent 0319854 commit 2161192
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
29 changes: 6 additions & 23 deletions nix/pkgs/gomobile/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.";
Expand Down
2 changes: 1 addition & 1 deletion nix/status-go/mobile/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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") ''
Expand Down

0 comments on commit 2161192

Please sign in to comment.