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