python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / security / fail2ban / default.nix
blob459f9f12c1ea0fafe7dc46acb438c286efdc244b
1 { lib, stdenv, fetchFromGitHub
2 , python3
3 , fetchpatch
4 }:
6 python3.pkgs.buildPythonApplication rec {
7   pname = "fail2ban";
8   version = "0.11.2";
10   src = fetchFromGitHub {
11     owner = "fail2ban";
12     repo = "fail2ban";
13     rev = version;
14     sha256 = "q4U9iWCa1zg8sA+6pPNejt6v/41WGIKN5wITJCrCqQE=";
15   };
17   pythonPath = with python3.pkgs;
18     lib.optionals stdenv.isLinux [
19       systemd
20       pyinotify
21     ];
23   patches = [
24     # remove references to use_2to3, for setuptools>=58
25     # has been merged into master, remove next release
26     (fetchpatch {
27       url = "https://github.com/fail2ban/fail2ban/commit/5ac303df8a171f748330d4c645ccbf1c2c7f3497.patch";
28       sha256 = "sha256-aozQJHwPcJTe/D/PLQzBk1YH3OAP6Qm7wO7cai5CVYI=";
29     })
30     # fix use of MutableMapping with Python >= 3.10
31     # https://github.com/fail2ban/fail2ban/issues/3142
32     (fetchpatch {
33       url = "https://github.com/fail2ban/fail2ban/commit/294ec73f629d0e29cece3a1eb5dd60b6fccea41f.patch";
34       sha256 = "sha256-Eimm4xjBDYNn5QdTyMqGgT5EXsZdd/txxcWJojXlsFE=";
35     })
36   ];
38   preConfigure = ''
39     # workaround for setuptools 58+
40     # https://github.com/fail2ban/fail2ban/issues/3098
41     patchShebangs fail2ban-2to3
42     ./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
48     done
50     substituteInPlace config/filter.d/dovecot.conf \
51       --replace dovecot.service dovecot2.service
52   '';
54   doCheck = false;
56   preInstall = ''
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
61   '';
63   postPatch = ''
64     ${stdenv.shell} ./fail2ban-2to3
65   '';
67   postInstall =
68     let
69       sitePackages = "$out/${python3.sitePackages}";
70     in
71     ''
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"
77     '';
79   meta = with lib; {
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;
85   };