aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-25 21:14:27 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-01-25 21:15:58 +0100
commit35dbdbedd41dea45bf38ae11d74f72c39eb304c3 (patch)
treed9d72e5e38c227c95097fb6cdd39abc24986843a
parentfcf3528ad1ad3fc0eeac9a1241b7edfebf67eb3d (diff)
nix store ping: Report Nix daemon version
Fixes #5952.
-rw-r--r--doc/manual/src/release-notes/rl-next.md1
-rw-r--r--src/libstore/daemon.cc6
-rw-r--r--src/libstore/local-store.cc6
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.cc14
-rw-r--r--src/libstore/remote-store.hh3
-rw-r--r--src/libstore/store-api.hh3
-rw-r--r--src/libstore/worker-protocol.hh2
-rw-r--r--src/nix/ping-store.cc3
9 files changed, 37 insertions, 3 deletions
diff --git a/doc/manual/src/release-notes/rl-next.md b/doc/manual/src/release-notes/rl-next.md
index 78ae99f4b..d795e7b11 100644
--- a/doc/manual/src/release-notes/rl-next.md
+++ b/doc/manual/src/release-notes/rl-next.md
@@ -1,2 +1,3 @@
# Release X.Y (202?-??-??)
+* `nix store ping` now reports the version of the remote Nix daemon.
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 101aa13a5..1ddd1a4d5 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -981,7 +981,11 @@ void processConnection(
readInt(from);
}
- readInt(from); // obsolete reserveSpace
+ if (GET_PROTOCOL_MINOR(clientVersion) >= 11)
+ readInt(from); // obsolete reserveSpace
+
+ if (GET_PROTOCOL_MINOR(clientVersion) >= 33)
+ to << nixVersion;
/* Send startup error messages to the client. */
tunnelLogger->startWork();
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 1807940d8..284e385e6 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1919,4 +1919,10 @@ void LocalStore::addBuildLog(const StorePath & drvPath, std::string_view log)
throw SysError("renaming '%1%' to '%2%'", tmpFile, logPath);
}
+std::optional<std::string> LocalStore::getVersion()
+{
+ return nixVersion;
+}
+
+
} // namespace nix
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 6d867d778..8cf9c68b3 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -211,6 +211,8 @@ public:
void queryRealisationUncached(const DrvOutput&,
Callback<std::shared_ptr<const Realisation>> callback) noexcept override;
+ std::optional<std::string> getVersion() override;
+
private:
int getSchema();
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index aac2965e0..573becfbd 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -188,7 +188,12 @@ void RemoteStore::initConnection(Connection & conn)
}
if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 11)
- conn.to << false;
+ conn.to << false; // obsolete reserveSpace
+
+ if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 33) {
+ conn.to.flush();
+ conn.daemonNixVersion = readString(conn.from);
+ }
auto ex = conn.processStderr();
if (ex) std::rethrow_exception(ex);
@@ -920,6 +925,13 @@ void RemoteStore::addBuildLog(const StorePath & drvPath, std::string_view log)
}
+std::optional<std::string> RemoteStore::getVersion()
+{
+ auto conn(getConnection());
+ return conn->daemonNixVersion;
+}
+
+
void RemoteStore::connect()
{
auto conn(getConnection());
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 4754ff45a..b91d25fa9 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -118,6 +118,8 @@ public:
void addBuildLog(const StorePath & drvPath, std::string_view log) override;
+ std::optional<std::string> getVersion() override;
+
void connect() override;
unsigned int getProtocol() override;
@@ -129,6 +131,7 @@ public:
FdSink to;
FdSource from;
unsigned int daemonVersion;
+ std::optional<std::string> daemonNixVersion;
std::chrono::time_point<std::chrono::steady_clock> startTime;
virtual ~Connection();
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 8306509f3..4068f8f35 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -765,6 +765,9 @@ public:
* (a no-op when there’s no daemon)
*/
virtual void setOptions() { }
+
+ virtual std::optional<std::string> getVersion() { return {}; }
+
protected:
Stats stats;
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index ecf42a5d0..c8332afe6 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -9,7 +9,7 @@ namespace nix {
#define WORKER_MAGIC_1 0x6e697863
#define WORKER_MAGIC_2 0x6478696f
-#define PROTOCOL_VERSION (1 << 8 | 32)
+#define PROTOCOL_VERSION (1 << 8 | 33)
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
diff --git a/src/nix/ping-store.cc b/src/nix/ping-store.cc
index 62b645b06..3c3b7bb45 100644
--- a/src/nix/ping-store.cc
+++ b/src/nix/ping-store.cc
@@ -20,7 +20,10 @@ struct CmdPingStore : StoreCommand
void run(ref<Store> store) override
{
+ notice("Store URL: %s", store->getUri());
store->connect();
+ if (auto version = store->getVersion())
+ notice("Version: %s", *version);
}
};