go: refactor bootstrap

- also add bootstrap to passthru
This commit is contained in:
zowoq 2022-08-05 08:23:52 +10:00
parent 0628889e66
commit 0e2a36815d
4 changed files with 19 additions and 37 deletions

View file

@ -3,7 +3,6 @@
, fetchurl
, tzdata
, iana-etc
, runCommand
, perl
, which
, pkg-config
@ -21,15 +20,7 @@
}:
let
go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goBootstrap = runCommand "go-bootstrap" { } ''
mkdir $out
cp -rf ${go_bootstrap}/* $out/
chmod -R u+w $out
find $out -name "*.c" -delete
cp -rf $out/bin/* $out/share/go/bin/
'';
goBootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goarch = platform: {
"aarch64" = "arm64";
@ -277,6 +268,10 @@ stdenv.mkDerivation rec {
disallowedReferences = [ goBootstrap ];
passthru = {
inherit goBootstrap;
};
meta = with lib; {
description = "The Go Programming language";
homepage = "https://go.dev/";

View file

@ -3,7 +3,6 @@
, fetchurl
, tzdata
, iana-etc
, runCommand
, perl
, which
, pkg-config
@ -21,15 +20,7 @@
}:
let
go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goBootstrap = runCommand "go-bootstrap" { } ''
mkdir $out
cp -rf ${go_bootstrap}/* $out/
chmod -R u+w $out
find $out -name "*.c" -delete
cp -rf $out/bin/* $out/share/go/bin/
'';
goBootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goarch = platform: {
"aarch64" = "arm64";
@ -271,6 +262,10 @@ stdenv.mkDerivation rec {
disallowedReferences = [ goBootstrap ];
passthru = {
inherit goBootstrap;
};
meta = with lib; {
description = "The Go Programming language";
homepage = "https://go.dev/";

View file

@ -3,7 +3,6 @@
, fetchurl
, tzdata
, iana-etc
, runCommand
, perl
, which
, pkg-config
@ -21,15 +20,7 @@
}:
let
go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goBootstrap = runCommand "go-bootstrap" { } ''
mkdir $out
cp -rf ${go_bootstrap}/* $out/
chmod -R u+w $out
find $out -name "*.c" -delete
cp -rf $out/bin/* $out/share/go/bin/
'';
goBootstrap = buildPackages.callPackage ./bootstrap116.nix { };
goarch = platform: {
"aarch64" = "arm64";
@ -270,6 +261,10 @@ stdenv.mkDerivation rec {
disallowedReferences = [ goBootstrap ];
passthru = {
inherit goBootstrap;
};
meta = with lib; {
description = "The Go Programming language";
homepage = "https://go.dev/";

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, version, hashes }:
{ lib, stdenv, fetchurl, version, hashes, autoPatchelfHook }:
let
toGoKernel = platform:
if platform.isDarwin then "darwin"
@ -25,19 +25,16 @@ stdenv.mkDerivation rec {
sha256 = hashes.${platform} or (throw "Missing Go bootstrap hash for platform ${platform}");
};
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
# We must preserve the signature on Darwin
dontStrip = stdenv.hostPlatform.isDarwin;
installPhase = ''
runHook preInstall
mkdir -p $out/share/go $out/bin
mv bin/* $out/bin
cp -r . $out/share/go
${lib.optionalString stdenv.isLinux (''
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
$out/bin/go
'')}
ln -s $out/share/go/bin/go $out/bin/go
runHook postInstall
'';
}