ec9a51d0cc
OpenSMTPD does not require the setuid bit for its `sendmail`. This works around it by wrapping the called `sendmail` so that the wrapper falls back on either the setuid `sendmail` or the non-setuid `sendmail` depending on what's available. The solution of relying on `$PATH` to be set is unfortunately unreliable, as `mdadm --monitor` will likely be executed from a `systemd` unit, that runs with a clean `$PATH`.
54 lines
1.4 KiB
Nix
54 lines
1.4 KiB
Nix
{ stdenv, writeScript
|
|
, fetchurl, groff
|
|
, buildPlatform, hostPlatform
|
|
}:
|
|
|
|
assert stdenv.isLinux;
|
|
|
|
let
|
|
sendmail-script = writeScript "sendmail-script" ''
|
|
#!/bin/sh
|
|
|
|
if [ -x /run/wrappers/bin/sendmail ]; then
|
|
/run/wrappers/bin/sendmail "$@"
|
|
else
|
|
/run/current-system/sw/bin/sendmail "$@"
|
|
fi
|
|
'';
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
name = "mdadm-4.0";
|
|
|
|
src = fetchurl {
|
|
url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.xz";
|
|
sha256 = "1ad3mma641946wn5lsllwf0lifw9lps34fv1nnkhyfpd9krffshx";
|
|
};
|
|
|
|
# This is to avoid self-references, which causes the initrd to explode
|
|
# in size and in turn prevents mdraid systems from booting.
|
|
allowedReferences = [ stdenv.cc.libc.out sendmail-script ];
|
|
|
|
patches = [ ./no-self-references.patch ];
|
|
|
|
makeFlags = [
|
|
"NIXOS=1" "INSTALL=install" "INSTALL_BINDIR=$(out)/sbin"
|
|
"MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
|
|
"STRIP="
|
|
] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
|
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
|
];
|
|
|
|
nativeBuildInputs = [ groff ];
|
|
|
|
preConfigure = ''
|
|
sed -e 's@/lib/udev@''${out}/lib/udev@' \
|
|
-e 's@ -Werror @ @' \
|
|
-e 's@/usr/sbin/sendmail@${sendmail-script}@' -i Makefile
|
|
'';
|
|
|
|
meta = {
|
|
description = "Programs for managing RAID arrays under Linux";
|
|
homepage = http://neil.brown.name/blog/mdadm;
|
|
platforms = stdenv.lib.platforms.linux;
|
|
};
|
|
}
|