Repository navigation
Expand file tree
/
Copy pathdefault.nix
More file actions
71 lines (61 loc) · 1.49 KB
/
Copy pathdefault.nix
File metadata and controls
71 lines (61 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
lib,
buildGoApplication,
installShellFiles,
versionCheckHook,
}:
buildGoApplication (
lib.fix (finalAttrs: {
meta.mainProgram = finalAttrs.pname;
pname = "rfm";
version = lib.fileContents ./version.txt;
src =
with lib.fileset;
toSource {
root = ./.;
fileset = unions [
# code
./bpf
./cmd
./collector
./config
./ctl
./enrich
./export
./probe
./testutil
# meta
./go.mod
./go.sum
./gomod2nix.toml
./version.txt
];
};
modules = ./gomod2nix.toml;
subPackages = [ "cmd/rfm" ];
# the default check hook takes its package list from subPackages, which
# would test cmd/rfm alone, so every package is tested here and the
# tests that need root skip themselves in the sandbox
checkPhase = ''
runHook preCheck
go test -p "$NIX_BUILD_CORES" ./...
runHook postCheck
'';
CGO_ENABLED = 0;
ldflags = [
"-s"
"-w"
"-X"
"main.version=${finalAttrs.version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
for shell in bash zsh fish; do
installShellCompletion --cmd ${finalAttrs.pname} --''${shell} <("$out/bin/${finalAttrs.pname}" completion "$shell")
done
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "version";
})
)