From 75d0f2f221e0ef6257ee97e3406f7b2c67580746 Mon Sep 17 00:00:00 2001 From: Letgamer Date: Tue, 4 Nov 2025 11:28:52 +0100 Subject: [PATCH] ligolo-ng: refactor --- pkgs/by-name/li/ligolo-ng/package.nix | 49 +++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/pkgs/by-name/li/ligolo-ng/package.nix b/pkgs/by-name/li/ligolo-ng/package.nix index 85f863763255..d7571b1435ce 100644 --- a/pkgs/by-name/li/ligolo-ng/package.nix +++ b/pkgs/by-name/li/ligolo-ng/package.nix @@ -2,38 +2,67 @@ lib, buildGoModule, fetchFromGitHub, + nix-update-script, + pkgsCross ? { }, + versionCheckHook, }: -buildGoModule rec { +buildGoModule (finalAttrs: { pname = "ligolo-ng"; version = "0.8.2"; src = fetchFromGitHub { - owner = "tnpitsecurity"; + owner = "nicocha30"; repo = "ligolo-ng"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-ND0SFB0xj4WK6okNzChZWfK5bhNc4PTWuZoq/PodTW0="; }; vendorHash = "sha256-oc85xNPMFeaPC7TMcSh3i3Msd8sCJ5QGFmi2fKjcyvk="; - postConfigure = '' - export CGO_ENABLED=0 - ''; + env.CGO_ENABLED = 0; + + subPackages = [ + "cmd/agent" + "cmd/proxy" + ]; ldflags = [ "-s" "-w" "-extldflags '-static'" + "-X main.version=${finalAttrs.version}" ]; + # This will prefix all the binaries with ligolo- + postInstall = '' + for f in $out/bin/*; do + mv "$f" "$(dirname "$f")/ligolo-$(basename "$f")" + done + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgram = "${placeholder "out"}/bin/ligolo-agent"; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru = { + tests = { + win = pkgsCross.mingwW64.ligolo-ng or null; + linux64 = pkgsCross.gnu64.ligolo-ng or null; + }; + updateScript = nix-update-script { }; + }; + # Tests require network access doCheck = false; meta = { - description = "Tunneling/pivoting tool that uses a TUN interface"; - homepage = "https://github.com/tnpitsecurity/ligolo-ng"; - changelog = "https://github.com/nicocha30/ligolo-ng/releases/tag/v${version}"; + description = "Advanced TUN-based tunneling/pivoting tool"; + homepage = "https://github.com/nicocha30/ligolo-ng"; + changelog = "https://github.com/nicocha30/ligolo-ng/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ letgamer ]; + platforms = lib.platforms.linux ++ lib.platforms.windows; }; -} +})