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