2022-02-10 20:34:41 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
|
|
|
, python3
|
2023-02-09 11:40:11 +00:00
|
|
|
, installShellFiles
|
2022-02-10 20:34:41 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "fail2ban";
|
2023-03-24 00:07:29 +00:00
|
|
|
version = "1.0.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-08-05 21:33:18 +00:00
|
|
|
owner = "fail2ban";
|
|
|
|
repo = "fail2ban";
|
|
|
|
rev = version;
|
2023-03-24 00:07:29 +00:00
|
|
|
hash = "sha256-Zd8zLkFlvXTbeInEkNFyHgcAiOsX4WwF6hf5juSQvbY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
pythonPath = with python3.pkgs;
|
2021-01-15 22:18:51 +00:00
|
|
|
lib.optionals stdenv.isLinux [
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd
|
2022-04-27 09:35:20 +00:00
|
|
|
pyinotify
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
2022-02-10 20:34:41 +00:00
|
|
|
patchShebangs fail2ban-2to3
|
|
|
|
./fail2ban-2to3
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
for i in config/action.d/sendmail*.conf; do
|
|
|
|
substituteInPlace $i \
|
2023-03-24 00:07:29 +00:00
|
|
|
--replace /usr/sbin/sendmail sendmail
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2023-11-16 04:20:00 +00:00
|
|
|
${python3.pythonOnBuildForHost.interpreter} setup.py install_data --install-dir=$out --root=$out
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
sitePackages = "$out/${python3.sitePackages}";
|
|
|
|
in
|
|
|
|
''
|
2023-03-24 00:07:29 +00:00
|
|
|
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
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
2021-12-06 16:07:01 +00:00
|
|
|
rm -r "${sitePackages}/etc"
|
2023-02-09 11:40:11 +00:00
|
|
|
|
|
|
|
installManPage man/*.[1-9]
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
# This is a symlink to the build python version created by `updatePyExec`, seemingly to assure the same python version is used?
|
|
|
|
rm $out/bin/fail2ban-python
|
|
|
|
ln -s ${python3.interpreter} $out/bin/fail2ban-python
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
|
|
|
rm -r "${sitePackages}/usr"
|
2021-08-05 21:33:18 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2021-08-05 21:33:18 +00:00
|
|
|
homepage = "https://www.fail2ban.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A program that scans log files for repeated failing login attempts and bans IP addresses";
|
2021-08-05 21:33:18 +00:00
|
|
|
license = licenses.gpl2Plus;
|
2022-08-12 12:06:08 +00:00
|
|
|
maintainers = with maintainers; [ eelco lovek323 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|