aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/add-to-store.cc2
-rw-r--r--src/nix/hash.cc42
-rw-r--r--src/nix/installables.cc2
-rw-r--r--src/nix/main.cc2
-rw-r--r--src/nix/make-content-addressable.cc2
-rw-r--r--src/nix/path-info.cc2
-rw-r--r--src/nix/progress-bar.cc46
-rw-r--r--src/nix/repl.cc6
-rw-r--r--src/nix/sigs.cc2
-rw-r--r--src/nix/upgrade-nix.cc8
-rw-r--r--src/nix/verify.cc8
11 files changed, 61 insertions, 61 deletions
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index 139db3657..ed35616e6 100644
--- a/src/nix/add-to-store.cc
+++ b/src/nix/add-to-store.cc
@@ -40,7 +40,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
StringSink sink;
dumpPath(path, sink);
- auto narHash = hashString(htSHA256, *sink.s);
+ auto narHash = hashString(HashType::SHA256, *sink.s);
ValidPathInfo info(store->makeFixedOutputPath(true, narHash, *namePart));
info.narHash = narHash;
diff --git a/src/nix/hash.cc b/src/nix/hash.cc
index 0cc523f50..deced3d11 100644
--- a/src/nix/hash.cc
+++ b/src/nix/hash.cc
@@ -11,18 +11,18 @@ struct CmdHash : Command
{
enum Mode { mFile, mPath };
Mode mode;
- Base base = SRI;
+ Base base = Base::SRI;
bool truncate = false;
- HashType ht = htSHA256;
+ HashType ht = HashType::SHA256;
std::vector<std::string> paths;
std::optional<std::string> modulus;
CmdHash(Mode mode) : mode(mode)
{
- mkFlag(0, "sri", "print hash in SRI format", &base, SRI);
- mkFlag(0, "base64", "print hash in base-64", &base, Base64);
- mkFlag(0, "base32", "print hash in base-32 (Nix-specific)", &base, Base32);
- mkFlag(0, "base16", "print hash in base-16", &base, Base16);
+ mkFlag(0, "sri", "print hash in Base::SRI format", &base, Base::SRI);
+ mkFlag(0, "base64", "print hash in base-64", &base, Base::Base64);
+ mkFlag(0, "base32", "print hash in base-32 (Nix-specific)", &base, Base::Base32);
+ mkFlag(0, "base16", "print hash in base-16", &base, Base::Base16);
mkFlag()
.longName("type")
.mkHashTypeFlag(&ht);
@@ -61,7 +61,7 @@ struct CmdHash : Command
Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
std::cout << format("%1%\n") %
- h.to_string(base, base == SRI);
+ h.to_string(base, base == Base::SRI);
}
}
};
@@ -72,7 +72,7 @@ static RegisterCommand r2("hash-path", [](){ return make_ref<CmdHash>(CmdHash::m
struct CmdToBase : Command
{
Base base;
- HashType ht = htUnknown;
+ HashType ht = HashType::Unknown;
std::vector<std::string> args;
CmdToBase(Base base) : base(base)
@@ -86,28 +86,28 @@ struct CmdToBase : Command
std::string description() override
{
return fmt("convert a hash to %s representation",
- base == Base16 ? "base-16" :
- base == Base32 ? "base-32" :
- base == Base64 ? "base-64" :
- "SRI");
+ base == Base::Base16 ? "base-16" :
+ base == Base::Base32 ? "base-32" :
+ base == Base::Base64 ? "base-64" :
+ "Base::SRI");
}
void run() override
{
for (auto s : args)
- std::cout << fmt("%s\n", Hash(s, ht).to_string(base, base == SRI));
+ std::cout << fmt("%s\n", Hash(s, ht).to_string(base, base == Base::SRI));
}
};
-static RegisterCommand r3("to-base16", [](){ return make_ref<CmdToBase>(Base16); });
-static RegisterCommand r4("to-base32", [](){ return make_ref<CmdToBase>(Base32); });
-static RegisterCommand r5("to-base64", [](){ return make_ref<CmdToBase>(Base64); });
-static RegisterCommand r6("to-sri", [](){ return make_ref<CmdToBase>(SRI); });
+static RegisterCommand r3("to-base16", [](){ return make_ref<CmdToBase>(Base::Base16); });
+static RegisterCommand r4("to-base32", [](){ return make_ref<CmdToBase>(Base::Base32); });
+static RegisterCommand r5("to-base64", [](){ return make_ref<CmdToBase>(Base::Base64); });
+static RegisterCommand r6("to-sri", [](){ return make_ref<CmdToBase>(Base::SRI); });
/* Legacy nix-hash command. */
static int compatNixHash(int argc, char * * argv)
{
- HashType ht = htMD5;
+ HashType ht = HashType::MD5;
bool flat = false;
bool base32 = false;
bool truncate = false;
@@ -125,7 +125,7 @@ static int compatNixHash(int argc, char * * argv)
else if (*arg == "--type") {
string s = getArg(*arg, arg, end);
ht = parseHashType(s);
- if (ht == htUnknown)
+ if (ht == HashType::Unknown)
throw UsageError(format("unknown hash type '%1%'") % s);
}
else if (*arg == "--to-base16") op = opTo16;
@@ -140,14 +140,14 @@ static int compatNixHash(int argc, char * * argv)
if (op == opHash) {
CmdHash cmd(flat ? CmdHash::mFile : CmdHash::mPath);
cmd.ht = ht;
- cmd.base = base32 ? Base32 : Base16;
+ cmd.base = base32 ? Base::Base32 : Base::Base16;
cmd.truncate = truncate;
cmd.paths = ss;
cmd.run();
}
else {
- CmdToBase cmd(op == opTo32 ? Base32 : Base16);
+ CmdToBase cmd(op == opTo32 ? Base::Base32 : Base::Base16);
cmd.args = ss;
cmd.ht = ht;
cmd.run();
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index 013218cd9..03d03e90a 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -272,7 +272,7 @@ Buildables build(ref<Store> store, RealiseMode mode,
}
if (mode == DryRun)
- printMissing(store, pathsToBuild, lvlError);
+ printMissing(store, pathsToBuild, Verbosity::Error);
else if (mode == Build)
store->buildPaths(pathsToBuild);
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 3b5f5516f..d0a43ab23 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -148,7 +148,7 @@ void mainWrapped(int argc, char * * argv)
if (legacy) return legacy(argc, argv);
}
- verbosity = lvlWarn;
+ verbosity = Verbosity::Warn;
settings.verboseBuild = false;
NixArgs args;
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index f9c7fef3f..5c964ec27 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -69,7 +69,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
*sink.s = rewriteStrings(*sink.s, rewrites);
- HashModuloSink hashModuloSink(htSHA256, oldHashPart);
+ HashModuloSink hashModuloSink(HashType::SHA256, oldHashPart);
hashModuloSink((unsigned char *) sink.s->data(), sink.s->size());
auto narHash = hashModuloSink.finish().first;
diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc
index 45ec297d2..a15912ccc 100644
--- a/src/nix/path-info.cc
+++ b/src/nix/path-info.cc
@@ -89,7 +89,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
store->pathInfoToJSON(jsonRoot,
// FIXME: preserve order?
storePathsToSet(storePaths),
- true, showClosureSize, SRI, AllowInvalid);
+ true, showClosureSize, Base::SRI, AllowInvalid);
}
else {
diff --git a/src/nix/progress-bar.cc b/src/nix/progress-bar.cc
index 26631416c..d53e671ed 100644
--- a/src/nix/progress-bar.cc
+++ b/src/nix/progress-bar.cc
@@ -38,7 +38,7 @@ private:
struct ActInfo
{
std::string s, lastLine, phase;
- ActivityType type = actUnknown;
+ ActivityType type = ActivityType::Unknown;
uint64_t done = 0;
uint64_t expected = 0;
uint64_t running = 0;
@@ -152,7 +152,7 @@ public:
state->its.emplace(act, i);
state->activitiesByType[type].its.emplace(act, i);
- if (type == actBuild) {
+ if (type == ActivityType::Build) {
auto name = storePathToName(getS(fields, 0));
if (hasSuffix(name, ".drv"))
name = name.substr(0, name.size() - 4);
@@ -167,7 +167,7 @@ public:
i->name = DrvName(name).name;
}
- if (type == actSubstitute) {
+ if (type == ActivityType::Substitute) {
auto name = storePathToName(getS(fields, 0));
auto sub = getS(fields, 1);
i->s = fmt(
@@ -177,7 +177,7 @@ public:
name, sub);
}
- if (type == actPostBuildHook) {
+ if (type == ActivityType::PostBuildHook) {
auto name = storePathToName(getS(fields, 0));
if (hasSuffix(name, ".drv"))
name = name.substr(0, name.size() - 4);
@@ -185,14 +185,14 @@ public:
i->name = DrvName(name).name;
}
- if (type == actQueryPathInfo) {
+ if (type == ActivityType::QueryPathInfo) {
auto name = storePathToName(getS(fields, 0));
i->s = fmt("querying " ANSI_BOLD "%s" ANSI_NORMAL " on %s", name, getS(fields, 1));
}
- if ((type == actDownload && hasAncestor(*state, actCopyPath, parent))
- || (type == actDownload && hasAncestor(*state, actQueryPathInfo, parent))
- || (type == actCopyPath && hasAncestor(*state, actSubstitute, parent)))
+ if ((type == ActivityType::Download && hasAncestor(*state, ActivityType::CopyPath, parent))
+ || (type == ActivityType::Download && hasAncestor(*state, ActivityType::QueryPathInfo, parent))
+ || (type == ActivityType::CopyPath && hasAncestor(*state, ActivityType::Substitute, parent)))
i->visible = false;
update(*state);
@@ -237,13 +237,13 @@ public:
{
auto state(state_.lock());
- if (type == resFileLinked) {
+ if (type == ResultType::FileLinked) {
state->filesLinked++;
state->bytesLinked += getI(fields, 0);
update(*state);
}
- else if (type == resBuildLogLine || type == resPostBuildLogLine) {
+ else if (type == ResultType::BuildLogLine || type == ResultType::PostBuildLogLine) {
auto lastLine = trim(getS(fields, 0));
if (!lastLine.empty()) {
auto i = state->its.find(act);
@@ -251,10 +251,10 @@ public:
ActInfo info = *i->second;
if (printBuildLogs) {
auto suffix = "> ";
- if (type == resPostBuildLogLine) {
+ if (type == ResultType::PostBuildLogLine) {
suffix = " (post)> ";
}
- log(*state, lvlInfo, ANSI_FAINT + info.name.value_or("unnamed") + suffix + ANSI_NORMAL + lastLine);
+ log(*state, Verbosity::Info, ANSI_FAINT + info.name.value_or("unnamed") + suffix + ANSI_NORMAL + lastLine);
} else {
state->activities.erase(i->second);
info.lastLine = lastLine;
@@ -265,24 +265,24 @@ public:
}
}
- else if (type == resUntrustedPath) {
+ else if (type == ResultType::UntrustedPath) {
state->untrustedPaths++;
update(*state);
}
- else if (type == resCorruptedPath) {
+ else if (type == ResultType::CorruptedPath) {
state->corruptedPaths++;
update(*state);
}
- else if (type == resSetPhase) {
+ else if (type == ResultType::SetPhase) {
auto i = state->its.find(act);
assert(i != state->its.end());
i->second->phase = getS(fields, 0);
update(*state);
}
- else if (type == resProgress) {
+ else if (type == ResultType::Progress) {
auto i = state->its.find(act);
assert(i != state->its.end());
ActInfo & actInfo = *i->second;
@@ -293,7 +293,7 @@ public:
update(*state);
}
- else if (type == resSetExpected) {
+ else if (type == ResultType::SetExpected) {
auto i = state->its.find(act);
assert(i != state->its.end());
ActInfo & actInfo = *i->second;
@@ -405,10 +405,10 @@ public:
res += s;
};
- showActivity(actBuilds, "%s built");
+ showActivity(ActivityType::Builds, "%s built");
- auto s1 = renderActivity(actCopyPaths, "%s copied");
- auto s2 = renderActivity(actCopyPath, "%s MiB", "%.1f", MiB);
+ auto s1 = renderActivity(ActivityType::CopyPaths, "%s copied");
+ auto s2 = renderActivity(ActivityType::CopyPath, "%s MiB", "%.1f", MiB);
if (!s1.empty() || !s2.empty()) {
if (!res.empty()) res += ", ";
@@ -416,10 +416,10 @@ public:
if (!s2.empty()) { res += " ("; res += s2; res += ')'; }
}
- showActivity(actDownload, "%s MiB DL", "%.1f", MiB);
+ showActivity(ActivityType::Download, "%s MiB DL", "%.1f", MiB);
{
- auto s = renderActivity(actOptimiseStore, "%s paths optimised");
+ auto s = renderActivity(ActivityType::OptimiseStore, "%s paths optimised");
if (s != "") {
s += fmt(", %.1f MiB / %d inodes freed", state.bytesLinked / MiB, state.filesLinked);
if (!res.empty()) res += ", ";
@@ -428,7 +428,7 @@ public:
}
// FIXME: don't show "done" paths in green.
- showActivity(actVerifyPaths, "%s paths verified");
+ showActivity(ActivityType::VerifyPaths, "%s paths verified");
if (state.corruptedPaths) {
if (!res.empty()) res += ", ";
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 27727bd25..795aa6682 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -252,12 +252,12 @@ void NixRepl::mainLoop(const std::vector<std::string> & files)
// input without clearing the input so far.
continue;
} else {
- printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
+ printMsg(Verbosity::Error, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
}
} catch (Error & e) {
- printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
+ printMsg(Verbosity::Error, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
} catch (Interrupted & e) {
- printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
+ printMsg(Verbosity::Error, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
}
// We handled the current input fully, so we should clear it
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index 5f07448e0..2c3d2a107 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -45,7 +45,7 @@ struct CmdCopySigs : StorePathsCommand
//logger->setExpected(doneLabel, storePaths.size());
auto doPath = [&](const Path & storePathS) {
- //Activity act(*logger, lvlInfo, format("getting signatures for '%s'") % storePath);
+ //Activity act(*logger, Verbosity::Info, format("getting signatures for '%s'") % storePath);
checkInterrupt();
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc
index c05c29517..26de92d32 100644
--- a/src/nix/upgrade-nix.cc
+++ b/src/nix/upgrade-nix.cc
@@ -69,12 +69,12 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
}
{
- Activity act(*logger, lvlInfo, actUnknown, fmt("downloading '%s'...", store->printStorePath(storePath)));
+ Activity act(*logger, Verbosity::Info, ActivityType::Unknown, fmt("downloading '%s'...", store->printStorePath(storePath)));
store->ensurePath(storePath);
}
{
- Activity act(*logger, lvlInfo, actUnknown, fmt("verifying that '%s' works...", store->printStorePath(storePath)));
+ Activity act(*logger, Verbosity::Info, ActivityType::Unknown, fmt("verifying that '%s' works...", store->printStorePath(storePath)));
auto program = store->printStorePath(storePath) + "/bin/nix-env";
auto s = runProgram(program, false, {"--version"});
if (s.find("Nix") == std::string::npos)
@@ -84,7 +84,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
stopProgressBar();
{
- Activity act(*logger, lvlInfo, actUnknown,
+ Activity act(*logger, Verbosity::Info, ActivityType::Unknown,
fmt("installing '%s' into profile '%s'...", store->printStorePath(storePath), profileDir));
runProgram(settings.nixBinDir + "/nix-env", false,
{"--profile", profileDir, "-i", store->printStorePath(storePath), "--no-sandbox"});
@@ -135,7 +135,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
/* Return the store path of the latest stable Nix. */
StorePath getLatestNix(ref<Store> store)
{
- Activity act(*logger, lvlInfo, actUnknown, "querying latest Nix version");
+ Activity act(*logger, Verbosity::Info, ActivityType::Unknown, "querying latest Nix version");
// FIXME: use nixos.org?
auto req = DownloadRequest(storePathsUrl);
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index 9b0658803..17d4410cf 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -57,7 +57,7 @@ struct CmdVerify : StorePathsCommand
auto publicKeys = getDefaultPublicKeys();
- Activity act(*logger, actVerifyPaths);
+ Activity act(*logger, ActivityType::VerifyPaths);
std::atomic<size_t> done{0};
std::atomic<size_t> untrusted{0};
@@ -75,7 +75,7 @@ struct CmdVerify : StorePathsCommand
try {
checkInterrupt();
- Activity act2(*logger, lvlInfo, actUnknown, fmt("checking '%s'", storePath));
+ Activity act2(*logger, Verbosity::Info, ActivityType::Unknown, fmt("checking '%s'", storePath));
MaintainCount<std::atomic<size_t>> mcActive(active);
update();
@@ -96,7 +96,7 @@ struct CmdVerify : StorePathsCommand
if (hash.first != info->narHash) {
corrupted++;
- act2.result(resCorruptedPath, store->printStorePath(info->path));
+ act2.result(ResultType::CorruptedPath, store->printStorePath(info->path));
printError(
"path '%s' was modified! expected hash '%s', got '%s'",
store->printStorePath(info->path), info->narHash.to_string(), hash.first.to_string());
@@ -147,7 +147,7 @@ struct CmdVerify : StorePathsCommand
if (!good) {
untrusted++;
- act2.result(resUntrustedPath, store->printStorePath(info->path));
+ act2.result(ResultType::UntrustedPath, store->printStorePath(info->path));
printError("path '%s' is untrusted", store->printStorePath(info->path));
}