daemon: prefer daemon stores for nix-daemon --stdio

Using `AllowDaemon::Disallow` here broke `ssh-ng://` remote builds in
multi‐user setups where the remote builder user does not have write
access to the store, now that the automatic store selection logic
has changed. Switch to the default behaviour for this path to fix that.

This causes `ssh-ng://` builds to use the daemon by default on the
remote end, even as `root`. I think this is desirable, as the previous
change already made `ssh://` behave this way, and the pitfalls of
local stores apply to remote builds too. For instance, there were
persistent `ulimit` issues on the NixOS Hydra macOS builders that were
resolved by forcing use of the daemon, and I believe the Linux builders
also go through the daemon these days due to using non‐`root` SSH
users. I believe that the `root` vs. non‐`root` difference is just
as confusing for remote builds as it is for local ones.

`ssh-ng://root@builder?remote-store=local` can be used to revert back
to the previous default if necessary.

Closes: #884
Fixes: 9a59106c17
Change-Id: I6a6a696410f46cd3f2f5a94073ea924ad45dc99c
This commit is contained in:
Emily
2025-06-29 01:14:07 +01:00
parent b395831510
commit e1ccbe9abd
3 changed files with 4 additions and 15 deletions
+3 -3
View File
@@ -225,12 +225,12 @@ static PeerInfo getPeerInfo(int remote)
/**
* Open a store without a path info cache.
*/
static kj::Promise<Result<ref<Store>>> openUncachedStore()
static kj::Promise<Result<ref<Store>>> openUncachedStore(AllowDaemon allowDaemon = AllowDaemon::Allow)
try {
StoreConfig::Params params; // FIXME: get params from somewhere
// Disable caching since the client already does that.
params["path-info-cache-size"] = "0";
co_return TRY_AWAIT(openStore(settings.storeUri, params, AllowDaemon::Disallow));
co_return TRY_AWAIT(openStore(settings.storeUri, params, allowDaemon));
} catch (...) {
co_return result::current_exception();
}
@@ -369,7 +369,7 @@ static void daemonLoopImpl(std::optional<TrustedFlag> forceTrustClientOpt)
FdSource from(remote.get());
FdSink to(remote.get());
processConnection(
aio, aio.blockOn(openUncachedStore()), from, to, trusted
aio, aio.blockOn(openUncachedStore(AllowDaemon::Disallow)), from, to, trusted
);
exit(0);
-2
View File
@@ -122,8 +122,6 @@ in
};
};
sshUser = "test-user";
# FIXME: <https://git.lix.systems/lix-project/lix/issues/884>
expectSuccess = false;
};
# Test our Nix as a client against remotes that are older
+1 -10
View File
@@ -44,14 +44,6 @@ in
'';
default = "root";
};
expectSuccess = lib.mkOption {
type = lib.types.bool;
description = ''
Whether to expect the remote build to succeed or not.
'';
default = true;
};
};
config = {
@@ -123,9 +115,8 @@ in
client.succeed(f"ssh -o StrictHostKeyChecking=no {ssh_user}@{builder.name} 'echo hello world' >&2")
# Perform a build
out = client.${if test.config.expectSuccess then "succeed" else "fail"}("nix-build ${expr nodes.client 1} 2> build-output")
out = client.succeed("nix-build ${expr nodes.client 1} 2> build-output")
'' + lib.optionalString test.config.expectSuccess ''
# Verify that the build was done on the builder
builder.succeed(f"test -e {out.strip()}")