1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 09:11:47 +02:00

Add the nix-store --serve command

This is essentially the substituter API operating on the local store,
which will be used by the ssh substituter. It runs in a loop rather than
just taking one command so that in the future nix will be able to keep
one connection open for multiple instances of the substituter.

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2014-02-06 11:52:03 -05:00
parent 84a8b5e9af
commit 3a38d0f356
3 changed files with 55 additions and 0 deletions

View file

@ -834,6 +834,24 @@ static void opClearFailedPaths(Strings opFlags, Strings opArgs)
}
// Serve the nix store in a way usable by a restricted ssh user
static void opServe(Strings opFlags, Strings opArgs)
{
if (!opArgs.empty())
throw UsageError("no arguments expected");
// Could eventually take a username argument?
bool sign;
foreach (Strings::iterator, i, opFlags)
if (*i == "--sign") sign = true;
else throw UsageError(format("unknown flag `%1%'") % *i);
FdSource in(STDIN_FILENO);
FdSink out(STDOUT_FILENO);
store->serve(in, out, sign);
}
/* Scan the arguments; find the operation, set global flags, put all
other flags in a list, and put all other arguments in another
list. */
@ -904,6 +922,8 @@ void run(Strings args)
indirectRoot = true;
else if (arg == "--no-output")
noOutput = true;
else if (arg == "--serve")
op = opServe;
else if (arg[0] == '-') {
opFlags.push_back(arg);
if (arg == "--max-freed" || arg == "--max-links" || arg == "--max-atime") { /* !!! hack */