]> git.sesse.net Git - bcachefs-tools-debian/blob - binary.nix
make: remove libbcachefs.so when cleaning.
[bcachefs-tools-debian] / binary.nix
1 { lib
2 , stdenv
3 , pkg-config
4 , attr
5 , libuuid
6 , libsodium
7 , keyutils
8
9 , liburcu
10 , zlib
11 , libaio
12 , udev
13 , zstd
14 , lz4
15
16 , python39
17 , python39Packages
18 , docutils
19 , nixosTests
20
21 , versionString ? "0.1"
22 , doCheck ? true
23 , inShell ? false
24 , debugMode ? inShell
25
26 , testWithValgrind ? true
27 , valgrind 
28
29 , fuseSupport ? false
30 , fuse3 ? null }:
31
32 assert fuseSupport -> fuse3 != null;
33 assert testWithValgrind -> valgrind != null;
34 stdenv.mkDerivation {
35   pname = "bcachefs-bin";
36
37   version = "v0.1-flake-${versionString}";
38   VERSION = "v0.1-flake-${versionString}";
39
40   src = (lib.cleanSource (builtins.path { name = "bcachefs-tools-src"; path = ./. ;} ));
41
42   postPatch = "patchShebangs --build doc/macro2rst.py";
43
44   propagatedNativeBuildInputs = [
45     # used to find dependencies
46     ## see ./INSTALL
47     pkg-config
48   ];
49
50   propagatedBuildInputs = [
51     # bcachefs explicit dependencies
52     ## see ./INSTALL
53     libaio
54
55     # libblkid
56     keyutils # libkeyutils
57     lz4 # liblz4
58
59     libsodium
60     liburcu
61     libuuid
62     zstd # libzstd
63     zlib # zlib1g
64
65     # unspecified dependencies
66     attr
67     udev
68   ];
69
70   buildInputs = [
71     # documentation depenedencies
72     docutils
73     python39Packages.pygments
74   ] ++ (lib.optional fuseSupport fuse3)
75   ++ (lib.optional testWithValgrind valgrind);
76
77   makeFlags = [
78     "PREFIX=${placeholder "out"}"
79   ] ++ lib.optional debugMode "EXTRA_CFLAGS=-ggdb";
80
81   installFlags = [
82     "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
83   ];
84
85   doCheck = doCheck; # needs bcachefs module loaded on builder
86
87   checkInputs = [
88     python39Packages.pytest
89     python39Packages.pytest-xdist
90   ] ++ lib.optional testWithValgrind valgrind;
91
92   checkFlags = [
93     "BCACHEFS_TEST_USE_VALGRIND=${if testWithValgrind then "yes" else "no"}"
94     # cannot escape spaces within make flags, quotes are stripped
95     "PYTEST_CMD=pytest" # "PYTEST_ARGS='-n4 --version'"
96   ];
97
98   preCheck =
99     ''
100       makeFlagsArray+=(PYTEST_ARGS="--verbose -n2")
101     '' +
102     lib.optionalString fuseSupport ''
103       rm tests/test_fuse.py
104     '';
105
106   dontStrip = debugMode;
107   passthru = {
108     bcachefs_revision = let
109       file = builtins.readFile ./.bcachefs_revision;
110       removeLineFeeds = str: lib.lists.foldr (lib.strings.removeSuffix) str ["\r" "\n"];
111     in removeLineFeeds file;
112
113     tests = {
114       smoke-test = nixosTests.bcachefs;
115     };
116   };
117
118   enableParallelBuilding = true;
119   meta = with lib; {
120     description = "Userspace tools for bcachefs";
121     homepage    = http://bcachefs.org;
122     license     = licenses.gpl2;
123     platforms   = platforms.linux;
124     maintainers =
125       [ "Kent Overstreet <kent.overstreet@gmail.com>"
126       ];
127
128   };
129 }