From adf33551e4755d8626c4c2f3aa3ecc1a2561fe6a Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Wed, 5 Mar 2025 16:42:11 +0100 Subject: [PATCH] libstore: asyncify Store::setOptions Change-Id: I80d45ccdd027663a2b7c32f21a9a78fda6906044 --- lix/libexpr/flake/flake.cc | 2 +- lix/libstore/remote-store.cc | 7 +++++-- lix/libstore/remote-store.hh | 2 +- lix/libstore/store-api.hh | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lix/libexpr/flake/flake.cc b/lix/libexpr/flake/flake.cc index 15de043ae..c5eeac831 100644 --- a/lix/libexpr/flake/flake.cc +++ b/lix/libexpr/flake/flake.cc @@ -392,7 +392,7 @@ LockedFlake lockFlake( if (lockFlags.applyNixConfig) { flake.config.apply(); - state.ctx.store->setOptions(); + state.aio.blockOn(state.ctx.store->setOptions()); } try { diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index c313969b2..85785661b 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -194,9 +194,12 @@ RemoteStore::ConnectionHandle RemoteStore::getConnection() return ConnectionHandle(connections->get()); } -void RemoteStore::setOptions() -{ +kj::Promise> RemoteStore::setOptions() +try { setOptions(*(getConnection().handle)); + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } bool RemoteStore::isValidPathUncached(const StorePath & path) diff --git a/lix/libstore/remote-store.hh b/lix/libstore/remote-store.hh index 3a8888118..f6bf5fd9d 100644 --- a/lix/libstore/remote-store.hh +++ b/lix/libstore/remote-store.hh @@ -185,7 +185,7 @@ protected: virtual void setOptions(Connection & conn); - void setOptions() override; + kj::Promise> setOptions() override; struct ConnectionHandle; diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index a4fa04a7d..b819dcb4f 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -897,7 +897,7 @@ public: * Synchronises the options of the client with those of the daemon * (a no-op when there’s no daemon) */ - virtual void setOptions() { } + virtual kj::Promise> setOptions() { return {result::success()}; } virtual std::optional getVersion() { return {}; }