From c7d656214f40ba168a8cb0c857e9dd54302eb59a Mon Sep 17 00:00:00 2001 From: Varun Narravula Date: Wed, 3 Dec 2025 15:50:36 -0800 Subject: [PATCH] fix(nix): replace version string sub with ldflags, use gitignore on src --- flake.nix | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index f87ca0b..19301a4 100644 --- a/flake.nix +++ b/flake.nix @@ -25,22 +25,21 @@ # Update version when releasing version = "1.4.2"; - - # Update the version in a new source tree - srcWithReplacedVersion = pkgs.runCommand "newt-src-with-version" { } '' - cp -r ${./.} $out - chmod -R +w $out - rm -rf $out/.git $out/result $out/.envrc $out/.direnv - sed -i "s/version_replaceme/${version}/g" $out/main.go - ''; in { default = self.packages.${system}.pangolin-newt; + pangolin-newt = pkgs.buildGoModule { pname = "pangolin-newt"; - version = version; - src = srcWithReplacedVersion; + inherit version; + src = pkgs.nix-gitignore.gitignoreSource [ ] ./.; + vendorHash = "sha256-iLUeQ16KLRPdAZT3DCe4eGjlqPrNJJ27BNLtTpeQlC0="; + + ldflags = [ + "-X main.newtVersion=${version}" + ]; + meta = with pkgs.lib; { description = "A tunneling client for Pangolin"; homepage = "https://github.com/fosrl/newt";