1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, coreutils
6
7, perl
8, pkg-config
9
10, json_c
11, libaio
12, liburcu
13, linuxHeaders
14, lvm2
15, readline
16, systemd
17, util-linuxMinimal
18
19, cmocka
20, nixosTests
21}:
22
23stdenv.mkDerivation rec {
24 pname = "multipath-tools";
25 version = "0.9.8";
26
27 src = fetchFromGitHub {
28 owner = "opensvc";
29 repo = "multipath-tools";
30 rev = "refs/tags/${version}";
31 sha256 = "sha256-4cby19BjgnmWf7klK1sBgtZnyvo7q3L1uyVPlVoS+uk=";
32 };
33
34 patches = [
35 # Backport build fix for musl libc 1.2.5
36 (fetchpatch {
37 url = "https://github.com/openSUSE/multipath-tools/commit/e5004de8296cd596aeeac0a61b901e98cf7a69d2.patch";
38 hash = "sha256-3Qt8zfrWi9aOdqMObZQaNAaXDmjhvSYrXK7qycC9L1Q=";
39 })
40 ];
41
42 postPatch = ''
43 substituteInPlace create-config.mk \
44 --replace-fail /bin/echo ${coreutils}/bin/echo
45
46 substituteInPlace multipathd/multipathd.service.in \
47 --replace-fail /sbin/multipathd "$out/bin/multipathd"
48 '';
49
50 nativeBuildInputs = [
51 perl
52 pkg-config
53 ];
54 buildInputs = [
55 json_c
56 libaio
57 liburcu
58 linuxHeaders
59 lvm2
60 readline
61 systemd
62 util-linuxMinimal # for libmount
63 ];
64
65 makeFlags = [
66 "LIB=lib"
67 "prefix=$(out)"
68 "systemd_prefix=$(out)"
69 "kernel_incdir=${linuxHeaders}/include/"
70 "man8dir=$(out)/share/man/man8"
71 "man5dir=$(out)/share/man/man5"
72 "man3dir=$(out)/share/man/man3"
73 ];
74
75 doCheck = true;
76 preCheck = ''
77 # skip test attempting to access /sys/dev/block
78 substituteInPlace tests/Makefile --replace-fail ' devt ' ' '
79 '';
80 nativeCheckInputs = [ cmocka ];
81
82 passthru.tests = { inherit (nixosTests) iscsi-multipath-root; };
83
84 meta = with lib; {
85 description = "Tools for the Linux multipathing storage driver";
86 homepage = "http://christophe.varoqui.free.fr/";
87 license = licenses.gpl2Plus;
88 platforms = platforms.linux;
89 };
90}