Skip to content

Commit

Permalink
nix: inject tool paths via ldflags
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jan 11, 2024
1 parent ef1df3b commit 7c58e99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/runtime.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const genpolicyPath = "genpolicy"
var genpolicyPath = "genpolicy"
13 changes: 6 additions & 7 deletions packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ rec {
proxyVendor = true;
vendorHash = "sha256-8j8uZ0D07l6tdAd+rpZidsdXZ0IxptfgmxaDogvbgLk=";

postPatch = ''
echo subsituting genpolicyPath
substituteInPlace cli/runtime.go \
--replace 'genpolicyPath = "genpolicy"' 'genpolicyPath = "${genpolicy}/bin/genpolicy"'
'';

CGO_ENABLED = 0;
ldflags = [ "-s" "-w" "-buildid=" ];
ldflags = [
"-s"
"-w"
"-buildid="
"-X main.genpolicyPath=${genpolicy}/bin/genpolicy"
];

preCheck = ''
export CGO_ENABLED=1
Expand Down

0 comments on commit 7c58e99

Please sign in to comment.