Skip to content

Commit

Permalink
go_1_24: init at 1.24rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Dec 19, 2024
1 parent f596aed commit 78bfef8
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 0 deletions.
203 changes: 203 additions & 0 deletions pkgs/development/compilers/go/1.24.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
{
lib,
stdenv,
fetchurl,
tzdata,
substituteAll,
iana-etc,
apple-sdk_11,
xcbuild,
mailcap,
buildPackages,
pkgsBuildTarget,
threadsCross,
testers,
skopeo,
buildGo124Module,
}:

let
goBootstrap = buildPackages.callPackage ./bootstrap122.nix { };

skopeoTest = skopeo.override { buildGoModule = buildGo124Module; };

goarch =
platform:
{
"aarch64" = "arm64";
"arm" = "arm";
"armv5tel" = "arm";
"armv6l" = "arm";
"armv7l" = "arm";
"i686" = "386";
"mips" = "mips";
"mips64el" = "mips64le";
"mipsel" = "mipsle";
"powerpc64" = "ppc64";
"powerpc64le" = "ppc64le";
"riscv64" = "riscv64";
"s390x" = "s390x";
"x86_64" = "amd64";
"wasm32" = "wasm";
}
.${platform.parsed.cpu.name} or (throw "Unsupported system: ${platform.parsed.cpu.name}");

# We need a target compiler which is still runnable at build time,
# to handle the cross-building case where build != host == target
targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;

isCross = stdenv.buildPlatform != stdenv.targetPlatform;
in
stdenv.mkDerivation (finalAttrs: {
pname = "go";
version = "1.24rc1";

src = fetchurl {
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
hash = "sha256-r9iiP9Jg8qJG0XQEmgdrigW7C62T8SIHaNIZuL33U50=";
};

strictDeps = true;
buildInputs =
[ ]
++ lib.optionals stdenv.hostPlatform.isLinux [ stdenv.cc.libc.out ]
++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];

depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [
apple-sdk_11
xcbuild
];

depsBuildTarget = lib.optional isCross targetCC;

depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package;

postPatch = ''
patchShebangs .
'';

patches = [
(substituteAll {
src = ./iana-etc-1.17.patch;
iana = iana-etc;
})
# Patch the mimetype database location which is missing on NixOS.
# but also allow static binaries built with NixOS to run outside nix
(substituteAll {
src = ./mailcap-1.17.patch;
inherit mailcap;
})
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server
(substituteAll {
src = ./tzdata-1.19.patch;
inherit tzdata;
})
./remove-tools-1.11.patch
./go_no_vendor_checks-1.22.patch
];

GOOS = if stdenv.targetPlatform.isWasi then "wasip1" else stdenv.targetPlatform.parsed.kernel.name;
GOARCH = goarch stdenv.targetPlatform;
# GOHOSTOS/GOHOSTARCH must match the building system, not the host system.
# Go will nevertheless build a for host system that we will copy over in
# the install phase.
GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name;
GOHOSTARCH = goarch stdenv.buildPlatform;

# {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
# to be different from CC/CXX
CC_FOR_TARGET = if isCross then "${targetCC}/bin/${targetCC.targetPrefix}cc" else null;
CXX_FOR_TARGET = if isCross then "${targetCC}/bin/${targetCC.targetPrefix}c++" else null;

GOARM = toString (
lib.intersectLists [ (stdenv.hostPlatform.parsed.cpu.version or "") ] [ "5" "6" "7" ]
);
GO386 = "softfloat"; # from Arch: don't assume sse2 on i686
# Wasi does not support CGO
CGO_ENABLED = if stdenv.targetPlatform.isWasi then 0 else 1;

GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";

buildPhase = ''
runHook preBuild
export GOCACHE=$TMPDIR/go-cache
export PATH=$(pwd)/bin:$PATH
${lib.optionalString isCross ''
# Independent from host/target, CC should produce code for the building system.
# We only set it when cross-compiling.
export CC=${buildPackages.stdenv.cc}/bin/cc
''}
ulimit -a
pushd src
./make.bash
popd
runHook postBuild
'';

preInstall =
''
# Contains the wrong perl shebang when cross compiling,
# since it is not used for anything we can deleted as well.
rm src/regexp/syntax/make_perl_groups.pl
''
+ (
if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then
''
mv bin/*_*/* bin
rmdir bin/*_*
${lib.optionalString
(!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS))
''
rm -rf pkg/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} pkg/tool/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH}
''
}
''
else
lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) ''
rm -rf bin/*_*
${lib.optionalString
(!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS))
''
rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH}
''
}
''
);

installPhase = ''
runHook preInstall
mkdir -p $out/share/go
cp -a bin pkg src lib misc api doc go.env $out/share/go
mkdir -p $out/bin
ln -s $out/share/go/bin/* $out/bin
runHook postInstall
'';

disallowedReferences = [ goBootstrap ];

passthru = {
inherit goBootstrap skopeoTest;
tests = {
skopeo = testers.testVersion { package = skopeoTest; };
version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "go version";
version = "go${finalAttrs.version}";
};
};
};

meta = with lib; {
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
description = "Go Programming language";
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux ++ platforms.wasi ++ platforms.freebsd;
mainProgram = "go";
};
})
27 changes: 27 additions & 0 deletions pkgs/development/compilers/go/bootstrap122.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ callPackage }:
callPackage ./binary.nix {
version = "1.22.10";
hashes = {
# Use `print-hashes.sh ${version}` to generate the list below
darwin-amd64 = "dd2c4ac3702658c2c20e3a8b394da1917d86156b2cb4312c9d2f657f80067874";
darwin-arm64 = "21cf49415ffe0755b45f2b63e75d136528a32f7bb7bdd0166f51d22a03eb0a3f";
freebsd-386 = "f82f5d194114963693e0f51fd56d55d8417ca556438062f2b0df608473b62837";
freebsd-amd64 = "cce9da240870a4430c5cf1227bcf29d37575043ff16f7982a69f1139c6f564b5";
freebsd-arm64 = "abae388d0d42563a242db0d405172cb73e09236f68000ff90c2a327ec8c5764c";
freebsd-armv6l = "7c9c8fe30cbabbb4fb597f0f0ad1279fd2b320bc70831eba4c207b55ad46931d";
freebsd-riscv64 = "d6f25fd79e17b84d1b61bec3e2fdffc47377b28b51a04b6bdbeac0199313e059";
linux-386 = "2ae9f00e9621489b75494fa2b8abfc5d09e0cae6effdd4c13867957ad2e4deba";
linux-amd64 = "736ce492a19d756a92719a6121226087ccd91b652ed5caec40ad6dbfb2252092";
linux-arm64 = "5213c5e32fde3bd7da65516467b7ffbfe40d2bb5a5f58105e387eef450583eec";
linux-armv6l = "a7bbbc80fe736269820bbdf3555e91ada5d18a5cde2276aac3b559bc1d52fc70";
linux-loong64 = "0be34dbc69726b52414e0283736f997fee477379ebff66cebd7d8c35f4f64f9d";
linux-mips = "bb7d7e99db7ee70063cb57bb7395c392b8b5ed87f37d733a1c91de935c70bb91";
linux-mips64 = "c7f0571410297cb29e52d10fed7a2a21aeaeabb9539d0c04a6d778adf0fe7f1b";
linux-mips64le = "e66c440c03dd19bf8423034cbde7f6813321beb18d3fcf2ef234c13a25467952";
linux-mipsle = "b4e0061f62a9c1f874893aa4951a4883c19762a9dd64c5710554ec5a7aaf311a";
linux-ppc64 = "4192158cdedc6a124aa32a099cc6bebebabf1f4d380c46c5e36ea52c30a3888b";
linux-ppc64le = "db05b9838f69d741fb9a5301220b1a62014aee025b0baf341aba3d280087b981";
linux-riscv64 = "aef9b186c1b9b58c0472dbf54978f97682852a91b2e8d6bf354e59ba9c24438a";
linux-s390x = "4ab2286adb096576771801b5099760b1d625fd7b44080449151a4d9b21303672";
};
}
5 changes: 5 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11225,6 +11225,11 @@ with pkgs;
go = buildPackages.go_1_23;
};

go_1_24 = callPackage ../development/compilers/go/1.24.nix { };
buildGo124Module = callPackage ../build-support/go/module.nix {
go = buildPackages.go_1_24;
};

### DEVELOPMENT / HARE

hareHook = callPackage ../by-name/ha/hare/hook.nix { };
Expand Down

0 comments on commit 78bfef8

Please sign in to comment.