1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00
nix/src/libstore/store-dir-config.cc
John Ericson 2ea9f59978 New store settings system
Motivation:

See the linked issues for details.

The most notable user-relevant bits are:

- This cleans up the `MountedSSHStore`: decomposed into its orthogonal parts

- This brings us pretty close to being able to then implement a JSON-based config.
   - Store query parameters can be JSON
   - Stores can entirely be specified via JSON objects, but this is not yet hooked up to anything.

Also behind the scenes have these benefits:

1. The docs are moved out of the headers, good for less rebuilding when they changes
2. Stores are always constructed from store configs
3. Use JSON, avoid custom serializers

Context:

Part of #11106

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
2025-05-21 17:59:06 -04:00

45 lines
1.3 KiB
C++

#include "nix/store/store-dir-config.hh"
#include "nix/store/config-parse-impl.hh"
#include "nix/util/util.hh"
#include "nix/store/globals.hh"
namespace nix {
constexpr static const StoreDirConfigT<config::SettingInfo> storeDirConfigDescriptions = {
._storeDir{
.name = "store",
.description = R"(
Logical location of the Nix store, usually
`/nix/store`. Note that you can only copy store paths
between stores if they have the same `store` setting.
)",
},
};
#define STORE_DIR_CONFIG_FIELDS(X) X(_storeDir),
MAKE_PARSE(StoreDirConfig, storeDirConfig, STORE_DIR_CONFIG_FIELDS)
static StoreDirConfigT<config::PlainValue> storeDirConfigDefaults()
{
return {
._storeDir = {settings.nixStore},
};
}
MAKE_APPLY_PARSE(StoreDirConfig, storeDirConfig, STORE_DIR_CONFIG_FIELDS)
StoreDirConfig::StoreDirConfig(const StoreReference::Params & params)
: StoreDirConfigT<config::PlainValue>{storeDirConfigApplyParse(params)}
, MixStoreDirMethods{_storeDir.value}
{
}
config::SettingDescriptionMap StoreDirConfig::descriptions()
{
constexpr auto & descriptions = storeDirConfigDescriptions;
auto defaults = storeDirConfigDefaults();
return {STORE_DIR_CONFIG_FIELDS(DESCRIBE_ROW)};
}
}