
On 12/18/2014 03:20 AM, Alan Buxton wrote:
Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used?
The usual Setup.hs is just a dummy file; Cabal even ignores it. But if you switch to a "custom" build (from "simple") you can do some preprocessing in Setup.hs: https://www.haskell.org/cabal/users-guide/developing-packages.html In the section "More complex packages", it shows you how to add hooks that get executed before each configure/build/etc stage. If you add a configure hook that mangles the datadir template, you can override the default. Here's a Setup.hs that seems to work: -- Welcome to the jungle, baby. import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.InstallDirs import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup my_hooks :: UserHooks my_hooks = simpleUserHooks { confHook = my_conf_hook } main :: IO () main = defaultMainWithHooks my_hooks my_conf_hook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo my_conf_hook (gpd,hbi) cf = do lbi <- configure (gpd, hbi) cf let orig_dirs = installDirTemplates lbi let my_datadir = toPathTemplate "/foo/bar" let my_dirs = orig_dirs { datadir = my_datadir } let my_lbi = lbi { installDirTemplates = my_dirs } return my_lbi