1 { lib, stdenv, util-linux, coreutils, fetchurl, groff, system-sendmail, udev }:
3 stdenv.mkDerivation rec {
8 url = "mirror://kernel/linux/utils/raid/mdadm/mdadm-${version}.tar.xz";
9 sha256 = "sha256-QWcnrh8QgOpuMJDOo23QdoJvw2kVHjarc2VXupIZb58=";
13 ./no-self-references.patch
14 ./fix-hardcoded-mapdir.patch
17 url = "https://raw.githubusercontent.com/void-linux/void-packages/e58d2b17d3c40faffc0d426aab00184f28d9dafa/srcpkgs/mdadm/patches/musl.patch";
18 hash = "sha256-TIcQs+8RM5Q6Z8MHkI50kaJd7f9WdS/EVI16F7b2+SA=";
20 # Fixes build on musl 1.2.5+
22 url = "https://lore.kernel.org/linux-raid/20240220165158.3521874-1-raj.khem@gmail.com/raw";
23 hash = "sha256-JOZ8n7zi+nq236NPpB4e2gUy8I3l3DbcoLhpeL73f98=";
26 url = "https://github.com/md-raid-utilities/mdadm/commit/9dbd11e091f84eb0bf9d717283774816c4c4453d.patch";
27 hash = "sha256-8GdjP1ceVwejTOFXcHXG8wkIF9/D6hOUGD6btvuqs24=";
32 "NIXOS=1" "INSTALL=install" "BINDIR=$(out)/sbin"
33 "SYSTEMD_DIR=$(out)/lib/systemd/system"
34 "MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
36 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
37 "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
40 installFlags = [ "install-systemd" ];
42 enableParallelBuilding = true;
44 buildInputs = [ udev ];
46 nativeBuildInputs = [ groff ];
49 sed -e 's@/lib/udev@''${out}/lib/udev@' \
51 -e 's@/usr/sbin/sendmail@${system-sendmail}/bin/sendmail@' -i Makefile
53 -e 's@/usr/bin/basename@${coreutils}/bin/basename@g' \
54 -e 's@BINDIR/blkid@${util-linux}/bin/blkid@g' \
58 # This is to avoid self-references, which causes the initrd to explode
59 # in size and in turn prevents mdraid systems from booting.
61 grep -r $out $out/bin && false || true
65 description = "Programs for managing RAID arrays under Linux";
66 homepage = "https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git";
67 license = licenses.gpl2Plus;
68 mainProgram = "mdadm";
69 maintainers = with maintainers; [ ekleog ];
70 platforms = platforms.linux;