1{ lib, stdenv, fetchFromGitHub, fetchpatch, substituteAll, autoreconfHook, pkg-config, gtk-doc
2, docbook_xml_dtd_43, python3, gobject-introspection, glib, udev, kmod, parted
3, cryptsetup, lvm2, dmraid, util-linux, libbytesize, libndctl, nss, volume_key
4, libxslt, docbook_xsl, gptfdisk, libyaml, autoconf-archive
5, thin-provisioning-tools, makeWrapper
6}:
7stdenv.mkDerivation rec {
8 pname = "libblockdev";
9 version = "2.25";
10
11 src = fetchFromGitHub {
12 owner = "storaged-project";
13 repo = "libblockdev";
14 rev = "${version}-1";
15 sha256 = "sha256-eHUHTogKoNrnwwSo6JaI7NMxVt9JeMqfWyhR62bDMuQ=";
16 };
17
18 outputs = [ "out" "dev" "devdoc" ];
19
20 patches = [
21 (substituteAll {
22 src = ./fix-paths.patch;
23 sgdisk = "${gptfdisk}/bin/sgdisk";
24 })
25
26 # fix build with glib 2.68 (g_memdup is deprecated)
27 # https://github.com/storaged-project/libblockdev/pull/623
28 (fetchpatch {
29 url = "https://github.com/storaged-project/libblockdev/commit/5528baef6ccc835a06c45f9db34a2c9c3f2dd940.patch";
30 sha256 = "jxq4BLeyTMeNvBvY8k8QXIvYSJ2Gah0J75pq6FpG7PM=";
31 })
32 ];
33
34 postPatch = ''
35 patchShebangs scripts
36 '';
37
38 nativeBuildInputs = [
39 autoreconfHook pkg-config gtk-doc libxslt docbook_xsl docbook_xml_dtd_43
40 python3 gobject-introspection autoconf-archive makeWrapper
41 ];
42
43 buildInputs = [
44 glib udev kmod parted gptfdisk cryptsetup lvm2 dmraid util-linux libbytesize
45 libndctl nss volume_key libyaml
46 ];
47
48 postInstall = ''
49 wrapProgram $out/bin/lvm-cache-stats --prefix PATH : \
50 ${lib.makeBinPath [ thin-provisioning-tools ]}
51 '';
52
53 meta = with lib; {
54 description = "A library for manipulating block devices";
55 homepage = "http://storaged.org/libblockdev/";
56 license = with licenses; [ lgpl2Plus gpl2Plus ]; # lgpl2Plus for the library, gpl2Plus for the utils
57 maintainers = with maintainers; [ johnazoidberg ];
58 platforms = platforms.linux;
59 };
60}