treewide: add async io roots to entry points
it begins. Change-Id: I4b762d48180a763d2724fc635ca025f0333026b0
This commit is contained in:
@@ -55,7 +55,7 @@ static bool allSupportedLocally(Store & store, const std::set<std::string>& requ
|
||||
return true;
|
||||
}
|
||||
|
||||
static int main_build_remote(std::string programName, Strings argv)
|
||||
static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
logger = makeJSONLogger(*logger);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace nix {
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
static void main_nix_build(std::string programName, Strings argv)
|
||||
static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
auto dryRun = false;
|
||||
auto runEnv = std::regex_search(programName, std::regex("nix-shell$"));
|
||||
@@ -94,7 +94,7 @@ static void main_nix_build(std::string programName, Strings argv)
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(myName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(aio, myName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help") {
|
||||
showManPage(myName);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ static void update(const StringSet & channelNames)
|
||||
replaceSymlink(profile, channelLink);
|
||||
}
|
||||
|
||||
static int main_nix_channel(std::string programName, Strings argv)
|
||||
static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
// Figure out the name of the `.nix-channels' file to use
|
||||
@@ -184,7 +184,7 @@ static int main_nix_channel(std::string programName, Strings argv)
|
||||
cRollback
|
||||
} cmd = cNone;
|
||||
std::vector<std::string> args;
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help") {
|
||||
showManPage("nix-channel");
|
||||
} else if (*arg == "--version") {
|
||||
|
||||
@@ -56,14 +56,14 @@ void removeOldGenerations(std::string dir)
|
||||
}
|
||||
}
|
||||
|
||||
static int main_nix_collect_garbage(std::string programName, Strings argv)
|
||||
static int main_nix_collect_garbage(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
bool removeOld = false;
|
||||
|
||||
GCOptions options;
|
||||
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-collect-garbage");
|
||||
else if (*arg == "--version")
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
static int main_nix_copy_closure(std::string programName, Strings argv)
|
||||
static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
auto gzip = false;
|
||||
@@ -16,7 +16,7 @@ static int main_nix_copy_closure(std::string programName, Strings argv)
|
||||
std::string sshHost;
|
||||
PathSet storePaths;
|
||||
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-copy-closure");
|
||||
else if (*arg == "--version")
|
||||
|
||||
@@ -57,6 +57,7 @@ struct InstallSourceInfo
|
||||
|
||||
struct Globals
|
||||
{
|
||||
AsyncIoRoot & aio;
|
||||
InstallSourceInfo instSource;
|
||||
Path profile;
|
||||
std::shared_ptr<Evaluator> state;
|
||||
@@ -1412,7 +1413,7 @@ static void opVersion(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static int main_nix_env(std::string programName, Strings argv)
|
||||
static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
@@ -1421,7 +1422,7 @@ static int main_nix_env(std::string programName, Strings argv)
|
||||
bool showHelp = false;
|
||||
std::string file;
|
||||
|
||||
Globals globals;
|
||||
Globals globals{aio, {}, {}, {}, {}, {}, {}, {}, {}};
|
||||
|
||||
globals.instSource.type = srcUnknown;
|
||||
globals.instSource.systemFilter = "*";
|
||||
@@ -1451,7 +1452,7 @@ static int main_nix_env(std::string programName, Strings argv)
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
||||
if (*arg == "--help")
|
||||
|
||||
@@ -89,7 +89,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
}
|
||||
|
||||
|
||||
static int main_nix_instantiate(std::string programName, Strings argv)
|
||||
static int main_nix_instantiate(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings files;
|
||||
@@ -109,7 +109,7 @@ static int main_nix_instantiate(std::string programName, Strings argv)
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-instantiate");
|
||||
else if (*arg == "--version")
|
||||
|
||||
+29
-29
@@ -32,7 +32,7 @@ using std::cin;
|
||||
using std::cout;
|
||||
|
||||
|
||||
typedef void (* Operation) (Strings opFlags, Strings opArgs);
|
||||
typedef void (* Operation) (AsyncIoRoot & aio, Strings opFlags, Strings opArgs);
|
||||
|
||||
|
||||
static Path gcRoot;
|
||||
@@ -119,7 +119,7 @@ static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
||||
|
||||
|
||||
/* Realise the given paths. */
|
||||
static void opRealise(Strings opFlags, Strings opArgs)
|
||||
static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool dryRun = false;
|
||||
BuildMode buildMode = bmNormal;
|
||||
@@ -170,7 +170,7 @@ static void opRealise(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Add files to the Nix store and print the resulting paths. */
|
||||
static void opAdd(Strings opFlags, Strings opArgs)
|
||||
static void opAdd(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
|
||||
@@ -181,7 +181,7 @@ static void opAdd(Strings opFlags, Strings opArgs)
|
||||
|
||||
/* Preload the output of a fixed-output derivation into the Nix
|
||||
store. */
|
||||
static void opAddFixed(Strings opFlags, Strings opArgs)
|
||||
static void opAddFixed(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto method = FileIngestionMethod::Flat;
|
||||
|
||||
@@ -201,7 +201,7 @@ static void opAddFixed(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Hack to support caching in `nix-prefetch-url'. */
|
||||
static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||
static void opPrintFixedPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto method = FileIngestionMethod::Flat;
|
||||
|
||||
@@ -277,7 +277,7 @@ static void printTree(const StorePath & path,
|
||||
|
||||
|
||||
/* Perform various sorts of queries. */
|
||||
static void opQuery(Strings opFlags, Strings opArgs)
|
||||
static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
enum QueryType
|
||||
{ qOutputs, qRequisites, qReferences, qReferrers
|
||||
@@ -468,7 +468,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opPrintEnv(Strings opFlags, Strings opArgs)
|
||||
static void opPrintEnv(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("'--print-env' requires one derivation store path");
|
||||
@@ -494,7 +494,7 @@ static void opPrintEnv(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opReadLog(Strings opFlags, Strings opArgs)
|
||||
static void opReadLog(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
|
||||
@@ -512,7 +512,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opDumpDB(Strings opFlags, Strings opArgs)
|
||||
static void opDumpDB(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty()) {
|
||||
@@ -552,7 +552,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
||||
}
|
||||
|
||||
|
||||
static void opLoadDB(Strings opFlags, Strings opArgs)
|
||||
static void opLoadDB(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty())
|
||||
@@ -561,7 +561,7 @@ static void opLoadDB(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opRegisterValidity(Strings opFlags, Strings opArgs)
|
||||
static void opRegisterValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool reregister = false; // !!! maybe this should be the default
|
||||
bool hashGiven = false;
|
||||
@@ -577,7 +577,7 @@ static void opRegisterValidity(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opCheckValidity(Strings opFlags, Strings opArgs)
|
||||
static void opCheckValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool printInvalid = false;
|
||||
|
||||
@@ -597,7 +597,7 @@ static void opCheckValidity(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opGC(Strings opFlags, Strings opArgs)
|
||||
static void opGC(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool printRoots = false;
|
||||
GCOptions options;
|
||||
@@ -643,7 +643,7 @@ static void opGC(Strings opFlags, Strings opArgs)
|
||||
/* Remove paths from the Nix store if possible (i.e., if they do not
|
||||
have any remaining referrers and are not reachable from any GC
|
||||
roots). */
|
||||
static void opDelete(Strings opFlags, Strings opArgs)
|
||||
static void opDelete(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
GCOptions options;
|
||||
options.action = GCOptions::gcDeleteSpecific;
|
||||
@@ -664,7 +664,7 @@ static void opDelete(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Dump a path as a Nix archive. The archive is written to stdout */
|
||||
static void opDump(Strings opFlags, Strings opArgs)
|
||||
static void opDump(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
@@ -677,7 +677,7 @@ static void opDump(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Restore a value from a Nix archive. The archive is read from stdin. */
|
||||
static void opRestore(Strings opFlags, Strings opArgs)
|
||||
static void opRestore(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
@@ -687,7 +687,7 @@ static void opRestore(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opExport(Strings opFlags, Strings opArgs)
|
||||
static void opExport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -703,7 +703,7 @@ static void opExport(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opImport(Strings opFlags, Strings opArgs)
|
||||
static void opImport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -719,7 +719,7 @@ static void opImport(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Initialise the Nix databases. */
|
||||
static void opInit(Strings opFlags, Strings opArgs)
|
||||
static void opInit(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty())
|
||||
@@ -730,7 +730,7 @@ static void opInit(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Verify the consistency of the Nix environment. */
|
||||
static void opVerify(Strings opFlags, Strings opArgs)
|
||||
static void opVerify(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opArgs.empty())
|
||||
throw UsageError("no arguments expected");
|
||||
@@ -751,7 +751,7 @@ static void opVerify(Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Verify whether the contents of the given store path have not changed. */
|
||||
static void opVerifyPath(Strings opFlags, Strings opArgs)
|
||||
static void opVerifyPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty())
|
||||
throw UsageError("no flags expected");
|
||||
@@ -780,7 +780,7 @@ static void opVerifyPath(Strings opFlags, Strings opArgs)
|
||||
|
||||
/* Repair the contents of the given path by redownloading it using a
|
||||
substituter (if available). */
|
||||
static void opRepairPath(Strings opFlags, Strings opArgs)
|
||||
static void opRepairPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty())
|
||||
throw UsageError("no flags expected");
|
||||
@@ -791,7 +791,7 @@ static void opRepairPath(Strings opFlags, Strings opArgs)
|
||||
|
||||
/* Optimise the disk space usage of the Nix store by hard-linking
|
||||
files with the same contents. */
|
||||
static void opOptimise(Strings opFlags, Strings opArgs)
|
||||
static void opOptimise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opArgs.empty() || !opFlags.empty())
|
||||
throw UsageError("no arguments expected");
|
||||
@@ -800,7 +800,7 @@ static void opOptimise(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
/* Serve the nix store in a way usable by a restricted ssh user. */
|
||||
static void opServe(Strings opFlags, Strings opArgs)
|
||||
static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool writeAllowed = false;
|
||||
for (auto & i : opFlags)
|
||||
@@ -1003,7 +1003,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
|
||||
static void opGenerateBinaryCacheKey(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -1022,7 +1022,7 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opVersion(Strings opFlags, Strings opArgs)
|
||||
static void opVersion(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
printVersion("nix-store");
|
||||
}
|
||||
@@ -1031,7 +1031,7 @@ static void opVersion(Strings opFlags, Strings opArgs)
|
||||
/* Scan the arguments; find the operation, set global flags, put all
|
||||
other flags in a list, and put all other arguments in another
|
||||
list. */
|
||||
static int main_nix_store(std::string programName, Strings argv)
|
||||
static int main_nix_store(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
@@ -1040,7 +1040,7 @@ static int main_nix_store(std::string programName, Strings argv)
|
||||
std::string opName;
|
||||
bool showHelp = false;
|
||||
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
||||
if (*arg == "--help")
|
||||
@@ -1170,7 +1170,7 @@ static int main_nix_store(std::string programName, Strings argv)
|
||||
if (op != opDump && op != opRestore) /* !!! hack */
|
||||
store = openStore();
|
||||
|
||||
op(std::move(opFlags), std::move(opArgs));
|
||||
op(aio, std::move(opFlags), std::move(opArgs));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+31
-4
@@ -263,11 +263,14 @@ struct StorePathCommand : public StorePathsCommand
|
||||
*/
|
||||
struct RegisterCommand
|
||||
{
|
||||
typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
|
||||
typedef std::map<
|
||||
std::vector<std::string>,
|
||||
std::function<ref<Command>(AsyncIoRoot & aio)>
|
||||
> Commands;
|
||||
static Commands * commands;
|
||||
|
||||
RegisterCommand(std::vector<std::string> && name,
|
||||
std::function<ref<Command>()> command)
|
||||
std::function<ref<Command>(AsyncIoRoot & aio)> command)
|
||||
{
|
||||
if (!commands) commands = new Commands;
|
||||
commands->emplace(name, command);
|
||||
@@ -276,16 +279,40 @@ struct RegisterCommand
|
||||
static nix::Commands getCommandsFor(const std::vector<std::string> & prefix);
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
class MixAio : public Base
|
||||
{
|
||||
private:
|
||||
AsyncIoRoot & aio_;
|
||||
|
||||
public:
|
||||
template<typename... Args>
|
||||
MixAio(AsyncIoRoot & aio, Args &&... args)
|
||||
: Base(std::forward<Args>(args)...)
|
||||
, aio_(aio)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncIoRoot & aio() override
|
||||
{
|
||||
return aio_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static RegisterCommand registerCommand(const std::string & name)
|
||||
{
|
||||
return RegisterCommand({name}, [](){ return make_ref<T>(); });
|
||||
return RegisterCommand({name}, [](AsyncIoRoot & aio) {
|
||||
return make_ref<MixAio<T>>(aio);
|
||||
});
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
||||
{
|
||||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||
return RegisterCommand(std::move(name), [](AsyncIoRoot & aio) {
|
||||
return make_ref<MixAio<T>>(aio);
|
||||
});
|
||||
}
|
||||
|
||||
struct MixProfile : virtual StoreCommand
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "lix/libutil/async.hh"
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
@@ -8,7 +9,7 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
typedef std::function<void(std::string, std::list<std::string>)> MainFunction;
|
||||
typedef std::function<void(AsyncIoRoot &, std::string, std::list<std::string>)> MainFunction;
|
||||
|
||||
struct LegacyCommands
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ libcmd = library(
|
||||
lowdown,
|
||||
nlohmann_json,
|
||||
liblix_doc,
|
||||
kj,
|
||||
],
|
||||
# '../..' for self references like "lix/libcmd/*.hh"
|
||||
include_directories : [ '../..' ],
|
||||
|
||||
@@ -274,6 +274,7 @@ libexpr = library(
|
||||
boost,
|
||||
toml11,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
# for shared.hh
|
||||
include_directories : [
|
||||
|
||||
@@ -54,6 +54,7 @@ libfetchers = library(
|
||||
liblixstore,
|
||||
liblixutil,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
include_directories : [ '../..' ],
|
||||
cpp_pch : cpp_pch,
|
||||
|
||||
@@ -21,6 +21,7 @@ libmain = library(
|
||||
dependencies : [
|
||||
liblixutil,
|
||||
liblixstore,
|
||||
kj,
|
||||
],
|
||||
include_directories : [ '../..' ],
|
||||
cpp_pch : cpp_pch,
|
||||
|
||||
@@ -175,9 +175,9 @@ void initNix()
|
||||
}
|
||||
|
||||
|
||||
LegacyArgs::LegacyArgs(const std::string & programName,
|
||||
LegacyArgs::LegacyArgs(AsyncIoRoot & aio, const std::string & programName,
|
||||
std::function<bool(Strings::iterator & arg, const Strings::iterator & end)> parseArg)
|
||||
: MixCommonArgs(programName), parseArg(parseArg)
|
||||
: MixCommonArgs(programName), aio_(aio), parseArg(parseArg)
|
||||
{
|
||||
addFlag({
|
||||
.longName = "no-build-output",
|
||||
|
||||
@@ -53,9 +53,12 @@ template<class N> N getIntArg(const std::string & opt,
|
||||
|
||||
struct LegacyArgs : public MixCommonArgs, public RootArgs
|
||||
{
|
||||
AsyncIoRoot & aio_;
|
||||
AsyncIoRoot & aio() override { return aio_; }
|
||||
|
||||
std::function<bool(Strings::iterator & arg, const Strings::iterator & end)> parseArg;
|
||||
|
||||
LegacyArgs(const std::string & programName,
|
||||
LegacyArgs(AsyncIoRoot & aio, const std::string & programName,
|
||||
std::function<bool(Strings::iterator & arg, const Strings::iterator & end)> parseArg);
|
||||
|
||||
bool processFlag(Strings::iterator & pos, Strings::iterator end) override;
|
||||
|
||||
@@ -1257,7 +1257,8 @@ void LocalDerivationGoal::startDaemon()
|
||||
FdSource from(remote.get());
|
||||
FdSink to(remote.get());
|
||||
try {
|
||||
daemon::processConnection(store, from, to,
|
||||
AsyncIoRoot aio;
|
||||
daemon::processConnection(aio, store, from, to,
|
||||
NotTrusted, daemon::Recursive);
|
||||
debug("terminated daemon connection");
|
||||
} catch (SysError &) {
|
||||
|
||||
@@ -261,7 +261,7 @@ struct ClientSettings
|
||||
}
|
||||
};
|
||||
|
||||
static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||
static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store,
|
||||
TrustedFlag trusted, RecursiveFlag recursive, WorkerProto::Version clientVersion,
|
||||
Source & from, BufferedSink & to, WorkerProto::Op op)
|
||||
{
|
||||
@@ -995,6 +995,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||
}
|
||||
|
||||
void processConnection(
|
||||
AsyncIoRoot & aio,
|
||||
ref<Store> store,
|
||||
FdSource & from,
|
||||
FdSink & to,
|
||||
@@ -1073,7 +1074,7 @@ void processConnection(
|
||||
debug("performing daemon worker op: %d", op);
|
||||
|
||||
try {
|
||||
performOp(tunnelLogger, store, trusted, recursive, clientVersion, from, to, op);
|
||||
performOp(aio, tunnelLogger, store, trusted, recursive, clientVersion, from, to, op);
|
||||
} catch (Error & e) {
|
||||
/* If we're not in a state where we can send replies, then
|
||||
something went wrong processing the input of the
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/serialise.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
|
||||
@@ -9,6 +10,7 @@ namespace nix::daemon {
|
||||
enum RecursiveFlag : bool { NotRecursive = false, Recursive = true };
|
||||
|
||||
void processConnection(
|
||||
AsyncIoRoot & aio,
|
||||
ref<Store> store,
|
||||
FdSource & from,
|
||||
FdSink & to,
|
||||
|
||||
+2
-2
@@ -402,7 +402,7 @@ MultiCommand::MultiCommand(const Commands & commands_)
|
||||
auto suggestions = Suggestions::bestMatches(commandNames, s);
|
||||
throw UsageError(suggestions, "'%s' is not a recognised command", s);
|
||||
}
|
||||
command = {s, i->second()};
|
||||
command = {s, i->second(aio())};
|
||||
command->second->parent = this;
|
||||
}},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
@@ -437,7 +437,7 @@ nlohmann::json MultiCommand::toJSON()
|
||||
auto cmds = nlohmann::json::object();
|
||||
|
||||
for (auto & [name, commandFun] : commands) {
|
||||
auto command = commandFun();
|
||||
auto command = commandFun(aio());
|
||||
auto j = command->toJSON();
|
||||
auto cat = nlohmann::json::object();
|
||||
cat["id"] = command->category();
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/experimental-features.hh"
|
||||
#include "lix/libutil/types.hh"
|
||||
#include "lix/libutil/ref.hh"
|
||||
@@ -41,6 +42,8 @@ public:
|
||||
*/
|
||||
virtual std::string doc() { return ""; }
|
||||
|
||||
virtual AsyncIoRoot & aio() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@@ -337,7 +340,7 @@ struct Command : virtual public Args
|
||||
virtual Category category() { return catDefault; }
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::function<ref<Command>()>> Commands;
|
||||
typedef std::map<std::string, std::function<ref<Command>(AsyncIoRoot &)>> Commands;
|
||||
|
||||
/**
|
||||
* An argument parser that supports multiple subcommands,
|
||||
|
||||
@@ -295,6 +295,7 @@ libutil = library(
|
||||
brotli,
|
||||
openssl,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
include_directories : [ '../..' ],
|
||||
cpp_pch : cpp_pch,
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdConfig final : MultiCommand
|
||||
struct CmdConfig : MultiCommand
|
||||
{
|
||||
CmdConfig() : MultiCommand(RegisterCommand::getCommandsFor({"config"}))
|
||||
{ }
|
||||
|
||||
+13
-11
@@ -252,7 +252,7 @@ static std::pair<TrustedFlag, std::string> authPeer(const PeerInfo & peer)
|
||||
* the client. Otherwise, decide based on the authentication settings
|
||||
* and user credentials (from the unix domain socket).
|
||||
*/
|
||||
static void daemonLoop(std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
static void daemonLoop(AsyncIoRoot & aio, std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
{
|
||||
if (chdir("/") == -1)
|
||||
throw SysError("cannot change current directory");
|
||||
@@ -340,7 +340,7 @@ static void daemonLoop(std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
// Handle the connection.
|
||||
FdSource from(remote.get());
|
||||
FdSink to(remote.get());
|
||||
processConnection(openUncachedStore(), from, to, trusted, NotRecursive);
|
||||
processConnection(aio, openUncachedStore(), from, to, trusted, NotRecursive);
|
||||
|
||||
exit(0);
|
||||
}, options).release();
|
||||
@@ -403,11 +403,12 @@ static void forwardStdioConnection(RemoteStore & store) {
|
||||
* @param trustClient Whether to trust the client. Forwarded directly to
|
||||
* `processConnection()`.
|
||||
*/
|
||||
static void processStdioConnection(ref<Store> store, TrustedFlag trustClient)
|
||||
static void
|
||||
processStdioConnection(AsyncIoRoot & aio, ref<Store> store, TrustedFlag trustClient)
|
||||
{
|
||||
FdSource from(STDIN_FILENO);
|
||||
FdSink to(STDOUT_FILENO);
|
||||
processConnection(store, from, to, trustClient, NotRecursive);
|
||||
processConnection(aio, store, from, to, trustClient, NotRecursive);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +418,8 @@ static void processStdioConnection(ref<Store> store, TrustedFlag trustClient)
|
||||
* @param forceTrustClientOpt See `daemonLoop()` and the parameter with
|
||||
* the same name over there for details.
|
||||
*/
|
||||
static void runDaemon(bool stdio, std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
static void
|
||||
runDaemon(AsyncIoRoot & aio, bool stdio, std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
{
|
||||
if (stdio) {
|
||||
auto store = openUncachedStore();
|
||||
@@ -431,18 +433,18 @@ static void runDaemon(bool stdio, std::optional<TrustedFlag> forceTrustClientOpt
|
||||
// `Trusted` is passed in the auto (no override case) because we
|
||||
// cannot see who is on the other side of a plain pipe. Limiting
|
||||
// access to those is explicitly not `nix-daemon`'s responsibility.
|
||||
processStdioConnection(store, forceTrustClientOpt.value_or(Trusted));
|
||||
processStdioConnection(aio, store, forceTrustClientOpt.value_or(Trusted));
|
||||
} else
|
||||
daemonLoop(forceTrustClientOpt);
|
||||
daemonLoop(aio, forceTrustClientOpt);
|
||||
}
|
||||
|
||||
static int main_nix_daemon(std::string programName, Strings argv)
|
||||
static int main_nix_daemon(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
auto stdio = false;
|
||||
std::optional<TrustedFlag> isTrustedOpt = std::nullopt;
|
||||
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--daemon")
|
||||
; // ignored for backwards compatibility
|
||||
else if (*arg == "--help")
|
||||
@@ -464,7 +466,7 @@ static int main_nix_daemon(std::string programName, Strings argv)
|
||||
return true;
|
||||
}).parseCmdline(argv);
|
||||
|
||||
runDaemon(stdio, isTrustedOpt);
|
||||
runDaemon(aio, stdio, isTrustedOpt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -531,7 +533,7 @@ struct CmdDaemon : StoreCommand
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
runDaemon(stdio, isTrustedOpt);
|
||||
runDaemon(aio(), stdio, isTrustedOpt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdDerivation final : MultiCommand
|
||||
struct CmdDerivation : MultiCommand
|
||||
{
|
||||
CmdDerivation() : MultiCommand(RegisterCommand::getCommandsFor({"derivation"}))
|
||||
{ }
|
||||
|
||||
+12
-12
@@ -27,7 +27,7 @@ using namespace nix::flake;
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct CmdFlakeUpdate;
|
||||
class FlakeCommand : virtual Args, public MixFlakeOptions
|
||||
class FlakeCommand : public virtual Args, public MixFlakeOptions
|
||||
{
|
||||
protected:
|
||||
std::string flakeUrl = ".";
|
||||
@@ -1468,17 +1468,17 @@ struct CmdFlake : MultiCommand
|
||||
{
|
||||
CmdFlake()
|
||||
: MultiCommand({
|
||||
{"update", []() { return make_ref<CmdFlakeUpdate>(); }},
|
||||
{"lock", []() { return make_ref<CmdFlakeLock>(); }},
|
||||
{"metadata", []() { return make_ref<CmdFlakeMetadata>(); }},
|
||||
{"info", []() { return make_ref<CmdFlakeInfo>(); }},
|
||||
{"check", []() { return make_ref<CmdFlakeCheck>(); }},
|
||||
{"init", []() { return make_ref<CmdFlakeInit>(); }},
|
||||
{"new", []() { return make_ref<CmdFlakeNew>(); }},
|
||||
{"clone", []() { return make_ref<CmdFlakeClone>(); }},
|
||||
{"archive", []() { return make_ref<CmdFlakeArchive>(); }},
|
||||
{"show", []() { return make_ref<CmdFlakeShow>(); }},
|
||||
{"prefetch", []() { return make_ref<CmdFlakePrefetch>(); }},
|
||||
{"update", [](auto & aio) { return make_ref<MixAio<CmdFlakeUpdate>>(aio); }},
|
||||
{"lock", [](auto & aio) { return make_ref<MixAio<CmdFlakeLock>>(aio); }},
|
||||
{"metadata", [](auto & aio) { return make_ref<MixAio<CmdFlakeMetadata>>(aio); }},
|
||||
{"info", [](auto & aio) { return make_ref<MixAio<CmdFlakeInfo>>(aio); }},
|
||||
{"check", [](auto & aio) { return make_ref<MixAio<CmdFlakeCheck>>(aio); }},
|
||||
{"init", [](auto & aio) { return make_ref<MixAio<CmdFlakeInit>>(aio); }},
|
||||
{"new", [](auto & aio) { return make_ref<MixAio<CmdFlakeNew>>(aio); }},
|
||||
{"clone", [](auto & aio) { return make_ref<MixAio<CmdFlakeClone>>(aio); }},
|
||||
{"archive", [](auto & aio) { return make_ref<MixAio<CmdFlakeArchive>>(aio); }},
|
||||
{"show", [](auto & aio) { return make_ref<MixAio<CmdFlakeShow>>(aio); }},
|
||||
{"prefetch", [](auto & aio) { return make_ref<MixAio<CmdFlakePrefetch>>(aio); }},
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
+23
-12
@@ -128,14 +128,25 @@ struct CmdHash : MultiCommand
|
||||
{
|
||||
CmdHash()
|
||||
: MultiCommand({
|
||||
{"file", []() { return make_ref<CmdHashBase>(FileIngestionMethod::Flat);; }},
|
||||
{"path", []() { return make_ref<CmdHashBase>(FileIngestionMethod::Recursive); }},
|
||||
{"to-base16", []() { return make_ref<CmdToBase>(Base::Base16); }},
|
||||
{"to-base32", []() { return make_ref<CmdToBase>(Base::Base32); }},
|
||||
{"to-base64", []() { return make_ref<CmdToBase>(Base::Base64); }},
|
||||
{"to-sri", []() { return make_ref<CmdToBase>(Base::SRI); }},
|
||||
})
|
||||
{ }
|
||||
{"file",
|
||||
[](auto & aio) {
|
||||
return make_ref<MixAio<CmdHashBase>>(aio, FileIngestionMethod::Flat);
|
||||
;
|
||||
}},
|
||||
{"path",
|
||||
[](auto & aio) {
|
||||
return make_ref<MixAio<CmdHashBase>>(aio, FileIngestionMethod::Recursive);
|
||||
}},
|
||||
{"to-base16",
|
||||
[](auto & aio) { return make_ref<MixAio<CmdToBase>>(aio, Base::Base16); }},
|
||||
{"to-base32",
|
||||
[](auto & aio) { return make_ref<MixAio<CmdToBase>>(aio, Base::Base32); }},
|
||||
{"to-base64",
|
||||
[](auto & aio) { return make_ref<MixAio<CmdToBase>>(aio, Base::Base64); }},
|
||||
{"to-sri", [](auto & aio) { return make_ref<MixAio<CmdToBase>>(aio, Base::SRI); }},
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
@@ -155,7 +166,7 @@ struct CmdHash : MultiCommand
|
||||
static auto rCmdHash = registerCommand<CmdHash>("hash");
|
||||
|
||||
/* Legacy nix-hash command. */
|
||||
static int compatNixHash(std::string programName, Strings argv)
|
||||
static int compatNixHash(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
std::optional<HashType> ht;
|
||||
bool flat = false;
|
||||
@@ -164,7 +175,7 @@ static int compatNixHash(std::string programName, Strings argv)
|
||||
enum { opHash, opTo } op = opHash;
|
||||
std::vector<std::string> ss;
|
||||
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-hash");
|
||||
else if (*arg == "--version")
|
||||
@@ -203,7 +214,7 @@ static int compatNixHash(std::string programName, Strings argv)
|
||||
}).parseCmdline(argv);
|
||||
|
||||
if (op == opHash) {
|
||||
CmdHashBase cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
|
||||
MixAio<CmdHashBase> cmd(aio, flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
|
||||
if (!ht.has_value()) ht = HashType::MD5;
|
||||
cmd.ht = ht.value();
|
||||
cmd.base = base;
|
||||
@@ -213,7 +224,7 @@ static int compatNixHash(std::string programName, Strings argv)
|
||||
}
|
||||
|
||||
else {
|
||||
CmdToBase cmd(base);
|
||||
MixAio<CmdToBase> cmd(aio, base);
|
||||
cmd.args = ss;
|
||||
if (ht.has_value()) cmd.ht = ht;
|
||||
cmd.run();
|
||||
|
||||
+14
-5
@@ -111,7 +111,13 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
|
||||
bool helpRequested = false;
|
||||
bool showVersion = false;
|
||||
|
||||
NixArgs() : MultiCommand(RegisterCommand::getCommandsFor({})), MixCommonArgs("nix")
|
||||
AsyncIoRoot & aio_;
|
||||
AsyncIoRoot & aio() override { return aio_; }
|
||||
|
||||
NixArgs(AsyncIoRoot & aio)
|
||||
: MultiCommand(RegisterCommand::getCommandsFor({}))
|
||||
, MixCommonArgs("nix")
|
||||
, aio_(aio)
|
||||
{
|
||||
categories.clear();
|
||||
categories[catHelp] = "Help commands";
|
||||
@@ -345,7 +351,7 @@ struct CmdHelpStores : Command
|
||||
|
||||
static auto rCmdHelpStores = registerCommand<CmdHelpStores>("help-stores");
|
||||
|
||||
void mainWrapped(int argc, char * * argv)
|
||||
void mainWrapped(AsyncIoRoot & aio, int argc, char * * argv)
|
||||
{
|
||||
savedArgv = argv;
|
||||
|
||||
@@ -384,7 +390,9 @@ void mainWrapped(int argc, char * * argv)
|
||||
{
|
||||
registerLegacyCommands();
|
||||
auto legacy = (*LegacyCommands::commands)[programName];
|
||||
if (legacy) return legacy(std::string(baseNameOf(argv[0])), Strings(argv + 1, argv + argc));
|
||||
if (legacy) {
|
||||
return legacy(aio, std::string(baseNameOf(argv[0])), Strings(argv + 1, argv + argc));
|
||||
}
|
||||
}
|
||||
|
||||
evalSettings.pureEval.setDefault(true);
|
||||
@@ -398,7 +406,7 @@ void mainWrapped(int argc, char * * argv)
|
||||
verbosity = lvlInfo;
|
||||
}
|
||||
|
||||
NixArgs args;
|
||||
NixArgs args(aio);
|
||||
|
||||
if (argc == 2 && std::string(argv[1]) == "__dump-cli") {
|
||||
logger->cout(args.dumpCli());
|
||||
@@ -543,6 +551,7 @@ int main(int argc, char * * argv)
|
||||
nix::setStackSize(64 * 1024 * 1024);
|
||||
|
||||
return nix::handleExceptions(argv[0], [&]() {
|
||||
nix::mainWrapped(argc, argv);
|
||||
nix::AsyncIoRoot aio;
|
||||
nix::mainWrapped(aio, argc, argv);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ nix = executable(
|
||||
liblixmain,
|
||||
boehm,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
install : true,
|
||||
|
||||
+7
-4
@@ -49,6 +49,7 @@ std::string resolveMirrorUrl(EvalState & state, const std::string & url)
|
||||
}
|
||||
|
||||
std::tuple<StorePath, Hash> prefetchFile(
|
||||
AsyncIoRoot & aio,
|
||||
ref<Store> store,
|
||||
const std::string & url,
|
||||
std::optional<std::string> name,
|
||||
@@ -132,7 +133,7 @@ std::tuple<StorePath, Hash> prefetchFile(
|
||||
return {storePath.value(), hash.value()};
|
||||
}
|
||||
|
||||
static int main_nix_prefetch_url(std::string programName, Strings argv)
|
||||
static int main_nix_prefetch_url(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
HashType ht = HashType::SHA256;
|
||||
@@ -149,7 +150,7 @@ static int main_nix_prefetch_url(std::string programName, Strings argv)
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-prefetch-url");
|
||||
else if (*arg == "--version")
|
||||
@@ -236,7 +237,8 @@ static int main_nix_prefetch_url(std::string programName, Strings argv)
|
||||
expectedHash = Hash::parseAny(args[1], ht);
|
||||
|
||||
auto [storePath, hash] = prefetchFile(
|
||||
store, resolveMirrorUrl(*state, url), name, ht, expectedHash, unpack, executable);
|
||||
aio, store, resolveMirrorUrl(*state, url), name, ht, expectedHash, unpack, executable
|
||||
);
|
||||
|
||||
logger->pause();
|
||||
|
||||
@@ -316,7 +318,8 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON
|
||||
}
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
auto [storePath, hash] = prefetchFile(store, url, name, hashType, expectedHash, unpack, executable);
|
||||
auto [storePath, hash] =
|
||||
prefetchFile(aio(), store, url, name, hashType, expectedHash, unpack, executable);
|
||||
|
||||
if (json) {
|
||||
auto res = nlohmann::json::object();
|
||||
|
||||
+8
-8
@@ -607,14 +607,14 @@ struct CmdProfile : MultiCommand
|
||||
{
|
||||
CmdProfile()
|
||||
: MultiCommand({
|
||||
{"install", []() { return make_ref<CmdProfileInstall>(); }},
|
||||
{"remove", []() { return make_ref<CmdProfileRemove>(); }},
|
||||
{"upgrade", []() { return make_ref<CmdProfileUpgrade>(); }},
|
||||
{"list", []() { return make_ref<CmdProfileList>(); }},
|
||||
{"diff-closures", []() { return make_ref<CmdProfileDiffClosures>(); }},
|
||||
{"history", []() { return make_ref<CmdProfileHistory>(); }},
|
||||
{"rollback", []() { return make_ref<CmdProfileRollback>(); }},
|
||||
{"wipe-history", []() { return make_ref<CmdProfileWipeHistory>(); }},
|
||||
{"install", [](auto & aio) { return make_ref<MixAio<CmdProfileInstall>>(aio); }},
|
||||
{"remove", [](auto & aio) { return make_ref<MixAio<CmdProfileRemove>>(aio); }},
|
||||
{"upgrade", [](auto & aio) { return make_ref<MixAio<CmdProfileUpgrade>>(aio); }},
|
||||
{"list", [](auto & aio) { return make_ref<MixAio<CmdProfileList>>(aio); }},
|
||||
{"diff-closures", [](auto & aio) { return make_ref<MixAio<CmdProfileDiffClosures>>(aio); }},
|
||||
{"history", [](auto & aio) { return make_ref<MixAio<CmdProfileHistory>>(aio); }},
|
||||
{"rollback", [](auto & aio) { return make_ref<MixAio<CmdProfileRollback>>(aio); }},
|
||||
{"wipe-history", [](auto & aio) { return make_ref<MixAio<CmdProfileWipeHistory>>(aio); }},
|
||||
})
|
||||
{ }
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdRealisation final : MultiCommand
|
||||
struct CmdRealisation : MultiCommand
|
||||
{
|
||||
CmdRealisation() : MultiCommand(RegisterCommand::getCommandsFor({"realisation"}))
|
||||
{ }
|
||||
|
||||
+6
-6
@@ -12,7 +12,7 @@ using namespace nix;
|
||||
using namespace nix::flake;
|
||||
|
||||
|
||||
class RegistryCommand : virtual Args
|
||||
class RegistryCommand : public virtual Args
|
||||
{
|
||||
std::string registry_path;
|
||||
|
||||
@@ -204,14 +204,14 @@ struct CmdRegistryPin : RegistryCommand, EvalCommand
|
||||
}
|
||||
};
|
||||
|
||||
struct CmdRegistry final : MultiCommand
|
||||
struct CmdRegistry : MultiCommand
|
||||
{
|
||||
CmdRegistry()
|
||||
: MultiCommand({
|
||||
{"list", []() { return make_ref<CmdRegistryList>(); }},
|
||||
{"add", []() { return make_ref<CmdRegistryAdd>(); }},
|
||||
{"remove", []() { return make_ref<CmdRegistryRemove>(); }},
|
||||
{"pin", []() { return make_ref<CmdRegistryPin>(); }},
|
||||
{"list", [](auto & aio) { return make_ref<MixAio<CmdRegistryList>>(aio); }},
|
||||
{"add", [](auto & aio) { return make_ref<MixAio<CmdRegistryAdd>>(aio); }},
|
||||
{"remove", [](auto & aio) { return make_ref<MixAio<CmdRegistryRemove>>(aio); }},
|
||||
{"pin", [](auto & aio) { return make_ref<MixAio<CmdRegistryPin>>(aio); }},
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
+5
-3
@@ -197,9 +197,11 @@ struct CmdKey : MultiCommand
|
||||
{
|
||||
CmdKey()
|
||||
: MultiCommand({
|
||||
{"generate-secret", []() { return make_ref<CmdKeyGenerateSecret>(); }},
|
||||
{"convert-secret-to-public", []() { return make_ref<CmdKeyConvertSecretToPublic>(); }},
|
||||
})
|
||||
{"generate-secret",
|
||||
[](auto & aio) { return make_ref<MixAio<CmdKeyGenerateSecret>>(aio); }},
|
||||
{"convert-secret-to-public",
|
||||
[](auto & aio) { return make_ref<MixAio<CmdKeyConvertSecretToPublic>>(aio); }},
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdStore final : MultiCommand
|
||||
struct CmdStore : MultiCommand
|
||||
{
|
||||
CmdStore() : MultiCommand(RegisterCommand::getCommandsFor({"store"}))
|
||||
{ }
|
||||
|
||||
@@ -9,6 +9,7 @@ libstoreconsumer_tester = executable(
|
||||
editline,
|
||||
boost,
|
||||
lowdown,
|
||||
kj,
|
||||
],
|
||||
build_by_default : false,
|
||||
)
|
||||
|
||||
@@ -114,6 +114,7 @@ libstore_test_support = library(
|
||||
liblixstore,
|
||||
rapidcheck,
|
||||
boehm,
|
||||
kj,
|
||||
],
|
||||
include_directories : include_directories(
|
||||
'libstore-support',
|
||||
@@ -152,6 +153,7 @@ libstore_tester = executable(
|
||||
rapidcheck,
|
||||
gtest,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
)
|
||||
@@ -220,6 +222,7 @@ libexpr_tester = executable(
|
||||
boehm,
|
||||
gtest,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
)
|
||||
@@ -248,6 +251,7 @@ libcmd_tester = executable(
|
||||
liblixstore_mstatic,
|
||||
gtest,
|
||||
boost,
|
||||
kj,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
)
|
||||
@@ -284,6 +288,7 @@ libmain_tester = executable(
|
||||
liblixstore,
|
||||
gtest,
|
||||
boost,
|
||||
kj,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user