diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,11 @@
+### 0.5.2.2
+
+- *nhm-tool*: command *init* generates *Makefile* which searches *nhm-tool* via
+  *cabal list-bin ngx-export-distribution* if the tool cannot be found in known
+  directories. Generated cabal files require *cabal-version 2.0* because now
+  they use *build-tool-depends: ngx-export-distribution:nhm-tool* in the
+  library stanza.
+
 ### 0.5.2.1
 
 - Fix import modules after update to *Cabal* *3.10.3.0*.
diff --git a/ngx-export-distribution.cabal b/ngx-export-distribution.cabal
--- a/ngx-export-distribution.cabal
+++ b/ngx-export-distribution.cabal
@@ -1,5 +1,5 @@
 name:                       ngx-export-distribution
-version:                    0.5.2.1
+version:                    0.5.2.2
 synopsis:                   Build custom libraries for Nginx Haskell module
 description:                Build custom libraries for
         <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.
diff --git a/nhm-tool.hs b/nhm-tool.hs
--- a/nhm-tool.hs
+++ b/nhm-tool.hs
@@ -447,7 +447,7 @@
     ["name:                       ", T.pack initDataProject, "\n\
      \version:                    0.1.0.0\n\
      \build-type:                 Custom\n\
-     \cabal-version:              1.24\n\
+     \cabal-version:              2.0\n\
      \\n\
      \custom-setup\n\
      \  setup-depends:            base >= 4.8 && < 5\n\
@@ -455,6 +455,7 @@
      \\n\
      \library\n\
      \  default-language:         Haskell2010\n\
+     \  build-tool-depends:       ngx-export-distribution:nhm-tool\n\
      \  build-depends:            base >= 4.8 && < 5\n\
      \                          , ngx-export\n\
      \\n\
@@ -478,6 +479,7 @@
      \KERNEL := $(shell uname -s | tr A-Z a-z)\n\
      \\n\
      \PKGDISTR := ngx-export-distribution\n\
+     \NHMTOOL := nhm-tool\n\
      \\n\
      \SRC := $(NAME).hs\n\
      \LIB := $(NAME).so\n\
@@ -495,7 +497,10 @@
      \$(DISTR): $(SRC)\n\
      \\tcabal install --lib --only-dependencies --package-env .\n\
      \\tsed -i 's/\\(^package-id \\)/--\\1/' $(GHCENV)\n\
-     \\tnhm-tool deps $(PKGNAME) >> $(GHCENV)\n\
+     \\tif ! command -v $(NHMTOOL) >/dev/null; then \\\n\
+     \\t  PATH=$$(dirname $$(cabal list-bin $(PKGDISTR))):$$PATH; \\\n\
+     \\tfi; \\\n\
+     \\t$(NHMTOOL) deps $(PKGNAME) >> $(GHCENV); \\\n\
      \\trunhaskell --ghc-arg=-package=base \\\n\
      \\t  --ghc-arg=-package=$(PKGDISTR) Setup.hs configure \\\n\
      \\t  --package-db=clear --package-db=global \\\n\
@@ -504,7 +509,7 @@
      \\t    `'\\(-\\([0-9]\\+\\.\\)*[0-9]\\+\\($$\\|-.*\\)\\)/'` \\\n\
      \\t    `'--dependency=\\1=\\1\\2/p' \\\n\
      \\t    $(GHCENV)) \\\n\
-     \\t  --prefix=$(PREFIX)\n\
+     \\t  --prefix=$(PREFIX); \\\n\
      \\trunhaskell --ghc-arg=-package=base \\\n\
      \\t  --ghc-arg=-package=$(PKGDISTR) Setup.hs build \\\n\
      \\t  --ghc-options=\"$(SRC) -o $(LIB) $(LINKRTS)\"\n\
