diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 216776e62c..d47a1935c3 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -6193,42 +6193,7 @@ (define-public fail2ban
                                 "paths-fedora.conf"
                                 "paths-freebsd.conf"
                                 "paths-opensuse.conf"
-                                "paths-osx.conf")))
-                  ;; Get rid of absolute file names.
-                  (substitute* "setup.py"
-                    (("/etc/fail2ban")
-                     "etc/fail2ban")
-                    (("/var/lib/fail2ban")
-                     "var/lib/fail2ban")
-                    (("\"/usr/bin/\"")
-                     "\"usr/bin/\"")
-                    (("\"/usr/lib/fail2ban/\"")
-                     "\"usr/lib/fail2ban/\"")
-                    (("'/usr/share/doc/fail2ban'")
-                     "'usr/share/doc/fail2ban'"))
-                  ;; disable tests performing unacceptable side-effects
-                  (let ((make-suite (lambda (t)
-                                      (string-append
-                                       "tests.addTest.unittest.makeSuite."
-                                       t ".."))))
-                    (substitute* "fail2ban/tests/utils.py"
-                      (((make-suite "actiontestcase.CommandActionTest"))
-                       "")
-                      (((make-suite "misctestcase.SetupTest"))
-                       "")
-                      (((make-suite
-                         "filtertestcase.DNSUtilsNetworkTests"))
-                       "")
-                      (((make-suite "filtertestcase.IgnoreIPDNS"))
-                       "")
-                      (((make-suite "filtertestcase.GetFailures"))
-                       "")
-                      (((make-suite
-                         "fail2banclienttestcase.Fail2banServerTest"))
-                       "")
-                      (((make-suite
-                         "servertestcase.ServerConfigReaderTests"))
-                       "")))))
+                                "paths-osx.conf")))))
               (patches (search-patches
                         "fail2ban-0.11.2_fix-setuptools-drop-2to3.patch"
                         "fail2ban-python310-server-action.patch"
@@ -6243,6 +6208,40 @@ (define-public fail2ban
                   (add-before 'build 'invoke-2to3
                     (lambda _
                       (invoke "./fail2ban-2to3")))
+                  (add-after 'unpack 'patch-setup.py
+                    (lambda _
+                      ;; Get rid of absolute file names.
+                      (substitute* "setup.py"
+                        (("/etc/fail2ban")
+                         "etc/fail2ban")
+                        (("/var/lib/fail2ban")
+                         "var/lib/fail2ban")
+                        (("\"/usr/bin/\"")
+                         "\"usr/bin/\"")
+                        (("\"/usr/lib/fail2ban/\"")
+                         "\"usr/lib/fail2ban/\"")
+                        (("'/usr/share/doc/fail2ban'")
+                         "'usr/share/doc/fail2ban'"))))
+                  (add-after 'unpack 'disable-some-tests
+                    (lambda _
+                      (define (make-suite str)
+                        (string-append "tests.addTest.unittest.makeSuite." str ".."))
+                      ;; disable tests performing unacceptable side-effects
+                      (substitute* "fail2ban/tests/utils.py"
+                        (((make-suite "actiontestcase.CommandActionTest"))
+                         "")
+                        (((make-suite "misctestcase.SetupTest"))
+                         "")
+                        (((make-suite "filtertestcase.DNSUtilsNetworkTests"))
+                         "")
+                        (((make-suite "filtertestcase.IgnoreIPDNS"))
+                         "")
+                        (((make-suite "filtertestcase.GetFailures"))
+                         "")
+                        (((make-suite "fail2banclienttestcase.Fail2banServerTest"))
+                         "")
+                        (((make-suite "servertestcase.ServerConfigReaderTests"))
+                         ""))))
                   (add-before 'install 'fix-default-config
                     (lambda* (#:key outputs #:allow-other-keys)
                       (substitute* '("config/paths-common.conf"
