1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 pkg-config,
6 util-linux,
7 bash,
8 replaceVars,
9 udevCheckHook,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "bcache-tools";
14 version = "1.0.8";
15
16 src = fetchFromGitHub {
17 owner = "g2p";
18 repo = "bcache-tools";
19 rev = "v${version}";
20 hash = "sha256-6gy0ymecMgEHXbwp/nXHlrUEeDFnmFXWZZPlzP292g4=";
21 };
22
23 nativeBuildInputs = [
24 pkg-config
25 udevCheckHook
26 ];
27 buildInputs = [ util-linux ];
28
29 doInstallCheck = true;
30
31 # * Remove broken install rules (they ignore $PREFIX) for stuff we don't need
32 # anyway (it's distro specific stuff).
33 # * Fixup absolute path to modprobe.
34 prePatch = ''
35 sed -e "/INSTALL.*initramfs\/hook/d" \
36 -e "/INSTALL.*initcpio\/install/d" \
37 -e "/INSTALL.*dracut\/module-setup.sh/d" \
38 -e "s/pkg-config/$PKG_CONFIG/" \
39 -i Makefile
40 '';
41
42 patches = [
43 (replaceVars ./bcache-udev-modern.patch {
44 shell = "${bash}/bin/sh";
45 })
46 ./fix-static.patch
47 ];
48
49 makeFlags = [
50 "PREFIX=${placeholder "out"}"
51 "UDEVLIBDIR=${placeholder "out"}/lib/udev/"
52 ];
53
54 preInstall = ''
55 mkdir -p "$out/sbin" "$out/lib/udev/rules.d" "$out/share/man/man8"
56 '';
57
58 meta = with lib; {
59 description = "User-space tools required for bcache (Linux block layer cache)";
60 longDescription = ''
61 Bcache is a Linux kernel block layer cache. It allows one or more fast
62 disk drives such as flash-based solid state drives (SSDs) to act as a
63 cache for one or more slower hard disk drives.
64
65 This package contains the required user-space tools.
66
67 User documentation is in Documentation/bcache.txt in the Linux kernel
68 tree.
69 '';
70 homepage = "https://bcache.evilpiepirate.org/";
71 license = licenses.gpl2Only;
72 platforms = platforms.linux;
73 maintainers = [ maintainers.bjornfor ];
74 };
75}