aboutsummaryrefslogtreecommitdiffhomepage
path: root/package.nix
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-06-07 03:10:36 +0900
committerOphestra <cat@gensokyo.uk>2025-06-07 03:10:36 +0900
commit9a7c81a44e4876f2efde1e2d71a5ffbb0b3e96a8 (patch)
tree80ffd4b7932e5d8efa84319c750c43c2a7faab26 /package.nix
parentb7e991de5bfa81bff474d07142555df51202640a (diff)
nix: go generate in src derivation
This saves the generated files in the nix store and exposes them for use by external tools. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'package.nix')
-rw-r--r--package.nix33
1 files changed, 26 insertions, 7 deletions
diff --git a/package.nix b/package.nix
index e0f01c61..57a77112 100644
--- a/package.nix
+++ b/package.nix
@@ -33,13 +33,34 @@ buildGoModule rec {
pname = "fortify";
version = "0.4.1";
- src = builtins.path {
+ srcFiltered = builtins.path {
name = "${pname}-src";
path = lib.cleanSource ./.;
filter = path: type: !(type == "regular" && (lib.hasSuffix ".nix" path || lib.hasSuffix ".py" path)) && !(type == "directory" && lib.hasSuffix "/test" path) && !(type == "directory" && lib.hasSuffix "/cmd/fsu" path);
};
vendorHash = null;
+ src = stdenv.mkDerivation {
+ name = "${pname}-src-full";
+ inherit version;
+ enableParallelBuilding = true;
+ src = srcFiltered;
+
+ buildInputs = [
+ wayland
+ wayland-protocols
+ ];
+
+ nativeBuildInputs = [
+ go
+ pkg-config
+ wayland-scanner
+ ];
+
+ buildPhase = "GOCACHE=$(mktemp -d) go generate ./...";
+ installPhase = "cp -r . $out";
+ };
+
ldflags =
lib.attrsets.foldlAttrs
(
@@ -67,7 +88,6 @@ buildGoModule rec {
libseccomp
acl
wayland
- wayland-protocols
]
++ (with xorg; [
libxcb
@@ -77,14 +97,9 @@ buildGoModule rec {
nativeBuildInputs = [
pkg-config
- wayland-scanner
makeBinaryWrapper
];
- preBuild = ''
- HOME="$(mktemp -d)" PATH="${pkg-config}/bin:$PATH" go generate ./...
- '';
-
postInstall =
let
appPackages = [
@@ -120,6 +135,10 @@ buildGoModule rec {
gcc
xorg.xorgproto
util-linux
+
+ # for go generate
+ wayland-protocols
+ wayland-scanner
]
++ buildInputs
++ nativeBuildInputs;