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