Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
dummy-store.hh
Go to the documentation of this file.
1#pragma once
3
6
7#include <boost/unordered/concurrent_flat_map.hpp>
8
9namespace nix {
10
11struct DummyStore;
12
13struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>, virtual StoreConfig
14{
15private:
16 void anchor() override;
17
18public:
19 DummyStoreConfig(const Params & params)
20 : StoreConfig(params, FilePathType::Unix)
21 {
22 // Disable caching since this a temporary in-memory store.
23 pathInfoCacheSize = 0;
24 }
25
26 DummyStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
27 : DummyStoreConfig(params)
28 {
29 if (!authority.empty())
30 throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
31 }
32
33 Setting<bool> readOnly{
34 this,
35 true,
36 "read-only",
37 R"(
38 Make any sort of write fail instead of succeeding.
39 No additional memory will be used, because no information needs to be stored.
40 )"};
41
42 bool getReadOnly() const override;
43
44 static const std::string name()
45 {
46 return "Dummy Store";
47 }
48
49 static std::string doc();
50
51 static StringSet uriSchemes()
52 {
53 return {"dummy"};
54 }
55
60
61 ref<Store> openStore() const override;
62
63 StoreReference getReference() const override
64 {
65 return {
66 .variant =
67 StoreReference::Specified{
68 .scheme = *uriSchemes().begin(),
69 },
70 .params = getQueryParams(),
71 };
72 }
73};
74
75template<>
76struct json_avoids_null<nix::DummyStoreConfig> : std::true_type
77{};
78
79template<>
80struct json_avoids_null<ref<nix::DummyStoreConfig>> : std::true_type
81{};
82
83template<>
84struct json_avoids_null<nix::DummyStore> : std::true_type
85{};
86
87template<>
88struct json_avoids_null<ref<nix::DummyStore>> : std::true_type
89{};
90
91} // namespace nix
92
93namespace nlohmann {
94
95template<>
96JSON_IMPL_INNER_TO(nix::DummyStoreConfig);
97template<>
98JSON_IMPL_INNER_FROM(nix::ref<nix::DummyStoreConfig>);
99template<>
100JSON_IMPL_INNER_TO(nix::DummyStore);
101template<>
102JSON_IMPL_INNER_FROM(nix::ref<nix::DummyStore>);
103
104} // namespace nlohmann
Definition configuration.hh:476
Definition error.hh:311
Definition ref.hh:58
Definition dummy-store.hh:14
ref< DummyStore > openDummyStore() const
Definition dummy-store.cc:398
ref< Store > openStore() const override
Definition dummy-store.cc:128
StoreReference getReference() const override
Definition dummy-store.hh:63
bool getReadOnly() const override
Definition dummy-store.cc:133
Definition dummy-store-impl.hh:17
@ Unix
Definition store-api.hh:131
StringMap getQueryParams() const
Definition store-api.hh:266
std::set< std::string, std::less<> > StringSet
Definition types.hh:45