mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-12-01 18:16:14 +02:00
Merge pull request #8774 from NixLayeredStore/experimental-stores
Add infra for experimental store implementations
This commit is contained in:
commit
635df5ee95
4 changed files with 39 additions and 4 deletions
|
@ -137,12 +137,29 @@ let
|
||||||
|
|
||||||
storeDocs =
|
storeDocs =
|
||||||
let
|
let
|
||||||
showStore = name: { settings, doc }:
|
showStore = name: { settings, doc, experimentalFeature }:
|
||||||
''
|
let
|
||||||
|
experimentalFeatureNote = optionalString (experimentalFeature != null) ''
|
||||||
|
> **Warning**
|
||||||
|
> This store is part of an
|
||||||
|
> [experimental feature](@docroot@/contributing/experimental-features.md).
|
||||||
|
|
||||||
|
To use this store, you need to make sure the corresponding experimental feature,
|
||||||
|
[`${experimentalFeature}`](@docroot@/contributing/experimental-features.md#xp-feature-${experimentalFeature}),
|
||||||
|
is enabled.
|
||||||
|
For example, include the following in [`nix.conf`](#):
|
||||||
|
|
||||||
|
```
|
||||||
|
extra-experimental-features = ${experimentalFeature}
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
in ''
|
||||||
## ${name}
|
## ${name}
|
||||||
|
|
||||||
${doc}
|
${doc}
|
||||||
|
|
||||||
|
${experimentalFeatureNote}
|
||||||
|
|
||||||
**Settings**:
|
**Settings**:
|
||||||
|
|
||||||
${showSettings { useAnchors = false; } settings}
|
${showSettings { useAnchors = false; } settings}
|
||||||
|
|
|
@ -1496,6 +1496,7 @@ ref<Store> openStore(const std::string & uri_,
|
||||||
if (implem.uriSchemes.count(parsedUri.scheme)) {
|
if (implem.uriSchemes.count(parsedUri.scheme)) {
|
||||||
auto store = implem.create(parsedUri.scheme, baseURI, params);
|
auto store = implem.create(parsedUri.scheme, baseURI, params);
|
||||||
if (store) {
|
if (store) {
|
||||||
|
experimentalFeatureSettings.require(store->experimentalFeature());
|
||||||
store->init();
|
store->init();
|
||||||
store->warnUnknownSettings();
|
store->warnUnknownSettings();
|
||||||
return ref<Store>(store);
|
return ref<Store>(store);
|
||||||
|
|
|
@ -109,13 +109,28 @@ struct StoreConfig : public Config
|
||||||
|
|
||||||
virtual ~StoreConfig() { }
|
virtual ~StoreConfig() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this type of store.
|
||||||
|
*/
|
||||||
virtual const std::string name() = 0;
|
virtual const std::string name() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Documentation for this type of store.
|
||||||
|
*/
|
||||||
virtual std::string doc()
|
virtual std::string doc()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An experimental feature this type store is gated, if it is to be
|
||||||
|
* experimental.
|
||||||
|
*/
|
||||||
|
virtual std::optional<ExperimentalFeature> experimentalFeature() const
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
const PathSetting storeDir_{this, settings.nixStore,
|
const PathSetting storeDir_{this, settings.nixStore,
|
||||||
"store",
|
"store",
|
||||||
R"(
|
R"(
|
||||||
|
|
|
@ -180,8 +180,10 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||||
for (auto & implem : *Implementations::registered) {
|
for (auto & implem : *Implementations::registered) {
|
||||||
auto storeConfig = implem.getConfig();
|
auto storeConfig = implem.getConfig();
|
||||||
auto storeName = storeConfig->name();
|
auto storeName = storeConfig->name();
|
||||||
stores[storeName]["doc"] = storeConfig->doc();
|
auto & j = stores[storeName];
|
||||||
stores[storeName]["settings"] = storeConfig->toJSON();
|
j["doc"] = storeConfig->doc();
|
||||||
|
j["settings"] = storeConfig->toJSON();
|
||||||
|
j["experimentalFeature"] = storeConfig->experimentalFeature();
|
||||||
}
|
}
|
||||||
res["stores"] = std::move(stores);
|
res["stores"] = std::move(stores);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue