Skip to content

Commit

Permalink
cabal2nix: support cabal-install 3.10.1.0 XDG paths.
Browse files Browse the repository at this point in the history
From 3.10.1.0 onwards, cabal-install uses XDG directories to store its
state and cache components.  cabal2nix expects to find the Hackage
tarball in ~/.cabal, where it may no longer be located.

This commit changes cabal2nix to look in ~/.cabal if that directory
exists (which matches the behaviour of cabal-install itself), but
otherwise looks in the appropriate XDG directory.
  • Loading branch information
athas committed Mar 10, 2023
1 parent 5e183d1 commit c26e7d0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hackage-db/src/Distribution/Hackage/DB/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ import Control.Exception
import System.Directory
import System.FilePath

-- Some logic to handle both old ~/.cabal and XDG cache directory used
-- by default from cabal-install 3.10.1.0.
cabalStateDir :: IO FilePath
cabalStateDir = getAppUserDataDirectory "cabal"
cabalStateDir = do
dotCabal <- getAppUserDataDirectory "cabal"
dotCabalExists <- doesDirectoryExist dotCabal
if dotCabalExists then pure dotCabal else
getXdgDirectory XdgCache "cabal"

cabalTarballDir :: String -> IO FilePath
cabalTarballDir repo = do
Expand Down

0 comments on commit c26e7d0

Please sign in to comment.