2021-04-12 16:59:39 +02:00
|
|
|
{ stdenv, lib, fetchgit, buildGo116Module, zlib
|
2021-06-30 15:47:40 +02:00
|
|
|
, makeWrapper, xcodeWrapper, androidPkgs }:
|
2019-03-25 17:35:01 +01:00
|
|
|
|
2021-04-12 16:59:39 +02:00
|
|
|
buildGo116Module {
|
2019-07-19 20:40:03 +02:00
|
|
|
pname = "gomobile";
|
2021-04-12 16:59:39 +02:00
|
|
|
version = "2021-06-14";
|
2019-03-25 17:35:01 +01:00
|
|
|
|
2021-04-12 16:59:39 +02:00
|
|
|
vendorSha256 = "1irgkgv72rakg7snk1bnp10ibr64ykz9l40s59l4fnl63zsh12a0";
|
2019-03-25 17:35:01 +01:00
|
|
|
|
2021-06-30 15:47:40 +02:00
|
|
|
src = fetchgit {
|
2021-04-12 16:59:39 +02:00
|
|
|
rev = "7c8f154d100840bc5828285bb390bbae1cb5a98c";
|
2021-06-30 15:47:40 +02:00
|
|
|
name = "gomobile";
|
|
|
|
url = "https://go.googlesource.com/mobile";
|
2021-04-12 16:59:39 +02:00
|
|
|
sha256 = "1w9mra1mqf60iafp0ywvja5196fjsjyfhvz4yizqq4qkyll5qmj1";
|
2021-06-30 15:47:40 +02:00
|
|
|
};
|
2019-03-25 17:35:01 +01:00
|
|
|
|
2021-06-30 15:47:40 +02:00
|
|
|
subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
|
|
|
|
|
|
|
|
# Fails with: go: cannot find GOROOT directory
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
|
|
|
++ lib.optional stdenv.isDarwin xcodeWrapper;
|
|
|
|
|
|
|
|
# Prevent a non-deterministic temporary directory from polluting the resulting object files
|
2019-07-18 13:52:17 +02:00
|
|
|
postPatch = ''
|
2021-06-30 15:47:40 +02:00
|
|
|
substituteInPlace cmd/gomobile/env.go --replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
|
|
|
|
'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")' \
|
2019-05-14 19:29:36 +02:00
|
|
|
--replace '"io/ioutil"' ""
|
2021-06-30 15:47:40 +02:00
|
|
|
substituteInPlace cmd/gomobile/init.go --replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
|
|
|
|
'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")'
|
2019-05-14 19:29:36 +02:00
|
|
|
'';
|
|
|
|
|
2020-08-05 16:06:56 +02:00
|
|
|
# Necessary for GOPATH when using gomobile.
|
|
|
|
postInstall = ''
|
2021-06-30 15:47:40 +02:00
|
|
|
mkdir -p $out/src/golang.org/x
|
|
|
|
ln -s $src $out/src/golang.org/x/mobile
|
|
|
|
wrapProgram $out/bin/gomobile \
|
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}" \
|
|
|
|
--prefix PATH : "${androidPkgs}/bin" \
|
|
|
|
--set ANDROID_NDK_HOME "${androidPkgs}/ndk-bundle" \
|
|
|
|
--set ANDROID_HOME "${androidPkgs}"
|
2019-03-25 17:35:01 +01:00
|
|
|
'';
|
|
|
|
|
2021-04-12 16:07:55 +02:00
|
|
|
meta = with lib; {
|
2021-06-30 15:47:40 +02:00
|
|
|
description = "A tool for building and running mobile apps written in Go";
|
|
|
|
homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ jakubgs ];
|
2019-03-25 17:35:01 +01:00
|
|
|
};
|
|
|
|
}
|