diff --git a/lix/legacy/nix-copy-closure.cc b/lix/legacy/nix-copy-closure.cc index 4f51b216a..b027b53fa 100644 --- a/lix/legacy/nix-copy-closure.cc +++ b/lix/legacy/nix-copy-closure.cc @@ -23,7 +23,7 @@ static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Str printVersion("nix-copy-closure"); else if (*arg == "--gzip" || *arg == "--bzip2" || *arg == "--xz") { if (*arg != "--gzip") - warn("'%1%' is not implemented, falling back to gzip", *arg); + printTaggedWarning("'%1%' is not implemented, falling back to gzip", *arg); gzip = true; } else if (*arg == "--from") toMode = false; diff --git a/lix/legacy/nix-env.cc b/lix/legacy/nix-env.cc index d6da555cb..531812b75 100644 --- a/lix/legacy/nix-env.cc +++ b/lix/legacy/nix-env.cc @@ -317,9 +317,9 @@ std::vector pickNewestOnly(EvalState & state, std::vector matches) matches.clear(); for (auto & [name, match] : newest) { if (multiple.find(name) != multiple.end()) - warn( - "there are multiple derivations named '%1%'; using the first one", - name); + printTaggedWarning( + "there are multiple derivations named '%1%'; using the first one", name + ); matches.push_back(match); } @@ -845,7 +845,7 @@ static void uninstallDerivations(Globals & globals, Strings & selectors, ); } if (split == workingElems.end()) - warn("selector '%s' matched no installed derivations", selector); + printTaggedWarning("selector '%s' matched no installed derivations", selector); for (auto removedElem = split; removedElem != workingElems.end(); removedElem++) { printInfo("uninstalling '%s'", removedElem->queryName(*state)); } diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index 7d101ff6e..515b7fae0 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -826,7 +826,7 @@ opVerify(std::shared_ptr store, AsyncIoRoot & aio, Strings opFlags, Strin else throw UsageError("unknown flag '%1%'", i); if (aio.blockOn(store->verifyStore(checkContents, repair))) { - warn("not all store errors were fixed"); + printTaggedWarning("not all store errors were fixed"); throw Exit(1); } } diff --git a/lix/libcmd/installables.cc b/lix/libcmd/installables.cc index aec13f4b6..a9fdf7748 100644 --- a/lix/libcmd/installables.cc +++ b/lix/libcmd/installables.cc @@ -61,7 +61,7 @@ MixFlakeOptions::MixFlakeOptions() .category = category, .handler = {[&]() { lockFlags.useRegistries = false; - warn("'--no-registries' is deprecated; use '--no-use-registries'"); + printTaggedWarning("'--no-registries' is deprecated; use '--no-use-registries'"); }} }); @@ -344,7 +344,7 @@ void completeFlakeRefWithFragment( } } } catch (Error & e) { - warn(e.msg()); + printTaggedWarning(e.msg()); } } diff --git a/lix/libcmd/repl-interacter.cc b/lix/libcmd/repl-interacter.cc index 677229ff6..8cf847082 100644 --- a/lix/libcmd/repl-interacter.cc +++ b/lix/libcmd/repl-interacter.cc @@ -244,8 +244,7 @@ void ReadlineLikeInteracter::writeHistory() // them so the user isn't confused why their history is getting eaten. std::string_view const errMsg(std::strerror(writeHistErr)); - warn("ignoring error writing repl history to %s: %s", this->historyFile, errMsg); - + printTaggedWarning("ignoring error writing repl history to %s: %s", this->historyFile, errMsg); } ReadlineLikeInteracter::~ReadlineLikeInteracter() diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 629aa5706..d372a373f 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -2591,7 +2591,7 @@ void Evaluator::maybePrintStats() // Make the final heap size more deterministic. #if HAVE_BOEHMGC if (!fullGC()) { - warn("failed to perform a full GC before reporting stats"); + printTaggedWarning("failed to perform a full GC before reporting stats"); } #endif printStatistics(); diff --git a/lix/libexpr/flake/config.cc b/lix/libexpr/flake/config.cc index 9ef84c6c8..6e72e8514 100644 --- a/lix/libexpr/flake/config.cc +++ b/lix/libexpr/flake/config.cc @@ -41,14 +41,24 @@ static bool askForSetting( auto reply = logger->ask(fmt("Do you want to allow configuration setting '%s' to be set to '" ANSI_RED "%s" ANSI_NORMAL "'?\nThis may allow the flake to gain root, see the nix.conf manual page (" ANSI_BOLD "y" ANSI_NORMAL "es/" ANSI_BOLD "n" ANSI_NORMAL "o/" ANSI_BOLD "N" ANSI_NORMAL "o to all) ", name, valueS)).value_or('n'); if (reply == 'N') { - warn("Rejecting all untrusted nix.conf entries"); - warn("you can set '%s' to '%b' to automatically reject configuration options supplied by flakes", "accept-flake-config", false); + printTaggedWarning("Rejecting all untrusted nix.conf entries"); + printTaggedWarning( + "you can set '%s' to '%b' to automatically reject configuration options supplied by " + "flakes", + "accept-flake-config", + false + ); negativeTrustOverride = true; } else { if (std::tolower(reply) == 'y') { trusted = true; } else { - warn("you can set '%s' to '%b' to automatically reject configuration options supplied by flakes", "accept-flake-config", false); + printTaggedWarning( + "you can set '%s' to '%b' to automatically reject configuration options supplied " + "by flakes", + "accept-flake-config", + false + ); } if (std::tolower(logger->ask(fmt("do you want to permanently (in %s) mark this value as %s? (y/N) ", trustedListPath(), trusted ? "trusted": "untrusted" )).value_or('n')) == 'y') { @@ -117,7 +127,12 @@ void ConfigFile::apply() debug("accepting trusted flake configuration setting '%s'", name); globalConfig.set(name, valueS); } else { - warn("ignoring untrusted flake configuration setting '%s', pass '%s' to trust it (may allow the flake to gain root, see the nix.conf manual page)", name, "--accept-flake-config"); + printTaggedWarning( + "ignoring untrusted flake configuration setting '%s', pass '%s' to trust it (may " + "allow the flake to gain root, see the nix.conf manual page)", + name, + "--accept-flake-config" + ); } } } diff --git a/lix/libexpr/flake/flake.cc b/lix/libexpr/flake/flake.cc index c1ca54fcd..374852607 100644 --- a/lix/libexpr/flake/flake.cc +++ b/lix/libexpr/flake/flake.cc @@ -555,9 +555,11 @@ LockedFlake lockFlake( auto follow = inputPath2.back(); inputPath2.pop_back(); if (inputPath2 == inputPathPrefix && !flakeInputs.count(follow)) - warn( + printTaggedWarning( "input '%s' has an override for a non-existent input '%s'", - printInputPath(inputPathPrefix), follow); + printInputPath(inputPathPrefix), + follow + ); } /* Go over the flake inputs, resolve/fetch them if @@ -768,12 +770,17 @@ LockedFlake lockFlake( for (auto & i : lockFlags.inputOverrides) if (!overridesUsed.count(i.first)) - warn("the flag '--override-input %s %s' does not match any input", - printInputPath(i.first), i.second); + printTaggedWarning( + "the flag '--override-input %s %s' does not match any input", + printInputPath(i.first), + i.second + ); for (auto & i : lockFlags.inputUpdates) if (!updatesUsed.count(i)) - warn("'%s' does not match any input of this flake", printInputPath(i)); + printTaggedWarning( + "'%s' does not match any input of this flake", printInputPath(i) + ); /* Check 'follows' inputs. */ newLockFile.check(); @@ -791,7 +798,12 @@ LockedFlake lockFlake( if (sourcePath || lockFlags.outputLockFilePath) { if (auto unlockedInput = newLockFile.isUnlocked()) { if (fetchSettings.warnDirty) - warn("will not write lock file of flake '%s' because it has an unlocked input ('%s')", topRef, *unlockedInput); + printTaggedWarning( + "will not write lock file of flake '%s' because it has an unlocked " + "input ('%s')", + topRef, + *unlockedInput + ); } else { if (!lockFlags.updateLockFile) throw Error("flake '%s' requires lock file changes but they're not allowed due to '--no-update-lock-file'", topRef); @@ -811,11 +823,19 @@ LockedFlake lockFlake( auto s = chomp(diff); if (lockFileExists) { if (s.empty()) - warn("updating lock file '%s'", outputLockFilePath); + printTaggedWarning( + "updating lock file '%s'", outputLockFilePath + ); else - warn("updating lock file '%s':\n%s", outputLockFilePath, Uncolored(s)); + printTaggedWarning( + "updating lock file '%s':\n%s", + outputLockFilePath, + Uncolored(s) + ); } else - warn("creating lock file '%s':\n%s", outputLockFilePath, Uncolored(s)); + printTaggedWarning( + "creating lock file '%s':\n%s", outputLockFilePath, Uncolored(s) + ); std::optional commitMessage = std::nullopt; @@ -848,7 +868,10 @@ LockedFlake lockFlake( if (lockFlags.commitLockFile && flake.lockedRef.input.getRev() && prevLockedRef.input.getRev() != flake.lockedRef.input.getRev()) - warn("committed new revision '%s'", flake.lockedRef.input.getRev()->gitRev()); + printTaggedWarning( + "committed new revision '%s'", + flake.lockedRef.input.getRev()->gitRev() + ); /* Make sure that we picked up the change, i.e. the tree should usually be dirty @@ -861,7 +884,9 @@ LockedFlake lockFlake( } else throw Error("cannot write modified lock file of flake '%s' (use '--no-write-lock-file' to ignore)", topRef); } else { - warn("not writing modified lock file of flake '%s':\n%s", topRef, chomp(diff)); + printTaggedWarning( + "not writing modified lock file of flake '%s':\n%s", topRef, chomp(diff) + ); flake.forceDirty = true; } } diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index eace29779..6d66877e5 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -906,18 +906,47 @@ drvName, Bindings * attrs, Value & v) } if (i->name == state.ctx.s.allowedReferences) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'allowedReferences'; use 'outputChecks..allowedReferences' instead", drvName); + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'allowedReferences'; use " + "'outputChecks..allowedReferences' instead", + drvName + ); if (i->name == state.ctx.s.allowedRequisites) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'allowedRequisites'; use 'outputChecks..allowedRequisites' instead", drvName); + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'allowedRequisites'; use " + "'outputChecks..allowedRequisites' instead", + drvName + ); if (i->name == state.ctx.s.disallowedReferences) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedReferences'; use 'outputChecks..disallowedReferences' instead", drvName); + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'disallowedReferences'; use " + "'outputChecks..disallowedReferences' instead", + drvName + ); if (i->name == state.ctx.s.disallowedRequisites) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedRequisites'; use 'outputChecks..disallowedRequisites' instead", drvName); + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'disallowedRequisites'; use " + "'outputChecks..disallowedRequisites' instead", + drvName + ); if (i->name == state.ctx.s.maxSize) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'maxSize'; use 'outputChecks..maxSize' instead", drvName); + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'maxSize'; use " + "'outputChecks..maxSize' instead", + drvName + ); if (i->name == state.ctx.s.maxClosureSize) - warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'maxClosureSize'; use 'outputChecks..maxClosureSize' instead", drvName); - + printTaggedWarning( + "In a derivation named '%s', 'structuredAttrs' disables the effect of " + "the derivation attribute 'maxClosureSize'; use " + "'outputChecks..maxClosureSize' instead", + drvName + ); } else { auto s = state.coerceToString(noPos, *i->value, context, context_below, StringCoercionMode::ToString).toOwned(); diff --git a/lix/libfetchers/cache.cc b/lix/libfetchers/cache.cc index aeded40da..9166282b7 100644 --- a/lix/libfetchers/cache.cc +++ b/lix/libfetchers/cache.cc @@ -45,7 +45,7 @@ struct CacheImpl : Cache try { createDirs(dirOf(dbPath)); } catch (SysError const & ex) { - warn("ignoring error initializing Lix fetcher cache: %s", ex.what()); + printTaggedWarning("ignoring error initializing Lix fetcher cache: %s", ex.what()); dbPath = ":memory:"; } diff --git a/lix/libfetchers/git.cc b/lix/libfetchers/git.cc index 118619c23..8af3407cb 100644 --- a/lix/libfetchers/git.cc +++ b/lix/libfetchers/git.cc @@ -134,7 +134,11 @@ std::optional readHeadCached(const std::string & actualUrl) // fails, it falls back to continuing with the most recent version. // This function must behave the same way, so we return the expired // cached ref here. - warn("could not get HEAD ref for repository '%s'; using expired cached ref '%s'", actualUrl, *cachedRef); + printTaggedWarning( + "could not get HEAD ref for repository '%s'; using expired cached ref '%s'", + actualUrl, + *cachedRef + ); return cachedRef; } @@ -225,8 +229,9 @@ try { if (!fetchSettings.allowDirty) throw Error("Git tree '%s' is dirty", workdir); - if (fetchSettings.warnDirty) - warn("Git tree '%s' is dirty", workdir); + if (fetchSettings.warnDirty) { + printTaggedWarning("Git tree '%s' is dirty", workdir); + } auto gitOpts = Strings({ "-C", workdir, "--git-dir", gitDir, "ls-files", "-z" }); if (submodules) @@ -544,7 +549,9 @@ struct GitInputScheme : InputScheme if (!input.getRef()) { auto head = readHead(actualUrl); if (!head) { - warn("could not read HEAD ref from repo at '%s', using 'master'", actualUrl); + printTaggedWarning( + "could not read HEAD ref from repo at '%s', using 'master'", actualUrl + ); head = "master"; } input.attrs.insert_or_assign("ref", *head); @@ -561,7 +568,9 @@ struct GitInputScheme : InputScheme if (useHeadRef) { auto head = readHeadCached(actualUrl); if (!head) { - warn("could not read HEAD ref from repo at '%s', using 'master'", actualUrl); + printTaggedWarning( + "could not read HEAD ref from repo at '%s', using 'master'", actualUrl + ); head = "master"; } input.attrs.insert_or_assign("ref", *head); @@ -685,13 +694,21 @@ struct GitInputScheme : InputScheme }, true); } catch (Error & e) { if (!pathExists(localRefFile)) throw; - warn("could not update local clone of Git repository '%s'; continuing with the most recent version", actualUrl); + printTaggedWarning( + "could not update local clone of Git repository '%s'; continuing with the " + "most recent version", + actualUrl + ); } if (!touchCacheFile(localRefFile, now)) - warn("could not update mtime for file '%s': %s", localRefFile, strerror(errno)); + printTaggedWarning( + "could not update mtime for file '%s': %s", localRefFile, strerror(errno) + ); if (useHeadRef && !storeCachedHead(actualUrl, *input.getRef())) - warn("could not update cached head '%s' for '%s'", *input.getRef(), actualUrl); + printTaggedWarning( + "could not update cached head '%s' for '%s'", *input.getRef(), actualUrl + ); } if (!input.getRev()) diff --git a/lix/libfetchers/github.cc b/lix/libfetchers/github.cc index c8402b80e..7623c1e0e 100644 --- a/lix/libfetchers/github.cc +++ b/lix/libfetchers/github.cc @@ -200,7 +200,7 @@ struct GitArchiveInputScheme : InputScheme if (hdr) headers.push_back(*hdr); else - warn("Unrecognized access token for host '%s'", host); + printTaggedWarning("Unrecognized access token for host '%s'", host); } return headers; } @@ -345,7 +345,7 @@ struct GitLabInputScheme : GitArchiveInputScheme return std::make_pair("Authorization", fmt("Bearer %s", token.substr(fldsplit+1))); if ("PAT" == token.substr(0, fldsplit)) return std::make_pair("Private-token", token.substr(fldsplit+1)); - warn("Unrecognized GitLab token type %s", token.substr(0, fldsplit)); + printTaggedWarning("Unrecognized GitLab token type %s", token.substr(0, fldsplit)); return std::make_pair(token.substr(0,fldsplit), token.substr(fldsplit+1)); } diff --git a/lix/libfetchers/mercurial.cc b/lix/libfetchers/mercurial.cc index 72300ca52..09c8ece12 100644 --- a/lix/libfetchers/mercurial.cc +++ b/lix/libfetchers/mercurial.cc @@ -185,7 +185,7 @@ struct MercurialInputScheme : InputScheme throw Error("Mercurial tree '%s' is unclean", actualUrl); if (fetchSettings.warnDirty) - warn("Mercurial tree '%s' is unclean", actualUrl); + printTaggedWarning("Mercurial tree '%s' is unclean", actualUrl); input.attrs.insert_or_assign("ref", chomp(runHg({ "branch", "-R", actualUrl }))); diff --git a/lix/libfetchers/registry.cc b/lix/libfetchers/registry.cc index 333959ea7..43df347cf 100644 --- a/lix/libfetchers/registry.cc +++ b/lix/libfetchers/registry.cc @@ -23,7 +23,7 @@ std::shared_ptr Registry::read( if (!pathExists(path)) { if (type == RegistryType::Global) { - warn("cannot read flake registry '%s': path does not exist", path); + printTaggedWarning("cannot read flake registry '%s': path does not exist", path); } return std::make_shared(type); } @@ -58,7 +58,7 @@ std::shared_ptr Registry::read( throw Error("flake registry '%s' has unsupported version %d", path, version); } catch (Error & e) { - warn("cannot read flake registry '%s': %s", path, e.what()); + printTaggedWarning("cannot read flake registry '%s': %s", path, e.what()); } return registry; @@ -170,7 +170,7 @@ try { *lk = Registry::read(settings.nixDataDir + "/flake-registry.json", Registry::Global); } else { if (!path.starts_with("/")) { - warn( + printTaggedWarning( "config option flake-registry referring to a URL is deprecated and will be " "removed in Lix 3.0; yours is: `%s'", path diff --git a/lix/libfetchers/tarball.cc b/lix/libfetchers/tarball.cc index 743c44468..ece4116e8 100644 --- a/lix/libfetchers/tarball.cc +++ b/lix/libfetchers/tarball.cc @@ -90,7 +90,7 @@ try { data = TRY_AWAIT(content->drain()); } catch (FileTransferError & e) { if (cached) { - warn("%s; using cached version", e.msg()); + printTaggedWarning("%s; using cached version", e.msg()); co_return useCached(); } else throw; diff --git a/lix/libmain/common-args.cc b/lix/libmain/common-args.cc index f9b60d4b3..a24a87f82 100644 --- a/lix/libmain/common-args.cc +++ b/lix/libmain/common-args.cc @@ -41,8 +41,9 @@ MixCommonArgs::MixCommonArgs(const std::string & programName) try { globalConfig.set(name, value); } catch (UsageError & e) { - if (!getRoot().completions) - warn(e.what()); + if (!getRoot().completions) { + printTaggedWarning(e.what()); + } } }}, .completer = [](AddCompletions & completions, size_t index, std::string_view prefix) { diff --git a/lix/libmain/shared.cc b/lix/libmain/shared.cc index ef197502e..6afd219d0 100644 --- a/lix/libmain/shared.cc +++ b/lix/libmain/shared.cc @@ -41,7 +41,7 @@ void printGCWarning() static bool haveWarned = false; if (!haveWarned) { haveWarned = true; - warn( + printTaggedWarning( "you did not specify '--add-root'; " "the result might be removed by the garbage collector" ); diff --git a/lix/libstore/binary-cache-store.cc b/lix/libstore/binary-cache-store.cc index 88ef9fee6..f77d191d8 100644 --- a/lix/libstore/binary-cache-store.cc +++ b/lix/libstore/binary-cache-store.cc @@ -208,7 +208,7 @@ try { // instead. // NOLINTNEXTLINE(lix-foreign-exceptions): see above } catch (JSON::exception & exc) { - warn( + printTaggedWarning( "Skipping NAR listing for path '%1%' due to serialization failure: %2%", printStorePath(narInfo->path), exc.what() diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index d65fc7af3..b92fac2ba 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -470,7 +470,7 @@ try { auto nixBuildsTmp = createTempDir( globalTmp, fmt("nix-builds-%s", geteuid()), false, false, toplevelDirMode ); - warn( + printTaggedWarning( "Failed to use the system-wide build directory '%s', falling back to a temporary " "directory inside '%s'", settings.buildDir.get(), @@ -949,7 +949,7 @@ void LocalDerivationGoal::setupConfiguredCertificateAuthority() if (std::find(impureVars.begin(), impureVars.end(), "NIX_SSL_CERT_FILE") != impureVars.end() && env["NIX_SSL_CERT_FILE"] != settings.caFile) { - warn( + printTaggedWarning( "'NIX_SSL_CERT_FILE' is an impure environment variable of this " "derivation but a *DIFFERENT* `ssl-cert-file` was set in the settings " "which takes precedence.\n" @@ -975,7 +975,7 @@ void LocalDerivationGoal::setupConfiguredCertificateAuthority() } else if (pathExists(settings.caFile)) { // The path exist but we were not able to access it. This is not a fatal // error, warn about this so the user can remediate. - warn( + printTaggedWarning( "Configured certificate authority '%1' exists but is inaccessible, it " "will not be copied in the sandbox. TLS operations inside the sandbox may " "be non-functional.", @@ -1242,7 +1242,7 @@ void LocalDerivationGoal::runChild() } else if (pathExists(path)) { // The path exist but we were not able to access it. This is not a fatal // error, warn about this so the user can remediate. - warn( + printTaggedWarning( "'%1%' exists but is inaccessible, it will not be copied in the " "sandbox", path @@ -1255,7 +1255,7 @@ void LocalDerivationGoal::runChild() } else if (pathExists("/etc/resolv.conf")) { // The path exist but we were not able to access it. This is not a fatal error, // warn about this so the user can remediate. - warn( + printTaggedWarning( "'/etc/resolv.conf' exists but is inaccessible, it will not be rewritten " "inside the sandbox; DNS operations inside the sandbox may be " "non-functional." @@ -2461,22 +2461,40 @@ try { if (auto structuredAttrs = parsedDrv->getStructuredAttrs()) { if (get(*structuredAttrs, "allowedReferences")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'allowedReferences'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute " + "'allowedReferences'; use 'outputChecks' instead" + ); } if (get(*structuredAttrs, "allowedRequisites")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'allowedRequisites'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute " + "'allowedRequisites'; use 'outputChecks' instead" + ); } if (get(*structuredAttrs, "disallowedRequisites")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'disallowedRequisites'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute " + "'disallowedRequisites'; use 'outputChecks' instead" + ); } if (get(*structuredAttrs, "disallowedReferences")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'disallowedReferences'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute " + "'disallowedReferences'; use 'outputChecks' instead" + ); } if (get(*structuredAttrs, "maxSize")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'maxSize'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute 'maxSize'; " + "use 'outputChecks' instead" + ); } if (get(*structuredAttrs, "maxClosureSize")){ - warn("'structuredAttrs' disables the effect of the top-level attribute 'maxClosureSize'; use 'outputChecks' instead"); + printTaggedWarning( + "'structuredAttrs' disables the effect of the top-level attribute " + "'maxClosureSize'; use 'outputChecks' instead" + ); } if (auto outputChecks = get(*structuredAttrs, "outputChecks")) { if (auto output = get(*outputChecks, outputName)) { diff --git a/lix/libstore/build/substitution-goal.cc b/lix/libstore/build/substitution-goal.cc index ee0846493..7b5e61ff0 100644 --- a/lix/libstore/build/substitution-goal.cc +++ b/lix/libstore/build/substitution-goal.cc @@ -153,8 +153,12 @@ try { only after we've downloaded the path. */ if (!sub->config().isTrusted && worker.store.pathInfoIsUntrusted(*info)) { - warn("ignoring substitute for '%s' from '%s', as it's not signed by any of the keys in 'trusted-public-keys'", - worker.store.printStorePath(storePath), sub->getUri()); + printTaggedWarning( + "ignoring substitute for '%s' from '%s', as it's not signed by any of the keys in " + "'trusted-public-keys'", + worker.store.printStorePath(storePath), + sub->getUri() + ); co_return co_await tryNext(); } diff --git a/lix/libstore/builtins/buildenv.cc b/lix/libstore/builtins/buildenv.cc index 2d6cac388..75e1fe69a 100644 --- a/lix/libstore/builtins/buildenv.cc +++ b/lix/libstore/builtins/buildenv.cc @@ -23,7 +23,9 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir, srcFiles = readDirectory(srcDir); } catch (SysError & e) { if (e.errNo == ENOTDIR) { - warn("not including '%s' in the user environment because it's not a directory", srcDir); + printTaggedWarning( + "not including '%s' in the user environment because it's not a directory", srcDir + ); return; } throw; @@ -42,7 +44,7 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir, throw SysError("getting status of '%1%'", srcFile); } catch (SysError & e) { if (e.errNo == ENOENT || e.errNo == ENOTDIR) { - warn("skipping dangling symlink '%s'", dstFile); + printTaggedWarning("skipping dangling symlink '%s'", dstFile); continue; } throw; diff --git a/lix/libstore/daemon.cc b/lix/libstore/daemon.cc index e5a133d26..422af163b 100644 --- a/lix/libstore/daemon.cc +++ b/lix/libstore/daemon.cc @@ -200,8 +200,12 @@ struct ClientSettings else if (!s.ends_with("/") && trusted.count(s + "/")) subs.push_back(s + "/"); else - warn("ignoring untrusted substituter '%s', you are not a trusted user.\n" - "Run `man nix.conf` for more information on the `substituters` configuration option.", s); + printTaggedWarning( + "ignoring untrusted substituter '%s', you are not a trusted user.\n" + "Run `man nix.conf` for more information on the `substituters` " + "configuration option.", + s + ); res.override(subs); return true; }; @@ -217,8 +221,11 @@ struct ClientSettings debug("Ignoring the client-specified experimental features"); } else if (name == settings.pluginFiles.name) { if (tokenizeString(value) != settings.pluginFiles.get()) - warn("Ignoring the client-specified plugin-files.\n" - "The client specifying plugins to the daemon never made sense, and was removed in Nix."); + printTaggedWarning( + "Ignoring the client-specified plugin-files.\n" + "The client specifying plugins to the daemon never made sense, and was " + "removed in Nix." + ); } else if (trusted || name == settings.buildTimeout.name || name == settings.maxSilentTime.name || name == settings.pollInterval.name @@ -230,9 +237,13 @@ struct ClientSettings } else if (setSubstituters(settings.substituters)) ; else - warn("Ignoring the client-specified setting '%s', because it is a restricted setting and you are not a trusted user", name); + printTaggedWarning( + "Ignoring the client-specified setting '%s', because it is a restricted " + "setting and you are not a trusted user", + name + ); } catch (UsageError & e) { - warn(e.what()); + printTaggedWarning(e.what()); } } } diff --git a/lix/libstore/filetransfer.cc b/lix/libstore/filetransfer.cc index e4134f934..21db2d2f7 100644 --- a/lix/libstore/filetransfer.cc +++ b/lix/libstore/filetransfer.cc @@ -1037,7 +1037,7 @@ struct curlFileTransfer : public FileTransfer ) try { if (totalReceived) { - warn( + printTaggedWarning( "%s; retrying from offset %d in %d ms (attempt %d/%d)", context, totalReceived, @@ -1046,7 +1046,9 @@ struct curlFileTransfer : public FileTransfer tries ); } else { - warn("%s; retrying in %d ms (attempt %d/%d)", context, waitTime, attempt, tries); + printTaggedWarning( + "%s; retrying in %d ms (attempt %d/%d)", context, waitTime, attempt, tries + ); } co_await AIO().provider.getTimer().afterDelay(waitTime.count() * kj::MILLISECONDS); diff --git a/lix/libstore/globals.cc b/lix/libstore/globals.cc index d23147b09..ad9c7435e 100644 --- a/lix/libstore/globals.cc +++ b/lix/libstore/globals.cc @@ -386,7 +386,9 @@ void initPlugins() // inaccessible, since it is *already* the case that plugins // are not guaranteed to load due to version mismatches etc // causing dlopen failures. - warn("could not access plugin file '%s', skipping it: %s", pluginFile, e.msg()); + printTaggedWarning( + "could not access plugin file '%s', skipping it: %s", pluginFile, e.msg() + ); continue; } pluginFiles.emplace_back(pluginFile); @@ -397,7 +399,9 @@ void initPlugins() void *handle = dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL); if (!handle) { - warn("could not dynamically open plugin file '%s', skipping it: %s", file, dlerror()); + printTaggedWarning( + "could not dynamically open plugin file '%s', skipping it: %s", file, dlerror() + ); continue; } @@ -447,8 +451,7 @@ static void preloadNSS() * * All other platforms are unaffected. */ - if (!dlopen(LIBNSS_DNS_SO, RTLD_NOW)) - warn("unable to load nss_dns backend"); + if (!dlopen(LIBNSS_DNS_SO, RTLD_NOW)) printTaggedWarning("unable to load nss_dns backend"); // FIXME: get hosts entry from nsswitch.conf. __nss_configure_lookup("hosts", "files dns"); #endif diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index dcb6754d6..057407ea4 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1576,7 +1576,7 @@ try { if (TRY_AWAIT(isValidPath(i))) logError(caught->info()); else - warn(caught->msg()); + printTaggedWarning(caught->msg()); errors = true; } } diff --git a/lix/libstore/optimise-store.cc b/lix/libstore/optimise-store.cc index d34f08441..1544bac4f 100644 --- a/lix/libstore/optimise-store.cc +++ b/lix/libstore/optimise-store.cc @@ -130,7 +130,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats, NixOS (example: $fontconfig/var/cache being modified). Skip those files. FIXME: check the modification time. */ if (S_ISREG(st.st_mode) && (st.st_mode & S_IWUSR)) { - warn("skipping suspicious writable file '%1%'", path); + printTaggedWarning("skipping suspicious writable file '%1%'", path); return; } @@ -162,9 +162,11 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats, || (repair && hash != hashPath(HashType::SHA256, linkPath).first)) { // XXX: Consider overwriting linkPath with our valid version. - warn("removing corrupted link '%s'", linkPath); - warn("There may be more corrupted paths." - "\nYou should run `nix-store --verify --check-contents --repair` to fix them all"); + printTaggedWarning("removing corrupted link '%s'", linkPath); + printTaggedWarning( + "There may be more corrupted paths." + "\nYou should run `nix-store --verify --check-contents --repair` to fix them all" + ); if (unlink(linkPath.c_str()) == -1 && errno != ENOENT) throw SysError("cannot unlink '%1%'", linkPath); stLinkOpt.reset(); diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index 32681f21c..8607a4945 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -1383,7 +1383,11 @@ openFromNonUri(const std::string & uri, const StoreConfig::Params & params, Allo } catch (Error & e) { return LocalStore::makeLocalStore(params); } - warn("'%s' does not exist, so Lix will use '%s' as a chroot store", stateDir, chrootStore); + printTaggedWarning( + "'%s' does not exist, so Lix will use '%s' as a chroot store", + stateDir, + chrootStore + ); } else debug("'%s' does not exist, so Lix will use '%s' as a chroot store", stateDir, chrootStore); StoreConfig::Params chrootStoreParams; diff --git a/lix/libutil/cgroup.cc b/lix/libutil/cgroup.cc index dd4288b59..4f34940ce 100644 --- a/lix/libutil/cgroup.cc +++ b/lix/libutil/cgroup.cc @@ -351,7 +351,7 @@ void AutoDestroyCgroup::destroy() [&, this](const Path & aliveCgroup) { auto maybeStats = destroyCgroup(name_, aliveCgroup); if (!maybeStats) { - warn( + printTaggedWarning( "cgroup '%s' was destroyed unexpectedly (something else removed the " "cgroup).", aliveCgroup @@ -390,7 +390,7 @@ void AutoDestroyCgroup::cleansePreviousInstancesAndRecordOurself( if (pathExists(cgroupFile)) { auto prevCgroup = readFile(cgroupFile); - warn("destroying past cgroup '%s' found in the state directory", name_); + printTaggedWarning("destroying past cgroup '%s' found in the state directory", name_); destroyCgroup(fmt("past %s", name_), prevCgroup); } diff --git a/lix/libutil/compression.cc b/lix/libutil/compression.cc index 89ad2b444..614ee982c 100644 --- a/lix/libutil/compression.cc +++ b/lix/libutil/compression.cc @@ -149,7 +149,9 @@ struct NoneSink : CompressionSink NoneSink(Sink & nextSink, int level = COMPRESSION_LEVEL_DEFAULT) : nextSink(nextSink) { if (level != COMPRESSION_LEVEL_DEFAULT) - warn("requested compression level '%d' not supported by compression method 'none'", level); + printTaggedWarning( + "requested compression level '%d' not supported by compression method 'none'", level + ); } void finish() override { flush(); } void writeUnbuffered(std::string_view data) override { nextSink(data); } diff --git a/lix/libutil/config-impl.hh b/lix/libutil/config-impl.hh index 449050bd2..9cdc5964b 100644 --- a/lix/libutil/config-impl.hh +++ b/lix/libutil/config-impl.hh @@ -74,15 +74,17 @@ void BaseSetting::set(const std::string & str, bool append, const ApplyConfig if (experimentalFeatureSettings.isEnabled(experimentalFeature)) { auto parsed = parse(str, options); if (deprecated && (append || parsed != value)) { - warn("deprecated setting '%s' found (set to '%s')", name, str); + printTaggedWarning("deprecated setting '%s' found (set to '%s')", name, str); } overridden = true; appendOrSet(std::move(parsed), append, options); } else { assert(experimentalFeature); - warn("Ignoring setting '%s' because experimental feature '%s' is not enabled", + printTaggedWarning( + "Ignoring setting '%s' because experimental feature '%s' is not enabled", name, - showExperimentalFeature(*experimentalFeature)); + showExperimentalFeature(*experimentalFeature) + ); } } diff --git a/lix/libutil/config.cc b/lix/libutil/config.cc index 22fcbc509..2489d5573 100644 --- a/lix/libutil/config.cc +++ b/lix/libutil/config.cc @@ -52,8 +52,11 @@ void Config::addSetting(AbstractSetting * setting) for (auto & alias : setting->aliases) { if (auto i = unknownSettings.find(alias); i != unknownSettings.end()) { if (set) - warn("setting '%s' is set, but it's an alias of '%s' which is also set", - alias, setting->name); + printTaggedWarning( + "setting '%s' is set, but it's an alias of '%s' which is also set", + alias, + setting->name + ); else { setting->set(std::move(i->second)); unknownSettings.erase(i); @@ -70,7 +73,7 @@ AbstractConfig::AbstractConfig(StringMap initials) void AbstractConfig::warnUnknownSettings() { for (const auto & s : unknownSettings) - warn("unknown setting '%s'", s.first); + printTaggedWarning("unknown setting '%s'", s.first); } void AbstractConfig::reapplyUnknownSettings() @@ -349,7 +352,7 @@ template<> ExperimentalFeatures BaseSetting::parse(const s if (auto thisXpFeature = parseExperimentalFeature(s); thisXpFeature) { res = res | thisXpFeature.value(); } else - warn("unknown experimental feature '%s'", s); + printTaggedWarning("unknown experimental feature '%s'", s); } return res; } @@ -378,7 +381,7 @@ template<> DeprecatedFeatures BaseSetting::parse(const std:: if (auto thisDpFeature = parseDeprecatedFeature(s); thisDpFeature) res = res | thisDpFeature.value(); else - warn("unknown deprecated feature '%s'", s); + printTaggedWarning("unknown deprecated feature '%s'", s); } return res; } diff --git a/lix/libutil/file-system.cc b/lix/libutil/file-system.cc index 60f2e91ff..6f0580062 100644 --- a/lix/libutil/file-system.cc +++ b/lix/libutil/file-system.cc @@ -794,7 +794,7 @@ void moveFile(const Path & oldName, const Path & newName) auto tempCopyTarget = temp / "copy-target"; if (e.code().value() == EXDEV) { fs::remove(newPath); - warn("Can’t rename %s as %s, copying instead", oldName, newName); + printTaggedWarning("Can’t rename %s as %s, copying instead", oldName, newName); copy(fs::directory_entry(oldPath), tempCopyTarget, { .deleteAfter = true }); renameFile(tempCopyTarget, newPath); } diff --git a/lix/libutil/hash.cc b/lix/libutil/hash.cc index d4771a177..d1aff4535 100644 --- a/lix/libutil/hash.cc +++ b/lix/libutil/hash.cc @@ -265,7 +265,7 @@ Hash newHashAllowEmpty(std::string_view hashStr, std::optional ht) if (!ht) throw BadHash("empty hash requires explicit hash type"); Hash h(*ht); - warn("found empty hash, assuming '%s'", h.to_string(Base::SRI, true)); + printTaggedWarning("found empty hash, assuming '%s'", h.to_string(Base::SRI, true)); return h; } else return Hash::parseAny(hashStr, ht); diff --git a/lix/libutil/logging.cc b/lix/libutil/logging.cc index 3e3ed3548..e2f3fcd69 100644 --- a/lix/libutil/logging.cc +++ b/lix/libutil/logging.cc @@ -305,10 +305,8 @@ bool handleJSONLogMessage(JSON & json, return true; } catch (JSON::exception &e) { // NOLINT(lix-foreign-exceptions) - warn( - "Unable to handle a JSON message from %s: %s", - Uncolored(source), - e.what() + printTaggedWarning( + "Unable to handle a JSON message from %s: %s", Uncolored(source), e.what() ); return false; } diff --git a/lix/libutil/logging.hh b/lix/libutil/logging.hh index 4ebccb02d..c157a6d2c 100644 --- a/lix/libutil/logging.hh +++ b/lix/libutil/logging.hh @@ -266,6 +266,7 @@ extern Verbosity verbosity; } while (0) #define printMsg(level, args...) printMsgUsing(::nix::logger, level, args) +#define printWarning(args...) printMsg(::nix::lvlWarn, args) #define printError(args...) printMsg(::nix::lvlError, args) #define notice(args...) printMsg(::nix::lvlNotice, args) #define printInfo(args...) printMsg(::nix::lvlInfo, args) @@ -273,16 +274,8 @@ extern Verbosity verbosity; #define debug(args...) printMsg(::nix::lvlDebug, args) #define vomit(args...) printMsg(::nix::lvlVomit, args) -/** - * if verbosity >= lvlWarn, print a message with a yellow 'warning:' prefix. - */ -template -inline void warn(const std::string & fs, const Args &... args) -{ - logger->log( - lvlWarn, fmt(ANSI_WARNING "warning:" ANSI_NORMAL " %1%", HintFmt(fs, args...).str()) - ); -} +#define printTaggedWarning(args...) \ + printWarning(ANSI_WARNING "warning:" ANSI_NORMAL " %1%", ::nix::HintFmt(args).str()) void writeLogsToStderr(std::string_view s); diff --git a/lix/libutil/namespaces.cc b/lix/libutil/namespaces.cc index f90368164..fbd285000 100644 --- a/lix/libutil/namespaces.cc +++ b/lix/libutil/namespaces.cc @@ -71,21 +71,29 @@ void unshareFilesystem() static void diagnoseUserNamespaces() { if (!pathExists("/proc/self/ns/user")) { - warn("'/proc/self/ns/user' does not exist; your kernel was likely built without CONFIG_USER_NS=y"); + printTaggedWarning( + "'/proc/self/ns/user' does not exist; your kernel was likely built without " + "CONFIG_USER_NS=y" + ); } Path maxUserNamespaces = "/proc/sys/user/max_user_namespaces"; if (!pathExists(maxUserNamespaces) || trim(readFile(maxUserNamespaces)) == "0") { - warn("user namespaces appear to be disabled; check '/proc/sys/user/max_user_namespaces'"); + printTaggedWarning( + "user namespaces appear to be disabled; check '/proc/sys/user/max_user_namespaces'" + ); } Path procSysKernelUnprivilegedUsernsClone = "/proc/sys/kernel/unprivileged_userns_clone"; if (pathExists(procSysKernelUnprivilegedUsernsClone) && trim(readFile(procSysKernelUnprivilegedUsernsClone)) == "0") { - warn("user namespaces appear to be disabled for unprivileged users; check '/proc/sys/kernel/unprivileged_userns_clone'"); + printTaggedWarning( + "user namespaces appear to be disabled for unprivileged users; check " + "'/proc/sys/kernel/unprivileged_userns_clone'" + ); } } @@ -99,7 +107,7 @@ bool userNamespacesSupported() auto r = pid.wait(); assert(!r); } catch (SysError & e) { - warn("user namespaces do not work on this system: %s", e.msg()); + printTaggedWarning("user namespaces do not work on this system: %s", e.msg()); diagnoseUserNamespaces(); return false; } diff --git a/lix/libutil/tarfile.cc b/lix/libutil/tarfile.cc index 74e5c05f9..c83e5dd74 100644 --- a/lix/libutil/tarfile.cc +++ b/lix/libutil/tarfile.cc @@ -94,7 +94,7 @@ static void extract_archive(TarArchive & archive, const Path & destDir) if (!name) throw Error("cannot get archive member name: %s", archive_error_string(archive.archive)); if (r == ARCHIVE_WARN) - warn(archive_error_string(archive.archive)); + printTaggedWarning(archive_error_string(archive.archive)); else archive.check(r); diff --git a/lix/libutil/users.cc b/lix/libutil/users.cc index 83490f30e..af4a9d1ce 100644 --- a/lix/libutil/users.cc +++ b/lix/libutil/users.cc @@ -41,7 +41,12 @@ Path getHome() int result = stat(homeDir->c_str(), &st); if (result != 0) { if (errno != ENOENT) { - warn("couldn't stat $HOME ('%s') for reason other than not existing ('%d'), falling back to the one defined in the 'passwd' file", *homeDir, errno); + printTaggedWarning( + "couldn't stat $HOME ('%s') for reason other than not existing ('%d'), " + "falling back to the one defined in the 'passwd' file", + *homeDir, + errno + ); homeDir.reset(); } } else if (st.st_uid != geteuid()) { @@ -51,7 +56,12 @@ Path getHome() if (!homeDir) { homeDir = getHomeOf(geteuid()); if (unownedUserHomeDir.has_value() && unownedUserHomeDir != homeDir) { - warn("$HOME ('%s') is not owned by you, falling back to the one defined in the 'passwd' file ('%s')", *unownedUserHomeDir, *homeDir); + printTaggedWarning( + "$HOME ('%s') is not owned by you, falling back to the one defined in the " + "'passwd' file ('%s')", + *unownedUserHomeDir, + *homeDir + ); } } return *homeDir; diff --git a/lix/nix/develop.cc b/lix/nix/develop.cc index dfbc09b95..7df9d1211 100644 --- a/lix/nix/develop.cc +++ b/lix/nix/develop.cc @@ -367,7 +367,11 @@ struct Common : InstallableCommand, MixProfile for (auto & path: builtPaths) { auto from = store->printStorePath(path); if (script.find(from) == std::string::npos) - warn("'%s' (path '%s') is not used by this build environment", installable->what(), from); + printTaggedWarning( + "'%s' (path '%s') is not used by this build environment", + installable->what(), + from + ); else { printInfo("redirecting '%s' to '%s'", from, dir); rewrites.insert({from, dir}); diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc index ee638c141..c23cc5078 100644 --- a/lix/nix/flake.cc +++ b/lix/nix/flake.cc @@ -94,7 +94,11 @@ public: for (const auto & inputToUpdate : inputsToUpdate) { auto inputPath = flake::parseInputPath(inputToUpdate); if (lockFlags.inputUpdates.contains(inputPath)) - warn("Input '%s' was specified multiple times. You may have done this by accident.", inputToUpdate); + printTaggedWarning( + "Input '%s' was specified multiple times. You may have done this by " + "accident.", + inputToUpdate + ); lockFlags.inputUpdates.insert(inputPath); } }}, @@ -320,7 +324,7 @@ struct CmdFlakeInfo : CmdFlakeMetadata { void run(nix::ref store) override { - warn("'nix flake info' is a deprecated alias for 'nix flake metadata'"); + printTaggedWarning("'nix flake info' is a deprecated alias for 'nix flake metadata'"); CmdFlakeMetadata::run(store); } }; @@ -605,7 +609,11 @@ struct CmdFlakeCheck : FlakeCommand name == "nixosModule" ? "nixosModules.default" : ""; if (replacement != "") - warn("flake output attribute '%s' is deprecated; use '%s' instead", name, replacement); + printTaggedWarning( + "flake output attribute '%s' is deprecated; use '%s' instead", + name, + replacement + ); if (name == "checks") { state->forceAttrs(vOutput, pos, ""); @@ -804,7 +812,7 @@ struct CmdFlakeCheck : FlakeCommand ; else - warn("unknown flake output '%s'", name); + printTaggedWarning("unknown flake output '%s'", name); } catch (Error & e) { e.addTrace(resolve(pos), HintFmt("while checking flake output '%s'", name)); @@ -823,7 +831,7 @@ struct CmdFlakeCheck : FlakeCommand throw Error("some errors were encountered during the evaluation"); if (!omittedSystems.empty()) { - warn( + printTaggedWarning( "The check omitted these incompatible systems: %s\n" "Use '--all-systems' to check all.", concatStringsSep(", ", omittedSystems) @@ -1340,7 +1348,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON if (!json) logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix)); else { - warn( + printTaggedWarning( "%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPath) ); @@ -1367,7 +1375,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON if (!json) logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix)); else { - warn( + printTaggedWarning( "%s omitted (use '--legacy' to show)", concatStringsSep(".", attrPath) ); @@ -1376,7 +1384,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON if (!json) logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix)); else { - warn( + printTaggedWarning( "%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPath) ); diff --git a/lix/nix/ls.cc b/lix/nix/ls.cc index 79adf8818..66bb6fb1a 100644 --- a/lix/nix/ls.cc +++ b/lix/nix/ls.cc @@ -145,7 +145,7 @@ struct CmdLsStore : StoreCommand, MixLs } } catch (NoSuchBinaryCacheFile &) { } catch (Error & e) { - warn( + printTaggedWarning( "nar listing for %s on %s is bad (falling back to full nar download): %s", path, store->getUri(), diff --git a/lix/nix/main.cc b/lix/nix/main.cc index 6735965c0..07c9f623c 100644 --- a/lix/nix/main.cc +++ b/lix/nix/main.cc @@ -292,8 +292,9 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs auto arg = *pos; auto i = aliases.find(arg); if (i == aliases.end()) return pos; - warn("'%s' is a deprecated alias for '%s'", - arg, concatStringsSep(" ", i->second)); + printTaggedWarning( + "'%s' is a deprecated alias for '%s'", arg, concatStringsSep(" ", i->second) + ); pos = args.erase(pos); for (auto j = i->second.rbegin(); j != i->second.rend(); ++j) pos = args.insert(pos, *j); @@ -608,7 +609,9 @@ void mainWrapped(AsyncIoRoot & aio, int argc, char * * argv) args.command->second->experimentalFeature()); if (args.useNet && !haveInternet()) { - warn("you don't have Internet access; disabling some network-dependent features"); + printTaggedWarning( + "you don't have Internet access; disabling some network-dependent features" + ); args.useNet = false; } diff --git a/lix/nix/profile.cc b/lix/nix/profile.cc index f61e4f74d..cb4798686 100644 --- a/lix/nix/profile.cc +++ b/lix/nix/profile.cc @@ -264,12 +264,12 @@ struct CmdProfileRemove : virtual EvalCommand, MixDefaultProfile, MixProfileElem if (removedCount == 0) { for (auto matcher: matchers) { if (const Path * path = std::get_if(&matcher)) { - warn("'%s' does not match any paths", *path); + printTaggedWarning("'%s' does not match any paths", *path); } else if (const RegexPattern * regex = std::get_if(&matcher)){ - warn("'%s' does not match any packages", regex->pattern); + printTaggedWarning("'%s' does not match any packages", regex->pattern); } } - warn ("Use 'nix profile list' to see the current profile."); + printTaggedWarning("Use 'nix profile list' to see the current profile."); } updateProfile(aio().blockOn(newManifest.build(store))); } @@ -310,16 +310,18 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf matchedCount += 1; if (!element.source) { - warn( - "Found package '%s', but it was not installed from a flake, so it can't be checked for upgrades", + printTaggedWarning( + "Found package '%s', but it was not installed from a flake, so it can't be " + "checked for upgrades", element.identifier() ); continue; } if (element.source->originalRef.input.isLocked()) { - warn( - "Found package '%s', but it was installed from a locked flake reference so it can't be upgraded", + printTaggedWarning( + "Found package '%s', but it was installed from a locked flake reference so it " + "can't be upgraded", element.identifier() ); continue; @@ -383,15 +385,15 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf if (matchedCount == 0) { for (auto & matcher : matchers) { if (const Path * path = std::get_if(&matcher)){ - warn("'%s' does not match any paths", *path); + printTaggedWarning("'%s' does not match any paths", *path); } else if (const RegexPattern * regex = std::get_if(&matcher)) { - warn("'%s' does not match any packages", regex->pattern); + printTaggedWarning("'%s' does not match any packages", regex->pattern); } } } else { - warn("Found some packages but none of them could be upgraded"); + printTaggedWarning("Found some packages but none of them could be upgraded"); } - warn ("Use 'nix profile list' to see the current profile."); + printTaggedWarning("Use 'nix profile list' to see the current profile."); } auto builtPaths = builtPathsPerInstallable( diff --git a/lix/nix/upgrade-nix.cc b/lix/nix/upgrade-nix.cc index 35a1a964b..5ad8ab84a 100644 --- a/lix/nix/upgrade-nix.cc +++ b/lix/nix/upgrade-nix.cc @@ -89,7 +89,7 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand if (dryRun) { logger->pause(); - warn("would upgrade to version %s", version); + printTaggedWarning("would upgrade to version %s", version); return; }