nix/upgrade-nix: disallow daemon connections for the store

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 <raito@lix.systems>
(cherry picked from commit d2ca1810b1)
This commit is contained in:
Raito Bezarius
2025-12-06 22:20:18 +00:00
parent 5dcb90548f
commit 0873bed39d
+13
View File
@@ -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<Store> createStore(AsyncIoRoot & aio) override
{
return aio.blockOn(openStore(settings.storeUri.get(), {}, AllowDaemon::Disallow));
}
/**
* This command is stable before the others
*/