Skip to content

Commit

Permalink
Merge pull request #8774 from NixLayeredStore/experimental-stores
Browse files Browse the repository at this point in the history
Add infra for experimental store implementations
  • Loading branch information
thufschmitt authored Aug 3, 2023
2 parents 3723363 + 3b592c8 commit 635df5e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
21 changes: 19 additions & 2 deletions doc/manual/generate-manpage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,29 @@ let

storeDocs =
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}
${doc}
${experimentalFeatureNote}
**Settings**:
${showSettings { useAnchors = false; } settings}
Expand Down
1 change: 1 addition & 0 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ ref<Store> openStore(const std::string & uri_,
if (implem.uriSchemes.count(parsedUri.scheme)) {
auto store = implem.create(parsedUri.scheme, baseURI, params);
if (store) {
experimentalFeatureSettings.require(store->experimentalFeature());
store->init();
store->warnUnknownSettings();
return ref<Store>(store);
Expand Down
15 changes: 15 additions & 0 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,28 @@ struct StoreConfig : public Config

virtual ~StoreConfig() { }

/**
* The name of this type of store.
*/
virtual const std::string name() = 0;

/**
* Documentation for this type of store.
*/
virtual std::string doc()
{
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,
"store",
R"(
Expand Down
6 changes: 4 additions & 2 deletions src/nix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
for (auto & implem : *Implementations::registered) {
auto storeConfig = implem.getConfig();
auto storeName = storeConfig->name();
stores[storeName]["doc"] = storeConfig->doc();
stores[storeName]["settings"] = storeConfig->toJSON();
auto & j = stores[storeName];
j["doc"] = storeConfig->doc();
j["settings"] = storeConfig->toJSON();
j["experimentalFeature"] = storeConfig->experimentalFeature();
}
res["stores"] = std::move(stores);

Expand Down

0 comments on commit 635df5e

Please sign in to comment.