mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
Merge pull request #5991 from edolstra/remote-nix-version
nix store ping: Report Nix daemon version
This commit is contained in:
commit
4f24a33d34
9 changed files with 37 additions and 3 deletions
|
@ -1,2 +1,3 @@
|
|||
# Release X.Y (202?-??-??)
|
||||
|
||||
* `nix store ping` now reports the version of the remote Nix daemon.
|
||||
|
|
|
@ -981,8 +981,12 @@ void processConnection(
|
|||
readInt(from);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue