mirror of
https://github.com/NixOS/nix.git
synced 2025-11-22 02:09:36 +01:00
libstore: Deduplicate LocalFSStoreConfig::rootDir initializers
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
This commit is contained in:
parent
3a64d3c0da
commit
0866ba0b4a
2 changed files with 24 additions and 8 deletions
|
|
@ -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{canonPath(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