1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

dropEmptyInitThenConcatStringsSep -> concatStringSep: diagnostics and docs

These are non-critical, so their behavior is ok to change.
Dropping empty items is not needed and usually not expected.
This commit is contained in:
Robert Hensing 2024-07-12 23:06:32 +02:00
parent a681d354e7
commit ea966a70fc
9 changed files with 28 additions and 16 deletions

View file

@ -16,6 +16,7 @@
#include "serialise.hh"
#include "build-result.hh"
#include "store-api.hh"
#include "strings.hh"
#include "derivations.hh"
#include "local-store.hh"
#include "legacy.hh"
@ -206,15 +207,15 @@ static int main_build_remote(int argc, char * * argv)
error
% drvstr
% neededSystem
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", requiredFeatures)
% concatStringsSep<StringSet>(", ", requiredFeatures)
% machines.size();
for (auto & m : machines)
error
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.systemTypes)
% concatStringsSep<StringSet>(", ", m.systemTypes)
% m.maxJobs
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.supportedFeatures)
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.mandatoryFeatures);
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
printMsg(couldBuildLocally ? lvlChatty : lvlWarn, error.str());

View file

@ -1,3 +1,5 @@
#include <nlohmann/json.hpp>
#include "command.hh"
#include "markdown.hh"
#include "store-api.hh"
@ -6,8 +8,7 @@
#include "nixexpr.hh"
#include "profiles.hh"
#include "repl.hh"
#include <nlohmann/json.hpp>
#include "strings.hh"
extern char * * environ __attribute__((weak));
@ -42,7 +43,7 @@ void NixMultiCommand::run()
for (auto & [name, _] : commands)
subCommandTextLines.insert(fmt("- `%s`", name));
std::string markdownError = fmt("`nix %s` requires a sub-command. Available sub-commands:\n\n%s\n",
commandName, dropEmptyInitThenConcatStringsSep("\n", subCommandTextLines));
commandName, concatStringsSep("\n", subCommandTextLines));
throw UsageError(renderMarkdownToTerminal(markdownError));
}
command->second->run();

View file

@ -27,6 +27,8 @@
#include <nlohmann/json.hpp>
#include "strings-inline.hh"
namespace nix {
void completeFlakeInputPath(
@ -630,7 +632,7 @@ static void throwBuildErrors(
}
failedPaths.insert(failedResult->path.to_string(store));
}
throw Error("build of %s failed", dropEmptyInitThenConcatStringsSep(", ", quoteStrings(failedPaths)));
throw Error("build of %s failed", concatStringsSep(", ", quoteStrings(failedPaths)));
}
}
}

View file

@ -33,6 +33,8 @@
#include <gc/gc_cpp.h>
#endif
#include "strings.hh"
namespace nix {
/**
@ -625,7 +627,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
markdown +=
"**Synopsis:** `builtins." + (std::string) (*doc->name) + "` "
+ dropEmptyInitThenConcatStringsSep(" ", args) + "\n\n";
+ concatStringsSep(" ", args) + "\n\n";
}
markdown += stripIndentation(doc->doc);

View file

@ -9,6 +9,8 @@
#include <iterator>
#include <nlohmann/json.hpp>
#include "strings.hh"
namespace nix::flake {
static FlakeRef getFlakeRef(
@ -61,7 +63,7 @@ static std::shared_ptr<Node> doFind(const ref<Node>& root, const InputPath & pat
std::vector<std::string> cycle;
std::transform(found, visited.cend(), std::back_inserter(cycle), printInputPath);
cycle.push_back(printInputPath(path));
throw Error("follow cycle detected: [%s]", dropEmptyInitThenConcatStringsSep(" -> ", cycle));
throw Error("follow cycle detected: [%s]", concatStringsSep(" -> ", cycle));
}
visited.push_back(path);
@ -367,7 +369,7 @@ void check();
std::string printInputPath(const InputPath & path)
{
return dropEmptyInitThenConcatStringsSep("/", path);
return concatStringsSep("/", path);
}
}

View file

@ -23,6 +23,7 @@
#include <openssl/crypto.h>
#include "exit.hh"
#include "strings.hh"
namespace nix {
@ -301,11 +302,11 @@ void printVersion(const std::string & programName)
#endif
cfg.push_back("signed-caches");
std::cout << "System type: " << settings.thisSystem << "\n";
std::cout << "Additional system types: " << dropEmptyInitThenConcatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
std::cout << "Features: " << dropEmptyInitThenConcatStringsSep(", ", cfg) << "\n";
std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
std::cout << "User configuration files: " <<
dropEmptyInitThenConcatStringsSep(":", settings.nixUserConfFiles)
concatStringsSep(":", settings.nixUserConfFiles)
<< "\n";
std::cout << "Store directory: " << settings.nixStore << "\n";
std::cout << "State directory: " << settings.nixStateDir << "\n";

View file

@ -4,6 +4,7 @@
# include "derivation-goal.hh"
#endif
#include "local-store.hh"
#include "strings.hh"
namespace nix {
@ -42,7 +43,7 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
throw std::move(*ex);
} else if (!failed.empty()) {
if (ex) logError(ex->info());
throw Error(worker.failingExitStatus(), "build of %s failed", dropEmptyInitThenConcatStringsSep(", ", quoteStrings(failed)));
throw Error(worker.failingExitStatus(), "build of %s failed", concatStringsSep(", ", quoteStrings(failed)));
}
}

View file

@ -10,6 +10,7 @@
#include "callback.hh"
#include "closure.hh"
#include "filetransfer.hh"
#include "strings.hh"
namespace nix {

View file

@ -3,12 +3,13 @@
#include "hook-instance.hh"
#include "file-system.hh"
#include "child.hh"
#include "strings.hh"
namespace nix {
HookInstance::HookInstance()
{
debug("starting build hook '%s'", dropEmptyInitThenConcatStringsSep(" ", settings.buildHook.get()));
debug("starting build hook '%s'", concatStringsSep(" ", settings.buildHook.get()));
auto buildHookArgs = settings.buildHook.get();