forked from mirrors/nixpkgs
12db8314d7
Update to 1.0.2: https://github.com/fail2ban/fail2ban/blob/1.0.2/ChangeLog#ver-102-20221109---finally-war-game-test-tape-not-a-nuclear-alarm 1.0.1 contained a few breaking changes, but I think they have little impact. I changed the module to use the systemd service shipping with fail2ban (now added to the package).
76 lines
2 KiB
Nix
76 lines
2 KiB
Nix
{ lib, stdenv, fetchFromGitHub
|
|
, python3
|
|
, installShellFiles
|
|
}:
|
|
|
|
python3.pkgs.buildPythonApplication rec {
|
|
pname = "fail2ban";
|
|
version = "1.0.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "fail2ban";
|
|
repo = "fail2ban";
|
|
rev = version;
|
|
hash = "sha256-Zd8zLkFlvXTbeInEkNFyHgcAiOsX4WwF6hf5juSQvbY=";
|
|
};
|
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
pythonPath = with python3.pkgs;
|
|
lib.optionals stdenv.isLinux [
|
|
systemd
|
|
pyinotify
|
|
];
|
|
|
|
preConfigure = ''
|
|
patchShebangs fail2ban-2to3
|
|
./fail2ban-2to3
|
|
|
|
for i in config/action.d/sendmail*.conf; do
|
|
substituteInPlace $i \
|
|
--replace /usr/sbin/sendmail sendmail
|
|
done
|
|
|
|
substituteInPlace config/filter.d/dovecot.conf \
|
|
--replace dovecot.service dovecot2.service
|
|
'';
|
|
|
|
doCheck = false;
|
|
|
|
preInstall = ''
|
|
substituteInPlace setup.py --replace /usr/share/doc/ share/doc/
|
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
|
${python3.interpreter} setup.py install_data --install-dir=$out --root=$out
|
|
'';
|
|
|
|
postInstall =
|
|
let
|
|
sitePackages = "$out/${python3.sitePackages}";
|
|
in
|
|
''
|
|
install -m 644 -D -t "$out/lib/systemd/system" build/fail2ban.service
|
|
# Replace binary paths
|
|
sed -i "s#build/bdist.*/wheel/fail2ban.*/scripts/#$out/bin/#g" $out/lib/systemd/system/fail2ban.service
|
|
# Delete creating the runtime directory, systemd does that
|
|
sed -i "/ExecStartPre/d" $out/lib/systemd/system/fail2ban.service
|
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
|
rm -r "${sitePackages}/etc"
|
|
|
|
installManPage man/*.[1-9]
|
|
'' + lib.optionalString stdenv.isLinux ''
|
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
|
rm -r "${sitePackages}/usr"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
homepage = "https://www.fail2ban.org/";
|
|
description = "A program that scans log files for repeated failing login attempts and bans IP addresses";
|
|
license = licenses.gpl2Plus;
|
|
maintainers = with maintainers; [ eelco lovek323 ];
|
|
};
|
|
}
|