nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchgit,
5 pkg-config,
6 util-linux,
7 bash,
8 udevCheckHook,
9 nixosTests,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "bcache-tools";
14 version = "1.1";
15
16 src = fetchgit {
17 url = "https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git";
18 rev = "bcache-tools-${finalAttrs.version}";
19 hash = "sha256-8BiHC8qxk4otFPyKnvGNk57JSZytEOy51AGertWo2O0=";
20 };
21
22 nativeBuildInputs = [
23 pkg-config
24 udevCheckHook
25 ];
26 buildInputs = [ util-linux ];
27
28 doInstallCheck = true;
29
30 prePatch = ''
31 # * Remove distro specific install rules which are not used in NixOS.
32 # * Remove binaries for udev which are not needed on modern systems.
33 sed -e "/INSTALL.*initramfs\/hook/d" \
34 -e "/INSTALL.*initcpio\/install/d" \
35 -e "/INSTALL.*dracut\/module-setup.sh/d" \
36 -e "/INSTALL.*probe-bcache/d" \
37 -e "s/pkg-config/$PKG_CONFIG/" \
38 -i Makefile
39 # * Remove probe-bcache which is handled by util-linux
40 sed -e "/probe-bcache/d" \
41 -i 69-bcache.rules
42 # * Replace bcache-register binary with a write to sysfs
43 substituteInPlace 69-bcache.rules \
44 --replace-fail "bcache-register \$tempnode" "${bash}/bin/sh -c 'echo \$tempnode > /sys/fs/bcache/register'"
45 '';
46
47 makeFlags = [
48 "PREFIX="
49 "DESTDIR=$(out)"
50 ];
51
52 preInstall = ''
53 mkdir -p "$out/sbin" "$out/lib/udev/rules.d" "$out/share/man/man8"
54 '';
55
56 passthru.tests = {
57 inherit (nixosTests) bcache;
58 };
59
60 meta = {
61 description = "User-space tools required for bcache (Linux block layer cache)";
62 longDescription = ''
63 Bcache is a Linux kernel block layer cache. It allows one or more fast
64 disk drives such as flash-based solid state drives (SSDs) to act as a
65 cache for one or more slower hard disk drives.
66
67 This package contains the required user-space tools.
68
69 User documentation is in Documentation/bcache.txt in the Linux kernel
70 tree.
71 '';
72 homepage = "https://www.kernel.org/doc/html/latest/admin-guide/bcache.html";
73 license = lib.licenses.gpl2Only;
74 maintainers = with lib.maintainers; [
75 bjornfor
76 pineapplehunter
77 ];
78 mainProgram = "bcache-tools";
79 platforms = lib.platforms.linux;
80 };
81})