nixpkgs/pkgs/servers/mail/system-sendmail/default.nix
Jörg Thalheim dadc7eb329
treewide: use runtimeShell instead of stdenv.shell whenever possible
Whenever we create scripts that are installed to $out, we must use runtimeShell
in order to get the shell that can be executed on the machine we create the
package for. This is relevant for cross-compiling. The only use case for
stdenv.shell are scripts that are executed as part of the build system.
Usages in checkPhase are borderline however to decrease the likelyhood
of people copying the wrong examples, I decided to use runtimeShell as well.
2019-02-26 14:10:49 +00:00

37 lines
973 B
Nix

{ stdenv, writeText, runtimeShell }:
let script = writeText "script" ''
#!${runtimeShell}
if command -v sendmail > /dev/null 2>&1 && [ "$(command -v sendmail)" != "{{MYPATH}}" ]; then
exec sendmail "$@"
elif [ -x /run/wrappers/bin/sendmail ]; then
exec /run/wrappers/bin/sendmail "$@"
elif [ -x /run/current-system/sw/bin/sendmail ]; then
exec /run/current-system/sw/bin/sendmail "$@"
else
echo "Unable to find system sendmail." >&2
exit 1
fi
''; in
stdenv.mkDerivation {
name = "system-sendmail-1.0";
src = script;
phases = [ "buildPhase" ];
buildPhase = ''
mkdir -p $out/bin
< $src sed "s#{{MYPATH}}#$out/bin/sendmail#" > $out/bin/sendmail
chmod +x $out/bin/sendmail
'';
meta = with stdenv.lib; {
description = ''
A sendmail wrapper that calls the system sendmail. Do not install as system-wide sendmail!
'';
platforms = platforms.unix;
maintainers = with maintainers; [ ekleog ];
};
}