diff --git a/pkgs/by-name/fl/flyctl/package.nix b/pkgs/by-name/fl/flyctl/package.nix index 4f2e9b5b1446..f302dbac2dd3 100644 --- a/pkgs/by-name/fl/flyctl/package.nix +++ b/pkgs/by-name/fl/flyctl/package.nix @@ -17,12 +17,15 @@ buildGoModule rec { owner = "superfly"; repo = "flyctl"; rev = "v${version}"; - leaveDotGit = true; - hash = "sha256-hzKKCwGTaz1MFQ1+F9piNBnaEDZJwJqoerR1c/uzSsQ="; + postCheckout = '' + cd "$out" + git rev-parse HEAD > COMMIT + ''; + hash = "sha256-sH2owlQOB2rRLSKbj6LWwQeuYJUjdqiDxCRKMEBpUbU="; }; proxyVendor = true; - vendorHash = "sha256-ezGA1LGwQVFMzV/Ogj26pooD06O7FNTXMrYWkv6AwWM="; + vendorHash = "sha256-AaUscVllqhDivsAc5SDbfiXDWPs/x1f7kqdr6Qhf8mg="; subPackages = [ "." ]; @@ -39,12 +42,15 @@ buildGoModule rec { git ]; - patches = [ ./disable-auto-update.patch ]; + patches = [ + ./disable-auto-update.patch + ./set-commit.patch + ]; preBuild = '' - # Embed VCS Infos - export GOFLAGS="$GOFLAGS -buildvcs=true" - + export GOFLAGS="$GOFLAGS -buildvcs=false" + substituteInPlace internal/buildinfo/buildinfo.go \ + --replace '@commit@' "$(cat COMMIT)" GOOS= GOARCH= CGO_ENABLED=0 go generate ./... ''; diff --git a/pkgs/by-name/fl/flyctl/set-commit.patch b/pkgs/by-name/fl/flyctl/set-commit.patch new file mode 100644 index 000000000000..03d564f743d8 --- /dev/null +++ b/pkgs/by-name/fl/flyctl/set-commit.patch @@ -0,0 +1,10 @@ +--- a/internal/buildinfo/buildinfo.go ++++ b/internal/buildinfo/buildinfo.go +@@ -117,6 +117,7 @@ func UserAgent() string { + } + + func Commit() string { ++ return "@commit@" + info, _ := debug.ReadBuildInfo() + var rev = "" + var dirty = ""