Skip to content

Commit

Permalink
[nixos-24.05] tailscale: 1.66.4 -> 1.74.1 (#346724)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Oct 7, 2024
2 parents 434dcf9 + cb2976a commit 1bfbbbe
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 8 deletions.
190 changes: 190 additions & 0 deletions pkgs/development/compilers/go/1.23.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{ lib
, stdenv
, fetchurl
, tzdata
, substituteAll
, iana-etc
, Security
, Foundation
, xcbuild
, mailcap
, buildPackages
, pkgsBuildTarget
, threadsCross
, testers
, skopeo
, buildGo123Module
}:

let
useGccGoBootstrap = stdenv.buildPlatform.isMusl;
goBootstrap = if useGccGoBootstrap then buildPackages.gccgo12 else buildPackages.callPackage ./bootstrap121.nix { };

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

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.23.1";

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

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

depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [ Foundation Security 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 = if useGccGoBootstrap then goBootstrap else "${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;
mainProgram = "go";
};
})
21 changes: 14 additions & 7 deletions pkgs/servers/tailscale/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
, shadow
, procps
, nixosTests
, installShellFiles
}:

let
version = "1.66.4";
version = "1.74.1";
in
buildGoModule {
pname = "tailscale";
Expand All @@ -23,7 +24,7 @@ buildGoModule {
owner = "tailscale";
repo = "tailscale";
rev = "v${version}";
hash = "sha256-ETBca3qKO2iS30teIF5sr/oyJdRSKFqLFVO3+mmm7bo=";
hash = "sha256-672FtDKgz7Nmoufoe4Xg/b8sA8EuKH8X+3n9PAKYjFk=";
};

patches = [
Expand All @@ -35,9 +36,9 @@ buildGoModule {
})
];

vendorHash = "sha256-Hd77xy8stw0Y6sfk3/ItqRIbM/349M/4uf0iNy1xJGw=";
vendorHash = "sha256-HJEgBs2GOzXvRa95LdwySQmG4/+QwupFDBGrQT6Y2vE=";

nativeBuildInputs = lib.optionals stdenv.isLinux [ makeWrapper ];
nativeBuildInputs = lib.optionals stdenv.isLinux [ makeWrapper ] ++ [ installShellFiles ];

CGO_ENABLED = 0;

Expand All @@ -62,9 +63,14 @@ buildGoModule {
wrapProgram $out/bin/tailscaled \
--prefix PATH : ${lib.makeBinPath [ iproute2 iptables getent shadow ]} \
--suffix PATH : ${lib.makeBinPath [ procps ]}
sed -i -e "s#/usr/sbin#$out/bin#" -e "/^EnvironmentFile/d" ./cmd/tailscaled/tailscaled.service
install -D -m0444 -t $out/lib/systemd/system ./cmd/tailscaled/tailscaled.service
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
local INSTALL="$out/bin/tailscale"
installShellCompletion --cmd tailscale \
--bash <($out/bin/tailscale completion bash) \
--fish <($out/bin/tailscale completion fish) \
--zsh <($out/bin/tailscale completion zsh)
'';

passthru.tests = {
Expand All @@ -73,9 +79,10 @@ buildGoModule {

meta = with lib; {
homepage = "https://tailscale.com";
description = "The node agent for Tailscale, a mesh VPN built on WireGuard";
description = "Node agent for Tailscale, a mesh VPN built on WireGuard";
changelog = "https://github.com/tailscale/tailscale/releases/tag/v${version}";
license = licenses.bsd3;
mainProgram = "tailscale";
maintainers = with maintainers; [ mbaillie jk mfrw ];
maintainers = with maintainers; [ mbaillie jk mfrw pyrox0 ];
};
}
13 changes: 12 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25177,6 +25177,17 @@ with pkgs;
go = buildPackages.go_1_22;
};

# requires a newer Apple SDK
go_1_23 = darwin.apple_sdk_11_0.callPackage ../development/compilers/go/1.23.nix {
inherit (darwin.apple_sdk_11_0.frameworks) Foundation Security;
};
buildGo123Module = darwin.apple_sdk_11_0.callPackage ../build-support/go/module.nix {
go = buildPackages.go_1_23;
};
buildGo123Package = darwin.apple_sdk_11_0.callPackage ../build-support/go/package.nix {
go = buildPackages.go_1_23;
};

leaps = callPackage ../development/tools/leaps { };

### DEVELOPMENT / JAVA MODULES
Expand Down Expand Up @@ -26581,7 +26592,7 @@ with pkgs;
systemd-journal2gelf = callPackage ../tools/system/systemd-journal2gelf { };

tailscale = callPackage ../servers/tailscale {
buildGoModule = buildGo122Module;
buildGoModule = buildGo123Module;
};

tailscale-systray = callPackage ../applications/misc/tailscale-systray { };
Expand Down

0 comments on commit 1bfbbbe

Please sign in to comment.