Skip to content

Commit

Permalink
Point to correct store dir when XDG is used
Browse files Browse the repository at this point in the history
Fixes #1089
  • Loading branch information
hasufell committed Jul 5, 2024
1 parent e05676a commit ba969f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/GHCup/CabalConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module GHCup.CabalConfig (getStoreDir) where
import Data.ByteString (ByteString)
import Data.List.NonEmpty (NonEmpty)
import Data.Map (Map)
import System.Directory (getAppUserDataDirectory)
import System.Directory (getAppUserDataDirectory, doesDirectoryExist, getXdgDirectory, XdgDirectory(XdgConfig))
import System.Environment (lookupEnv)
import System.FilePath ((</>))

Expand Down Expand Up @@ -52,7 +52,11 @@ findConfig = do
findCabalDir :: IO FilePath
findCabalDir = do
cabalDirVar <- lookupEnv "CABAL_DIR"
maybe (getAppUserDataDirectory "cabal") return cabalDirVar
appDir <- getAppUserDataDirectory "cabal"
isXdg <- not <$> doesDirectoryExist appDir
if | Just dir <- cabalDirVar -> pure dir
| isXdg -> getXdgDirectory XdgConfig "cabal"
| otherwise -> pure appDir


-------------------------------------------------------------------------------
Expand Down

0 comments on commit ba969f2

Please sign in to comment.