forked from siriobalmelli/nonlibc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
85 lines (71 loc) · 1.87 KB
/
default.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
{ buildtype ? "release"
, compiler ? "clang"
, mesonFlags ? ""
, nixpkgs ? import (builtins.fetchGit {
url = "https://[email protected]/siriobalmelli-foss/nixpkgs.git";
ref = "refs/tags/sirio-2021-07-12";
}) {}
}:
with nixpkgs;
stdenv.mkDerivation rec {
name = "nonlibc";
version = "0.4.2";
meta = with lib; {
description = "Collection of standard-not-standard utilities for the discerning C programmer";
homepage = https://siriobalmelli.github.io/nonlibc;
license = licenses.lgpl21Plus;
platforms = platforms.unix;
maintainers = with maintainers; [ siriobalmelli ];
};
buildInputs = [
clang
gcc
meson
ninja
pandoc
pkgconfig
python3
] ++ lib.optional lib.inNixShell [
cscope
gdb
lldb
valgrind
which
];
propagatedBuildInputs = [
liburcu
];
# TODO: split "packages" and "site" into separate outputs?
outputs = [ "out" ];
# just work with the current directory (aka: Git repo), no fancy tarness
src = nix-gitignore.gitignoreSource [] ./.;
# Override the setupHook in the meson nix der. - will config ourselves thanks
meson = pkgs.meson.overrideAttrs ( oldAttrs: rec { setupHook = ""; });
# don't harden away position-dependent speedups for static builds
hardeningDisable = [ "pic" "pie" ];
patchPhase = ''
patchShebangs util/test_fnvsum.py
patchShebangs util/test_ncp.py
# see include/nlc_linuxversion.h for the gory details
if [ -e /usr/include/linux/version.h ]; then
cp -fv /usr/include/linux/version.h include/nlc_linuxversion.h
fi
'';
# build
mFlags = mesonFlags
+ " --buildtype=${buildtype}";
configurePhase = ''
CC=${compiler} meson --prefix=$out build $mFlags
cd build
'';
buildPhase = ''
ninja
'';
doCheck = true;
checkPhase = ''
ninja test
'';
installPhase = ''
ninja install
'';
}