1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 autoreconfHook,
7 pkg-config,
8 gtk-doc,
9 docbook_xml_dtd_43,
10 python3,
11 gobject-introspection,
12 glib,
13 udev,
14 kmod,
15 parted,
16 cryptsetup,
17 lvm2,
18 util-linux,
19 libbytesize,
20 libndctl,
21 nss,
22 volume_key,
23 libxslt,
24 docbook_xsl,
25 gptfdisk,
26 libyaml,
27 autoconf-archive,
28 thin-provisioning-tools,
29 makeBinaryWrapper,
30 e2fsprogs,
31 libnvme,
32 keyutils,
33 libatasmart,
34 json-glib,
35 nix-update-script,
36}:
37stdenv.mkDerivation (finalAttrs: {
38 pname = "libblockdev";
39 version = "3.3.0";
40
41 src = fetchFromGitHub {
42 owner = "storaged-project";
43 repo = "libblockdev";
44 rev = finalAttrs.version;
45 hash = "sha256-Q7610i+2PQi+Oza3c2SwPneljrb+1cuFA4K4DQTpt8A=";
46 };
47
48 patches = [
49 # CVE-2025-6019: https://www.openwall.com/lists/oss-security/2025/06/17/5
50 (fetchpatch {
51 url = "https://github.com/storaged-project/libblockdev/commit/4e35eb93e4d2672686789b9705623cc4f9f85d02.patch";
52 hash = "sha256-3pQxvbFX6jmT5LCaePoVfvPTNPoTPPhT0GcLaGkVVso=";
53 })
54 ];
55
56 outputs = [
57 "out"
58 "dev"
59 "devdoc"
60 "python"
61 ];
62
63 postPatch = ''
64 patchShebangs scripts
65 substituteInPlace src/python/gi/overrides/Makefile.am \
66 --replace-fail ''\'''${exec_prefix}' '@PYTHON_EXEC_PREFIX@'
67 '';
68
69 configureFlags = [
70 "--with-python_prefix=${placeholder "python"}"
71 ];
72
73 nativeBuildInputs = [
74 autoconf-archive
75 autoreconfHook
76 docbook_xsl
77 docbook_xml_dtd_43
78 gobject-introspection
79 gtk-doc
80 libxslt
81 makeBinaryWrapper
82 pkg-config
83 python3
84 ];
85
86 buildInputs = [
87 cryptsetup
88 e2fsprogs
89 glib
90 gptfdisk
91 json-glib
92 keyutils
93 kmod
94 libatasmart
95 libbytesize
96 libndctl
97 libnvme
98 libyaml
99 lvm2
100 nss
101 parted
102 udev
103 util-linux
104 volume_key
105 ];
106
107 postInstall = ''
108 wrapProgram $out/bin/lvm-cache-stats --prefix PATH : \
109 ${lib.makeBinPath [ thin-provisioning-tools ]}
110 '';
111
112 passthru.updateScript = nix-update-script { };
113
114 meta = {
115 changelog = "https://github.com/storaged-project/libblockdev/raw/${finalAttrs.src.rev}/NEWS.rst";
116 description = "Library for manipulating block devices";
117 homepage = "http://storaged.org/libblockdev/";
118 license = with lib.licenses; [
119 lgpl2Plus
120 gpl2Plus
121 ]; # lgpl2Plus for the library, gpl2Plus for the utils
122 maintainers = with lib.maintainers; [ johnazoidberg ];
123 platforms = lib.platforms.linux;
124 };
125})