Skip to content

Commit

Permalink
debug: bring in gomobile derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Jan 16, 2025
1 parent 45de074 commit 504f556
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ status-go-deps:
statusgo-android: generate
statusgo-android: ##@cross-compile Build status-go for Android
@echo "Building status-go for Android..."
export GO111MODULE=off; \
export GO111MODULE=on; \
gomobile init; \
gomobile bind -v \
-target=android -ldflags="-s -w" \
Expand All @@ -182,7 +182,7 @@ statusgo-android: ##@cross-compile Build status-go for Android
statusgo-ios: generate
statusgo-ios: ##@cross-compile Build status-go for iOS
@echo "Building status-go for iOS..."
export GO111MODULE=off; \
export GO111MODULE=on; \
gomobile init; \
gomobile bind -v \
-target=ios -ldflags="-s -w" \
Expand Down
90 changes: 90 additions & 0 deletions nix/pkgs/gomobile/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
stdenv,
lib,
fetchgit,
fetchurl,
buildGo123Module,
zlib,
makeWrapper,
xcodeenv,
androidenv,
xcodeWrapperArgs ? { },
xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs,
withAndroidPkgs ? true,
androidPkgs ? (
androidenv.composeAndroidPackages {
includeNDK = true;
}
),
}:
buildGo123Module {
pname = "gomobile";
version = "0-unstable-2024-12-13";

src = fetchgit {
name = "gomobile";
url = "https://go.googlesource.com/mobile";
rev = "a87c1cf6cf463f0d4476cfe0fcf67c2953d76e7c";
hash = "sha256-7j4rdmCZMC8tn4vAsC9x/mMNkom/+Tl7uAY+5gkSvfY=";
};

vendorHash = "sha256-6ycxEDEE0/i6Lxo0gb8wq3U2U7Q49AJj+PdzSl57wwI=";

GOPROXY = "https://proxy.golang.org,direct";
GOSUMDB = "sum.golang.org";
# GO111MODULE = "on";

# Add these to handle vendoring
modVendorDir = null;
vendorSha256 = null;

# You might also need to set these
# GOFLAGS = "-mod=mod";
# GO111MODULE = "on";

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-quiet \
'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
'tmpdir = filepath.Join(os.Getenv("NIX_BUILD_TOP"), "gomobile-work")'
substituteInPlace cmd/gomobile/init.go --replace-quiet \
'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/src/golang.org/x
ln -s $src $out/src/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 = "Tool for building and running mobile apps written in Go";
homepage = "https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile";
license = with lib.licenses; [ bsd3 ];
maintainers = with lib.maintainers; [ jakubgs ];
};
}

0 comments on commit 504f556

Please sign in to comment.