1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 01:39:36 +01:00

Simplify "Store dir" superclass

We can cut out some gratuitous inhertence as follows:

- `MixStoreDirMethods` -> `StoreDirConfig`

- `StoreDirConfig` deleted because no longer needed. It is just folded
  into `StoreConfig`.

- `StoreDirConfigBase` -> `StoreConfigBase` same trick still needed, but
  now is for `StoreConfig` not `StoreDirConfig`

Here's how we got here:

1. I once factored out `StoreDirConfig` in #6236.

2. I factored out `MixStoreDirMethods` in #13154.

But, I didn't realize at point (2) that we didn't need `StoreDirConfig`
anymore, all uses of `StoreDirConfig` could instead be uses of
`MixStoreDirMethods`. Now I am doing that, and renaming
`MixStoreDirMethods` to just `StoreDirConfig` to reduce churn.
This commit is contained in:
John Ericson 2025-08-15 13:48:50 -04:00
parent 22378ea093
commit 64c2ee3f45
4 changed files with 59 additions and 67 deletions

View file

@ -27,12 +27,18 @@ using json = nlohmann::json;
namespace nix {
bool MixStoreDirMethods::isInStore(PathView path) const
StoreConfig::StoreConfig(const Params & params)
: StoreConfigBase(params)
, StoreDirConfig{storeDir_}
{
}
bool StoreDirConfig::isInStore(PathView path) const
{
return isInDir(path, storeDir);
}
std::pair<StorePath, Path> MixStoreDirMethods::toStorePath(PathView path) const
std::pair<StorePath, Path> StoreDirConfig::toStorePath(PathView path) const
{
if (!isInStore(path))
throw Error("path '%1%' is not in the Nix store", path);
@ -293,7 +299,7 @@ StringSet Store::Config::getDefaultSystemFeatures()
}
Store::Store(const Store::Config & config)
: MixStoreDirMethods{config}
: StoreDirConfig{config}
, config{config}
, state({(size_t) config.pathInfoCacheSize})
{
@ -1082,7 +1088,7 @@ decodeValidPathInfo(const Store & store, std::istream & str, std::optional<HashR
return std::optional<ValidPathInfo>(std::move(info));
}
std::string MixStoreDirMethods::showPaths(const StorePathSet & paths) const
std::string StoreDirConfig::showPaths(const StorePathSet & paths) const
{
std::string s;
for (auto & i : paths) {