Nix 2.26.3
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 "store-api.hh"
6#include "ssh.hh"
7#include "callback.hh"
8#include "pool.hh"
9#include "serve-protocol.hh"
10
11namespace nix {
12
13struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig
14{
15 using CommonSSHStoreConfig::CommonSSHStoreConfig;
16
17 LegacySSHStoreConfig(
18 std::string_view scheme,
19 std::string_view authority,
20 const Params & params);
21
22 const Setting<Strings> remoteProgram{this, {"nix-store"}, "remote-program",
23 "Path to the `nix-store` executable on the remote machine."};
24
25 const Setting<int> maxConnections{this, 1, "max-connections",
26 "Maximum number of concurrent SSH connections."};
27
31 Strings extraSshArgs = {};
32
36 std::optional<size_t> connPipeSize;
37
38 const std::string name() override { return "SSH Store"; }
39
40 static std::set<std::string> uriSchemes() { return {"ssh"}; }
41
42 std::string doc() override;
43};
44
45struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Store
46{
47#ifndef _WIN32
48 // Hack for getting remote build log output.
49 // Intentionally not in `LegacySSHStoreConfig` so that it doesn't appear in
50 // the documentation
51 const Setting<int> logFD{this, INVALID_DESCRIPTOR, "log-fd", "file descriptor to which SSH's stderr is connected"};
52#else
53 Descriptor logFD = INVALID_DESCRIPTOR;
54#endif
55
56 struct Connection;
57
58 ref<Pool<Connection>> connections;
59
60 SSHMaster master;
61
62 LegacySSHStore(
63 std::string_view scheme,
64 std::string_view host,
65 const Params & params);
66
67 ref<Connection> openConnection();
68
69 std::string getUri() override;
70
71 void queryPathInfoUncached(const StorePath & path,
72 Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
73
74 std::map<StorePath, UnkeyedValidPathInfo> queryPathInfosUncached(
75 const StorePathSet & paths);
76
77 void addToStore(const ValidPathInfo & info, Source & source,
78 RepairFlag repair, CheckSigsFlag checkSigs) override;
79
80 void narFromPath(const StorePath & path, Sink & sink) override;
81
90 void narFromPath(const StorePath & path, std::function<void(Source &)> fun);
91
92 std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
93 { unsupported("queryPathFromHashPart"); }
94
96 std::string_view name,
97 const SourcePath & path,
99 HashAlgorithm hashAlgo,
100 const StorePathSet & references,
101 PathFilter & filter,
102 RepairFlag repair) override
103 { unsupported("addToStore"); }
104
106 Source & dump,
107 std::string_view name,
110 HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
111 const StorePathSet & references = StorePathSet(),
112 RepairFlag repair = NoRepair) override
113 { unsupported("addToStore"); }
114
115public:
116
117 BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv,
118 BuildMode buildMode) override;
119
126 std::function<BuildResult()> buildDerivationAsync(
127 const StorePath & drvPath, const BasicDerivation & drv,
128 const ServeProto::BuildOptions & options);
129
130 void buildPaths(const std::vector<DerivedPath> & drvPaths, BuildMode buildMode, std::shared_ptr<Store> evalStore) override;
131
132 void ensurePath(const StorePath & path) override
133 { unsupported("ensurePath"); }
134
135 virtual ref<SourceAccessor> getFSAccessor(bool requireValidPath) override
136 { unsupported("getFSAccessor"); }
137
146 void repairPath(const StorePath & path) override
147 { unsupported("repairPath"); }
148
149 void computeFSClosure(const StorePathSet & paths,
150 StorePathSet & out, bool flipDirection = false,
151 bool includeOutputs = false, bool includeDerivers = false) override;
152
153 StorePathSet queryValidPaths(const StorePathSet & paths,
154 SubstituteFlag maybeSubstitute = NoSubstitute) override;
155
164 StorePathSet queryValidPaths(const StorePathSet & paths,
165 bool lock,
166 SubstituteFlag maybeSubstitute = NoSubstitute);
167
172 void addMultipleToStoreLegacy(Store & srcStore, const StorePathSet & paths);
173
174 void connect() override;
175
176 unsigned int getProtocol() override;
177
179 size_t bytesReceived, bytesSent;
180 };
181
182 ConnectionStats getConnectionStats();
183
184 pid_t getConnectionPid();
185
190 std::optional<TrustedFlag> isTrustedClient() override
191 {
192 return std::nullopt;
193 }
194
195 void queryRealisationUncached(const DrvOutput &,
196 Callback<std::shared_ptr<const Realisation>> callback) noexcept override
197 // TODO: Implement
198 { unsupported("queryRealisation"); }
199};
200
201}
Definition callback.hh:17
Definition ssh.hh:11
Definition config.hh:320
Definition path.hh:27
Definition store-api.hh:169
void unsupported(const std::string &op)
Definition store-api.hh:786
Definition ref.hh:15
FileSerialisationMethod
Definition file-content-address.hh:20
@ NixArchive
Definition file-content-address.hh:36
@ NixArchive
Definition file-content-address.hh:114
int Descriptor
Definition file-descriptor.hh:20
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:365
std::function< void(Sink &)> fun
Definition lexer.l:3485
RepairFlag repair
Definition lexer.l:7173
WriteLock lock()
Definition lexer.l:6739
Definition derivations.hh:285
Definition build-result.hh:14
std::string host
Definition common-ssh-store-config.hh:49
Definition content-address.hh:31
Definition realisation.hh:24
std::string doc() override
Definition legacy-ssh-store.cc:27
const std::string name() override
Definition legacy-ssh-store.hh:38
std::optional< size_t > connPipeSize
Definition legacy-ssh-store.hh:36
Strings extraSshArgs
Definition legacy-ssh-store.hh:31
Definition legacy-ssh-store.hh:178
Definition legacy-ssh-store.cc:36
BuildResult buildDerivation(const StorePath &drvPath, const BasicDerivation &drv, BuildMode buildMode) override
Definition legacy-ssh-store.cc:234
virtual 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:105
void addMultipleToStoreLegacy(Store &srcStore, const StorePathSet &paths)
Definition legacy-ssh-store.cc:337
void connect() override
Definition legacy-ssh-store.cc:354
std::optional< StorePath > queryPathFromHashPart(const std::string &hashPart) override
Definition legacy-ssh-store.hh:92
unsigned int getProtocol() override
Definition legacy-ssh-store.cc:360
StorePathSet queryValidPaths(const StorePathSet &paths, SubstituteFlag maybeSubstitute=NoSubstitute) override
Definition legacy-ssh-store.cc:319
void buildPaths(const std::vector< DerivedPath > &drvPaths, BuildMode buildMode, std::shared_ptr< Store > evalStore) override
Definition legacy-ssh-store.cc:258
std::function< BuildResult()> buildDerivationAsync(const StorePath &drvPath, const BasicDerivation &drv, const ServeProto::BuildOptions &options)
Definition legacy-ssh-store.cc:244
std::string getUri() override
Definition legacy-ssh-store.cc:101
virtual ref< SourceAccessor > getFSAccessor(bool requireValidPath) override
Definition legacy-ssh-store.hh:135
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:95
void ensurePath(const StorePath &path) override
Definition legacy-ssh-store.hh:132
void computeFSClosure(const StorePathSet &paths, StorePathSet &out, bool flipDirection=false, bool includeOutputs=false, bool includeDerivers=false) override
Definition legacy-ssh-store.cc:297
void repairPath(const StorePath &path) override
Definition legacy-ssh-store.hh:146
void narFromPath(const StorePath &path, Sink &sink) override
Definition legacy-ssh-store.cc:206
void addToStore(const ValidPathInfo &info, Source &source, RepairFlag repair, CheckSigsFlag checkSigs) override
Definition legacy-ssh-store.cc:151
std::optional< TrustedFlag > isTrustedClient() override
Definition legacy-ssh-store.hh:190
Definition serve-protocol.hh:121
Definition serialise.hh:20
Definition source-path.hh:22
Definition serialise.hh:68
Definition path-info.hh:130