1 { lib, stdenv, fetchFromGitHub
6 python3.pkgs.buildPythonApplication rec {
10 src = fetchFromGitHub {
14 sha256 = "q4U9iWCa1zg8sA+6pPNejt6v/41WGIKN5wITJCrCqQE=";
17 pythonPath = with python3.pkgs;
18 lib.optionals stdenv.isLinux [
24 # remove references to use_2to3, for setuptools>=58
25 # has been merged into master, remove next release
27 url = "https://github.com/fail2ban/fail2ban/commit/5ac303df8a171f748330d4c645ccbf1c2c7f3497.patch";
28 sha256 = "sha256-aozQJHwPcJTe/D/PLQzBk1YH3OAP6Qm7wO7cai5CVYI=";
30 # fix use of MutableMapping with Python >= 3.10
31 # https://github.com/fail2ban/fail2ban/issues/3142
33 url = "https://github.com/fail2ban/fail2ban/commit/294ec73f629d0e29cece3a1eb5dd60b6fccea41f.patch";
34 sha256 = "sha256-Eimm4xjBDYNn5QdTyMqGgT5EXsZdd/txxcWJojXlsFE=";
39 # workaround for setuptools 58+
40 # https://github.com/fail2ban/fail2ban/issues/3098
41 patchShebangs fail2ban-2to3
44 for i in config/action.d/sendmail*.conf; do
45 substituteInPlace $i \
46 --replace /usr/sbin/sendmail sendmail \
47 --replace /usr/bin/whois whois
50 substituteInPlace config/filter.d/dovecot.conf \
51 --replace dovecot.service dovecot2.service
57 substituteInPlace setup.py --replace /usr/share/doc/ share/doc/
59 # see https://github.com/NixOS/nixpkgs/issues/4968
60 ${python3.interpreter} setup.py install_data --install-dir=$out --root=$out
64 ${stdenv.shell} ./fail2ban-2to3
69 sitePackages = "$out/${python3.sitePackages}";
72 # see https://github.com/NixOS/nixpkgs/issues/4968
73 rm -r "${sitePackages}/etc"
74 '' + lib.optionalString stdenv.isLinux ''
75 # see https://github.com/NixOS/nixpkgs/issues/4968
76 rm -r "${sitePackages}/usr"
80 homepage = "https://www.fail2ban.org/";
81 description = "A program that scans log files for repeated failing login attempts and bans IP addresses";
82 license = licenses.gpl2Plus;
83 maintainers = with maintainers; [ eelco lovek323 ];
84 platforms = platforms.unix;