1 { stdenv, lib, fetchgit, buildGoModule, zlib, makeWrapper, xcodeenv, androidenv
2 , xcodeWrapperArgs ? { }
3 , xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs
4 , withAndroidPkgs ? true
5 , androidPkgs ? androidenv.composeAndroidPackages {
7 ndkVersion = "22.1.7171670";
12 version = "unstable-2022-05-18";
14 vendorSha256 = "sha256-AmOy3X+d2OD7ZLbFuy+SptdlgWbZJaXYEgO79M64ufE=";
17 rev = "8578da9835fd365e78a6e63048c103b27a53a82c";
19 url = "https://go.googlesource.com/mobile";
20 sha256 = "sha256-AOR/p+DW83f2+BOxm2rFXBCrotcIyunK3UzQ/dnauWY=";
23 subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
25 # Fails with: go: cannot find GOROOT directory
28 nativeBuildInputs = [ makeWrapper ]
29 ++ lib.optionals stdenv.isDarwin [ xcodeWrapper ];
31 # Prevent a non-deterministic temporary directory from polluting the resulting object files
33 substituteInPlace cmd/gomobile/env.go --replace \
34 'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
35 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")'
36 substituteInPlace cmd/gomobile/init.go --replace \
37 'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
38 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")'
41 # Necessary for GOPATH when using gomobile.
43 mkdir -p $out/src/golang.org/x
44 ln -s $src $out/src/golang.org/x/mobile
48 for bin in $(ls $out/bin); do
49 wrapProgram $out/bin/$bin \
50 --suffix GOPATH : $out \
51 '' + lib.optionalString withAndroidPkgs ''
52 --prefix PATH : "${androidPkgs.androidsdk}/bin" \
53 --set-default ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" \
55 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}"
60 description = "A tool for building and running mobile apps written in Go";
61 homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile";
62 license = licenses.bsd3;
63 maintainers = with maintainers; [ jakubgs ];