mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
https://go.dev/doc/go1.27 fix: vet The "nixpkgs-vet"[^0] CI job was failing before. - Attribute `pkgs.go_1_27` is a new top-level package using `pkgs.callPackage ./pkgs/development/compilers/go/1.27.nix { /* ... */ }`. Please define it in pkgs/by-name/go/go_1_27/package.nix instead. See `pkgs/by-name/README.md` for more details. Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. (https://github.com/NixOS/nixpkgs-vet/wiki/NPV-162) This PR introduces additional instances of discouraged patterns as listed above. Please fix them before merging. error: Cannot build '/nix/store/69y050xrdffqxils57mrqw43cf90i0xf-nixpkgs-vet.drv'. Reason: builder failed with exit code 1. Output paths: /nix/store/kxrknx65q0abw9m5mhpcivwhggpwm7l3-nixpkgs-vet Last 6 log lines: > - Attribute `pkgs.go_1_27` is a new top-level package using `pkgs.callPackage ./pkgs/development/compilers/go/1.27.nix { /* ... */ }`. > Please define it in pkgs/by-name/go/go_1_27/package.nix instead. > See `pkgs/by-name/README.md` for more details. > Since the second `callPackage` argument is `{ }`, no manual `callPackage` in pkgs/top-level/all-packages.nix is needed anymore. > (https://github.com/NixOS/nixpkgs-vet/wiki/NPV-162) > This PR introduces additional instances of discouraged patterns as listed above. Please fix them before merging. For full logs, run: nix log /nix/store/69y050xrdffqxils57mrqw43cf90i0xf-nixpkgs-vet.drv To run locally: ./ci/nixpkgs-vet.sh master https://github.com/NixOS/nixpkgs.git If you're having trouble, ping @NixOS/nixpkgs-vet Moving 1.27.nix into `pkgs/by-name/go/go_1_27/package.nix` is impractical because the file references many sibling files in `pkgs/development/compilers/go/` (patches, bootstrap files, etc.) Follow `pkgs/by-name/README.md` and use `inherit` to please the vet linter. [^0]: https://github.com/NixOS/nixpkgs/actions/runs/27820342521/job/82331726385?pr=533254#step:6:210
204 lines
6.3 KiB
Nix
204 lines
6.3 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchurl,
|
|
tzdata,
|
|
replaceVars,
|
|
iana-etc,
|
|
mailcap,
|
|
buildPackages,
|
|
pkgsBuildTarget,
|
|
targetPackages,
|
|
# for testing
|
|
buildGo127Module,
|
|
callPackage,
|
|
}:
|
|
|
|
let
|
|
goBootstrap = buildPackages.callPackage ./bootstrap124.nix { };
|
|
|
|
# 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.27rc1";
|
|
|
|
src = fetchurl {
|
|
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
|
|
hash = "sha256-M49R9VfG2xI1o+64mgk2r29ODUEWKR7zuOQRhrxlUzQ=";
|
|
};
|
|
|
|
strictDeps = true;
|
|
buildInputs =
|
|
[ ]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ stdenv.cc.libc.out ]
|
|
++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
|
|
|
|
depsBuildTarget = lib.optional isCross targetCC;
|
|
|
|
depsTargetTarget = lib.optional stdenv.targetPlatform.isMinGW targetPackages.threads.package;
|
|
|
|
postPatch = ''
|
|
patchShebangs .
|
|
'';
|
|
|
|
patches = [
|
|
(replaceVars ./iana-etc-1.25.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
|
|
(replaceVars ./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
|
|
(replaceVars ./tzdata-1.19.patch {
|
|
inherit tzdata;
|
|
})
|
|
./remove-tools-1.11.patch
|
|
./go_no_vendor_checks-1.27.patch
|
|
./go-env-go_ldso.patch
|
|
];
|
|
|
|
env = {
|
|
inherit (stdenv.targetPlatform.go) GOOS GOARCH GOARM;
|
|
# 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.go.GOOS;
|
|
GOHOSTARCH = stdenv.buildPlatform.go.GOARCH;
|
|
|
|
GO386 = "softfloat"; # from Arch: don't assume sse2 on i686
|
|
# Wasi does not support CGO
|
|
# ppc64/linux CGO is incomplete/borked, and will likely not receive any further improvements
|
|
# https://github.com/golang/go/issues/8912
|
|
# https://github.com/golang/go/issues/13192
|
|
CGO_ENABLED =
|
|
if
|
|
(
|
|
stdenv.targetPlatform.isWasi
|
|
|| (stdenv.targetPlatform.isPower64 && stdenv.targetPlatform.isBigEndian)
|
|
)
|
|
then
|
|
0
|
|
else
|
|
1;
|
|
|
|
GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
|
|
}
|
|
// lib.optionalAttrs isCross {
|
|
# {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 = "${targetCC}/bin/${targetCC.targetPrefix}cc";
|
|
CXX_FOR_TARGET = "${targetCC}/bin/${targetCC.targetPrefix}c++";
|
|
};
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
export GOCACHE=$TMPDIR/go-cache
|
|
if [ -f "$NIX_CC/nix-support/dynamic-linker" ]; then
|
|
export GO_LDSO=$(cat $NIX_CC/nix-support/dynamic-linker)
|
|
fi
|
|
|
|
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
|
|
# Prefer external linker for cross when CGO is supported, since
|
|
# we haven't taught go's internal linker to pick the correct ELF
|
|
# interpreter for cross
|
|
# When CGO is not supported we rely on static binaries being built
|
|
# since they don't need an ELF interpreter
|
|
export GO_EXTLINK_ENABLED=${toString finalAttrs.env.CGO_ENABLED}
|
|
''}
|
|
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.env.GOHOSTARCH == finalAttrs.env.GOARCH && finalAttrs.env.GOOS == finalAttrs.env.GOHOSTOS
|
|
)
|
|
)
|
|
''
|
|
rm -rf pkg/${finalAttrs.env.GOHOSTOS}_${finalAttrs.env.GOHOSTARCH} pkg/tool/${finalAttrs.env.GOHOSTOS}_${finalAttrs.env.GOHOSTARCH}
|
|
''
|
|
}
|
|
''
|
|
else
|
|
lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) ''
|
|
rm -rf bin/*_*
|
|
${lib.optionalString
|
|
(
|
|
!(
|
|
finalAttrs.env.GOHOSTARCH == finalAttrs.env.GOARCH && finalAttrs.env.GOOS == finalAttrs.env.GOHOSTOS
|
|
)
|
|
)
|
|
''
|
|
rm -rf pkg/${finalAttrs.env.GOOS}_${finalAttrs.env.GOARCH} pkg/tool/${finalAttrs.env.GOOS}_${finalAttrs.env.GOARCH}
|
|
''
|
|
}
|
|
''
|
|
);
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/share/go
|
|
cp -a bin pkg src lib misc api doc go.env VERSION $out/share/go
|
|
mkdir -p $out/bin
|
|
ln -s $out/share/go/bin/* $out/bin
|
|
runHook postInstall
|
|
'';
|
|
|
|
disallowedReferences = [ goBootstrap ];
|
|
|
|
passthru = {
|
|
inherit goBootstrap;
|
|
tests = callPackage ./tests.nix {
|
|
go = finalAttrs.finalPackage;
|
|
buildGoModule = buildGo127Module;
|
|
};
|
|
};
|
|
|
|
__structuredAttrs = true;
|
|
|
|
meta = {
|
|
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
|
|
description = "Go Programming language";
|
|
homepage = "https://go.dev/";
|
|
license = lib.licenses.bsd3;
|
|
teams = [ lib.teams.golang ];
|
|
platforms =
|
|
lib.platforms.darwin ++ lib.platforms.linux ++ lib.platforms.wasi ++ lib.platforms.freebsd;
|
|
badPlatforms = [
|
|
# Support for big-endian POWER < 8 was dropped in 1.9, but POWER8 users have less of a reason to run in big-endian mode than pre-POWER8 ones
|
|
# So non-LE ppc64 is effectively unsupported, and Go SIGILLs on affordable ppc64 hardware
|
|
# https://github.com/golang/go/issues/19074 - Dropped support for big-endian POWER < 8, with community pushback
|
|
# https://github.com/golang/go/issues/73349 - upstream will not accept submissions to fix this
|
|
"powerpc64-linux"
|
|
];
|
|
mainProgram = "go";
|
|
};
|
|
})
|