Skip to content

Commit

Permalink
ci: upgrade go to 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Feb 5, 2025
1 parent 25072cf commit 3c8b904
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 20 deletions.
23 changes: 6 additions & 17 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,14 @@ in {
xcodeWrapper = callPackage ./pkgs/xcodeenv/compose-xcodewrapper.nix { } {
versions = ["16.0" "16.1" "16.2"];
};
go = super.go_1_21;
go = super.go_1_22;
clang = super.clang_15;
buildGoPackage = super.buildGo121Package;
buildGoModule = super.buildGo121Module;
gomobile = (super.gomobile.overrideAttrs (old: {
patches = [
(self.fetchurl { # https://github.com/golang/mobile/pull/84
url = "https://github.com/golang/mobile/commit/f20e966e05b8f7e06bed500fa0da81cf6ebca307.patch";
sha256 = "sha256-TZ/Yhe8gMRQUZFAs9G5/cf2b9QGtTHRSObBFD5Pbh7Y=";
})
(self.fetchurl { # https://github.com/golang/go/issues/58426
url = "https://github.com/golang/mobile/commit/406ed3a7b8e44dc32844953647b49696d8847d51.patch";
sha256 = "sha256-dqbYukHkQEw8npOkKykOAzMC3ot/Y4DEuh7fE+ptlr8=";
})
];
})).override {
# FIXME: No Android SDK packages for aarch64-darwin.
withAndroidPkgs = stdenv.system != "aarch64-darwin";
buildGoPackage = super.buildGo122Package;
buildGoModule = super.buildGo122Module;
gomobile = callPackage ./pkgs/gomobile {
#FIXME: No Android SDK packages for aarch64-darwin.
androidPkgs = self.androidEnvCustom.compose;
withAndroidPkgs = stdenv.system != "aarch64-darwin";
};

# Android environment
Expand Down
85 changes: 85 additions & 0 deletions nix/pkgs/gomobile/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
stdenv,
lib,
fetchgit,
fetchurl,
buildGo122Module,
zlib,
makeWrapper,
xcodeenv,
androidenv,
xcodeWrapperArgs ? { },
xcodeWrapper ? xcodeenv.composeXcodeWrapper xcodeWrapperArgs,
withAndroidPkgs ? stdenv.system != "aarch64-darwin",
androidPkgs ? (
androidenv.composeAndroidPackages {
includeNDK = true;
}
),
}:
buildGo122Module {
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=";

CGO_ENABLED = "1";

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")'
# To fix unable to import bind: no Go package in golang.org/x/mobile/bind
substituteInPlace cmd/gomobile/init.go --replace \
'golang.org/x/mobile/cmd/gobind@latest' \
'golang.org/x/mobile/cmd/gobind'
'';

# 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 ];
};
}
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v10.0.0",
"commit-sha1": "dcce8e9b8aec04876b854eacb56d9de95fd96a59",
"src-sha256": "008z0wrf6slf32iy3navq4zznfy6lam72lpqhxqwl8705hk4a4mj"
"version": "bump-go-to-1-23",
"commit-sha1": "71a04fe168be2d4de9cf155f2768cf8082ddec85",
"src-sha256": "03i75sdw4866713nj68k2ficmj37p10q70vksc33kqzgm03rccjz"
}

0 comments on commit 3c8b904

Please sign in to comment.