Skip to content

Commit

Permalink
gomobile: format
Browse files Browse the repository at this point in the history
  • Loading branch information
aucub committed Dec 4, 2024
1 parent 5f708cb commit 886fbeb
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions pkgs/development/mobile/gomobile/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{ stdenv, lib, fetchgit, buildGoModule, zlib, makeWrapper, xcodeenv, androidenv
, xcodeWrapperArgs ? { }
, xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs
, withAndroidPkgs ? true
, androidPkgs ? androidenv.composeAndroidPackages {
{
stdenv,
lib,
fetchgit,
buildGoModule,
zlib,
makeWrapper,
xcodeenv,
androidenv,
xcodeWrapperArgs ? { },
xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs,
withAndroidPkgs ? true,
androidPkgs ? androidenv.composeAndroidPackages {
includeNDK = true;
ndkVersion = "22.1.7171670";
} }:
},
}:

buildGoModule {
pname = "gomobile";
Expand All @@ -20,13 +29,16 @@ buildGoModule {
sha256 = "sha256-AOR/p+DW83f2+BOxm2rFXBCrotcIyunK3UzQ/dnauWY=";
};

subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
subPackages = [
"bind"
"cmd/gobind"
"cmd/gomobile"
];

# Fails with: go: cannot find GOROOT directory
doCheck = false;

nativeBuildInputs = [ makeWrapper ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ xcodeWrapper ];
nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcodeWrapper ];

# Prevent a non-deterministic temporary directory from polluting the resulting object files
postPatch = ''
Expand All @@ -44,22 +56,25 @@ buildGoModule {
ln -s $src $out/src/golang.org/x/mobile
'';

postFixup = ''
for bin in $(ls $out/bin); do
wrapProgram $out/bin/$bin \
--suffix GOPATH : $out \
'' + lib.optionalString withAndroidPkgs ''
--prefix PATH : "${androidPkgs.androidsdk}/bin" \
--set-default ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" \
'' + ''
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}"
done
'';
postFixup =
''
for bin in $(ls $out/bin); do
wrapProgram $out/bin/$bin \
--suffix GOPATH : $out \
''
+ lib.optionalString withAndroidPkgs ''
--prefix PATH : "${androidPkgs.androidsdk}/bin" \
--set-default ANDROID_HOME "${androidPkgs.androidsdk}/libexec/android-sdk" \
''
+ ''
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ zlib ]}"
done
'';

meta = with lib; {
meta = {
description = "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 ];
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ jakubgs ];
};
}

0 comments on commit 886fbeb

Please sign in to comment.