Skip to content

Commit 0deb492

Browse files
xokdviumEricson2314
authored andcommitted
Restore ServeProto::Command::ImportPaths
This partially reverts commit 5e46df9, partially reversing changes made to 8c789db. We do this because Hydra, while using the newer version of the protocol, still uses this command, even though Nix (as a client) doesn't use it. On that basis, we don't want to remove it (or consider it only part of the older versions of the protocol) until Hydra no longer uses the Legacy SSH Protocol.
1 parent 94cfba7 commit 0deb492

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

src/libstore/include/nix/store/serve-protocol-connection.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct ServeProto::BasicClientConnection
8282
BuildResult getBuildDerivationResponse(const StoreDirConfig & store);
8383

8484
void narFromPath(const StoreDirConfig & store, const StorePath & path, std::function<void(Source &)> fun);
85+
86+
void importPaths(const StoreDirConfig & store, std::function<void(Sink &)> fun);
8587
};
8688

8789
struct ServeProto::BasicServerConnection

src/libstore/include/nix/store/serve-protocol.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ enum struct ServeProto::Command : uint64_t {
108108
QueryValidPaths = 1,
109109
QueryPathInfos = 2,
110110
DumpStorePath = 3,
111+
/**
112+
* @note This is no longer used by Nix (as a client), but it is used
113+
* by Hydra. We should therefore not remove it until Hydra no longer
114+
* uses it either.
115+
*/
116+
ImportPaths = 4,
117+
// ExportPaths = 5,
111118
BuildPaths = 6,
112119
QueryClosure = 7,
113120
BuildDerivation = 8,

src/libstore/serve-protocol-connection.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,14 @@ void ServeProto::BasicClientConnection::narFromPath(
9393
fun(from);
9494
}
9595

96+
void ServeProto::BasicClientConnection::importPaths(const StoreDirConfig & store, std::function<void(Sink &)> fun)
97+
{
98+
to << ServeProto::Command::ImportPaths;
99+
fun(to);
100+
to.flush();
101+
102+
if (readInt(from) != 1)
103+
throw Error("remote machine failed to import closure");
104+
}
105+
96106
} // namespace nix

src/nix/nix-store/nix-store.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,16 @@ static void opServe(Strings opFlags, Strings opArgs)
986986
store->narFromPath(store->parseStorePath(readString(in)), out);
987987
break;
988988

989+
case ServeProto::Command::ImportPaths: {
990+
if (!writeAllowed)
991+
throw Error("importing paths is not allowed");
992+
// FIXME: should we skip sig checking?
993+
importPaths(*store, in, NoCheckSigs);
994+
// indicate success
995+
out << 1;
996+
break;
997+
}
998+
989999
case ServeProto::Command::BuildPaths: {
9901000

9911001
if (!writeAllowed)

0 commit comments

Comments
 (0)