Skip to content

Commit

Permalink
chore(nix/daemon): port the flags of nix-daemon to nix daemon
Browse files Browse the repository at this point in the history
The new `nix daemon` command didn't accept the same flags that `nix-daemon` did.
  • Loading branch information
bryanhonof committed Aug 4, 2023
1 parent 635df5e commit 2c94ac5
Showing 1 changed file with 40 additions and 1 deletion.
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.",
.handler = {[&]() {
experimentalFeatureSettings.require(Xp::DaemonTrustOverride);
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);
isTrustedOpt = NotTrusted;
}},
});

addFlag({
.longName = "default-trust",
.description = "Use Nix's default trust.",
.handler = {[&]() {
experimentalFeatureSettings.require(Xp::DaemonTrustOverride);
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

0 comments on commit 2c94ac5

Please sign in to comment.