From 9a96f4cd53a1a4b7b7332d3f79b84b600ba7454a Mon Sep 17 00:00:00 2001 From: aucub <78630225+aucub@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:32:43 +0800 Subject: [PATCH] gomobile: 2022-05-18 -> 0-unstable-2024-11-08 --- pkgs/development/mobile/gomobile/default.nix | 87 +++++++++++++++----- 1 file changed, 66 insertions(+), 21 deletions(-) diff --git a/pkgs/development/mobile/gomobile/default.nix b/pkgs/development/mobile/gomobile/default.nix index caeb524af94e0..b93b3d5cfcc0e 100644 --- a/pkgs/development/mobile/gomobile/default.nix +++ b/pkgs/development/mobile/gomobile/default.nix @@ -1,33 +1,78 @@ { + stdenv, lib, - fetchFromGitHub, + fetchgit, buildGoModule, - gitUpdater, + zlib, + makeWrapper, + xcodeenv, + androidenv, + xcodeWrapperArgs ? { }, + xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs, + withAndroidPkgs ? true, + androidPkgs ? ( + androidenv.composeAndroidPackages { + includeNDK = true; + } + ), }: -let - pname = "cast-text"; - version = "0.1.3"; - src = fetchFromGitHub { - owner = "piqoni"; - repo = "cast-text"; - rev = "v${version}"; - hash = "sha256-PU0haunPF2iAHehRT76wHXsdv5oWiBH7xVJUkQbr4QU="; - }; -in buildGoModule { - inherit pname version src; + pname = "gomobile"; + version = "0-unstable-2024-11-08"; - vendorHash = "sha256-rTrV8qzGHNNC8wTLJVerOHwFjjCGQmVuHOnBJxuYMAk="; + vendorHash = "sha256-xTl8Hd1+GHRrUb5ktl1XkQa18HsHIeEvnujrcK0E1eU="; - passthru.updateScript = gitUpdater { - rev-prefix = "v"; + src = fetchgit { + rev = "fa514ef75a0ffd7d89e1b4c9b45485f7bb39cf83"; + name = "gomobile"; + url = "https://go.googlesource.com/mobile"; + hash = "sha256-vuh6Rw27WA0BId+8JUqZdNCrvUH2sorvv15eIK/GFj0="; }; + subPackages = [ + "bind" + "cmd/gobind" + "cmd/gomobile" + ]; + + # Fails with: go: cannot find GOROOT directory + doCheck = false; + + nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.hostPlatform.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")' + 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 = '' + mkdir -p $out/pkg/golang.org/x + ln -s $src $out/pkg/golang.org/x/mobile + ''; + + postFixup = '' + for prog in gomobile gobind; do + wrapProgram $out/bin/$prog \ + --suffix GOPATH : $out \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}" \ + ${lib.optionalString withAndroidPkgs '' + --prefix PATH : "${androidPkgs.androidsdk}/bin" \ + --set-default ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" + ''} + done + ''; + meta = { - description = "Zero latency, easy-to-use full-text news terminal reader"; - homepage = "https://github.com/piqoni/cast-text"; - license = with lib.licenses; [ mit ]; - maintainers = with lib.maintainers; [ aucub ]; - platforms = lib.platforms.all; + description = "Tool for building and running mobile apps written in Go"; + homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile"; + mainProgram = "gomobile"; + license = with lib.licenses; [ bsd3 ]; + maintainers = with lib.maintainers; [ jakubgs ]; }; }