Move config binary and GHC intermediate outputs to cacheDir

That's where they belong. As XDG was more or less broken in previous
xmonad releases, we can assume few people use it so now's the best time
to move files around.

For users of `~/.xmonad`, this only causes intermediate outputs (.o,
.hi) to go elsewhere.

Fixes: https://github.com/xmonad/xmonad/issues/178
This commit is contained in:
Tomas Janousek
2021-08-07 22:45:14 +01:00
parent 403e4df624
commit 9813e218b0
3 changed files with 21 additions and 10 deletions

View File

@@ -29,6 +29,10 @@
In the cases of 1. and 3., the build script or executable is
expected to be in the config dir.
Additionally, the xmonad config binary and intermediate object files were
moved to the cache directory (only relevant if using XDG or
`XMONAD_CACHE_DIR`).
* Change `ScreenDetail` to a newtype and make `RationalRect` strict in
its contents.

View File

@@ -356,13 +356,13 @@ exec xmonad
in your `~/.xinitrc`, you would write
``` shell
exec $HOME/.local/share/xmonad/xmonad-x86_64-linux
exec $HOME/.cache/xmonad/xmonad-x86_64-linux
```
The `~/.local/share` prefix is the `$XDG_DATA_DIR` directory. Note that
The `~/.cache` prefix is the `$XDG_CACHE_HOME` directory. Note that
if your xmonad configuration resides within `~/.xmonad`, then the
executable will also be within that directory and not in
`$XDG_DATA_DIR`.
`$XDG_CACHE_HOME`.
[XDG]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
[git]: https://git-scm.com/

View File

@@ -480,8 +480,7 @@ runOnWorkspaces job = do
-- the following purposes:
--
-- * @dataDir@: This directory is used by XMonad to store data files
-- such as the run-time state file and the configuration binary
-- generated by GHC.
-- such as the run-time state file.
--
-- * @cfgDir@: This directory is where user configuration files are
-- stored (e.g, the xmonad.hs file). You may also create a @lib@
@@ -489,7 +488,9 @@ runOnWorkspaces job = do
-- command will add it to the GHC include path.
--
-- * @cacheDir@: This directory is used to store temporary files that
-- can easily be recreated. For example, the XPrompt history file.
-- can easily be recreated such as the configuration binary and any
-- intermediate object files generated by GHC.
-- Also, the XPrompt history file goes here.
--
-- For how these directories are chosen, see 'getDirectories'.
--
@@ -565,12 +566,17 @@ getXMonadDataDir :: X String
getXMonadDataDir = asks (dataDir . directories)
{-# DEPRECATED getXMonadDataDir "Use `asks (dataDir . directories)' instead." #-}
binFileName, errFileName, stateFileName, srcFileName, libFileName :: Directories -> FilePath
binFileName Directories{ dataDir } = dataDir </> "xmonad-" <> arch <> "-" <> os
binFileName, buildDirName :: Directories -> FilePath
binFileName Directories{ cacheDir } = cacheDir </> "xmonad-" <> arch <> "-" <> os
buildDirName Directories{ cacheDir } = cacheDir </> "build-" <> arch <> "-" <> os
errFileName, stateFileName :: Directories -> FilePath
errFileName Directories{ dataDir } = dataDir </> "xmonad.errors"
stateFileName Directories{ dataDir } = dataDir </> "xmonad.state"
srcFileName Directories{ cfgDir } = cfgDir </> "xmonad.hs"
libFileName Directories{ cfgDir } = cfgDir </> "lib"
srcFileName, libFileName :: Directories -> FilePath
srcFileName Directories{ cfgDir } = cfgDir </> "xmonad.hs"
libFileName Directories{ cfgDir } = cfgDir </> "lib"
buildScriptFileName, stackYamlFileName :: Directories -> FilePath
buildScriptFileName Directories{ cfgDir } = cfgDir </> "build"
@@ -664,6 +670,7 @@ compile dirs method =
, "-fforce-recomp"
, "-main-is", "main"
, "-v0"
, "-outputdir", buildDirName dirs
, "-o", binFileName dirs
]