diff --git a/Cabal-tests/tests/HackageTests.hs b/Cabal-tests/tests/HackageTests.hs index df27938d221..b33179f724e 100644 --- a/Cabal-tests/tests/HackageTests.hs +++ b/Cabal-tests/tests/HackageTests.hs @@ -25,7 +25,7 @@ import Distribution.PackageDescription.PrettyPrint (showGenericPackageDescriptio import Distribution.PackageDescription.Quirks (patchQuirks) import Distribution.Simple.Utils (fromUTF8BS, toUTF8BS) import Numeric (showFFloat) -import System.Directory (getXdgDirectory, XdgDirectory(XdgCache, XdgConfig), getAppUserDataDirectory, doesDirectoryExist) +import System.Directory (getAppUserDataDirectory) import System.Environment (lookupEnv) import System.Exit (exitFailure) import System.FilePath (()) @@ -63,38 +63,27 @@ import Data.TreeDiff.Pretty (ansiWlEditExprCompact) parseIndex :: (Monoid a, NFData a) => (FilePath -> Bool) -> (FilePath -> B.ByteString -> IO a) -> IO a parseIndex predicate action = do - configPath <- getCabalConfigPath + cabalDir <- getCabalDir + configPath <- getCabalConfigPath cabalDir cfg <- B.readFile configPath cfgFields <- either (fail . show) pure $ Parsec.readFields cfg - repoCache <- case lookupInConfig "remote-repo-cache" cfgFields of - [] -> getCacheDirPath -- Default - (rrc : _) -> return rrc -- User-specified let repos = reposFromConfig cfgFields + repoCache = case lookupInConfig "remote-repo-cache" cfgFields of + [] -> cabalDir "packages" -- Default + (rrc : _) -> rrc -- User-specified tarName repo = repoCache repo "01-index.tar" mconcat <$> traverse (parseIndex' predicate action . tarName) repos where - getCacheDirPath = - getXdgDirectory XdgCache $ "cabal" "packages" - getCabalConfigPath = do + getCabalDir = do + mx <- lookupEnv "CABAL_DIR" + case mx of + Just x -> return x + Nothing -> getAppUserDataDirectory "cabal" + getCabalConfigPath cabalDir = do mx <- lookupEnv "CABAL_CONFIG" case mx of Just x -> return x - Nothing -> do - mDir <- maybeGetCabalDir - case mDir of - Nothing -> getXdgDirectory XdgConfig $ "cabal" "config" - Just dir -> return $ dir "config" - maybeGetCabalDir :: IO (Maybe FilePath) - maybeGetCabalDir = do - mDir <- lookupEnv "CABAL_DIR" - case mDir of - Just dir -> return $ Just dir - Nothing -> do - defaultDir <- getAppUserDataDirectory "cabal" - dotCabalExists <- doesDirectoryExist defaultDir - return $ if dotCabalExists - then Just defaultDir - else Nothing + Nothing -> return (cabalDir "config") parseIndex' diff --git a/bootstrap/linux-8.10.7.json b/bootstrap/linux-8.10.7.json index a27028a1e3b..34ff8c40d19 100644 --- a/bootstrap/linux-8.10.7.json +++ b/bootstrap/linux-8.10.7.json @@ -1,14 +1,5 @@ { "dependencies": [ - { - "cabal_sha256": "1125a0a4be3aafc8da208940f219d4e4df8a0db87d892cc42bb369071855c590", - "revision": 0, - "src_sha256": "dc2785d6548cec2e80700fab007d3e9467f65d3c58ab3efa21b34d9017cf0efd", - "flags": [], - "package": "directory", - "source": "hackage", - "version": "1.3.7.1" - }, { "cabal_sha256": null, "revision": null, @@ -361,6 +352,10 @@ "package": "unix", "version": "2.7.2.2" }, + { + "package": "directory", + "version": "1.3.6.0" + }, { "package": "transformers", "version": "0.5.6.2" diff --git a/bootstrap/linux-8.6.5.json b/bootstrap/linux-8.6.5.json index 4b6d7d16c6f..ac629a89ccc 100644 --- a/bootstrap/linux-8.6.5.json +++ b/bootstrap/linux-8.6.5.json @@ -1,14 +1,5 @@ { "dependencies": [ - { - "cabal_sha256": "1125a0a4be3aafc8da208940f219d4e4df8a0db87d892cc42bb369071855c590", - "revision": 0, - "src_sha256": "dc2785d6548cec2e80700fab007d3e9467f65d3c58ab3efa21b34d9017cf0efd", - "flags": [], - "package": "directory", - "source": "hackage", - "version": "1.3.7.1" - }, { "cabal_sha256": null, "revision": null, @@ -372,6 +363,10 @@ "package": "unix", "version": "2.7.2.2" }, + { + "package": "directory", + "version": "1.3.3.0" + }, { "package": "transformers", "version": "0.5.6.2" diff --git a/bootstrap/linux-8.8.4.json b/bootstrap/linux-8.8.4.json index c9a6c9c5ea1..2a46e755c6f 100644 --- a/bootstrap/linux-8.8.4.json +++ b/bootstrap/linux-8.8.4.json @@ -1,14 +1,5 @@ { "dependencies": [ - { - "cabal_sha256": "1125a0a4be3aafc8da208940f219d4e4df8a0db87d892cc42bb369071855c590", - "revision": 0, - "src_sha256": "dc2785d6548cec2e80700fab007d3e9467f65d3c58ab3efa21b34d9017cf0efd", - "flags": [], - "package": "directory", - "source": "hackage", - "version": "1.3.7.1" - }, { "cabal_sha256": null, "revision": null, @@ -372,6 +363,10 @@ "package": "unix", "version": "2.7.2.2" }, + { + "package": "directory", + "version": "1.3.6.0" + }, { "package": "transformers", "version": "0.5.6.2" diff --git a/bootstrap/linux-9.0.2.json b/bootstrap/linux-9.0.2.json index 753984e7016..b9527b73c2c 100644 --- a/bootstrap/linux-9.0.2.json +++ b/bootstrap/linux-9.0.2.json @@ -1,14 +1,5 @@ { "dependencies": [ - { - "cabal_sha256": "1125a0a4be3aafc8da208940f219d4e4df8a0db87d892cc42bb369071855c590", - "revision": 0, - "src_sha256": "dc2785d6548cec2e80700fab007d3e9467f65d3c58ab3efa21b34d9017cf0efd", - "flags": [], - "package": "directory", - "source": "hackage", - "version": "1.3.7.1" - }, { "cabal_sha256": null, "revision": null, @@ -361,6 +352,10 @@ "package": "unix", "version": "2.7.2.2" }, + { + "package": "directory", + "version": "1.3.6.2" + }, { "package": "transformers", "version": "0.5.6.2" diff --git a/bootstrap/linux-9.2.3.json b/bootstrap/linux-9.2.3.json index 98d7d689c1f..08db7275892 100644 --- a/bootstrap/linux-9.2.3.json +++ b/bootstrap/linux-9.2.3.json @@ -1,14 +1,5 @@ { "dependencies": [ - { - "cabal_sha256": "1125a0a4be3aafc8da208940f219d4e4df8a0db87d892cc42bb369071855c590", - "revision": 0, - "src_sha256": "dc2785d6548cec2e80700fab007d3e9467f65d3c58ab3efa21b34d9017cf0efd", - "flags": [], - "package": "directory", - "source": "hackage", - "version": "1.3.7.1" - }, { "cabal_sha256": null, "revision": null, @@ -364,6 +355,10 @@ "package": "unix", "version": "2.7.2.2" }, + { + "package": "directory", + "version": "1.3.6.2" + }, { "package": "transformers", "version": "0.5.6.2" diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index b02800e2ce4..981f42e88bf 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -208,7 +208,7 @@ library bytestring >= 0.10.6.0 && < 0.12, containers >= 0.5.6.2 && < 0.7, cryptohash-sha256 >= 0.11 && < 0.12, - directory >= 1.3.7.0 && < 1.4, + directory >= 1.2.2.0 && < 1.4, echo >= 0.1.3 && < 0.2, edit-distance >= 0.2.2 && < 0.3, exceptions >= 0.10.4 && < 0.11, diff --git a/cabal-install/main/Main.hs b/cabal-install/main/Main.hs index 3a6bee8c5cf..7c74359c25d 100644 --- a/cabal-install/main/Main.hs +++ b/cabal-install/main/Main.hs @@ -427,7 +427,7 @@ filterBuildFlags version config buildFlags buildNumJobs = NoFlag } buildFlags_latest = buildFlags { - -- Take the 'jobs' setting config file into account. + -- Take the 'jobs' setting '~/.cabal/config' into account. buildNumJobs = Flag . Just . determineNumJobs $ (numJobsConfigFlag `mappend` numJobsCmdLineFlag) } diff --git a/cabal-install/src/Distribution/Client/CmdClean.hs b/cabal-install/src/Distribution/Client/CmdClean.hs index d0d1a573e4c..a0eee3e33fa 100644 --- a/cabal-install/src/Distribution/Client/CmdClean.hs +++ b/cabal-install/src/Distribution/Client/CmdClean.hs @@ -4,12 +4,12 @@ module Distribution.Client.CmdClean (cleanCommand, cleanAction) where import Prelude () import Distribution.Client.Compat.Prelude -import Distribution.Client.Config - ( defaultScriptBuildsDir ) import Distribution.Client.DistDirLayout ( DistDirLayout(..), defaultDistDirLayout ) import Distribution.Client.ProjectConfig ( findProjectRoot ) +import Distribution.Client.ScriptUtils + ( getScriptCacheDirectoryRoot ) import Distribution.Client.Setup ( GlobalFlags ) import Distribution.ReadE ( succeedReadE ) @@ -121,7 +121,7 @@ cleanAction CleanFlags{..} extraArgs _ = do -- There is currently no good way to specify to only clean orphaned caches. -- It would be better as part of an explicit gc step (see issue #3333) toClean <- Set.fromList <$> mapM canonicalizePath extraArgs - cacheDir <- defaultScriptBuildsDir + cacheDir <- getScriptCacheDirectoryRoot existsCD <- doesDirectoryExist cacheDir caches <- if existsCD then listDirectory cacheDir else return [] paths <- fmap concat . forM caches $ \cache -> do diff --git a/cabal-install/src/Distribution/Client/CmdInstall.hs b/cabal-install/src/Distribution/Client/CmdInstall.hs index fdac338c0d5..fd47f5545c2 100644 --- a/cabal-install/src/Distribution/Client/CmdInstall.hs +++ b/cabal-install/src/Distribution/Client/CmdInstall.hs @@ -64,7 +64,7 @@ import Distribution.Simple.BuildPaths import Distribution.Simple.Program.Find ( ProgramSearchPathEntry(..) ) import Distribution.Client.Config - ( defaultInstallPath, loadConfig, SavedConfig(..) ) + ( defaultInstallPath, getCabalDir, loadConfig, SavedConfig(..) ) import qualified Distribution.Simple.PackageIndex as PI import Distribution.Solver.Types.PackageIndex ( lookupPackageName, searchByName ) @@ -150,7 +150,7 @@ installCommand = CommandUI , commandDescription = Just $ \_ -> wrapText $ "Installs one or more packages. This is done by installing them " ++ "in the store and symlinking/copying the executables in the directory " - ++ "specified by the --installdir flag (`~/.local/bin/` by default). " + ++ "specified by the --installdir flag (`~/.cabal/bin/` by default). " ++ "If you want the installed executables to be available globally, " ++ "make sure that the PATH environment variable contains that directory. " ++ "\n\n" @@ -254,6 +254,7 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe withoutProject globalConfig = do tss <- traverse (parseWithoutProjectTargetSelector verbosity) targetStrings' + cabalDir <- getCabalDir let projectConfig = globalConfig <> cliConfig @@ -267,9 +268,8 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe mlogsDir = flagToMaybe projectConfigLogsDir mstoreDir = flagToMaybe projectConfigStoreDir - cabalDirLayout <- mkCabalDirLayout mstoreDir mlogsDir + cabalDirLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir - let buildSettings = resolveBuildTimeSettings verbosity cabalDirLayout projectConfig @@ -605,7 +605,7 @@ installExes verbosity baseCtx buildCtx platform compiler installdir <- fromFlagOrDefault (warn verbosity installdirUnknown >> pure installPath) $ pure <$> cinstInstalldir clientInstallFlags - createDirectoryIfMissingVerbose verbosity True installdir + createDirectoryIfMissingVerbose verbosity False installdir warnIfNoExes verbosity buildCtx installMethod <- flagElim defaultMethod return $ @@ -912,10 +912,11 @@ getPackageDbStack -> Flag FilePath -> IO PackageDBStack getPackageDbStack compilerId storeDirFlag logsDirFlag = do + cabalDir <- getCabalDir mstoreDir <- traverse makeAbsolute $ flagToMaybe storeDirFlag let mlogsDir = flagToMaybe logsDirFlag - cabalLayout <- mkCabalDirLayout mstoreDir mlogsDir + cabalLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir pure $ storePackageDBStack (cabalStoreDirLayout cabalLayout) compilerId -- | This defines what a 'TargetSelector' means for the @bench@ command. diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index a6c42a07834..20249386af6 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -24,14 +24,12 @@ module Distribution.Client.Config ( showConfigWithComments, parseConfig, + getCabalDir, defaultConfigFile, defaultCacheDir, - defaultScriptBuildsDir, - defaultStoreDir, defaultCompiler, defaultInstallPath, defaultLogsDir, - defaultReportsDir, defaultUserInstall, baseSavedConfig, @@ -50,7 +48,6 @@ module Distribution.Client.Config ( postProcessRepo, ) where -import Distribution.Compat.Environment (lookupEnv) import Distribution.Client.Compat.Prelude import Prelude () @@ -95,7 +92,7 @@ import Distribution.Simple.Setup , Flag(..), toFlag, flagToMaybe, fromFlagOrDefault ) import Distribution.Simple.InstallDirs ( InstallDirs(..), defaultInstallDirs - , PathTemplate, toPathTemplate) + , PathTemplate, toPathTemplate ) import Distribution.Deprecated.ParseUtils ( FieldDescr(..), liftField, runP , ParseResult(..), PError(..), PWarning(..) @@ -135,7 +132,7 @@ import Text.PrettyPrint import Text.PrettyPrint.HughesPJ ( text, Doc ) import System.Directory - ( createDirectoryIfMissing, getHomeDirectory, getXdgDirectory, XdgDirectory(XdgCache, XdgConfig, XdgState), renameFile, getAppUserDataDirectory, doesDirectoryExist ) + ( createDirectoryIfMissing, getAppUserDataDirectory, renameFile ) import Network.URI ( URI(..), URIAuth(..), parseURI ) import System.FilePath @@ -143,7 +140,7 @@ import System.FilePath import System.IO.Error ( isDoesNotExistError ) import Distribution.Compat.Environment - ( getEnvironment ) + ( getEnvironment, lookupEnv ) import qualified Data.Map as M import qualified Data.ByteString as BS @@ -544,7 +541,7 @@ instance Semigroup SavedConfig where -- baseSavedConfig :: IO SavedConfig baseSavedConfig = do - userPrefix <- defaultInstallPrefix + userPrefix <- getCabalDir cacheDir <- defaultCacheDir logsDir <- defaultLogsDir return mempty { @@ -592,91 +589,40 @@ initialSavedConfig = do } } --- | If @CABAL\_DIR@ is set or @~/.cabal@ exists, return that --- directory. Otherwise returns Nothing. If this function returns --- Nothing, then it implies that we are not using a single directory --- for everything, but instead use XDG paths. Fundamentally, this --- function is used to implement transparent backwards compatibility --- with pre-XDG versions of cabal-install. -maybeGetCabalDir :: IO (Maybe FilePath) -maybeGetCabalDir = do - mDir <- lookupEnv "CABAL_DIR" - case mDir of - Just dir -> return $ Just dir - Nothing -> do - defaultDir <- getAppUserDataDirectory "cabal" - dotCabalExists <- doesDirectoryExist defaultDir - return $ if dotCabalExists - then Just defaultDir - else Nothing - --- | The default behaviour of cabal-install is to use the XDG --- directory standard. However, if @CABAL_DIR@ is set, we instead use --- that directory as a single store for everything cabal-related, like --- the old @~/.cabal@ behaviour. Also, for backwards compatibility, --- if @~/.cabal@ exists we treat that as equivalent to @CABAL_DIR@ --- being set. This function abstracts that decision-making. -getDefaultDir :: XdgDirectory -> FilePath -> IO FilePath -getDefaultDir xdg subdir = do - mDir <- maybeGetCabalDir - case mDir of - Just dir -> return $ dir subdir - Nothing -> getXdgDirectory xdg $ "cabal" subdir +defaultCabalDir :: IO FilePath +defaultCabalDir = getAppUserDataDirectory "cabal" --- | The default prefix used for installation. -defaultInstallPrefix :: IO FilePath -defaultInstallPrefix = do - mDir <- maybeGetCabalDir +getCabalDir :: IO FilePath +getCabalDir = do + mDir <- lookupEnv "CABAL_DIR" case mDir of - Just dir -> - return dir - Nothing -> do - dir <- getHomeDirectory - return $ dir ".local" + Nothing -> defaultCabalDir + Just dir -> return dir defaultConfigFile :: IO FilePath -defaultConfigFile = - getDefaultDir XdgConfig "config" +defaultConfigFile = do + dir <- getCabalDir + return $ dir "config" defaultCacheDir :: IO FilePath -defaultCacheDir = - getDefaultDir XdgCache "packages" - -defaultScriptBuildsDir :: IO FilePath -defaultScriptBuildsDir = - getDefaultDir XdgCache "script-builds" - -defaultStoreDir :: IO FilePath -defaultStoreDir = - getDefaultDir XdgState "store" +defaultCacheDir = do + dir <- getCabalDir + return $ dir "packages" defaultLogsDir :: IO FilePath -defaultLogsDir = - getDefaultDir XdgCache "logs" - -defaultReportsDir :: IO FilePath -defaultReportsDir = - getDefaultDir XdgCache "reports" +defaultLogsDir = do + dir <- getCabalDir + return $ dir "logs" defaultExtraPath :: IO [FilePath] defaultExtraPath = do - mDir <- maybeGetCabalDir - case mDir of - Just dir -> - return [dir "bin"] - Nothing -> do - dir <- getHomeDirectory - return [dir ".local" "bin"] + dir <- getCabalDir + return [dir "bin"] defaultInstallPath :: IO FilePath defaultInstallPath = do - mDir <- maybeGetCabalDir - case mDir of - Just dir -> - return $ dir "bin" - Nothing -> do - dir <- getHomeDirectory - return $ dir ".local" "bin" + dir <- getCabalDir + return (dir "bin") defaultCompiler :: CompilerFlavor defaultCompiler = fromMaybe GHC defaultCompilerFlavor @@ -692,7 +638,7 @@ defaultRemoteRepo = RemoteRepo name uri Nothing [] 0 False str = "hackage.haskell.org" name = RepoName str uri = URI "http:" (Just (URIAuth "" str "")) "/" "" "" - -- Note that lots of old config files will have the old url + -- Note that lots of old ~/.cabal/config files will have the old url -- http://hackage.haskell.org/packages/archive -- but new config files can use the new url (without the /packages/archive) -- and avoid having to do a http redirect @@ -1486,7 +1432,7 @@ parseExtraLines verbosity extraLines = unlines (map (showPWarning "Error parsing additional config lines") ws) -- | Get the differences (as a pseudo code diff) between the user's --- config file and the one that cabal would generate if it didn't exist. +-- '~/.cabal/config' and the one that cabal would generate if it didn't exist. userConfigDiff :: Verbosity -> GlobalFlags -> [String] -> IO [String] userConfigDiff verbosity globalFlags extraLines = do userConfig <- loadRawConfig normal (globalConfigFile globalFlags) @@ -1533,7 +1479,7 @@ userConfigDiff verbosity globalFlags extraLines = do in (topAndTail left, topAndTail (drop 1 right)) --- | Update the user's config file keeping the user's customizations. +-- | Update the user's ~/.cabal/config' keeping the user's customizations. userConfigUpdate :: Verbosity -> GlobalFlags -> [String] -> IO () userConfigUpdate verbosity globalFlags extraLines = do userConfig <- loadRawConfig normal (globalConfigFile globalFlags) diff --git a/cabal-install/src/Distribution/Client/DistDirLayout.hs b/cabal-install/src/Distribution/Client/DistDirLayout.hs index 2b88ddc4302..d8923370797 100644 --- a/cabal-install/src/Distribution/Client/DistDirLayout.hs +++ b/cabal-install/src/Distribution/Client/DistDirLayout.hs @@ -27,8 +27,6 @@ import Prelude () import System.FilePath -import Distribution.Client.Config - ( defaultStoreDir, defaultLogsDir) import Distribution.Package ( PackageId, PackageIdentifier, ComponentId, UnitId ) import Distribution.Compiler @@ -294,16 +292,19 @@ defaultStoreDirLayout storeRoot = storeIncomingDirectory compid prettyShow unitid <.> "lock" -defaultCabalDirLayout :: IO CabalDirLayout -defaultCabalDirLayout = - mkCabalDirLayout Nothing Nothing +defaultCabalDirLayout :: FilePath -> CabalDirLayout +defaultCabalDirLayout cabalDir = + mkCabalDirLayout cabalDir Nothing Nothing -mkCabalDirLayout :: Maybe FilePath -- ^ Store directory. Must be absolute +mkCabalDirLayout :: FilePath -- ^ Cabal directory + -> Maybe FilePath -- ^ Store directory. Must be absolute -> Maybe FilePath -- ^ Log directory - -> IO CabalDirLayout -mkCabalDirLayout mstoreDir mlogDir = do - cabalStoreDirLayout <- - defaultStoreDirLayout <$> maybe defaultStoreDir pure mstoreDir - cabalLogsDirectory <- - maybe defaultLogsDir pure mlogDir - pure $ CabalDirLayout {..} + -> CabalDirLayout +mkCabalDirLayout cabalDir mstoreDir mlogDir = + CabalDirLayout {..} + where + cabalStoreDirLayout :: StoreDirLayout + cabalStoreDirLayout = + defaultStoreDirLayout (fromMaybe (cabalDir "store") mstoreDir) + cabalLogsDirectory :: FilePath + cabalLogsDirectory = fromMaybe (cabalDir "logs") mlogDir diff --git a/cabal-install/src/Distribution/Client/HttpUtils.hs b/cabal-install/src/Distribution/Client/HttpUtils.hs index 54c88d97ea5..228c7dc44ac 100644 --- a/cabal-install/src/Distribution/Client/HttpUtils.hs +++ b/cabal-install/src/Distribution/Client/HttpUtils.hs @@ -500,7 +500,7 @@ wgetTransport prog = warningMsg = "the 'wget' transport currently doesn't support" ++ " range requests, which wastes network bandwidth." ++ " To fix this, set 'http-transport' to 'curl' or" - ++ " 'plain-http' in '~/.config/cabal/config'." + ++ " 'plain-http' in '~/.cabal/config'." ++ " Note that the 'plain-http' transport doesn't" ++ " support HTTPS.\n" diff --git a/cabal-install/src/Distribution/Client/Install.hs b/cabal-install/src/Distribution/Client/Install.hs index 2baa8af9e49..d099ec4dfff 100644 --- a/cabal-install/src/Distribution/Client/Install.hs +++ b/cabal-install/src/Distribution/Client/Install.hs @@ -71,7 +71,7 @@ import Distribution.Client.Setup , ConfigExFlags(..), InstallFlags(..) , filterTestFlags ) import Distribution.Client.Config - ( defaultReportsDir, defaultUserInstall ) + ( getCabalDir, defaultUserInstall ) import Distribution.Client.Tar (extractTarGzFile) import Distribution.Client.Types as Source import Distribution.Client.BuildReports.Types @@ -197,7 +197,7 @@ install verbosity packageDBs repos comp platform progdb warn verbosity $ "--root-cmd is no longer supported, " ++ "see https://github.com/haskell/cabal/issues/3353" ++ " (if you didn't type --root-cmd, comment out root-cmd" - ++ " in your ~/.config/cabal/config file)" + ++ " in your ~/.cabal/config file)" let userOrSandbox = fromFlag (configUserInstall configFlags) unless userOrSandbox $ warn verbosity $ "the --global flag is deprecated -- " @@ -831,10 +831,10 @@ postInstallActions verbosity storeDetailedBuildReports :: Verbosity -> FilePath -> [(BuildReports.BuildReport, Maybe Repo)] -> IO () storeDetailedBuildReports verbosity logsDir reports = sequence_ - [ do allReportsDir <- defaultReportsDir + [ do dotCabal <- getCabalDir let logFileName = prettyShow (BuildReports.package report) <.> "log" logFile = logsDir logFileName - reportsDir = allReportsDir unRepoName (remoteRepoName remoteRepo) + reportsDir = dotCabal "reports" unRepoName (remoteRepoName remoteRepo) reportFile = reportsDir logFileName handleMissingLogFile $ do diff --git a/cabal-install/src/Distribution/Client/Manpage.hs b/cabal-install/src/Distribution/Client/Manpage.hs index 34023c7bd48..19e80ba9f5f 100644 --- a/cabal-install/src/Distribution/Client/Manpage.hs +++ b/cabal-install/src/Distribution/Client/Manpage.hs @@ -46,7 +46,7 @@ data FileInfo = FileInfo String String -- ^ path, description -- | A list of files that should be documented in the manual page. files :: [FileInfo] files = - [ (FileInfo "~/.config/cabal/config" "The defaults that can be overridden with command-line options.") + [ (FileInfo "~/.cabal/config" "The defaults that can be overridden with command-line options.") ] manpageCmd :: String -> [CommandSpec a] -> ManpageFlags -> IO () diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 645ebe6f621..e693d1aad66 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -622,7 +622,7 @@ writeProjectConfigFile file = writeFile file . showProjectConfig --- | Read the user's cabal-install config file. +-- | Read the user's @~/.cabal/config@ file. -- readGlobalConfig :: Verbosity -> Flag FilePath -> Rebuild ProjectConfig readGlobalConfig verbosity configFileFlag = do diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs index 95c3fad5629..1c7aba8243e 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs @@ -365,7 +365,7 @@ commandLineFlagsToProjectConfig globalFlags NixStyleFlags {..} clientInstallFlag , packageConfigHaddockLinkedSource = packageConfigHaddockLinkedSource pc }) --- | Convert from the types currently used for the user-wide Cabal config +-- | Convert from the types currently used for the user-wide @~/.cabal/config@ -- file into the 'ProjectConfig' type. -- -- Only a subset of the 'ProjectConfig' can be represented in the user-wide diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs index 143e8fb1049..e2a84f82d95 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs @@ -73,7 +73,7 @@ import qualified Data.Map as Map -- | This type corresponds directly to what can be written in the -- @cabal.project@ file. Other sources of configuration can also be injected --- into this type, such as the user-wide config file and the +-- into this type, such as the user-wide @~/.cabal/config@ file and the -- command line of @cabal configure@ or @cabal build@. -- -- Since it corresponds to the external project file it is an instance of diff --git a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs index 3d93b0db115..276964b93be 100644 --- a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs @@ -138,6 +138,7 @@ import qualified Distribution.Client.BuildReports.Anonymous as BuildReports import qualified Distribution.Client.BuildReports.Storage as BuildReports ( storeLocal ) +import Distribution.Client.Config (getCabalDir) import Distribution.Client.HttpUtils import Distribution.Client.Setup hiding (packageName) import Distribution.Compiler @@ -221,6 +222,8 @@ establishProjectBaseContextWithRoot -> CurrentCommand -> IO ProjectBaseContext establishProjectBaseContextWithRoot verbosity cliConfig projectRoot currentCommand = do + cabalDir <- getCabalDir + let distDirLayout = defaultDistDirLayout projectRoot mdistDirectory httpTransport <- configureTransport verbosity @@ -244,9 +247,9 @@ establishProjectBaseContextWithRoot verbosity cliConfig projectRoot currentComma mlogsDir = Setup.flagToMaybe projectConfigLogsDir mstoreDir <- sequenceA $ makeAbsolute <$> Setup.flagToMaybe projectConfigStoreDir - cabalDirLayout <- mkCabalDirLayout mstoreDir mlogsDir + let cabalDirLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir - let buildSettings = resolveBuildTimeSettings + buildSettings = resolveBuildTimeSettings verbosity cabalDirLayout projectConfig @@ -1318,6 +1321,8 @@ establishDummyProjectBaseContext -> CurrentCommand -> IO ProjectBaseContext establishDummyProjectBaseContext verbosity projectConfig distDirLayout localPackages currentCommand = do + cabalDir <- getCabalDir + let ProjectConfigBuildOnly { projectConfigLogsDir } = projectConfigBuildOnly projectConfig @@ -1328,10 +1333,9 @@ establishDummyProjectBaseContext verbosity projectConfig distDirLayout localPack mlogsDir = flagToMaybe projectConfigLogsDir mstoreDir = flagToMaybe projectConfigStoreDir + cabalDirLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir - cabalDirLayout <- mkCabalDirLayout mstoreDir mlogsDir - - let buildSettings :: BuildTimeSettings + buildSettings :: BuildTimeSettings buildSettings = resolveBuildTimeSettings verbosity cabalDirLayout projectConfig diff --git a/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs b/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs index 0d13cda1093..4b7c18a2275 100644 --- a/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs +++ b/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs @@ -81,7 +81,7 @@ userPackageEnvironmentFile = "cabal.config" -- | Type of the current package environment. data PackageEnvironmentType = UserPackageEnvironment -- ^ './cabal.config' - | AmbientPackageEnvironment -- ^ '~/.config/cabal/config' + | AmbientPackageEnvironment -- ^ '~/.cabal/config' -- | Is there a 'cabal.config' in this directory? classifyPackageEnvironment :: FilePath -> IO PackageEnvironmentType @@ -271,7 +271,7 @@ showPackageEnvironment :: PackageEnvironment -> String showPackageEnvironment pkgEnv = showPackageEnvironmentWithComments Nothing pkgEnv -- | Pretty-print the package environment with default values for empty fields --- commented out (just like the default Cabal config file). +-- commented out (just like the default ~/.cabal/config). showPackageEnvironmentWithComments :: (Maybe PackageEnvironment) -> PackageEnvironment -> String diff --git a/cabal-install/src/Distribution/Client/ScriptUtils.hs b/cabal-install/src/Distribution/Client/ScriptUtils.hs index db377c8f10a..1613f8258d3 100644 --- a/cabal-install/src/Distribution/Client/ScriptUtils.hs +++ b/cabal-install/src/Distribution/Client/ScriptUtils.hs @@ -6,7 +6,7 @@ -- | Utilities to help commands with scripts -- module Distribution.Client.ScriptUtils ( - getScriptHash, getScriptCacheDirectory, ensureScriptCacheDirectory, + getScriptCacheDirectoryRoot, getScriptHash, getScriptCacheDirectory, ensureScriptCacheDirectory, withContextAndSelectors, AcceptNoTargets(..), TargetContext(..), updateContextAndWriteProjectFile, updateContextAndWriteProjectFile', fakeProjectSourcePackage, lSrcpkgDescription @@ -22,7 +22,7 @@ import Distribution.CabalSpecVersion ( CabalSpecVersion (..), cabalSpecLatest) import Distribution.Client.ProjectOrchestration import Distribution.Client.Config - ( defaultScriptBuildsDir ) + ( getCabalDir ) import Distribution.Client.DistDirLayout ( DistDirLayout(..) ) import Distribution.Client.HashValue @@ -120,6 +120,14 @@ import qualified Text.Parsec as P -- repl to deal with the fact that the repl is relative to the working directory and not -- the project root. +-- | Get the directory where script builds are cached. +-- +-- @CABAL_DIR\/script-builds\/@ +getScriptCacheDirectoryRoot :: IO FilePath +getScriptCacheDirectoryRoot = do + cabalDir <- getCabalDir + return $ cabalDir "script-builds" + -- | Get the hash of a script's absolute path) -- -- Two hashes will be the same as long as the absolute paths @@ -130,14 +138,14 @@ getScriptHash script = showHashValue . hashValue . fromString <$> canonicalizePa -- | Get the directory for caching a script build. -- -- The only identity of a script is it's absolute path, so append the --- hashed path to the @script-builds@ dir to get the cache directory. +-- hashed path to @CABAL_DIR\/script-builds\/@ to get the cache directory. getScriptCacheDirectory :: FilePath -> IO FilePath -getScriptCacheDirectory script = () <$> defaultScriptBuildsDir <*> getScriptHash script +getScriptCacheDirectory script = () <$> getScriptCacheDirectoryRoot <*> getScriptHash script -- | Get the directory for caching a script build and ensure it exists. -- -- The only identity of a script is it's absolute path, so append the --- hashed path to the @script-builds@ dir to get the cache directory. +-- hashed path to @CABAL_DIR\/script-builds\/@ to get the cache directory. ensureScriptCacheDirectory :: Verbosity -> FilePath -> IO FilePath ensureScriptCacheDirectory verbosity script = do cacheDir <- getScriptCacheDirectory script diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index 57615a9755b..e509b99ce2f 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -1274,7 +1274,7 @@ reportCommand = CommandUI { commandSynopsis = "Upload build reports to a remote server.", commandDescription = Nothing, commandNotes = Just $ \_ -> - "You can store your Hackage login in the ~/.config/cabal/config file\n", + "You can store your Hackage login in the ~/.cabal/config file\n", commandUsage = usageAlternatives "report" ["[FLAGS]"], commandDefaultFlags = defaultReportFlags, commandOptions = \_ -> @@ -1681,7 +1681,7 @@ installCommand = CommandUI { ++ " `v1-configure` for a list of commands being affected.\n" ++ "\n" ++ "Installed executables will by default" - ++ " be put into `~/.local/bin/`." + ++ " be put into `~/.cabal/bin/`." ++ " If you want installed executable to be available globally, make" ++ " sure that the PATH environment variable contains that directory.\n" ++ "\n", @@ -2003,7 +2003,7 @@ uploadCommand = CommandUI { commandSynopsis = "Uploads source packages or documentation to Hackage.", commandDescription = Nothing, commandNotes = Just $ \_ -> - "You can store your Hackage login in the ~/.config/cabal/config file\n" + "You can store your Hackage login in the ~/.cabal/config file\n" ++ relevantConfigValuesText ["username", "password", "password-command"], commandUsage = \pname -> "Usage: " ++ pname ++ " upload [FLAGS] TARFILES\n", @@ -2358,18 +2358,18 @@ userConfigCommand = CommandUI { commandDescription = Just $ \_ -> wrapText $ "When upgrading cabal, the set of configuration keys and their default" ++ " values may change. This command provides means to merge the existing" - ++ " config in ~/.config/cabal/config" + ++ " config in ~/.cabal/config" ++ " (i.e. all bindings that are actually defined and not commented out)" ++ " and the default config of the new version.\n" ++ "\n" - ++ "init: Creates a new config file at either ~/.config/cabal/config or as" + ++ "init: Creates a new config file at either ~/.cabal/config or as" ++ " specified by --config-file, if given. An existing file won't be " ++ " overwritten unless -f or --force is given.\n" - ++ "diff: Shows a pseudo-diff of the user's ~/.config/cabal/config file and" + ++ "diff: Shows a pseudo-diff of the user's ~/.cabal/config file and" ++ " the default configuration that would be created by cabal if the" ++ " config file did not exist.\n" ++ "update: Applies the pseudo-diff to the configuration that would be" - ++ " created by default, and write the result back to ~/.config/cabal/config.", + ++ " created by default, and write the result back to ~/.cabal/config.", commandNotes = Nothing, commandUsage = usageAlternatives "user-config" ["init", "diff", "update"], diff --git a/cabal-install/src/Distribution/Client/SetupWrapper.hs b/cabal-install/src/Distribution/Client/SetupWrapper.hs index e4885ed07c6..1ac82efcbd7 100644 --- a/cabal-install/src/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/src/Distribution/Client/SetupWrapper.hs @@ -77,7 +77,7 @@ import Distribution.Simple.PackageIndex (InstalledPackageIndex) import qualified Distribution.InstalledPackageInfo as IPI import Distribution.Client.Types import Distribution.Client.Config - ( defaultCacheDir ) + ( getCabalDir ) import Distribution.Client.IndexUtils ( getInstalledPackages ) import Distribution.Client.JobControl @@ -240,7 +240,7 @@ data SetupScriptOptions = SetupScriptOptions { -- When we are installing in parallel, we always use the external setup -- method. Since compiling the setup script each time adds noticeable -- overhead, we use a shared setup script cache - -- ('$XDG_CACHE_HOME/cabal/setup-exe-cache'). For each (compiler, platform, Cabal + -- ('~/.cabal/setup-exe-cache'). For each (compiler, platform, Cabal -- version) combination the cache holds a compiled setup script -- executable. This only affects the Simple build type; for the Custom, -- Configure and Make build types we always compile the setup script anew. @@ -740,8 +740,8 @@ getExternalSetupMethod verbosity options pkg bt = do cachedSetupDirAndProg :: SetupScriptOptions -> Version -> IO (FilePath, FilePath) cachedSetupDirAndProg options' cabalLibVersion = do - cacheDir <- defaultCacheDir - let setupCacheDir = cacheDir "setup-exe-cache" + cabalDir <- getCabalDir + let setupCacheDir = cabalDir "setup-exe-cache" cachedSetupProgFile = setupCacheDir ("setup-" ++ buildTypeString ++ "-" ++ cabalVersionString ++ "-" diff --git a/cabal-install/src/Distribution/Client/Upload.hs b/cabal-install/src/Distribution/Client/Upload.hs index d5f46439954..1c23aa21696 100644 --- a/cabal-install/src/Distribution/Client/Upload.hs +++ b/cabal-install/src/Distribution/Client/Upload.hs @@ -183,9 +183,9 @@ report verbosity repoCtxt mUsername mPassword = do let auth :: (String, String) auth = (username, password) - reportsDir <- defaultReportsDir + dotCabal <- getCabalDir let srcDir :: FilePath - srcDir = reportsDir unRepoName (remoteRepoName remoteRepo) + srcDir = dotCabal "reports" unRepoName (remoteRepoName remoteRepo) -- We don't want to bomb out just because we haven't built any packages -- from this repo yet. srcExists <- doesDirectoryExist srcDir diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 1e552605446..da1652aadd6 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -15,6 +15,7 @@ import Prelude () import Distribution.Client.DistDirLayout import Distribution.Client.ProjectConfig +import Distribution.Client.Config (getCabalDir) import Distribution.Client.HttpUtils import Distribution.Client.TargetSelector hiding (DirActions(..)) import qualified Distribution.Client.TargetSelector as TS (DirActions(..)) @@ -1677,7 +1678,8 @@ type ProjDetails = (DistDirLayout, configureProject :: FilePath -> ProjectConfig -> IO ProjDetails configureProject testdir cliConfig = do - cabalDirLayout <- defaultCabalDirLayout + cabalDir <- getCabalDir + let cabalDirLayout = defaultCabalDirLayout cabalDir projectRootDir <- canonicalizePath (basedir testdir) isexplict <- doesFileExist (projectRootDir "cabal.project") diff --git a/changelog.d/pr-7386 b/changelog.d/pr-7386 deleted file mode 100644 index 36c81b21e65..00000000000 --- a/changelog.d/pr-7386 +++ /dev/null @@ -1,32 +0,0 @@ -synopsis: Switch to using XDG directories -prs: #7386 -issues: #680 -significance: significant - -description: { - -Cabal/cabal-install now uses the XDG Base Directory Specification to -store configuration, caches, and the store. Specifically, -`$XDG_CONFIG_HOME/cabal` stores the configuration file, -`$XDG_CACHE_HOME/cabal` stores downloaded packages and similar, and -`$XDG_STATE_HOME/cabal` mainly contains the store of compiled -packages. Further, `cabal install will put executables in -`~/.local/bin` by default. - -The `dist`/`dist-newstyle` directories are not affected. - -On Windows, these XDG paths are mapped to other (hopefully) -appropriate locations. See the Cabal User Guide for information. - -If the `CABAL_DIR` environment variable is set, the indicated -directory will be used to store all Cabal-related files, as in -previous versions. - -Backwards compatibility: If `~/.cabal` already exists, this will be -interpreted as `CABAL_DIR=~/.cabal`. This means that upgrading on an -existing system already using cabal-install should not cause any -change in behaviour. An existing system can be migrated by deleting -`~/.cabal` (possibly copying `~/.cabal/config` to -`~/.config/cabal/config` first). - -} diff --git a/doc/cabal-commands.rst b/doc/cabal-commands.rst index 7671e41cdf9..b6380ce05cd 100644 --- a/doc/cabal-commands.rst +++ b/doc/cabal-commands.rst @@ -121,7 +121,7 @@ Arguments and flags common to some or all commands are: $ cabal install --allow-newer=foo:base,lens --allow-newer=bar:time Finally, one can enable :option:`--allow-newer` permanently by setting - ``allow-newer: True`` in the :ref:`config file `. Enabling + ``allow-newer: True`` in the ``~/.cabal/config`` file. Enabling 'allow-newer' selectively is also supported in the config file (``allow-newer: foo, bar, baz:base``). @@ -598,7 +598,7 @@ cabal install ^^^^^^^^^^^^^ ``cabal install [FLAGS] [TARGETS]`` builds the specified target packages and -symlinks/copies their executables in ``installdir`` (usually ``~/.local/bin``). +symlinks/copies their executables in ``installdir`` (usually ``~/.cabal/bin``). .. warning:: diff --git a/doc/cabal-package.rst b/doc/cabal-package.rst index ef236aeb586..9ba500cf472 100644 --- a/doc/cabal-package.rst +++ b/doc/cabal-package.rst @@ -1574,7 +1574,7 @@ in ghc's package DB and so we can figure out what the location of the library is. Foreign libraries however don't get registered, which means that we'd have to have a way of finding out where a platform library got installed (other than by searching the ``lib/`` directory). Instead, we install foreign libraries in -``~/.local/lib``. +``~/.cabal/lib``, much like we install executables in ``~/.cabal/bin``. Build information ^^^^^^^^^^^^^^^^^ diff --git a/doc/cabal-project.rst b/doc/cabal-project.rst index 4ba2c26f87f..a816ed91b06 100644 --- a/doc/cabal-project.rst +++ b/doc/cabal-project.rst @@ -24,7 +24,7 @@ The full configuration of a project is determined by combining the following sources (later entries override earlier ones, except for appendable options): -1. :ref:`The user-wide global configuration ` (default: ``~/.config/cabal/config``) +1. ``~/.cabal/config`` (the user-wide global configuration) 2. ``cabal.project`` (the project configuration) diff --git a/doc/config.rst b/doc/config.rst index a97b954037e..4f2e44dd9e3 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -7,7 +7,7 @@ Overview -------- The global configuration file for ``cabal-install`` is by default -``$XDG_CONFIG_HOME/cabal/config``. If you do not have this file, ``cabal`` will create +``$HOME/.cabal/config``. If you do not have this file, ``cabal`` will create it for you on the first call to ``cabal update`` (details see `configuration file discovery`_). Alternatively, you can explicitly ask ``cabal`` to create it for you using @@ -18,7 +18,7 @@ Alternatively, you can explicitly ask ``cabal`` to create it for you using You can change the location of the global configuration file by specifying either ``--config-file=FILE`` on the command line or by setting the -``CABAL_CONFIG`` or ``CABAL_DIR`` environment variable. +``CABAL_CONFIG`` environment variable. Most of the options in this configuration file are also available as command line arguments, and the corresponding documentation can be used @@ -51,22 +51,16 @@ Various environment variables affect ``cabal-install``. The variable to find global configuration file. ``CABAL_DIR`` - - If set, *all* ``cabal-install`` content files will be stored as - subdirectories of this directory, including the configuration file - if ``CABAL_CONFIG`` is unset. If ``CABAL_DIR`` is unset, Cabal - will store data files according to the XDG Base Directory - Specification (see `directories`_). + Default content directory for ``cabal-install`` files. + Default value is ``getAppUserDataDirectory "cabal"``, which is + ``$HOME/.cabal`` on unix systems and ``%APPDATA%\cabal`` in Windows. .. note:: - For backwards compatibility, if the directory ``~/.cabal`` on - Unix or ``%APPDATA%\cabal`` on Windows exist and ``CABAL_DIR`` - is unset, ``cabal-install`` will behave as if ``CABAL_DIR`` was - set to point at this directory. + The CABAL_DIR might be dropped in the future, when + ``cabal-install`` starts to use XDG Directory specification. ``CABAL_BUILDDIR`` - The override for default ``dist`` build directory. Note, the nix-style builds build directory (``dist-newstyle``) is not affected by this environment variable. @@ -81,40 +75,13 @@ The configuration file location is determined as follows: 1. If option ``--config-file`` is given, use it; 2. otherwise, if ``$CABAL_CONFIG`` is set use it; 3. otherwise, if ``$CABAL_DIR`` is set use ``$CABAL_DIR/config``; -4. otherwise use ``config`` in ``$XDG_CONFIG_HOME/cabal``, which - defaults to ``~/.config/cabal`` on Unix. +4. otherwise use ``config`` in ``getAppUserDirectory "cabal"``. If the configuration file does not exist, and it was not given explicitly via ``--config-file`` or ``$CABAL_CONFIG``, then ``cabal-install`` will generate the default one, with directories -based on ``$CABAL_DIR`` (if set) or according to the XDG Base -Directory Specification, as listed below. - -.. _directories: - -Directories ------------ - -Unless the ``CABAL_DIR`` environment variable is set or `~/.cabal` exists, Cabal will store -data in directories according to the XDG Base Directory Specification. -The following directories are used: - -* ``$XDG_CONFIG_HOME/cabal`` for the main configuration file. On - Unix, this defaults to ``~/.config/cabal``. On Windows this defaults to - ``%APPDATA%/cabal``. Overridden by the ``CABAL_CONFIG`` environment - variable if set. - -* ``$XDG_CACHE_HOME/cabal`` for downloaded packages and script - executables. Defaults to ``~/.cache/cabal`` on Unix, and - ``%LOCALAPPDATA%/cabal`` on Windows. You can delete this directory - and expect that its contents will be reconstructed as needed. - -* ``$XDG_STATE_HOME/cabal`` for compiled libraries and other stateful - artifacts. Defaults to ``~/.local/state/cabal`` on Unix and - ``%LOCALAPPDATA%/cabal`` on Windows. Deleting this directory might - cause installed programs to stop working. - -* ``~/.local/bin`` for executables installed with ``cabal install``. +based on ``$CABAL_DIR`` (if set) or ``getAppUserDirectory "cabal"`` +prefix. Repository specification ------------------------ @@ -130,7 +97,7 @@ the repository to be the central Hackage server: The name of the repository is given on the first line, and can be anything; packages downloaded from this repository will be cached under -``$XDG_CACHE_HOME/cabal/packages/hackage.haskell.org`` (or whatever name you specify; +``~/.cabal/packages/hackage.haskell.org`` (or whatever name you specify; you can change the prefix by changing the value of :cfg-field:`remote-repo-cache`). If you want, you can configure multiple repositories, and ``cabal`` will combine them and be able to download @@ -247,8 +214,7 @@ thus, looks similar to a ``package-name.cabal``'s ``build-depends`` section. .. note:: The ``preferred-versions`` file can be used to restrict the package set from Hackage, by preferring certain versions or marking a specific version as deprecated. To achieve this, add a - local no-index repository to your :ref:`configuration file `, - where the directory contains your custom + local no-index repository to your ``~/.cabal/config``, where the directory contains your custom ``preferred-versions``. After running ``cabal update``, all ``cabal`` operations will honour the configuration. diff --git a/doc/nix-integration.rst b/doc/nix-integration.rst index 6edf595b6f0..24b2a6de87b 100644 --- a/doc/nix-integration.rst +++ b/doc/nix-integration.rst @@ -12,7 +12,7 @@ Enabling Nix Integration ------------------------ To enable Nix integration, simply pass the ``--enable-nix`` global option when you call ``cabal`` (eg. ``cabal --enable-nix v1-build``). -To use this option everywhere, edit your :ref:`global configuration file` (default: ``~/.config/cabal/config``) to include: +To use this option everywhere, edit your :ref:`global configuration file` (default: ``$HOME/.cabal/config``) to include: .. code-block:: cabal