1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#include "lix/libstore/dummy-store.hh"
#include "lix/libstore/store-api.hh"
#include "lix/libutil/async-io.hh"
namespace nix {
struct DummyStoreConfig final : StoreConfig {
using StoreConfig::StoreConfig;
const std::string name() override { return "Dummy Store"; }
std::string doc() override
{
return
#include "dummy-store.md"
;
}
};
struct DummyStore final : public Store
{
DummyStoreConfig config_;
DummyStoreConfig & config() override { return config_; }
const DummyStoreConfig & config() const override { return config_; }
DummyStore(const std::string scheme, const std::string uri, DummyStoreConfig config)
: DummyStore(std::move(config))
{ }
DummyStore(DummyStoreConfig config) : Store(config), config_(std::move(config)) {}
std::string getUri() override
{
return *uriSchemes().begin();
}
kj::Promise<Result<std::shared_ptr<const ValidPathInfo>>>
queryPathInfoUncached(const StorePath & path, const Activity * context) override
{
return {result::success(nullptr)};
}
/**
* The dummy store is incapable of *not* trusting! :)
*/
virtual kj::Promise<Result<std::optional<TrustedFlag>>> isTrustedClient() override
{
return {result::success(Trusted)};
}
static std::set<std::string> uriSchemes() {
return {"dummy"};
}
kj::Promise<Result<std::optional<StorePath>>>
queryPathFromHashPart(const std::string & hashPart) override
try {
unsupported("queryPathFromHashPart");
} catch (...) {
return {result::current_exception()};
}
kj::Promise<Result<void>> addToStore(
const ValidPathInfo & info,
AsyncInputStream & source,
RepairFlag repair,
CheckSigsFlag checkSigs,
const Activity * context
) override
try {
unsupported("addToStore");
} catch (...) {
return {result::current_exception()};
}
kj::Promise<Result<StorePath>> addTextToStore(
std::string_view name,
std::string_view s,
const StorePathSet & references,
RepairFlag repair) override
try { unsupported("addTextToStore"); } catch (...) { return {result::current_exception()}; }
kj::Promise<Result<box_ptr<AsyncInputStream>>>
narFromPath(const StorePath & path, const Activity * context) override
try {
unsupported("narFromPath");
} catch (...) {
return {result::current_exception()};
}
virtual ref<FSAccessor> getFSAccessor() override
{ unsupported("getFSAccessor"); }
};
void registerDummyStore() {
StoreImplementations::add<DummyStore, DummyStoreConfig>();
}
}
|