diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,10 +1,18 @@
+### 1.6.1
+
+- Use custom *Setup.hs* to configure Haddock options on build of documentation.
+
 ### 1.6
 
 - Refactor module *NgxExport.Log.Gen*.
 - Add CPP macro *NGX_CSTUB* in module *NgxExport.Log.CLog* to work around the
   lack of macro *\_\_HADDOCK_VERSION\_\_* in recent Haddock versions. Use this
-  macro in *simple/Makefile*: this must fix building the simple module with
+  macro in *simple/cabal.project*: this must fix building the simple module with
   documentation for dependencies.
+- **Note**: due to a [bug](https://gitlab.haskell.org/ghc/ghc/-/issues/26136)
+  introduced in GHC major versions *9.12*, *9.10*, and *9.8*, the code won't
+  compile with GHC *9.12.2*, *9.12.1* (fixed in *9.12.4*), *9.10.2* (fixed in
+  *9.10.3*), *9.8.4* (not fixed, compile with *9.8.2*).
 
 ### 1.5.2
 
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,24 @@
+import Distribution.Simple
+import Distribution.Simple.Setup
+
+import Data.List
+
+userHooks :: UserHooks
+userHooks =
+    simpleUserHooks { haddockHook = \desc lbi hooks flags -> do
+                        let (oghc, ocstub) = ("ghc", "-DNGX_CSTUB")
+                            hadflag = haddockProgramArgs flags
+                            (h, t) = break ((oghc ==) . fst) hadflag
+                            hadflag' =
+                                case uncons t of
+                                    Nothing ->
+                                        (oghc, [ocstub]) : hadflag
+                                    Just ((_, args), t') ->
+                                        h ++ (oghc, ocstub : args) : t'
+                            flags' = flags { haddockProgramArgs = hadflag' }
+                        haddockHook simpleUserHooks desc lbi hooks flags'
+                    }
+
+main :: IO ()
+main = defaultMainWithHooks userHooks
+
diff --git a/ngx-export-log.cabal b/ngx-export-log.cabal
--- a/ngx-export-log.cabal
+++ b/ngx-export-log.cabal
@@ -1,5 +1,5 @@
 name:                  ngx-export-log
-version:               1.6
+version:               1.6.1
 synopsis:    Native Nginx logging from configuration files and Haskell handlers
 description: Native Nginx logging from configuration files and Haskell handlers.
         .
@@ -14,8 +14,12 @@
 stability:             stable
 copyright:             2022-2026 Alexey Radkov
 category:              Network
-build-type:            Simple
-cabal-version:         1.20
+build-type:            Custom
+cabal-version:         2.0
+
+custom-setup
+  setup-depends:       base >= 4.8 && < 5
+                     , Cabal >= 3.0.0.0 && < 4
 
 source-repository head
   type:                git
