1
1
Fork 0
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:
John Ericson 2025-09-28 12:06:02 -04:00 committed by GitHub
commit f7d35dc1dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 8 deletions

View file

@ -9,6 +9,18 @@ namespace nix {
struct LocalFSStoreConfig : virtual StoreConfig 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; using StoreConfig::StoreConfig;
/** /**
@ -20,7 +32,7 @@ struct LocalFSStoreConfig : virtual StoreConfig
*/ */
LocalFSStoreConfig(PathView path, const Params & params); 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: private:

View file

@ -20,13 +20,17 @@ Path LocalFSStoreConfig::getDefaultLogDir()
LocalFSStoreConfig::LocalFSStoreConfig(PathView rootDir, const Params & params) LocalFSStoreConfig::LocalFSStoreConfig(PathView rootDir, const Params & params)
: StoreConfig(params) : StoreConfig(params)
// Default `?root` from `rootDir` if non set /* Default `?root` from `rootDir` if non set
// FIXME don't duplicate description once we don't have root setting * NOTE: We would like to just do rootDir.set(...), which would take care of
, rootDir{ * all normalization and error checking for us. Unfortunately we cannot do
this, * that because of the complicated initialization order of other fields with
!rootDir.empty() && params.count("root") == 0 ? (std::optional<Path>{rootDir}) : std::nullopt, * the virtual class hierarchy of nix store configs, and the design of the
"root", * settings system. As such, we have no choice but to redefine the field and
"Directory prefixed to all other paths."} * manually repeat the same normalization logic.
*/
, rootDir{makeRootDirSetting(
*this,
!rootDir.empty() && params.count("root") == 0 ? std::optional<Path>{canonPath(rootDir)} : std::nullopt)}
{ {
} }