aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-14 14:04:02 +0200
committerregnat <rg@regnat.ovh>2020-09-16 13:53:09 +0200
commitb73adacc1ebda8a790cd8e0b0988c3b0607d947a (patch)
tree08e8416aa8b4db343dbe7f10b07abadca58a49f1 /src
parentf24f0888f93b0881e2cefa1ceb4c8fc187c94f21 (diff)
Add a name to the stores
So that it can be printed by `nix describe-stores`
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc7
-rw-r--r--src/libstore/dummy-store.cc2
-rw-r--r--src/libstore/http-binary-cache-store.cc2
-rw-r--r--src/libstore/legacy-ssh-store.cc2
-rw-r--r--src/libstore/local-binary-cache-store.cc2
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/s3-binary-cache-store.cc2
-rw-r--r--src/libstore/ssh-store.cc2
-rw-r--r--src/libstore/store-api.hh1
-rw-r--r--src/nix/describe-stores.cc13
11 files changed, 30 insertions, 7 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 18bb9b12e..6e55f83d5 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2872,11 +2872,16 @@ void DerivationGoal::writeStructuredAttrs()
chownToBuilder(tmpDir + "/.attrs.sh");
}
+struct RestrictedStoreConfig : LocalFSStoreConfig
+{
+ using LocalFSStoreConfig::LocalFSStoreConfig;
+ const std::string name() { return "Restricted Store"; }
+};
/* A wrapper around LocalStore that only allows building/querying of
paths that are in the input closures of the build or were added via
recursive Nix calls. */
-struct RestrictedStore : public LocalFSStore
+struct RestrictedStore : public LocalFSStore, public virtual RestrictedStoreConfig
{
ref<LocalStore> next;
diff --git a/src/libstore/dummy-store.cc b/src/libstore/dummy-store.cc
index 074953b1d..128832e60 100644
--- a/src/libstore/dummy-store.cc
+++ b/src/libstore/dummy-store.cc
@@ -4,6 +4,8 @@ namespace nix {
struct DummyStoreConfig : virtual StoreConfig {
using StoreConfig::StoreConfig;
+
+ const std::string name() override { return "Dummy Store"; }
};
struct DummyStore : public Store, public virtual DummyStoreConfig
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc
index bd65273eb..f4ab15a10 100644
--- a/src/libstore/http-binary-cache-store.cc
+++ b/src/libstore/http-binary-cache-store.cc
@@ -10,6 +10,8 @@ MakeError(UploadToHTTP, Error);
struct HttpBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
{
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
+
+ const std::string name() override { return "Http Binary Cache Store"; }
};
class HttpBinaryCacheStore : public BinaryCacheStore, public HttpBinaryCacheStoreConfig
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index ce9051d20..6563c001f 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -17,6 +17,8 @@ struct LegacySSHStoreConfig : virtual StoreConfig
const Setting<bool> compress{this, false, "compress", "whether to compress the connection"};
const Setting<Path> remoteProgram{this, "nix-store", "remote-program", "path to the nix-store executable on the remote system"};
const Setting<std::string> remoteStore{this, "", "remote-store", "URI of the store on the remote system"};
+
+ const std::string name() override { return "Legacy SSH Store"; }
};
struct LegacySSHStore : public Store, public virtual LegacySSHStoreConfig
diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc
index b893befbc..357bc74df 100644
--- a/src/libstore/local-binary-cache-store.cc
+++ b/src/libstore/local-binary-cache-store.cc
@@ -7,6 +7,8 @@ namespace nix {
struct LocalBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
{
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
+
+ const std::string name() override { return "Local Binary Cache Store"; }
};
class LocalBinaryCacheStore : public BinaryCacheStore, public virtual LocalBinaryCacheStoreConfig
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 0265f0837..e7c9d1605 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -37,6 +37,8 @@ struct LocalStoreConfig : virtual LocalFSStoreConfig
Setting<bool> requireSigs{(StoreConfig*) this,
settings.requireSigs,
"require-sigs", "whether store paths should have a trusted signature on import"};
+
+ const std::string name() override { return "Local Store"; }
};
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index cceb8d185..a23690830 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -158,6 +158,8 @@ struct UDSRemoteStoreConfig : virtual LocalFSStoreConfig, virtual RemoteStoreCon
: UDSRemoteStoreConfig(Store::Params({}))
{
}
+
+ const std::string name() override { return "Local Daemon Store"; }
};
class UDSRemoteStore : public LocalFSStore, public RemoteStore, public virtual UDSRemoteStoreConfig
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc
index e4548dd22..0b9c9bb31 100644
--- a/src/libstore/s3-binary-cache-store.cc
+++ b/src/libstore/s3-binary-cache-store.cc
@@ -186,6 +186,8 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
this, false, "multipart-upload", "whether to use multi-part uploads"};
const Setting<uint64_t> bufferSize{
this, 5 * 1024 * 1024, "buffer-size", "size (in bytes) of each part in multi-part uploads"};
+
+ const std::string name() override { return "S3 Binary Cache Store"; }
};
struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore, virtual S3BinaryCacheStoreConfig
diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc
index fac251d8f..df383bba6 100644
--- a/src/libstore/ssh-store.cc
+++ b/src/libstore/ssh-store.cc
@@ -16,6 +16,8 @@ struct SSHStoreConfig : virtual RemoteStoreConfig
const Setting<bool> compress{(StoreConfig*) this, false, "compress", "whether to compress the connection"};
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
+
+ const std::string name() override { return "SSH Store"; }
};
class SSHStore : public virtual RemoteStore, public virtual SSHStoreConfig
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index a67123ff0..81b979b73 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -194,6 +194,7 @@ struct StoreConfig : public Config
*/
StoreConfig() { assert(false); }
+ virtual const std::string name() = 0;
const PathSetting storeDir_{this, false, settings.nixStore,
"store", "path to the Nix store"};
diff --git a/src/nix/describe-stores.cc b/src/nix/describe-stores.cc
index f019ec9c2..027187bd9 100644
--- a/src/nix/describe-stores.cc
+++ b/src/nix/describe-stores.cc
@@ -18,13 +18,14 @@ struct CmdDescribeStores : Command, MixJSON
void run() override
{
-
+ auto res = nlohmann::json::object();
+ for (auto & implem : *Implementations::registered) {
+ auto storeConfig = implem.getConfig();
+ auto storeName = storeConfig->name();
+ res[storeName] = storeConfig->toJSON();
+ }
if (json) {
- auto res = nlohmann::json::array();
- for (auto & implem : *Implementations::registered) {
- auto storeConfig = implem.getConfig();
- std::cout << storeConfig->toJSON().dump() << std::endl;
- }
+ std::cout << res;
} else {
throw Error("Only json is available for describe-stores");
}