1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 lvm2,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "dmraid";
11 version = "1.0.0.rc16";
12
13 src = fetchurl {
14 url = "https://people.redhat.com/~heinzm/sw/dmraid/src/old/dmraid-${version}.tar.bz2";
15 sha256 = "0m92971gyqp61darxbiri6a48jz3wq3gkp8r2k39320z0i6w8jgq";
16 };
17
18 patches = [
19 ./hardening-format.patch
20 ./fix-dmevent_tool.patch
21
22 # Fix build with gcc15, based on
23 # https://gitlab.alpinelinux.org/alpine/aports/-/raw/dc5b3135517ede55f5e3530e538ca75048d26565/main/dmraid/008-gcc15.patch
24 ./dmraid-fix-build-with-gcc15.patch
25 ]
26 ++ lib.optionals stdenv.hostPlatform.isMusl [
27 (fetchpatch {
28 url = "https://raw.githubusercontent.com/void-linux/void-packages/fceed4b8e96b3c1da07babf6f67b6ed1588a28b2/srcpkgs/dmraid/patches/006-musl-libc.patch";
29 sha256 = "1j8xda0fpz8lxjxnqdidy7qb866qrzwpbca56yjdg6vf4x21hx6w";
30 stripLen = 2;
31 extraPrefix = "1.0.0.rc16/";
32 })
33 (fetchpatch {
34 url = "https://raw.githubusercontent.com/void-linux/void-packages/fceed4b8e96b3c1da07babf6f67b6ed1588a28b2/srcpkgs/dmraid/patches/007-fix-loff_t-musl.patch";
35 sha256 = "0msnq39qnzg3b1pdksnz1dgqwa3ak03g41pqh0lw3h7w5rjc016k";
36 stripLen = 2;
37 extraPrefix = "1.0.0.rc16/";
38 })
39 ];
40
41 postPatch = ''
42 sed -i 's/\[\[[^]]*\]\]/[ "''$''${n##*.}" = "so" ]/' */lib/Makefile.in
43 ''
44 + lib.optionalString stdenv.hostPlatform.isMusl ''
45 NIX_CFLAGS_COMPILE+=" -D_GNU_SOURCE"
46 '';
47
48 preConfigure = "cd */";
49
50 buildInputs = [ lvm2 ];
51
52 # Hand-written Makefile does not have full dependencies to survive
53 # parallel build:
54 # tools/dmraid.c:12:10: fatal error: dmraid/dmraid.h: No such file
55 enableParallelBuilding = false;
56
57 meta = {
58 description = "Old-style RAID configuration utility";
59 longDescription = ''
60 Old RAID configuration utility (still under development, though).
61 It is fully compatible with modern kernels and mdadm recognizes
62 its volumes. May be needed for rescuing an older system or nuking
63 the metadata when reformatting.
64 '';
65 maintainers = [ lib.maintainers.raskin ];
66 platforms = lib.platforms.linux;
67 license = lib.licenses.gpl2Plus;
68 };
69}