git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #116747 from jakubgs/gomobile-20200622
commit496d33dc179f5e0032d5fe61f3961ce57621a62b authorSandro <sandro.jaeckel@gmail.com> dateSat 24 Apr 2021, 07:14 (6 years ago) parent747970ddd2a824
4 files changed+86
maintainers/maintainer-list.nix+6 pkgs/development/mobile/gomobile/default.nix+61 pkgs/development/mobile/gomobile/resolve-nix-android-sdk.patch+15 pkgs/top-level/all-packages.nix+4
maintainers/maintainer-list.nix+6
@@ -4401,6 +4401,12 @@
44014401 githubId = 5283991;
44024402 name = "Jake Waksbaum";
44034403 };
4404+ jakubgs = {
4405+ email = "jakub@gsokolowski.pl";
4406+ github = "jakubgs";
4407+ githubId = 2212681;
4408+ name = "Jakub Grzgorz Sokołowski";
4409+ };
44044410 jamiemagee = {
44054411 email = "jamie.magee@gmail.com";
44064412 github = "JamieMagee";
pkgs/development/mobile/gomobile/default.nixnew file+61
@@ -0,0 +1,61 @@
1+{ stdenv, lib, fetchgit, buildGoModule, zlib, makeWrapper, xcodeenv, androidenv
2+, xcodeWrapperArgs ? { }
3+, xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs
4+, androidPkgs ? androidenv.composeAndroidPackages {
5+ includeNDK = true;
6+ ndkVersion = "21.3.6528147"; # WARNING: 22.0.7026061 is broken.
7+ } }:
8+
9+buildGoModule {
10+ pname = "gomobile";
11+ version = "unstable-2020-06-22";
12+
13+ vendorSha256 = "1n1338vqkc1n8cy94501n7jn3qbr28q9d9zxnq2b4rxsqjfc9l94";
14+
15+ src = fetchgit {
16+ # WARNING: Next commit removes support for ARM 32 bit builds for iOS
17+ rev = "33b80540585f2b31e503da24d6b2a02de3c53ff5";
18+ name = "gomobile";
19+ url = "https://go.googlesource.com/mobile";
20+ sha256 = "0c9map2vrv34wmaycsv71k4day3b0z5p16yzxmlp8amvqb38zwlm";
21+ };
22+
23+ subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
24+
25+ # Fails with: go: cannot find GOROOT directory
26+ doCheck = false;
27+
28+ patches = [ ./resolve-nix-android-sdk.patch ];
29+
30+ nativeBuildInputs = [ makeWrapper ]
31+ ++ lib.optionals stdenv.isDarwin [ xcodeWrapper ];
32+
33+ # Prevent a non-deterministic temporary directory from polluting the resulting object files
34+ postPatch = ''
35+ substituteInPlace cmd/gomobile/env.go --replace \
36+ 'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
37+ 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")' \
38+ --replace '"io/ioutil"' ""
39+ substituteInPlace cmd/gomobile/init.go --replace \
40+ 'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
41+ 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")'
42+ '';
43+
44+ # Necessary for GOPATH when using gomobile.
45+ postInstall = ''
46+ mkdir -p $out/src/golang.org/x
47+ ln -s $src $out/src/golang.org/x/mobile
48+ wrapProgram $out/bin/gomobile \
49+ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}" \
50+ --prefix PATH : "${androidPkgs.androidsdk}/bin" \
51+ --set ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" \
52+ --set GOPATH $out
53+ '';
54+
55+ meta = with lib; {
56+ description = "A tool for building and running mobile apps written in Go";
57+ homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile";
58+ license = licenses.bsd3;
59+ maintainers = with maintainers; [ jakubgs ];
60+ };
61+}
pkgs/development/mobile/gomobile/resolve-nix-android-sdk.patchnew file+15
@@ -0,0 +1,15 @@
1+diff --git a/cmd/gomobile/bind_androidapp.go b/cmd/gomobile/bind_androidapp.go
2+index 3b01adc..76216fa 100644
3+--- a/cmd/gomobile/bind_androidapp.go
4++++ b/cmd/gomobile/bind_androidapp.go
5+@@ -372,6 +372,10 @@ func androidAPIPath() (string, error) {
6+ var apiVer int
7+ for _, fi := range fis {
8+ name := fi.Name()
9++ // Resolve symlinked directories (this is how the Nix Android SDK package is built)
10++ if fi2, err := os.Stat(filepath.Join(sdkDir.Name(), name)); err == nil {
11++ fi = fi2
12++ }
13+ if !fi.IsDir() || !strings.HasPrefix(name, "android-") {
14+ continue
15+ }
pkgs/top-level/all-packages.nix+4
@@ -1567,6 +1567,10 @@ in
15671567
15681568 xcodeenv = callPackage ../development/mobile/xcodeenv { };
15691569
1570+ gomobile = callPackage ../development/mobile/gomobile {
1571+ buildGoModule = buildGo115Module;
1572+ };
1573+
15701574 ssh-agents = callPackage ../tools/networking/ssh-agents { };
15711575
15721576 ssh-import-id = python3Packages.callPackage ../tools/admin/ssh-import-id { };