2020-05-27 21:56:34 +01:00
|
|
|
#include "libmain/common-args.hh"
|
2020-05-19 15:54:39 +01:00
|
|
|
|
2020-05-19 01:03:09 +01:00
|
|
|
#include <glog/logging.h>
|
2020-05-19 15:54:39 +01:00
|
|
|
|
2020-05-27 21:56:34 +01:00
|
|
|
#include "libstore/globals.hh"
|
2016-02-09 21:07:48 +01:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2020-05-24 22:29:21 +01:00
|
|
|
MixCommonArgs::MixCommonArgs(const std::string& programName)
|
2016-02-09 21:28:29 +01:00
|
|
|
: programName(programName) {
|
2017-06-07 18:41:20 +02:00
|
|
|
mkFlag()
|
|
|
|
.longName("option")
|
|
|
|
.labels({"name", "value"})
|
|
|
|
.description("set a Nix configuration option (overriding nix.conf)")
|
|
|
|
.arity(2)
|
2017-10-24 12:45:11 +02:00
|
|
|
.handler([](std::vector<std::string> ss) {
|
2017-04-13 20:53:23 +02:00
|
|
|
try {
|
2018-03-27 18:41:31 +02:00
|
|
|
globalConfig.set(ss[0], ss[1]);
|
2017-04-13 20:53:23 +02:00
|
|
|
} catch (UsageError& e) {
|
2020-05-19 01:03:09 +01:00
|
|
|
LOG(WARNING) << e.what();
|
2017-04-13 20:53:23 +02:00
|
|
|
}
|
2016-02-09 21:07:48 +01:00
|
|
|
});
|
2020-05-17 16:31:57 +01:00
|
|
|
|
2019-06-15 16:34:06 +02:00
|
|
|
mkFlag()
|
|
|
|
.longName("max-jobs")
|
|
|
|
.shortName('j')
|
|
|
|
.label("jobs")
|
|
|
|
.description("maximum number of parallel builds")
|
2020-05-20 22:58:43 +01:00
|
|
|
.handler([=](const std::string& s) { settings.set("max-jobs", s); });
|
2020-05-17 16:31:57 +01:00
|
|
|
|
2017-11-14 14:04:09 +01:00
|
|
|
std::string cat = "config";
|
2018-03-27 18:41:31 +02:00
|
|
|
globalConfig.convertToArgs(*this, cat);
|
2020-05-17 16:31:57 +01:00
|
|
|
|
2018-02-08 15:25:03 +01:00
|
|
|
// Backward compatibility hack: nix-env already had a --system flag.
|
|
|
|
if (programName == "nix-env") {
|
|
|
|
longFlags.erase("system");
|
2020-05-19 18:55:58 +01:00
|
|
|
}
|
2020-05-17 16:31:57 +01:00
|
|
|
|
2017-11-14 14:04:09 +01:00
|
|
|
hiddenCategories.insert(cat);
|
2016-02-09 21:07:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace nix
|