mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Merge pull request #14099 from xokdvium/fix-assert-failure
libstore: Call canonPath for constructing LocalFSStoreConfig::rootDir
This commit is contained in:
commit
f7d35dc1dc
2 changed files with 24 additions and 8 deletions
|
|
@ -9,6 +9,18 @@ namespace nix {
|
|||
|
||||
struct LocalFSStoreConfig : virtual StoreConfig
|
||||
{
|
||||
private:
|
||||
static OptionalPathSetting makeRootDirSetting(LocalFSStoreConfig & self, std::optional<Path> defaultValue)
|
||||
{
|
||||
return {
|
||||
&self,
|
||||
std::move(defaultValue),
|
||||
"root",
|
||||
"Directory prefixed to all other paths.",
|
||||
};
|
||||
}
|
||||
|
||||
public:
|
||||
using StoreConfig::StoreConfig;
|
||||
|
||||
/**
|
||||
|
|
@ -20,7 +32,7 @@ struct LocalFSStoreConfig : virtual StoreConfig
|
|||
*/
|
||||
LocalFSStoreConfig(PathView path, const Params & params);
|
||||
|
||||
OptionalPathSetting rootDir{this, std::nullopt, "root", "Directory prefixed to all other paths."};
|
||||
OptionalPathSetting rootDir = makeRootDirSetting(*this, std::nullopt);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,17 @@ Path LocalFSStoreConfig::getDefaultLogDir()
|
|||
|
||||
LocalFSStoreConfig::LocalFSStoreConfig(PathView rootDir, const Params & params)
|
||||
: StoreConfig(params)
|
||||
// Default `?root` from `rootDir` if non set
|
||||
// FIXME don't duplicate description once we don't have root setting
|
||||
, rootDir{
|
||||
this,
|
||||
!rootDir.empty() && params.count("root") == 0 ? (std::optional<Path>{rootDir}) : std::nullopt,
|
||||
"root",
|
||||
"Directory prefixed to all other paths."}
|
||||
/* Default `?root` from `rootDir` if non set
|
||||
* NOTE: We would like to just do rootDir.set(...), which would take care of
|
||||
* all normalization and error checking for us. Unfortunately we cannot do
|
||||
* that because of the complicated initialization order of other fields with
|
||||
* the virtual class hierarchy of nix store configs, and the design of the
|
||||
* settings system. As such, we have no choice but to redefine the field and
|
||||
* manually repeat the same normalization logic.
|
||||
*/
|
||||
, rootDir{makeRootDirSetting(
|
||||
*this,
|
||||
!rootDir.empty() && params.count("root") == 0 ? std::optional<Path>{canonPath(rootDir)} : std::nullopt)}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue