From 0873bed39db9dbfbd91c422f40b027d83fe41227 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Fri, 5 Dec 2025 01:07:15 +0100 Subject: [PATCH] nix/upgrade-nix: disallow daemon connections for the store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to I6a6a6964d2b5ad47ae5ea9eb11af9b6373ce2141 — `sudo nix upgrade-nix` would perform direct store access. This ensured a certain number of desireable properties for upgrading the Lix binary itself. We re-introduce direct store access for upgrading Lix binaries. Fixes #1060. Change-Id: I523c4d3023ed5fe9eff8fde9a266c56a0de47d8c Signed-off-by: Raito Bezarius (cherry picked from commit d2ca1810b1e8f9ff284357f38693b14275800096) --- lix/nix/upgrade-nix.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lix/nix/upgrade-nix.cc b/lix/nix/upgrade-nix.cc index 5d2066b4c..681039137 100644 --- a/lix/nix/upgrade-nix.cc +++ b/lix/nix/upgrade-nix.cc @@ -49,6 +49,19 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand }); } + // NOTE(Raito): we override the store creation + // to prevent any store daemon connection. + // + // An upgrade, by nature, requires a direct store access + // to avoid having the daemon die in the middle of changing the binary. + // + // If more commands needs that, we can move it into a mixin. This was deliberately not done + // here. + virtual ref createStore(AsyncIoRoot & aio) override + { + return aio.blockOn(openStore(settings.storeUri.get(), {}, AllowDaemon::Disallow)); + } + /** * This command is stable before the others */