Commit 22d8e326 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov Committed by GitHub
Browse files

Merge pull request #4623 from alexbiehl/pr/global-store-flag

Add 'store-dir' global flag for custom store location
parents 0fdf2174 6d22eb2e
......@@ -145,11 +145,11 @@ identify the result of a build; if we compute this identifier and we
find that we already have this ID built, we can just use the already
built version.
The global package store is ``~/.cabal/store``; if you need to clear
your store for whatever reason (e.g., to reclaim disk space or because
the global store is corrupted), deleting this directory is safe
(``new-build`` will just rebuild everything it needs on its next
invocation).
The global package store is ``~/.cabal/store`` (configurable via
global `store-dir` option); if you need to clear your store for
whatever reason (e.g., to reclaim disk space or because the global
store is corrupted), deleting this directory is safe (``new-build``
will just rebuild everything it needs on its next invocation).
This split motivates some of the UI choices for Nix-style local build
commands. For example, flags passed to ``cabal new-build`` are only
......@@ -641,6 +641,10 @@ package, and thus apply globally:
This option cannot be specified via a ``cabal.project`` file.
.. option:: --store-dir=DIR
Specifies the name of the directory of the global package store.
Solver configuration options
----------------------------
......
......@@ -227,7 +227,8 @@ instance Semigroup SavedConfig where
globalIgnoreSandbox = combine globalIgnoreSandbox,
globalIgnoreExpiry = combine globalIgnoreExpiry,
globalHttpTransport = combine globalHttpTransport,
globalNix = combine globalNix
globalNix = combine globalNix,
globalStoreDir = combine globalStoreDir
}
where
combine = combine' savedGlobalFlags
......
{-# LANGUAGE RecordWildCards #-}
-- |
-- |
--
-- The layout of the .\/dist\/ directory where cabal keeps all of it's state
-- and build artifacts.
......@@ -18,7 +18,8 @@ module Distribution.Client.DistDirLayout (
-- * 'CabalDirLayout'
CabalDirLayout(..),
defaultCabalDirLayout,
mkCabalDirLayout,
defaultCabalDirLayout
) where
import Data.Maybe (fromMaybe)
......@@ -243,12 +244,16 @@ defaultStoreDirLayout storeRoot =
defaultCabalDirLayout :: FilePath -> CabalDirLayout
defaultCabalDirLayout cabalDir =
mkCabalDirLayout cabalDir Nothing Nothing
mkCabalDirLayout :: FilePath -- ^ Cabal directory
-> Maybe FilePath -- ^ Store directory
-> Maybe FilePath -- ^ Log directory
-> CabalDirLayout
mkCabalDirLayout cabalDir mstoreDir mlogDir =
CabalDirLayout {..}
where
cabalStoreDirLayout = defaultStoreDirLayout (cabalDir </> "store")
cabalLogsDirectory = cabalDir </> "logs"
cabalWorldFile = cabalDir </> "world"
cabalStoreDirLayout =
defaultStoreDirLayout (fromMaybe (cabalDir </> "store") mstoreDir)
cabalLogsDirectory = fromMaybe (cabalDir </> "logs") mlogDir
cabalWorldFile = cabalDir </> "world"
\ No newline at end of file
......@@ -68,7 +68,8 @@ data GlobalFlags = GlobalFlags {
globalIgnoreSandbox :: Flag Bool,
globalIgnoreExpiry :: Flag Bool, -- ^ Ignore security expiry dates
globalHttpTransport :: Flag String,
globalNix :: Flag Bool -- ^ Integrate with Nix
globalNix :: Flag Bool, -- ^ Integrate with Nix
globalStoreDir :: Flag FilePath
} deriving Generic
defaultGlobalFlags :: GlobalFlags
......@@ -87,7 +88,8 @@ defaultGlobalFlags = GlobalFlags {
globalIgnoreSandbox = Flag False,
globalIgnoreExpiry = Flag False,
globalHttpTransport = mempty,
globalNix = Flag False
globalNix = Flag False,
globalStoreDir = mempty
}
instance Monoid GlobalFlags where
......
......@@ -399,7 +399,8 @@ convertLegacyBuildOnlyFlags globalFlags configFlags
globalLogsDir = projectConfigLogsDir,
globalWorldFile = _,
globalHttpTransport = projectConfigHttpTransport,
globalIgnoreExpiry = projectConfigIgnoreExpiry
globalIgnoreExpiry = projectConfigIgnoreExpiry,
globalStoreDir = projectConfigStoreDir
} = globalFlags
ConfigFlags {
......@@ -479,7 +480,8 @@ convertToLegacySharedConfig
globalIgnoreSandbox = mempty,
globalIgnoreExpiry = projectConfigIgnoreExpiry,
globalHttpTransport = projectConfigHttpTransport,
globalNix = mempty
globalNix = mempty,
globalStoreDir = projectConfigStoreDir
}
configFlags = mempty {
......@@ -805,7 +807,7 @@ legacySharedConfigFieldDescrs =
]
. filterFields
[ "remote-repo-cache"
, "logs-dir", "ignore-expiry", "http-transport"
, "logs-dir", "store-dir", "ignore-expiry", "http-transport"
]
. commandOptionsToFields
) (commandOptions (globalCommand []) ParseArgs)
......
......@@ -143,7 +143,8 @@ data ProjectConfigBuildOnly
projectConfigHttpTransport :: Flag String,
projectConfigIgnoreExpiry :: Flag Bool,
projectConfigCacheDir :: Flag FilePath,
projectConfigLogsDir :: Flag FilePath
projectConfigLogsDir :: Flag FilePath,
projectConfigStoreDir :: Flag FilePath
}
deriving (Eq, Show, Generic)
......
......@@ -167,8 +167,7 @@ establishProjectBaseContext verbosity cliConfig = do
projectRoot <- either throwIO return =<<
findProjectRoot Nothing mprojectFile
let cabalDirLayout = defaultCabalDirLayout cabalDir
distDirLayout = defaultDistDirLayout projectRoot
let distDirLayout = defaultDistDirLayout projectRoot
mdistDirectory
(projectConfig, localPackages) <-
......@@ -176,7 +175,16 @@ establishProjectBaseContext verbosity cliConfig = do
distDirLayout
cliConfig
let buildSettings = resolveBuildTimeSettings
let ProjectConfigBuildOnly {
projectConfigLogsDir,
projectConfigStoreDir
} = projectConfigBuildOnly projectConfig
mlogsDir = Setup.flagToMaybe projectConfigLogsDir
mstoreDir = Setup.flagToMaybe projectConfigStoreDir
cabalDirLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir
buildSettings = resolveBuildTimeSettings
verbosity cabalDirLayout
projectConfig
......
......@@ -368,6 +368,11 @@ globalCommand commands = CommandUI {
"The location of the world file"
globalWorldFile (\v flags -> flags { globalWorldFile = v })
(reqArgFlag "FILE")
,option [] ["store-dir"]
"The location of the nix-local-build store"
globalStoreDir (\v flags -> flags { globalStoreDir = v })
(reqArgFlag "DIR")
]
-- ------------------------------------------------------------
......
......@@ -15,8 +15,10 @@
relaxation can be now limited to a specific release of a package,
plus there's a now syntax for relaxing only caret-style (i.e. '^>=')
dependencies (#4575, #4669).
* `--store-dir` option can be used to configure the location of
the build global build store.
2.0.0.0 Ryan Thomas <ryan@ryant.org> July 2017
2.0.0.2 Mikhail Glushenkov <mikhail.glushenkov@gmail.com> July 2017
* Removed the '--root-cmd' parameter of the 'install' command
(#3356).
* Deprecated 'cabal install --global' (#3356).
......
......@@ -359,6 +359,7 @@ instance Arbitrary ProjectConfigBuildOnly where
<*> arbitrary
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary)
where
arbitraryNumJobs = fmap (fmap getPositive) <$> arbitrary
......@@ -378,7 +379,8 @@ instance Arbitrary ProjectConfigBuildOnly where
, projectConfigHttpTransport = x13
, projectConfigIgnoreExpiry = x14
, projectConfigCacheDir = x15
, projectConfigLogsDir = x16 } =
, projectConfigLogsDir = x16
, projectConfigStoreDir = x17 } =
[ ProjectConfigBuildOnly { projectConfigVerbosity = x00'
, projectConfigDryRun = x01'
, projectConfigOnlyDeps = x02'
......@@ -395,7 +397,8 @@ instance Arbitrary ProjectConfigBuildOnly where
, projectConfigHttpTransport = x13
, projectConfigIgnoreExpiry = x14'
, projectConfigCacheDir = x15
, projectConfigLogsDir = x16 }
, projectConfigLogsDir = x16
, projectConfigStoreDir = x17}
| ((x00', x01', x02', x03', x04'),
(x05', x06', x07', x08', x09'),
(x10', x11', x12', x14'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment