mirror of
https://github.com/NixOS/nix
synced 2025-06-28 22:01:15 +02:00
Merge remote-tracking branch 'origin/master' into tmp
This commit is contained in:
commit
15d2e0e63b
12 changed files with 85 additions and 85 deletions
|
@ -115,10 +115,6 @@ sub downloadFile {
|
||||||
|
|
||||||
write_file("$tmpFile.sha256", $sha256_actual);
|
write_file("$tmpFile.sha256", $sha256_actual);
|
||||||
|
|
||||||
if (! -e "$tmpFile.asc") {
|
|
||||||
system("gpg2 --detach-sign --armor $tmpFile") == 0 or die "unable to sign $tmpFile\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sha256_expected;
|
return $sha256_expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +190,7 @@ for my $fn (glob "$tmpDir/*") {
|
||||||
my $configuration = ();
|
my $configuration = ();
|
||||||
$configuration->{content_type} = "application/octet-stream";
|
$configuration->{content_type} = "application/octet-stream";
|
||||||
|
|
||||||
if ($fn =~ /.sha256|.asc|install/) {
|
if ($fn =~ /.sha256|install/) {
|
||||||
# Text files
|
# Text files
|
||||||
$configuration->{content_type} = "text/plain";
|
$configuration->{content_type} = "text/plain";
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
|
||||||
// prefer direct pos, but if noPos then try the expr.
|
// prefer direct pos, but if noPos then try the expr.
|
||||||
auto pos = dt.pos
|
auto pos = dt.pos
|
||||||
? dt.pos
|
? dt.pos
|
||||||
: (std::shared_ptr<AbstractPos>) positions[dt.expr.getPos() ? dt.expr.getPos() : noPos];
|
: static_cast<std::shared_ptr<AbstractPos>>(positions[dt.expr.getPos() ? dt.expr.getPos() : noPos]);
|
||||||
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
out << pos;
|
out << pos;
|
||||||
|
|
|
@ -786,7 +786,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
|
||||||
? std::make_unique<DebugTraceStacker>(
|
? std::make_unique<DebugTraceStacker>(
|
||||||
*this,
|
*this,
|
||||||
DebugTrace {
|
DebugTrace {
|
||||||
.pos = error->info().errPos ? error->info().errPos : (std::shared_ptr<AbstractPos>) positions[expr.getPos()],
|
.pos = error->info().errPos ? error->info().errPos : static_cast<std::shared_ptr<AbstractPos>>(positions[expr.getPos()]),
|
||||||
.expr = expr,
|
.expr = expr,
|
||||||
.env = env,
|
.env = env,
|
||||||
.hint = error->info().msg,
|
.hint = error->info().msg,
|
||||||
|
@ -1189,7 +1189,7 @@ void EvalState::evalFile(const SourcePath & path, Value & v, bool mustBeTrivial)
|
||||||
*this,
|
*this,
|
||||||
*e,
|
*e,
|
||||||
this->baseEnv,
|
this->baseEnv,
|
||||||
e->getPos() ? (std::shared_ptr<AbstractPos>) positions[e->getPos()] : nullptr,
|
e->getPos() ? static_cast<std::shared_ptr<AbstractPos>>(positions[e->getPos()]) : nullptr,
|
||||||
"while evaluating the file '%1%':", resolvedPath.to_string())
|
"while evaluating the file '%1%':", resolvedPath.to_string())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void ConfigFile::apply()
|
||||||
auto tlname = get(trustedList, name);
|
auto tlname = get(trustedList, name);
|
||||||
if (auto saved = tlname ? get(*tlname, valueS) : nullptr) {
|
if (auto saved = tlname ? get(*tlname, valueS) : nullptr) {
|
||||||
trusted = *saved;
|
trusted = *saved;
|
||||||
warn("Using saved setting for '%s = %s' from ~/.local/share/nix/trusted-settings.json.", name,valueS);
|
printInfo("Using saved setting for '%s = %s' from ~/.local/share/nix/trusted-settings.json.", name, valueS);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: filter ANSI escapes, newlines, \r, etc.
|
// FIXME: filter ANSI escapes, newlines, \r, etc.
|
||||||
if (std::tolower(logger->ask(fmt("do you want to allow configuration setting '%s' to be set to '" ANSI_RED "%s" ANSI_NORMAL "' (y/N)?", name, valueS)).value_or('n')) == 'y') {
|
if (std::tolower(logger->ask(fmt("do you want to allow configuration setting '%s' to be set to '" ANSI_RED "%s" ANSI_NORMAL "' (y/N)?", name, valueS)).value_or('n')) == 'y') {
|
||||||
|
|
|
@ -8,62 +8,55 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct SourcePathAdapter : AbstractPos
|
struct PosAdapter : AbstractPos
|
||||||
{
|
{
|
||||||
SourcePath path;
|
Pos::Origin origin;
|
||||||
|
|
||||||
SourcePathAdapter(SourcePath path)
|
PosAdapter(Pos::Origin origin)
|
||||||
: path(std::move(path))
|
: origin(std::move(origin))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getSource() const override
|
std::optional<std::string> getSource() const override
|
||||||
{
|
{
|
||||||
try {
|
return std::visit(overloaded {
|
||||||
return path.readFile();
|
[](const Pos::none_tag &) -> std::optional<std::string> {
|
||||||
} catch (Error &) {
|
return std::nullopt;
|
||||||
return std::nullopt;
|
},
|
||||||
}
|
[](const Pos::Stdin & s) -> std::optional<std::string> {
|
||||||
|
// Get rid of the null terminators added by the parser.
|
||||||
|
return std::string(s.source->c_str());
|
||||||
|
},
|
||||||
|
[](const Pos::String & s) -> std::optional<std::string> {
|
||||||
|
// Get rid of the null terminators added by the parser.
|
||||||
|
return std::string(s.source->c_str());
|
||||||
|
},
|
||||||
|
[](const SourcePath & path) -> std::optional<std::string> {
|
||||||
|
try {
|
||||||
|
return path.readFile();
|
||||||
|
} catch (Error &) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(std::ostream & out) const override
|
void print(std::ostream & out) const override
|
||||||
{
|
{
|
||||||
out << path;
|
std::visit(overloaded {
|
||||||
}
|
[&](const Pos::none_tag &) { out << "«none»"; },
|
||||||
};
|
[&](const Pos::Stdin &) { out << "«stdin»"; },
|
||||||
|
[&](const Pos::String & s) { out << "«string»"; },
|
||||||
struct StringPosAdapter : AbstractPos
|
[&](const SourcePath & path) { out << path; }
|
||||||
{
|
}, origin);
|
||||||
void print(std::ostream & out) const override
|
|
||||||
{
|
|
||||||
out << "«string»";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct StdinPosAdapter : AbstractPos
|
|
||||||
{
|
|
||||||
void print(std::ostream & out) const override
|
|
||||||
{
|
|
||||||
out << "«stdin»";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Pos::operator std::shared_ptr<AbstractPos>() const
|
Pos::operator std::shared_ptr<AbstractPos>() const
|
||||||
{
|
{
|
||||||
std::shared_ptr<AbstractPos> pos;
|
auto pos = std::make_shared<PosAdapter>(origin);
|
||||||
|
pos->line = line;
|
||||||
if (auto path = std::get_if<SourcePath>(&origin))
|
pos->column = column;
|
||||||
pos = std::make_shared<SourcePathAdapter>(*path);
|
|
||||||
else if (std::get_if<stdin_tag>(&origin))
|
|
||||||
pos = std::make_shared<StdinPosAdapter>();
|
|
||||||
else if (std::get_if<string_tag>(&origin))
|
|
||||||
pos = std::make_shared<StringPosAdapter>();
|
|
||||||
|
|
||||||
if (pos) {
|
|
||||||
pos->line = line;
|
|
||||||
pos->column = column;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,11 @@ struct Pos
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
uint32_t column;
|
uint32_t column;
|
||||||
|
|
||||||
struct stdin_tag {};
|
struct none_tag { };
|
||||||
struct string_tag {};
|
struct Stdin { ref<std::string> source; };
|
||||||
|
struct String { ref<std::string> source; };
|
||||||
|
|
||||||
typedef std::variant<stdin_tag, string_tag, SourcePath> Origin;
|
typedef std::variant<none_tag, Stdin, String, SourcePath> Origin;
|
||||||
|
|
||||||
Origin origin;
|
Origin origin;
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ public:
|
||||||
mutable uint32_t idx = std::numeric_limits<uint32_t>::max();
|
mutable uint32_t idx = std::numeric_limits<uint32_t>::max();
|
||||||
|
|
||||||
// Used for searching in PosTable::[].
|
// Used for searching in PosTable::[].
|
||||||
explicit Origin(uint32_t idx): idx(idx), origin{Pos::stdin_tag()} {}
|
explicit Origin(uint32_t idx): idx(idx), origin{Pos::none_tag()} {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Pos::Origin origin;
|
const Pos::Origin origin;
|
||||||
|
|
|
@ -716,10 +716,11 @@ Expr * EvalState::parseExprFromFile(const SourcePath & path, std::shared_ptr<Sta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expr * EvalState::parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv)
|
Expr * EvalState::parseExprFromString(std::string s_, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv)
|
||||||
{
|
{
|
||||||
s.append("\0\0", 2);
|
auto s = make_ref<std::string>(std::move(s_));
|
||||||
return parse(s.data(), s.size(), Pos::string_tag(), basePath, staticEnv);
|
s->append("\0\0", 2);
|
||||||
|
return parse(s->data(), s->size(), Pos::String{.source = s}, basePath, staticEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -735,7 +736,8 @@ Expr * EvalState::parseStdin()
|
||||||
auto buffer = drainFD(0);
|
auto buffer = drainFD(0);
|
||||||
// drainFD should have left some extra space for terminators
|
// drainFD should have left some extra space for terminators
|
||||||
buffer.append("\0\0", 2);
|
buffer.append("\0\0", 2);
|
||||||
return parse(buffer.data(), buffer.size(), Pos::stdin_tag(), rootPath(absPath(".")), staticBaseEnv);
|
auto s = make_ref<std::string>(std::move(buffer));
|
||||||
|
return parse(s->data(), s->size(), Pos::Stdin{.source = s}, rootPath(absPath(".")), staticBaseEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace nix {
|
||||||
|
|
||||||
MATCHER_P(IsAttrsOfSize, n, fmt("Is a set of size [%1%]", n)) {
|
MATCHER_P(IsAttrsOfSize, n, fmt("Is a set of size [%1%]", n)) {
|
||||||
if (arg.type() != nAttrs) {
|
if (arg.type() != nAttrs) {
|
||||||
*result_listener << "Expexted set got " << arg.type();
|
*result_listener << "Expected set got " << arg.type();
|
||||||
return false;
|
return false;
|
||||||
} else if (arg.attrs->size() != (size_t)n) {
|
} else if (arg.attrs->size() != (size_t)n) {
|
||||||
*result_listener << "Expected a set with " << n << " attributes but got " << arg.attrs->size();
|
*result_listener << "Expected a set with " << n << " attributes but got " << arg.attrs->size();
|
||||||
|
|
|
@ -8,12 +8,15 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
SQLiteError::SQLiteError(const char *path, int errNo, int extendedErrNo, hintformat && hf)
|
SQLiteError::SQLiteError(const char *path, const char *errMsg, int errNo, int extendedErrNo, int offset, hintformat && hf)
|
||||||
: Error(""), path(path), errNo(errNo), extendedErrNo(extendedErrNo)
|
: Error(""), path(path), errMsg(errMsg), errNo(errNo), extendedErrNo(extendedErrNo), offset(offset)
|
||||||
{
|
{
|
||||||
err.msg = hintfmt("%s: %s (in '%s')",
|
auto offsetStr = (offset == -1) ? "" : "at offset " + std::to_string(offset) + ": ";
|
||||||
|
err.msg = hintfmt("%s: %s%s, %s (in '%s')",
|
||||||
normaltxt(hf.str()),
|
normaltxt(hf.str()),
|
||||||
|
offsetStr,
|
||||||
sqlite3_errstr(extendedErrNo),
|
sqlite3_errstr(extendedErrNo),
|
||||||
|
errMsg,
|
||||||
path ? path : "(in-memory)");
|
path ? path : "(in-memory)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,11 +24,13 @@ SQLiteError::SQLiteError(const char *path, int errNo, int extendedErrNo, hintfor
|
||||||
{
|
{
|
||||||
int err = sqlite3_errcode(db);
|
int err = sqlite3_errcode(db);
|
||||||
int exterr = sqlite3_extended_errcode(db);
|
int exterr = sqlite3_extended_errcode(db);
|
||||||
|
int offset = sqlite3_error_offset(db);
|
||||||
|
|
||||||
auto path = sqlite3_db_filename(db, nullptr);
|
auto path = sqlite3_db_filename(db, nullptr);
|
||||||
|
auto errMsg = sqlite3_errmsg(db);
|
||||||
|
|
||||||
if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {
|
if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {
|
||||||
auto exp = SQLiteBusy(path, err, exterr, std::move(hf));
|
auto exp = SQLiteBusy(path, errMsg, err, exterr, offset, std::move(hf));
|
||||||
exp.err.msg = hintfmt(
|
exp.err.msg = hintfmt(
|
||||||
err == SQLITE_PROTOCOL
|
err == SQLITE_PROTOCOL
|
||||||
? "SQLite database '%s' is busy (SQLITE_PROTOCOL)"
|
? "SQLite database '%s' is busy (SQLITE_PROTOCOL)"
|
||||||
|
@ -33,7 +38,7 @@ SQLiteError::SQLiteError(const char *path, int errNo, int extendedErrNo, hintfor
|
||||||
path ? path : "(in-memory)");
|
path ? path : "(in-memory)");
|
||||||
throw exp;
|
throw exp;
|
||||||
} else
|
} else
|
||||||
throw SQLiteError(path, err, exterr, std::move(hf));
|
throw SQLiteError(path, errMsg, err, exterr, offset, std::move(hf));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLite::SQLite(const Path & path, bool create)
|
SQLite::SQLite(const Path & path, bool create)
|
||||||
|
|
|
@ -98,21 +98,22 @@ struct SQLiteTxn
|
||||||
|
|
||||||
struct SQLiteError : Error
|
struct SQLiteError : Error
|
||||||
{
|
{
|
||||||
const char *path;
|
std::string path;
|
||||||
int errNo, extendedErrNo;
|
std::string errMsg;
|
||||||
|
int errNo, extendedErrNo, offset;
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
[[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, const Args & ... args) {
|
[[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, const Args & ... args) {
|
||||||
throw_(db, hintfmt(fs, args...));
|
throw_(db, hintfmt(fs, args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLiteError(const char *path, int errNo, int extendedErrNo, hintformat && hf);
|
SQLiteError(const char *path, const char *errMsg, int errNo, int extendedErrNo, int offset, hintformat && hf);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
SQLiteError(const char *path, int errNo, int extendedErrNo, const std::string & fs, const Args & ... args)
|
SQLiteError(const char *path, const char *errMsg, int errNo, int extendedErrNo, int offset, const std::string & fs, const Args & ... args)
|
||||||
: SQLiteError(path, errNo, extendedErrNo, hintfmt(fs, args...))
|
: SQLiteError(path, errNo, extendedErrNo, offset, hintfmt(fs, args...))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
[[noreturn]] static void throw_(sqlite3 * db, hintformat && hf);
|
[[noreturn]] static void throw_(sqlite3 * db, hintformat && hf);
|
||||||
|
|
|
@ -131,6 +131,21 @@ Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type,
|
||||||
logger.startActivity(id, lvl, type, s, fields, parent);
|
logger.startActivity(id, lvl, type, s, fields, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json & json, std::shared_ptr<AbstractPos> pos)
|
||||||
|
{
|
||||||
|
if (pos) {
|
||||||
|
json["line"] = pos->line;
|
||||||
|
json["column"] = pos->column;
|
||||||
|
std::ostringstream str;
|
||||||
|
pos->print(str);
|
||||||
|
json["file"] = str.str();
|
||||||
|
} else {
|
||||||
|
json["line"] = nullptr;
|
||||||
|
json["column"] = nullptr;
|
||||||
|
json["file"] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct JSONLogger : Logger {
|
struct JSONLogger : Logger {
|
||||||
Logger & prevLogger;
|
Logger & prevLogger;
|
||||||
|
|
||||||
|
@ -177,29 +192,14 @@ struct JSONLogger : Logger {
|
||||||
json["level"] = ei.level;
|
json["level"] = ei.level;
|
||||||
json["msg"] = oss.str();
|
json["msg"] = oss.str();
|
||||||
json["raw_msg"] = ei.msg.str();
|
json["raw_msg"] = ei.msg.str();
|
||||||
|
to_json(json, ei.errPos);
|
||||||
if (ei.errPos) {
|
|
||||||
json["line"] = ei.errPos->line;
|
|
||||||
json["column"] = ei.errPos->column;
|
|
||||||
//json["file"] = ei.errPos->file;
|
|
||||||
json["file"] = nullptr;
|
|
||||||
} else {
|
|
||||||
json["line"] = nullptr;
|
|
||||||
json["column"] = nullptr;
|
|
||||||
json["file"] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loggerSettings.showTrace.get() && !ei.traces.empty()) {
|
if (loggerSettings.showTrace.get() && !ei.traces.empty()) {
|
||||||
nlohmann::json traces = nlohmann::json::array();
|
nlohmann::json traces = nlohmann::json::array();
|
||||||
for (auto iter = ei.traces.rbegin(); iter != ei.traces.rend(); ++iter) {
|
for (auto iter = ei.traces.rbegin(); iter != ei.traces.rend(); ++iter) {
|
||||||
nlohmann::json stackFrame;
|
nlohmann::json stackFrame;
|
||||||
stackFrame["raw_msg"] = iter->hint.str();
|
stackFrame["raw_msg"] = iter->hint.str();
|
||||||
if (iter->pos) {
|
to_json(stackFrame, iter->pos);
|
||||||
stackFrame["line"] = iter->pos->line;
|
|
||||||
stackFrame["column"] = iter->pos->column;
|
|
||||||
//stackFrame["file"] = iter->pos->file;
|
|
||||||
stackFrame["file"] = nullptr;
|
|
||||||
}
|
|
||||||
traces.push_back(stackFrame);
|
traces.push_back(stackFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,10 +192,12 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
|
||||||
drv.env.erase("allowedRequisites");
|
drv.env.erase("allowedRequisites");
|
||||||
drv.env.erase("disallowedReferences");
|
drv.env.erase("disallowedReferences");
|
||||||
drv.env.erase("disallowedRequisites");
|
drv.env.erase("disallowedRequisites");
|
||||||
|
drv.env.erase("name");
|
||||||
|
|
||||||
/* Rehash and write the derivation. FIXME: would be nice to use
|
/* Rehash and write the derivation. FIXME: would be nice to use
|
||||||
'buildDerivation', but that's privileged. */
|
'buildDerivation', but that's privileged. */
|
||||||
drv.name += "-env";
|
drv.name += "-env";
|
||||||
|
drv.env.emplace("name", drv.name);
|
||||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||||
if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) {
|
if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) {
|
||||||
for (auto & output : drv.outputs) {
|
for (auto & output : drv.outputs) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue