Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port the flags of nix-daemon to nix daemon #8788

Merged
merged 9 commits into from
Aug 28, 2023
41 changes: 40 additions & 1 deletion src/nix/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,45 @@ static RegisterLegacyCommand r_nix_daemon("nix-daemon", main_nix_daemon);

struct CmdDaemon : StoreCommand
{
bool stdio = false;
std::optional<TrustedFlag> isTrustedOpt = std::nullopt;

CmdDaemon()
{
addFlag({
.longName = "stdio",
.description = "Attach to standard I/O instead of listening on a socket.",
.handler = {&stdio, true},
});

addFlag({
.longName = "force-trusted",
.description = "Causes the daemon to blindly foward the connection to the next daemon.",
Ericson2314 marked this conversation as resolved.
Show resolved Hide resolved
.handler = {[&]() {
experimentalFeatureSettings.require(Xp::DaemonTrustOverride);
bryanhonof marked this conversation as resolved.
Show resolved Hide resolved
isTrustedOpt = Trusted;
}},
});

addFlag({
.longName = "force-untrusted",
.description = "Causes the daemon to process the connection itself, instead of blindly forwarding it to the next daemon.",
.handler = {[&]() {
experimentalFeatureSettings.require(Xp::DaemonTrustOverride);
bryanhonof marked this conversation as resolved.
Show resolved Hide resolved
isTrustedOpt = NotTrusted;
}},
});

addFlag({
.longName = "default-trust",
.description = "Use Nix's default trust.",
.handler = {[&]() {
experimentalFeatureSettings.require(Xp::DaemonTrustOverride);
bryanhonof marked this conversation as resolved.
Show resolved Hide resolved
isTrustedOpt = std::nullopt;
}},
});
}

std::string description() override
{
return "daemon to perform store operations on behalf of non-root clients";
Expand All @@ -516,7 +555,7 @@ struct CmdDaemon : StoreCommand

void run(ref<Store> store) override
{
runDaemon(false, std::nullopt);
runDaemon(stdio, isTrustedOpt);
}
};

Expand Down