nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 77 lines 2.2 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchgit, 5 buildGoModule, 6 zlib, 7 makeWrapper, 8 xcodeenv, 9 androidenv, 10 xcodeWrapperArgs ? { }, 11 xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs, 12 withAndroidPkgs ? true, 13 androidPkgs ? ( 14 androidenv.composeAndroidPackages { 15 includeNDK = true; 16 } 17 ), 18}: 19buildGoModule { 20 pname = "gomobile"; 21 version = "0-unstable-2024-12-13"; 22 23 src = fetchgit { 24 name = "gomobile"; 25 url = "https://go.googlesource.com/mobile"; 26 rev = "a87c1cf6cf463f0d4476cfe0fcf67c2953d76e7c"; 27 hash = "sha256-7j4rdmCZMC8tn4vAsC9x/mMNkom/+Tl7uAY+5gkSvfY="; 28 }; 29 30 vendorHash = "sha256-6ycxEDEE0/i6Lxo0gb8wq3U2U7Q49AJj+PdzSl57wwI="; 31 32 subPackages = [ 33 "bind" 34 "cmd/gobind" 35 "cmd/gomobile" 36 ]; 37 38 # Fails with: go: cannot find GOROOT directory 39 doCheck = false; 40 41 nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcodeWrapper ]; 42 43 # Prevent a non-deterministic temporary directory from polluting the resulting object files 44 postPatch = '' 45 substituteInPlace cmd/gomobile/env.go --replace \ 46 'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \ 47 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")' 48 substituteInPlace cmd/gomobile/init.go --replace \ 49 'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \ 50 'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "work")' 51 ''; 52 53 # Necessary for GOPATH when using gomobile. 54 postInstall = '' 55 mkdir -p $out/src/golang.org/x 56 ln -s $src $out/src/golang.org/x/mobile 57 ''; 58 59 postFixup = '' 60 for prog in gomobile gobind; do 61 wrapProgram $out/bin/$prog \ 62 --suffix GOPATH : $out \ 63 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}" \ 64 ${lib.optionalString withAndroidPkgs '' 65 --prefix PATH : "${androidPkgs.androidsdk}/bin" \ 66 --set-default ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" 67 ''} 68 done 69 ''; 70 71 meta = { 72 description = "Tool for building and running mobile apps written in Go"; 73 homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile"; 74 license = with lib.licenses; [ bsd3 ]; 75 maintainers = with lib.maintainers; [ jakubgs ]; 76 }; 77}