cabal-pkg-config-version-hook- Make Cabal aware of pkg-config package versions
Safe HaskellSafe-Inferred



     main :: IO ()
     main =
       defaultMainWithHooks $
           & addHook
             (mkSettings "nix-store")
               { macroName = NIX,
                 flagPrefixName = "nix"

The above will look for a pkg-config package nix-store, and then

  • Define CPP, C and C++ macros

    • NIX_MAJOR, an integer
    • NIX_MINOR, an integer
    • NIX_PATCH, an integer; 0 if missing
    • NIX_IS_AT_LEAST(major,minor,patch), returning true when the discovered version >= the specified version
  • Set or unset flags like `nix-2_4` so that the flag is true when the discovered version is at least the version in the flag's name.


addHook :: Settings -> UserHooks -> UserHooks Source #

Hook into Cabal to provide pkg-config metadata. Can be applied multiple times to support multiple packages.

mkSettings :: String -> Settings Source #

Derive a default Settings value from just a pkg-config package name.

data Settings Source #

How the metadata for a pkg-config package should be made available to the cabal file.




  • pkgConfigName :: String

    Name of the package; used for querying pkg-config.

  • macroName :: String

    Name to use in the Haskell CPP and C/C++ preprocessor macros.

    For example, `pkgConfigName = FOO` will set the macros

    • FOO_IS_AT_LEAST(major, minor, patch)
  • flagPrefixName :: String

    Name to use when setting flag values in the cabal file.

    Flags named with this prefix, followed by a dash, followed by a major version number, an underscore and a minor version number will be set when the detected package is at least that version.

composeConfHook :: Settings -> ((GenericPackageDescription, a) -> ConfigFlags -> IO b) -> (GenericPackageDescription, a) -> ConfigFlags -> IO b Source #

Extend the value of confHook. It's what powers addHook.