go: switch to finalAttrs

also add version test

Co-authored-by: Ivan Trubach <mr.trubach@icloud.com>
This commit is contained in:
zowoq 2023-09-11 14:41:27 +10:00
parent 5d866fe3fb
commit 99283f44be
4 changed files with 49 additions and 29 deletions

View file

@ -45,12 +45,12 @@ let
isCross = stdenv.buildPlatform != stdenv.targetPlatform;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "go";
version = "1.18.10";
src = fetchurl {
url = "https://go.dev/dl/go${version}.src.tar.gz";
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
sha256 = "sha256-nO3MpYhF3wyUdK4AJ0xEqVyd+u+xMvxZkhwox8EG+OY=";
};
@ -152,13 +152,13 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then ''
mv bin/*_*/* bin
rmdir bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
${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 (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) ''
rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH}
''}
'');
@ -177,15 +177,20 @@ stdenv.mkDerivation rec {
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 version}";
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
description = "The Go Programming language";
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux;
};
}
})

View file

@ -45,12 +45,12 @@ let
isCross = stdenv.buildPlatform != stdenv.targetPlatform;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "go";
version = "1.19.13";
src = fetchurl {
url = "https://go.dev/dl/go${version}.src.tar.gz";
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
hash = "sha256-zPNrU/sAJKAXNTw92yLB8AvHqAc8aqx5BC2iTuNENNM=";
};
@ -152,13 +152,13 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then ''
mv bin/*_*/* bin
rmdir bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
${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 (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) ''
rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH}
''}
'');
@ -177,15 +177,20 @@ stdenv.mkDerivation rec {
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 version}";
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
description = "The Go Programming language";
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux;
};
}
})

View file

@ -44,12 +44,12 @@ let
isCross = stdenv.buildPlatform != stdenv.targetPlatform;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "go";
version = "1.20.8";
src = fetchurl {
url = "https://go.dev/dl/go${version}.src.tar.gz";
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
hash = "sha256-ONcXFPpSeflyQEUZVtjkfjwbal3ny4QTeUnWK13TGC4=";
};
@ -144,13 +144,13 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then ''
mv bin/*_*/* bin
rmdir bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
${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 (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) ''
rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH}
''}
'');
@ -169,15 +169,20 @@ stdenv.mkDerivation rec {
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 version}";
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
description = "The Go Programming language";
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux;
};
}
})

View file

@ -44,12 +44,12 @@ let
isCross = stdenv.buildPlatform != stdenv.targetPlatform;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "go";
version = "1.21.1";
src = fetchurl {
url = "https://go.dev/dl/go${version}.src.tar.gz";
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz";
hash = "sha256-v6Nr916aHpy725q8+dFwfkeb06B4gKiuNWTK7lcRy5k=";
};
@ -136,7 +136,7 @@ stdenv.mkDerivation rec {
installPhase = ''
runHook preInstall
mkdir -p $out/{share,bin}
tar -C $out/share -x -z -f "pkg/distpack/go${version}.$GOOS-$GOARCH.tar.gz"
tar -C $out/share -x -z -f "pkg/distpack/go${finalAttrs.version}.$GOOS-$GOARCH.tar.gz"
ln -s $out/share/go/bin/* $out/bin
runHook postInstall
'';
@ -147,15 +147,20 @@ stdenv.mkDerivation rec {
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 version}";
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}";
description = "The Go Programming language";
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux;
};
}
})