Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
legacy-ssh-store.hh
Go to the documentation of this file.
1#pragma once
3
5#include "nix/store/ssh.hh"
7#include "nix/util/pool.hh"
9
10namespace nix {
11
12struct LegacySSHStoreConfig : std::enable_shared_from_this<LegacySSHStoreConfig>, virtual CommonSSHStoreConfig
13{
14private:
15 void anchor() override;
16
17public:
18 LegacySSHStoreConfig(const Params & params)
20 , CommonSSHStoreConfig(params)
21 {
22 }
23
24 LegacySSHStoreConfig(const ParsedURL::Authority & authority, const Params & params);
25
26#ifndef _WIN32
27 // Hack for getting remote build log output.
28 // Intentionally not in `LegacySSHStoreConfig` so that it doesn't appear in
29 // the documentation
30 Setting<int> logFD{this, INVALID_DESCRIPTOR, "log-fd", "file descriptor to which SSH's stderr is connected"};
31#else
32 Descriptor logFD = INVALID_DESCRIPTOR;
33#endif
34
35 Setting<Strings> remoteProgram{
36 this, {"nix-store"}, "remote-program", "Path to the `nix-store` executable on the remote machine."};
37
38 Setting<int> maxConnections{this, 1, "max-connections", "Maximum number of concurrent SSH connections."};
39
43 Strings extraSshArgs = {};
44
48 std::optional<size_t> connPipeSize;
49
50 static const std::string name()
51 {
52 return "SSH Store";
53 }
54
55 static StringSet uriSchemes()
56 {
57 return {"ssh"};
58 }
59
60 static std::string doc();
61
62 ref<Store> openStore() const override;
63
64 StoreReference getReference() const override;
65};
66
67struct LegacySSHStore : public virtual Store
68{
69private:
70 void anchor() override;
71
72public:
73 using Config = LegacySSHStoreConfig;
74
75 ref<const Config> config;
76
77 struct Connection;
78
79 ref<Pool<Connection>> connections;
80
81 SSHMaster master;
82
83 LegacySSHStore(ref<const Config>);
84
85 ref<Connection> openConnection();
86
87 void queryPathInfoUncached(
88 const StorePath & path, Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
89
90 std::map<StorePath, UnkeyedValidPathInfo> queryPathInfosUncached(const StorePathSet & paths);
91
92 void addToStore(const ValidPathInfo & info, Source & source, RepairFlag repair, CheckSigsFlag checkSigs) override;
93
94 void narFromPath(const StorePath & path, Sink & sink) override;
95
104 void narFromPath(const StorePath & path, fun<void(Source &)> receiveNar);
105
106 std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
107 {
108 unsupported("queryPathFromHashPart");
109 }
110
112 std::string_view name,
113 const SourcePath & path,
115 HashAlgorithm hashAlgo,
116 const StorePathSet & references,
117 PathFilter & filter,
118 RepairFlag repair) override
119 {
120 unsupported("addToStore");
121 }
122
124 Source & dump,
125 std::string_view name,
128 HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
129 const StorePathSet & references = StorePathSet(),
130 RepairFlag repair = NoRepair) override
131 {
132 unsupported("addToStore");
133 }
134
135 void registerDrvOutputUnchecked(const Realisation & output) override
136 {
137 unsupported("registerDrvOutput");
138 }
139
140public:
141
142 ref<Builder> getBuilder(std::shared_ptr<Store> evalStore) override;
143
144 ref<SourceAccessor> getFSAccessor(bool requireValidPath) override
145 {
146 unsupported("getFSAccessor");
147 }
148
149 std::shared_ptr<SourceAccessor> getFSAccessor(const StorePath & path, bool requireValidPath) override
150 {
151 unsupported("getFSAccessor");
152 }
153
154 void computeFSClosure(
155 const StorePathSet & paths,
156 StorePathSet & out,
157 bool flipDirection = false,
158 bool includeOutputs = false,
159 bool includeDerivers = false) override;
160
161 StorePathSet queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute = NoSubstitute) override;
162
171 StorePathSet queryValidPaths(const StorePathSet & paths, bool lock, SubstituteFlag maybeSubstitute = NoSubstitute);
172
173 void connect() override;
174
175 unsigned int getProtocol() override;
176
178 {
179 size_t bytesReceived, bytesSent;
180 };
181
182 ConnectionStats getConnectionStats();
183
184 pid_t getConnectionPid();
185
190 std::optional<TrustedFlag> isTrustedClient() override;
191
192 void queryRealisationUncached(
193 const DrvOutput &, Callback<std::shared_ptr<const UnkeyedRealisation>> callback) noexcept override
194 {
195 /* The serve protocol doesn't support querying realisations,
196 so act as if this store doesn't have any. */
197 callback(nullptr);
198 }
199
200 StorePathSet querySubstitutablePaths(const StorePathSet & paths) override
201 {
202 // not supported
203 return {};
204 }
205
206 friend struct LegacySSHBuilder;
207};
208
209} // namespace nix
Definition callback.hh:19
Definition ssh.hh:22
Definition configuration.hh:476
Definition path.hh:33
void unsupported(const std::string &op)
Definition store-api.hh:1032
Definition fun.hh:19
Definition ref.hh:58
FileSerialisationMethod
Definition file-content-address.hh:20
@ NixArchive
Definition file-content-address.hh:36
@ NixArchive
Definition file-content-address.hh:111
int Descriptor
Definition file-descriptor.hh:36
fun< bool(const std::string &path)> PathFilter
Definition file-system.hh:494
ParsedURL::Authority authority
Definition common-ssh-store-config.hh:45
Definition content-address.hh:32
Definition realisation.hh:26
Definition legacy-ssh-store.cc:23
Definition legacy-ssh-store.hh:13
std::optional< size_t > connPipeSize
Definition legacy-ssh-store.hh:48
Strings extraSshArgs
Definition legacy-ssh-store.hh:43
ref< Store > openStore() const override
Definition legacy-ssh-store.cc:468
StoreReference getReference() const override
Definition legacy-ssh-store.cc:146
Definition legacy-ssh-store.hh:178
Definition legacy-ssh-store.cc:86
void registerDrvOutputUnchecked(const Realisation &output) override
Definition legacy-ssh-store.hh:135
ref< Builder > getBuilder(std::shared_ptr< Store > evalStore) override
Definition legacy-ssh-store.cc:390
StorePathSet querySubstitutablePaths(const StorePathSet &paths) override
Definition legacy-ssh-store.hh:200
std::optional< StorePath > queryPathFromHashPart(const std::string &hashPart) override
Definition legacy-ssh-store.hh:106
unsigned int getProtocol() override
Definition legacy-ssh-store.cc:433
std::shared_ptr< SourceAccessor > getFSAccessor(const StorePath &path, bool requireValidPath) override
Definition legacy-ssh-store.hh:149
StorePathSet queryValidPaths(const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
Definition legacy-ssh-store.cc:416
StorePath addToStore(std::string_view name, const SourcePath &path, ContentAddressMethod method, HashAlgorithm hashAlgo, const StorePathSet &references, PathFilter &filter, RepairFlag repair) override
Definition legacy-ssh-store.hh:111
void computeFSClosure(const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false) override
Definition legacy-ssh-store.cc:398
void narFromPath(const StorePath &path, Sink &sink) override
Definition legacy-ssh-store.cc:225
void addToStore(const ValidPathInfo &info, Source &source, RepairFlag repair, CheckSigsFlag checkSigs) override
Definition legacy-ssh-store.cc:200
ref< SourceAccessor > getFSAccessor(bool requireValidPath) override
Definition legacy-ssh-store.hh:144
std::optional< TrustedFlag > isTrustedClient() override
Definition legacy-ssh-store.cc:463
StorePath addToStoreFromDump(Source &dump, std::string_view name, FileSerialisationMethod dumpMethod=FileSerialisationMethod::NixArchive, ContentAddressMethod hashMethod=FileIngestionMethod::NixArchive, HashAlgorithm hashAlgo=HashAlgorithm::SHA256, const StorePathSet &references=StorePathSet(), RepairFlag repair=NoRepair) override
Definition legacy-ssh-store.hh:123
Definition url.hh:32
Definition realisation.hh:103
Definition serialise.hh:18
Definition source-path.hh:22
Definition serialise.hh:95
@ Unix
Definition store-api.hh:131
Definition store-api.hh:240
Definition path-info.hh:159
std::set< std::string, std::less<> > StringSet
Definition types.hh:45
void connect(Socket fd, const std::filesystem::path &path)
Definition unix-domain-socket.cc:190