wireguard-go: clean up, use versionCheckHook (#422334)

This commit is contained in:
Aleksana
2026-01-01 04:30:38 +00:00
committed by GitHub

View File

@@ -1,70 +1,62 @@
{
lib,
buildGoModule,
fetchzip,
testers,
wireguard-go,
fetchgit,
versionCheckHook,
}:
buildGoModule (
finalAttrs:
let
version = "0.0.20250522";
in
{
pname = "wireguard-go";
inherit version;
buildGoModule (finalAttrs: {
pname = "wireguard-go";
version = "0.0.20250522";
src = fetchzip {
url = "https://git.zx2c4.com/wireguard-go/snapshot/wireguard-go-${version}.tar.xz";
hash = "sha256-GRr8NKKb4SHd0WxmNL84eiofFHcauDDmSyNNrXermcA=";
};
src = fetchgit {
url = "https://git.zx2c4.com/wireguard-go";
tag = finalAttrs.version;
hash = "sha256-GRr8NKKb4SHd0WxmNL84eiofFHcauDDmSyNNrXermcA=";
};
postPatch = ''
# Skip formatting tests
rm -f format_test.go
'';
postPatch = ''
# Skip formatting tests
rm -f format_test.go
'';
vendorHash = "sha256-sCajxTV26jjlmgmbV4GG6hg9NkLGS773ZbFyKucvuBE=";
vendorHash = "sha256-sCajxTV26jjlmgmbV4GG6hg9NkLGS773ZbFyKucvuBE=";
subPackages = [ "." ];
subPackages = [ "." ];
ldflags = [ "-s" ];
ldflags = [ "-s" ];
# No tests besides the formatting one are in root.
# We can't override subPackages per-phase (and we don't
# want to needlessly build packages that have build
# constraints), so just use the upstream Makefile (that
# runs `go test ./...`) to actually run the tests.
checkPhase = ''
runHook preCheck
export GOFLAGS=''${GOFLAGS//-trimpath/}
make test
runHook postCheck
'';
# No tests besides the formatting one are in root.
# We can't override subPackages per-phase (and we don't
# want to needlessly build packages that have build
# constraints), so just use the upstream Makefile (that
# runs `go test ./...`) to actually run the tests.
checkPhase = ''
runHook preCheck
export GOFLAGS=''${GOFLAGS//-trimpath/}
make test
runHook postCheck
'';
# Tests require networking.
__darwinAllowLocalNetworking = finalAttrs.doCheck;
# Tests require networking.
__darwinAllowLocalNetworking = finalAttrs.doCheck;
postInstall = ''
mv $out/bin/wireguard $out/bin/wireguard-go
'';
postInstall = ''
mv $out/bin/wireguard $out/bin/wireguard-go
'';
passthru.tests.version = testers.testVersion {
package = wireguard-go;
version = "v${version}";
};
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
meta = {
description = "Userspace Go implementation of WireGuard";
homepage = "https://git.zx2c4.com/wireguard-go/about/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
kirelagin
winter
zx2c4
];
mainProgram = "wireguard-go";
};
}
)
meta = {
description = "Userspace Go implementation of WireGuard";
homepage = "https://git.zx2c4.com/wireguard-go/about/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
kirelagin
winter
zx2c4
];
mainProgram = "wireguard-go";
};
})