diff --git a/nix/pkgs/gomobile/default.nix b/nix/pkgs/gomobile/default.nix index e82b686500..f6650d0006 100644 --- a/nix/pkgs/gomobile/default.nix +++ b/nix/pkgs/gomobile/default.nix @@ -1,68 +1,56 @@ -{ stdenv, lib, utils, callPackage, fetchgit, buildGo114Package, - ncurses5, zlib, makeWrapper, patchelf, androidPkgs, xcodeWrapper -}: +{ stdenv, lib, fetchgit, buildGo114Module, zlib +, makeWrapper, xcodeWrapper, androidPkgs }: -let - inherit (stdenv) isDarwin; - inherit (lib) optional optionalString strings; -in buildGo114Package rec { +buildGo114Module { pname = "gomobile"; - version = "20200622-${strings.substring 0 7 rev}"; - # WARNING: Next commit removes support for ARM 32 bit builds for iOS - rev = "33b80540585f2b31e503da24d6b2a02de3c53ff5"; - sha256 = "0c9map2vrv34wmaycsv71k4day3b0z5p16yzxmlp8amvqb38zwlm"; + version = "2020-06-22"; - goPackagePath = "golang.org/x/mobile"; - subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ]; - goDeps = ./deps.nix; + vendorSha256 = "1n1338vqkc1n8cy94501n7jn3qbr28q9d9zxnq2b4rxsqjfc9l94"; - buildInputs = [ makeWrapper ] - ++ optional isDarwin xcodeWrapper; - - # Ensure XCode and the iPhone SDK are present, instead of failing at the end of the build - preConfigure = optionalString isDarwin utils.enforceiPhoneSDKAvailable; + src = fetchgit { + # WARNING: Next commit removes support for ARM 32 bit builds for iOS + rev = "33b80540585f2b31e503da24d6b2a02de3c53ff5"; + name = "gomobile"; + url = "https://go.googlesource.com/mobile"; + sha256 = "0c9map2vrv34wmaycsv71k4day3b0z5p16yzxmlp8amvqb38zwlm"; + }; patches = [ ./resolve-nix-android-sdk.patch ]; - postPatch = '' - substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${androidPkgs}/bin/adb\`" - - # Prevent a non-deterministic temporary directory from polluting the resulting object files - substituteInPlace cmd/gomobile/env.go \ - --replace \ - 'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \ - "tmpdir = filepath.Join(os.Getenv(\"NIX_BUILD_TOP\"), \"gomobile-work\")" \ - --replace '"io/ioutil"' "" - substituteInPlace cmd/gomobile/init.go \ - --replace \ - 'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \ - "tmpdir = filepath.Join(os.Getenv(\"NIX_BUILD_TOP\"), \"work\")" - ''; + subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ]; - preBuild = '' - mkdir $NIX_BUILD_TOP/gomobile-work $NIX_BUILD_TOP/work + # 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 + postPatch = '' + substituteInPlace cmd/gomobile/env.go --replace \ + 'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \ + 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")' \ + --replace '"io/ioutil"' "" + substituteInPlace cmd/gomobile/init.go --replace \ + 'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \ + 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")' ''; # 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 + 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}" ''; - src = fetchgit { - inherit rev sha256; - name = "gomobile"; - url = "https://go.googlesource.com/mobile"; - }; - meta = with 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."; - homepage = https://go.googlesource.com/mobile; - license = licenses.bsdOriginal; - maintainers = with maintainers; [ sheenobu pombeirp ]; - platforms = with platforms; linux ++ darwin; + 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 ]; }; } diff --git a/nix/pkgs/gomobile/deps.nix b/nix/pkgs/gomobile/deps.nix deleted file mode 100644 index 1df2cc154c..0000000000 --- a/nix/pkgs/gomobile/deps.nix +++ /dev/null @@ -1,102 +0,0 @@ -# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix) -[ - { - goPackagePath = "github.com/BurntSushi/xgb"; - fetch = { - type = "git"; - url = "https://github.com/BurntSushi/xgb"; - rev = "27f122750802"; - sha256 = "18lp2x8f5bljvlz0r7xn744f0c9rywjsb9ifiszqqdcpwhsa0kvj"; - }; - } - { - goPackagePath = "golang.org/x/crypto"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/crypto"; - rev = "87dc89f01550"; - sha256 = "0z4i1m2yn3f31ci7wvcm2rxkx2yiv7a78mfzklncmsz2k97rlh2g"; - }; - } - { - goPackagePath = "golang.org/x/exp"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/exp"; - rev = "ec7cb31e5a56"; - sha256 = "19b4kdwfahq9f809v4lmn9h47sq1y67nkl7csnracn5qd334hp06"; - }; - } - { - goPackagePath = "golang.org/x/image"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/image"; - rev = "cff245a6509b"; - sha256 = "0hiznlkiaay30acwvvyq8g6bm32r7bc6gv47pygrcxqpapasbz84"; - }; - } - { - goPackagePath = "golang.org/x/mod"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/mod"; - rev = "331c550502dd"; - sha256 = "0942gzs6mlsjal4drjmm8gr54pj1cdhsl9mnj3ygm200mf3fj6pi"; - }; - } - { - goPackagePath = "golang.org/x/net"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/net"; - rev = "3b0461eec859"; - sha256 = "0l00c8l0a8xnv6qdpwfzxxsr58jggacgzdrwiprrfx2xqm37b6d5"; - }; - } - { - goPackagePath = "golang.org/x/sync"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/sync"; - rev = "112230192c58"; - sha256 = "05i2k43j2d0llq768hg5pf3hb2yhfzp9la1w5wp0rsnnzblr0lfn"; - }; - } - { - goPackagePath = "golang.org/x/sys"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/sys"; - rev = "97732733099d"; - sha256 = "118hkp01i4z1f5h6hcjm0ff2ngqhrzj1f7731n0kw8dr6hvbx0sw"; - }; - } - { - goPackagePath = "golang.org/x/text"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/text"; - rev = "v0.3.0"; - sha256 = "0r6x6zjzhr8ksqlpiwm5gdd7s209kwk5p4lw54xjvz10cs3qlq19"; - }; - } - { - goPackagePath = "golang.org/x/tools"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/tools"; - rev = "6edc0a871e69"; - sha256 = "1nxrr7nin65cmsm6i3vxdc57n03v1i541hfllw0p4zw8f414wfll"; - }; - } - { - goPackagePath = "golang.org/x/xerrors"; - fetch = { - type = "git"; - url = "https://go.googlesource.com/xerrors"; - rev = "1b5146add898"; - sha256 = "0w2akj91krxjag0xdhsg78470888nicc5ismc2ap9jqpss6v1zih"; - }; - } -] diff --git a/nix/status-go/mobile/build.nix b/nix/status-go/mobile/build.nix index cb764332c7..b122b18432 100644 --- a/nix/status-go/mobile/build.nix +++ b/nix/status-go/mobile/build.nix @@ -41,11 +41,10 @@ in buildGo114Package { preBuild = let NIX_GOWORKDIR = "$NIX_BUILD_TOP/go-build"; in '' - mkdir ${NIX_GOWORKDIR} export GO111MODULE=off - export GOPATH=${gomobile.out}:$GOPATH + export GOPATH=${gomobile}:$GOPATH export NIX_GOWORKDIR=${NIX_GOWORKDIR} '' + optionalString (platform == "android") ''