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