From 7c58e99db9138e04b45e1ea2db62f47f23b4e3d5 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:21:43 +0100 Subject: [PATCH] nix: inject tool paths via ldflags Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- cli/runtime.go | 2 +- packages/default.nix | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cli/runtime.go b/cli/runtime.go index ac5159b7e..7a1dce974 100644 --- a/cli/runtime.go +++ b/cli/runtime.go @@ -1,3 +1,3 @@ package main -const genpolicyPath = "genpolicy" +var genpolicyPath = "genpolicy" diff --git a/packages/default.nix b/packages/default.nix index 0f89a5ff6..8b5f0dac2 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -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