From cfec51eaa7e70d411e257ab434750f035eb08a43 Mon Sep 17 00:00:00 2001 From: Sizhe Zhao Date: Fri, 4 Jul 2025 16:10:06 +0800 Subject: [PATCH 1/2] wireguard-go: clean up --- pkgs/by-name/wi/wireguard-go/package.nix | 101 +++++++++++------------ 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/pkgs/by-name/wi/wireguard-go/package.nix b/pkgs/by-name/wi/wireguard-go/package.nix index 11ce83bcc317..e218fb838d56 100644 --- a/pkgs/by-name/wi/wireguard-go/package.nix +++ b/pkgs/by-name/wi/wireguard-go/package.nix @@ -1,70 +1,65 @@ { lib, buildGoModule, - fetchzip, + fetchgit, testers, wireguard-go, }: -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}"; - }; + passthru.tests.version = testers.testVersion { + package = wireguard-go; + version = "v${finalAttrs.version}"; + }; - 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"; + }; +}) From b8762938bc3e0614bfadf8e9c0e96d2da59ca03b Mon Sep 17 00:00:00 2001 From: Sizhe Zhao Date: Fri, 4 Jul 2025 16:14:59 +0800 Subject: [PATCH 2/2] wireguard-go: use versionCheckHook --- pkgs/by-name/wi/wireguard-go/package.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/wi/wireguard-go/package.nix b/pkgs/by-name/wi/wireguard-go/package.nix index e218fb838d56..438aacec0e10 100644 --- a/pkgs/by-name/wi/wireguard-go/package.nix +++ b/pkgs/by-name/wi/wireguard-go/package.nix @@ -2,8 +2,7 @@ lib, buildGoModule, fetchgit, - testers, - wireguard-go, + versionCheckHook, }: buildGoModule (finalAttrs: { @@ -46,10 +45,8 @@ buildGoModule (finalAttrs: { mv $out/bin/wireguard $out/bin/wireguard-go ''; - passthru.tests.version = testers.testVersion { - package = wireguard-go; - version = "v${finalAttrs.version}"; - }; + nativeInstallCheckInputs = [ versionCheckHook ]; + doInstallCheck = true; meta = { description = "Userspace Go implementation of WireGuard";