-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpkg-fun.nix
86 lines (80 loc) · 2.21 KB
/
pkg-fun.nix
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ============================================================================ #
#
#
#
# ---------------------------------------------------------------------------- #
{ stdenv
, pkg-config
, nlohmann_json
, nix
, boost
, bats
, gnused
, jq
}: let
batsWith =
bats.withLibraries ( p: [p.bats-assert p.bats-file p.bats-support] );
in stdenv.mkDerivation {
pname = "parser-util";
version = "0.1.2";
src = builtins.path {
path = ./.;
filter = name: type: let
bname = baseNameOf name;
ignores = [
"pkg-fun.nix"
"default.nix"
"flake.nix"
"flake.lock"
".git"
".github"
".gitignore"
"out"
"bin"
".ccls"
".ccls-cache"
];
notIgnored = ! (builtins.elem bname ignores);
notObject = ( builtins.match ".*\\.o" name ) == null;
notResult = ( builtins.match "result(-*)?" bname ) == null;
in notIgnored && notObject && notResult;
};
boost_CFLAGS = "-I" + boost + "/include";
libExt = stdenv.hostPlatform.extensions.sharedLibrary;
nix_INCDIR = nix.dev + "/include";
nativeBuildInputs = [
# required for builds:
pkg-config
# required for tests:
batsWith
gnused
jq
];
buildInputs = [nlohmann_json nix.dev boost];
configurePhase = ''
runHook preConfigure;
export PREFIX="$out";
if [[ "''${enableParallelBuilding:-1}" = 1 ]]; then
makeFlagsArray+=( '-j4' );
fi
runHook postConfigure;
'';
# Real tests require internet connection and cannot be run in a sandbox.
# Still we do a smoke test running `parser-util --help' to catch low hanging
# issues like dynamic library resolution and init processes.
doInstallCheck = false;
doCheck = true;
checkPhase = ''
runHook preCheck;
if ! ./bin/parser-util --help >/dev/null; then
echo "FAIL: parser-util --help" >&2;
exit 1;
fi
runHook postCheck;
'';
}
# ---------------------------------------------------------------------------- #
#
#
#
# ============================================================================ #