1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

treewide: Apply clang-format

Nixpkgs bump in the flake bumps clang-format, so we now have a diff
compared to what was used to format the codebase previously. We should
have made sure that the nixpkgs input is the same in the first place.
This commit is contained in:
Sergei Zimmerman 2025-08-18 21:20:35 +03:00
parent 448bbbe0fd
commit 945d9d7264
No known key found for this signature in database
33 changed files with 428 additions and 356 deletions

View file

@ -505,8 +505,9 @@ Installables SourceExprCommand::parseInstallables(ref<Store> store, std::vector<
for (auto & s : ss) { for (auto & s : ss) {
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(s); auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(s);
result.push_back(make_ref<InstallableAttrPath>( result.push_back(
InstallableAttrPath::parse(state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec)))); make_ref<InstallableAttrPath>(InstallableAttrPath::parse(
state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec))));
} }
} else { } else {
@ -521,7 +522,8 @@ Installables SourceExprCommand::parseInstallables(ref<Store> store, std::vector<
if (prefix.find('/') != std::string::npos) { if (prefix.find('/') != std::string::npos) {
try { try {
result.push_back(make_ref<InstallableDerivedPath>( result.push_back(
make_ref<InstallableDerivedPath>(
InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw))); InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw)));
continue; continue;
} catch (BadStorePath &) { } catch (BadStorePath &) {
@ -534,7 +536,8 @@ Installables SourceExprCommand::parseInstallables(ref<Store> store, std::vector<
try { try {
auto [flakeRef, fragment] = auto [flakeRef, fragment] =
parseFlakeRefWithFragment(fetchSettings, std::string{prefix}, absPath(getCommandBaseDir())); parseFlakeRefWithFragment(fetchSettings, std::string{prefix}, absPath(getCommandBaseDir()));
result.push_back(make_ref<InstallableFlake>( result.push_back(
make_ref<InstallableFlake>(
this, this,
getEvalState(), getEvalState(),
std::move(flakeRef), std::move(flakeRef),
@ -610,7 +613,8 @@ static void throwBuildErrors(std::vector<KeyedBuildResult> & buildResults, const
StringSet failedPaths; StringSet failedPaths;
for (; failedResult != failed.end(); failedResult++) { for (; failedResult != failed.end(); failedResult++) {
if (!failedResult->errorMsg.empty()) { if (!failedResult->errorMsg.empty()) {
logError(ErrorInfo{ logError(
ErrorInfo{
.level = lvlError, .level = lvlError,
.msg = failedResult->errorMsg, .msg = failedResult->errorMsg,
}); });

View file

@ -223,20 +223,23 @@ INSTANTIATE_TEST_SUITE_P(
#define X4(w, x, y, z) \ #define X4(w, x, y, z) \
TEST_F(TrivialExpressionTest, nestedAttrsetMerge##w##x##y##z) \ TEST_F(TrivialExpressionTest, nestedAttrsetMerge##w##x##y##z) \
{ \ { \
auto v = eval("{ a.b = { c = 1; d = 2; }; } == { " X_EXPAND_IF##w( \ auto v = eval( \
"{ a.b = { c = 1; d = 2; }; } == { " X_EXPAND_IF##w( \
"a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " }"); \ "a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " }"); \
ASSERT_THAT(v, IsTrue()); \ ASSERT_THAT(v, IsTrue()); \
}; \ }; \
TEST_F(TrivialExpressionTest, nestedAttrsetMergeDup##w##x##y##z) \ TEST_F(TrivialExpressionTest, nestedAttrsetMergeDup##w##x##y##z) \
{ \ { \
ASSERT_THROW( \ ASSERT_THROW( \
eval("{ " X_EXPAND_IF##w("a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y( \ eval( \
"{ " X_EXPAND_IF##w("a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y( \
"a", X_EXPAND_IF##z("b", "c = 2;")) " }"), \ "a", X_EXPAND_IF##z("b", "c = 2;")) " }"), \
Error); \ Error); \
}; \ }; \
TEST_F(TrivialExpressionTest, nestedAttrsetMergeLet##w##x##y##z) \ TEST_F(TrivialExpressionTest, nestedAttrsetMergeLet##w##x##y##z) \
{ \ { \
auto v = eval("{ b = { c = 1; d = 2; }; } == (let " X_EXPAND_IF##w( \ auto v = eval( \
"{ b = { c = 1; d = 2; }; } == (let " X_EXPAND_IF##w( \
"a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " in a)"); \ "a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " in a)"); \
ASSERT_THAT(v, IsTrue()); \ ASSERT_THAT(v, IsTrue()); \
}; };

View file

@ -185,8 +185,8 @@ struct AttrDb
auto state(_state->lock()); auto state(_state->lock());
state->insertAttribute state->insertAttribute
.use()(key.first)(symbols[key.second])(AttrType::ListOfStrings)( .use()(key.first)(symbols[key.second])(
dropEmptyInitThenConcatStringsSep("\t", l)) AttrType::ListOfStrings) (dropEmptyInitThenConcatStringsSep("\t", l))
.exec(); .exec();
return state->db.getLastInsertedRowId(); return state->db.getLastInsertedRowId();

View file

@ -44,7 +44,8 @@ EvalErrorBuilder<T> & EvalErrorBuilder<T>::withFrame(const Env & env, const Expr
// NOTE: This is abusing side-effects. // NOTE: This is abusing side-effects.
// TODO: check compatibility with nested debugger calls. // TODO: check compatibility with nested debugger calls.
// TODO: What side-effects?? // TODO: What side-effects??
error.state.debugTraces.push_front(DebugTrace{ error.state.debugTraces.push_front(
DebugTrace{
.pos = expr.getPos(), .pos = expr.getPos(),
.expr = expr, .expr = expr,
.env = env, .env = env,

View file

@ -795,7 +795,8 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
printError("%s\n", error->what()); printError("%s\n", error->what());
if (trylevel > 0 && error->info().level != lvlInfo) if (trylevel > 0 && error->info().level != lvlInfo)
printError("This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL printError(
"This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL
" to skip these.\n"); " to skip these.\n");
} }

View file

@ -68,7 +68,8 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
std::visit( std::visit(
overloaded{ overloaded{
[&](const NixStringContextElem::Built & b) { [&](const NixStringContextElem::Built & b) {
drvs.push_back(DerivedPath::Built{ drvs.push_back(
DerivedPath::Built{
.drvPath = b.drvPath, .drvPath = b.drvPath,
.outputs = OutputsSpec::Names{b.output}, .outputs = OutputsSpec::Names{b.output},
}); });
@ -117,7 +118,8 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
/* Get all the output paths corresponding to the placeholders we had */ /* Get all the output paths corresponding to the placeholders we had */
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) { if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
res.insert_or_assign( res.insert_or_assign(
DownstreamPlaceholder::fromSingleDerivedPathBuilt(SingleDerivedPath::Built{ DownstreamPlaceholder::fromSingleDerivedPathBuilt(
SingleDerivedPath::Built{
.drvPath = drv.drvPath, .drvPath = drv.drvPath,
.output = outputName, .output = outputName,
}) })
@ -297,7 +299,8 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
} }
} }
static RegisterPrimOp primop_scopedImport(PrimOp{ static RegisterPrimOp primop_scopedImport(
PrimOp{
.name = "scopedImport", .arity = 2, .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) { .name = "scopedImport", .arity = 2, .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) {
import(state, pos, *args[1], args[0], v); import(state, pos, *args[1], args[0], v);
}}); }});
@ -806,7 +809,8 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar
v.mkList(list); v.mkList(list);
} }
static RegisterPrimOp primop_genericClosure(PrimOp{ static RegisterPrimOp primop_genericClosure(
PrimOp{
.name = "__genericClosure", .name = "__genericClosure",
.args = {"attrset"}, .args = {"attrset"},
.arity = 1, .arity = 1,
@ -872,7 +876,8 @@ static RegisterPrimOp primop_break(
)", )",
.fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) { .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) {
if (state.canDebug()) { if (state.canDebug()) {
auto error = Error(ErrorInfo{ auto error = Error(
ErrorInfo{
.level = lvlInfo, .level = lvlInfo,
.msg = HintFmt("breakpoint reached"), .msg = HintFmt("breakpoint reached"),
.pos = state.positions[pos], .pos = state.positions[pos],
@ -940,7 +945,8 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value ** a
} }
} }
static RegisterPrimOp primop_addErrorContext(PrimOp{ static RegisterPrimOp primop_addErrorContext(
PrimOp{
.name = "__addErrorContext", .name = "__addErrorContext",
.arity = 2, .arity = 2,
// The normal trace item is redundant // The normal trace item is redundant
@ -1656,7 +1662,8 @@ static void derivationStrictInternal(EvalState & state, const std::string & drvN
v.mkAttrs(result); v.mkAttrs(result);
} }
static RegisterPrimOp primop_derivationStrict(PrimOp{ static RegisterPrimOp primop_derivationStrict(
PrimOp{
.name = "derivationStrict", .name = "derivationStrict",
.arity = 1, .arity = 1,
.fun = prim_derivationStrict, .fun = prim_derivationStrict,
@ -1898,7 +1905,8 @@ static void prim_readFile(EvalState & state, const PosIdx pos, Value ** args, Va
} }
NixStringContext context; NixStringContext context;
for (auto && p : std::move(refs)) { for (auto && p : std::move(refs)) {
context.insert(NixStringContextElem::Opaque{ context.insert(
NixStringContextElem::Opaque{
.path = std::move((StorePath &&) p), .path = std::move((StorePath &&) p),
}); });
} }
@ -1956,7 +1964,8 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
.debugThrow(); .debugThrow();
} }
lookupPath.elements.emplace_back(LookupPath::Elem{ lookupPath.elements.emplace_back(
LookupPath::Elem{
.prefix = LookupPath::Prefix{.s = prefix}, .prefix = LookupPath::Prefix{.s = prefix},
.path = LookupPath::Path{.s = path}, .path = LookupPath::Path{.s = path},
}); });
@ -1968,7 +1977,8 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
v.mkPath(state.findFile(lookupPath, path, pos)); v.mkPath(state.findFile(lookupPath, path, pos));
} }
static RegisterPrimOp primop_findFile(PrimOp{ static RegisterPrimOp primop_findFile(
PrimOp{
.name = "__findFile", .name = "__findFile",
.args = {"search-path", "lookup-path"}, .args = {"search-path", "lookup-path"},
.doc = R"( .doc = R"(
@ -2871,7 +2881,8 @@ static void prim_unsafeGetAttrPos(EvalState & state, const PosIdx pos, Value **
state.mkPos(v, i->pos); state.mkPos(v, i->pos);
} }
static RegisterPrimOp primop_unsafeGetAttrPos(PrimOp{ static RegisterPrimOp primop_unsafeGetAttrPos(
PrimOp{
.name = "__unsafeGetAttrPos", .name = "__unsafeGetAttrPos",
.arity = 2, .arity = 2,
.fun = prim_unsafeGetAttrPos, .fun = prim_unsafeGetAttrPos,

View file

@ -276,7 +276,8 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg
if (auto attr = i.value->attrs()->get(sPath)) { if (auto attr = i.value->attrs()->get(sPath)) {
if (state.forceBool(*attr->value, attr->pos, "while evaluating the `path` attribute of a string context")) if (state.forceBool(*attr->value, attr->pos, "while evaluating the `path` attribute of a string context"))
context.emplace(NixStringContextElem::Opaque{ context.emplace(
NixStringContextElem::Opaque{
.path = namePath, .path = namePath,
}); });
} }
@ -291,7 +292,8 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg
.atPos(i.pos) .atPos(i.pos)
.debugThrow(); .debugThrow();
} }
context.emplace(NixStringContextElem::DrvDeep{ context.emplace(
NixStringContextElem::DrvDeep{
.drvPath = namePath, .drvPath = namePath,
}); });
} }
@ -309,7 +311,8 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg
for (auto elem : attr->value->listItems()) { for (auto elem : attr->value->listItems()) {
auto outputName = auto outputName =
state.forceStringNoCtx(*elem, attr->pos, "while evaluating an output name within a string context"); state.forceStringNoCtx(*elem, attr->pos, "while evaluating an output name within a string context");
context.emplace(NixStringContextElem::Built{ context.emplace(
NixStringContextElem::Built{
.drvPath = makeConstantStorePathRef(namePath), .drvPath = makeConstantStorePathRef(namePath),
.output = std::string{outputName}, .output = std::string{outputName},
}); });

View file

@ -44,7 +44,8 @@ static void downloadToSink(
static std::string getLfsApiToken(const ParsedURL & url) static std::string getLfsApiToken(const ParsedURL & url)
{ {
auto [status, output] = runProgram(RunOptions{ auto [status, output] = runProgram(
RunOptions{
.program = "ssh", .program = "ssh",
.args = {*url.authority, "git-lfs-authenticate", url.path, "download"}, .args = {*url.authority, "git-lfs-authenticate", url.path, "download"},
}); });

View file

@ -389,7 +389,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
continue; continue;
std::string key2(key, 0, key.size() - 5); std::string key2(key, 0, key.size() - 5);
auto path = CanonPath(value); auto path = CanonPath(value);
result.push_back(Submodule{ result.push_back(
Submodule{
.path = path, .path = path,
.url = entries[key2 + ".url"], .url = entries[key2 + ".url"],
.branch = entries[key2 + ".branch"], .branch = entries[key2 + ".branch"],
@ -533,7 +534,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
append(gitArgs, {"--depth", "1"}); append(gitArgs, {"--depth", "1"});
append(gitArgs, {std::string("--"), url, refspec}); append(gitArgs, {std::string("--"), url, refspec});
runProgram(RunOptions{ runProgram(
RunOptions{
.program = "git", .program = "git",
.lookupPath = true, .lookupPath = true,
// FIXME: git stderr messes up our progress indicator, so // FIXME: git stderr messes up our progress indicator, so
@ -566,7 +568,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
writeFile(allowedSignersFile, allowedSigners); writeFile(allowedSignersFile, allowedSigners);
// Run verification command // Run verification command
auto [status, output] = runProgram(RunOptions{ auto [status, output] = runProgram(
RunOptions{
.program = "git", .program = "git",
.args = .args =
{"-c", {"-c",

View file

@ -56,7 +56,8 @@ Path getCachePath(std::string_view key, bool shallow)
// ... // ...
std::optional<std::string> readHead(const Path & path) std::optional<std::string> readHead(const Path & path)
{ {
auto [status, output] = runProgram(RunOptions{ auto [status, output] = runProgram(
RunOptions{
.program = "git", .program = "git",
// FIXME: use 'HEAD' to avoid returning all refs // FIXME: use 'HEAD' to avoid returning all refs
.args = {"ls-remote", "--symref", path}, .args = {"ls-remote", "--symref", path},
@ -325,7 +326,8 @@ struct GitInputScheme : InputScheme
writeFile(*repoPath / path.rel(), contents); writeFile(*repoPath / path.rel(), contents);
auto result = runProgram(RunOptions{ auto result = runProgram(
RunOptions{
.program = "git", .program = "git",
.args = .args =
{"-C", {"-C",

View file

@ -35,7 +35,8 @@ std::shared_ptr<Registry> Registry::read(const Settings & settings, const Path &
toAttrs.erase(j); toAttrs.erase(j);
} }
auto exact = i.find("exact"); auto exact = i.find("exact");
registry->entries.push_back(Entry{ registry->entries.push_back(
Entry{
.from = Input::fromAttrs(settings, jsonToAttrs(i["from"])), .from = Input::fromAttrs(settings, jsonToAttrs(i["from"])),
.to = Input::fromAttrs(settings, std::move(toAttrs)), .to = Input::fromAttrs(settings, std::move(toAttrs)),
.extraAttrs = extraAttrs, .extraAttrs = extraAttrs,

View file

@ -14,7 +14,8 @@ Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary()
return gen::just((OutputsSpec) OutputsSpec::All{}); return gen::just((OutputsSpec) OutputsSpec::All{});
case 1: case 1:
return gen::map( return gen::map(
gen::nonEmpty(gen::container<StringSet>( gen::nonEmpty(
gen::container<StringSet>(
gen::map(gen::arbitrary<StorePathName>(), [](StorePathName n) { return n.name; }))), gen::map(gen::arbitrary<StorePathName>(), [](StorePathName n) { return n.name; }))),
[](StringSet names) { return (OutputsSpec) OutputsSpec::Names{names}; }); [](StringSet names) { return (OutputsSpec) OutputsSpec::Names{names}; });
default: default:

View file

@ -82,13 +82,15 @@ VERSIONED_CHARACTERIZATION_TEST(
.path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"}, .path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
}, },
DerivedPath::Built{ DerivedPath::Built{
.drvPath = makeConstantStorePathRef(StorePath{ .drvPath = makeConstantStorePathRef(
StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}), }),
.outputs = OutputsSpec::All{}, .outputs = OutputsSpec::All{},
}, },
DerivedPath::Built{ DerivedPath::Built{
.drvPath = makeConstantStorePathRef(StorePath{ .drvPath = makeConstantStorePathRef(
StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}), }),
.outputs = OutputsSpec::Names{"x", "y"}, .outputs = OutputsSpec::Names{"x", "y"},
@ -108,13 +110,15 @@ VERSIONED_CHARACTERIZATION_TEST(
.path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"}, .path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
}, },
DerivedPath::Built{ DerivedPath::Built{
.drvPath = makeConstantStorePathRef(StorePath{ .drvPath = makeConstantStorePathRef(
StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}), }),
.outputs = OutputsSpec::All{}, .outputs = OutputsSpec::All{},
}, },
DerivedPath::Built{ DerivedPath::Built{
.drvPath = makeConstantStorePathRef(StorePath{ .drvPath = makeConstantStorePathRef(
StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}), }),
.outputs = OutputsSpec::Names{"x", "y"}, .outputs = OutputsSpec::Names{"x", "y"},
@ -369,7 +373,8 @@ VERSIONED_CHARACTERIZATION_TEST(WorkerProtoTest, keyedBuildResult_1_29, "keyed-b
}, },
/* .path = */ /* .path = */
DerivedPath::Built{ DerivedPath::Built{
.drvPath = makeConstantStorePathRef(StorePath{ .drvPath = makeConstantStorePathRef(
StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}), }),
.outputs = OutputsSpec::Names{"out"}, .outputs = OutputsSpec::Names{"out"},

View file

@ -1456,7 +1456,8 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
// derivation, and the output path is valid, but we don't have // derivation, and the output path is valid, but we don't have
// its realisation stored (probably because it has been built // its realisation stored (probably because it has been built
// without the `ca-derivations` experimental flag). // without the `ca-derivations` experimental flag).
worker.store.registerDrvOutput(Realisation{ worker.store.registerDrvOutput(
Realisation{
drvOutput, drvOutput,
info.known->path, info.known->path,
}); });
@ -1551,7 +1552,8 @@ void DerivationGoal::waiteeDone(GoalPtr waitee, ExitCode result)
auto & outputs = nodeP->value; auto & outputs = nodeP->value;
for (auto & outputName : outputs) { for (auto & outputName : outputs) {
auto buildResult = dg->getBuildResult(DerivedPath::Built{ auto buildResult = dg->getBuildResult(
DerivedPath::Built{
.drvPath = makeConstantStorePathRef(dg->drvPath), .drvPath = makeConstantStorePathRef(dg->drvPath),
.outputs = OutputsSpec::Names{outputName}, .outputs = OutputsSpec::Names{outputName},
}); });

View file

@ -68,7 +68,8 @@ std::vector<KeyedBuildResult> Store::buildPathsWithResults(
results.reserve(state.size()); results.reserve(state.size());
for (auto & [req, goalPtr] : state) for (auto & [req, goalPtr] : state)
results.emplace_back(KeyedBuildResult{ results.emplace_back(
KeyedBuildResult{
goalPtr->getBuildResult(req), goalPtr->getBuildResult(req),
/* .path = */ req, /* .path = */ req,
}); });
@ -88,7 +89,8 @@ BuildResult Store::buildDerivation(const StorePath & drvPath, const BasicDerivat
try { try {
worker.run(Goals{goal}); worker.run(Goals{goal});
return goal->getBuildResult(DerivedPath::Built{ return goal->getBuildResult(
DerivedPath::Built{
.drvPath = makeConstantStorePathRef(drvPath), .drvPath = makeConstantStorePathRef(drvPath),
.outputs = OutputsSpec::All{}, .outputs = OutputsSpec::All{},
}); });

View file

@ -279,7 +279,8 @@ void Worker::run(const Goals & _topGoals)
for (auto & i : _topGoals) { for (auto & i : _topGoals) {
topGoals.insert(i); topGoals.insert(i);
if (auto goal = dynamic_cast<DerivationGoal *>(i.get())) { if (auto goal = dynamic_cast<DerivationGoal *>(i.get())) {
topPaths.push_back(DerivedPath::Built{ topPaths.push_back(
DerivedPath::Built{
.drvPath = makeConstantStorePathRef(goal->drvPath), .drvPath = makeConstantStorePathRef(goal->drvPath),
.outputs = goal->wantedOutputs, .outputs = goal->wantedOutputs,
}); });

View file

@ -39,7 +39,8 @@ LegacySSHStore::LegacySSHStore(std::string_view scheme, std::string_view host, c
, CommonSSHStoreConfig(scheme, host, params) , CommonSSHStoreConfig(scheme, host, params)
, LegacySSHStoreConfig(scheme, host, params) , LegacySSHStoreConfig(scheme, host, params)
, Store(params) , Store(params)
, connections(make_ref<Pool<Connection>>( , connections(
make_ref<Pool<Connection>>(
std::max(1, (int) maxConnections), std::max(1, (int) maxConnections),
[this]() { return openConnection(); }, [this]() { return openConnection(); },
[](const ref<Connection> & r) { return r->good; })) [](const ref<Connection> & r) { return r->good; }))

View file

@ -15,7 +15,8 @@ Machine::Machine(
decltype(supportedFeatures) supportedFeatures, decltype(supportedFeatures) supportedFeatures,
decltype(mandatoryFeatures) mandatoryFeatures, decltype(mandatoryFeatures) mandatoryFeatures,
decltype(sshPublicHostKey) sshPublicHostKey) decltype(sshPublicHostKey) sshPublicHostKey)
: storeUri(StoreReference::parse( : storeUri(
StoreReference::parse(
// Backwards compatibility: if the URI is schemeless, is not a path, // Backwards compatibility: if the URI is schemeless, is not a path,
// and is not one of the special store connection words, prepend // and is not one of the special store connection words, prepend
// ssh://. // ssh://.
@ -171,7 +172,8 @@ static Machine parseBuilderLine(const std::set<std::string> & defaultSystems, co
// TODO use designated initializers, once C++ supports those with // TODO use designated initializers, once C++ supports those with
// custom constructors. // custom constructors.
return {// `storeUri` return {
// `storeUri`
tokens[0], tokens[0],
// `systemTypes` // `systemTypes`
isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : defaultSystems, isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : defaultSystems,

View file

@ -27,7 +27,8 @@ namespace nix {
RemoteStore::RemoteStore(const Params & params) RemoteStore::RemoteStore(const Params & params)
: RemoteStoreConfig(params) : RemoteStoreConfig(params)
, Store(params) , Store(params)
, connections(make_ref<Pool<Connection>>( , connections(
make_ref<Pool<Connection>>(
std::max(1, (int) maxConnections), std::max(1, (int) maxConnections),
[this]() { [this]() {
auto conn = openConnectionWrapper(); auto conn = openConnectionWrapper();
@ -655,7 +656,8 @@ std::vector<KeyedBuildResult> RemoteStore::buildPathsWithResults(
std::visit( std::visit(
overloaded{ overloaded{
[&](const DerivedPath::Opaque & bo) { [&](const DerivedPath::Opaque & bo) {
results.push_back(KeyedBuildResult{ results.push_back(
KeyedBuildResult{
{ {
.status = BuildResult::Substituted, .status = BuildResult::Substituted,
}, },

View file

@ -93,8 +93,10 @@ static void initAWS()
S3Helper::S3Helper( S3Helper::S3Helper(
const std::string & profile, const std::string & region, const std::string & scheme, const std::string & endpoint) const std::string & profile, const std::string & region, const std::string & scheme, const std::string & endpoint)
: config(makeConfig(region, scheme, endpoint)) : config(makeConfig(region, scheme, endpoint))
, client(make_ref<Aws::S3::S3Client>( , client(
profile == "" ? std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>( make_ref<Aws::S3::S3Client>(
profile == ""
? std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>(
std::make_shared<Aws::Auth::DefaultAWSCredentialsProviderChain>()) std::make_shared<Aws::Auth::DefaultAWSCredentialsProviderChain>())
: std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>( : std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>(
std::make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>(profile.c_str())), std::make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>(profile.c_str())),

View file

@ -88,7 +88,8 @@ void handleDiffHook(
if (diffHookOpt && settings.runDiffHook) { if (diffHookOpt && settings.runDiffHook) {
auto & diffHook = *diffHookOpt; auto & diffHook = *diffHookOpt;
try { try {
auto diffRes = runProgram(RunOptions{ auto diffRes = runProgram(
RunOptions{
.program = diffHook, .program = diffHook,
.lookupPath = true, .lookupPath = true,
.args = {tryA, tryB, drvPath, tmpDir}, .args = {tryA, tryB, drvPath, tmpDir},
@ -2715,7 +2716,8 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
std::filesystem::rename(tmpOutput, actualPath); std::filesystem::rename(tmpOutput, actualPath);
auto newInfo0 = newInfoFromCA(DerivationOutput::CAFloating{ auto newInfo0 = newInfoFromCA(
DerivationOutput::CAFloating{
.method = dof.ca.method, .method = dof.ca.method,
.hashAlgo = wanted.algo, .hashAlgo = wanted.algo,
}); });
@ -2754,7 +2756,8 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
}, },
[&](const DerivationOutput::Impure & doi) { [&](const DerivationOutput::Impure & doi) {
return newInfoFromCA(DerivationOutput::CAFloating{ return newInfoFromCA(
DerivationOutput::CAFloating{
.method = doi.method, .method = doi.method,
.hashAlgo = doi.hashAlgo, .hashAlgo = doi.hashAlgo,
}); });

View file

@ -314,7 +314,8 @@ TEST(Config, applyConfigFailsOnMissingIncludes)
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"}; Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
ASSERT_THROW( ASSERT_THROW(
config.applyConfig("name-of-the-setting = value-from-file\n" config.applyConfig(
"name-of-the-setting = value-from-file\n"
"# name-of-the-setting = foo\n" "# name-of-the-setting = foo\n"
"include /nix/store/does/not/exist.nix"), "include /nix/store/does/not/exist.nix"),
Error); Error);

View file

@ -31,7 +31,8 @@ TEST(to_json, vectorOfOptionalInts)
TEST(to_json, optionalVectorOfInts) TEST(to_json, optionalVectorOfInts)
{ {
std::optional<std::vector<int>> val = std::make_optional(std::vector<int>{ std::optional<std::vector<int>> val = std::make_optional(
std::vector<int>{
-420, -420,
420, 420,
}); });

View file

@ -41,7 +41,8 @@ Suggestions Suggestions::bestMatches(const std::set<std::string> & allMatches, s
{ {
std::set<Suggestion> res; std::set<Suggestion> res;
for (const auto & possibleMatch : allMatches) { for (const auto & possibleMatch : allMatches) {
res.insert(Suggestion{ res.insert(
Suggestion{
.distance = levenshteinDistance(query, possibleMatch), .distance = levenshteinDistance(query, possibleMatch),
.suggestion = possibleMatch, .suggestion = possibleMatch,
}); });

View file

@ -253,8 +253,13 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
std::string runProgram( std::string runProgram(
Path program, bool lookupPath, const Strings & args, const std::optional<std::string> & input, bool isInteractive) Path program, bool lookupPath, const Strings & args, const std::optional<std::string> & input, bool isInteractive)
{ {
auto res = runProgram(RunOptions{ auto res = runProgram(
.program = program, .lookupPath = lookupPath, .args = args, .input = input, .isInteractive = isInteractive}); RunOptions{
.program = program,
.lookupPath = lookupPath,
.args = args,
.input = input,
.isInteractive = isInteractive});
if (!statusOk(res.first)) if (!statusOk(res.first))
throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first)); throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first));

View file

@ -84,8 +84,13 @@ int Pid::wait()
std::string runProgram( std::string runProgram(
Path program, bool lookupPath, const Strings & args, const std::optional<std::string> & input, bool isInteractive) Path program, bool lookupPath, const Strings & args, const std::optional<std::string> & input, bool isInteractive)
{ {
auto res = runProgram(RunOptions{ auto res = runProgram(
.program = program, .lookupPath = lookupPath, .args = args, .input = input, .isInteractive = isInteractive}); RunOptions{
.program = program,
.lookupPath = lookupPath,
.args = args,
.input = input,
.isInteractive = isInteractive});
if (!statusOk(res.first)) if (!statusOk(res.first))
throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first)); throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first));

View file

@ -480,7 +480,8 @@ static void main_nix_build(int argc, char ** argv)
throw Error("the 'bashInteractive' attribute in <nixpkgs> did not evaluate to a derivation"); throw Error("the 'bashInteractive' attribute in <nixpkgs> did not evaluate to a derivation");
auto bashDrv = drv->requireDrvPath(); auto bashDrv = drv->requireDrvPath();
pathsToBuild.push_back(DerivedPath::Built{ pathsToBuild.push_back(
DerivedPath::Built{
.drvPath = makeConstantStorePathRef(bashDrv), .drvPath = makeConstantStorePathRef(bashDrv),
.outputs = OutputsSpec::Names{"out"}, .outputs = OutputsSpec::Names{"out"},
}); });
@ -499,7 +500,8 @@ static void main_nix_build(int argc, char ** argv)
accumDerivedPath = [&](ref<SingleDerivedPath> inputDrv, accumDerivedPath = [&](ref<SingleDerivedPath> inputDrv,
const DerivedPathMap<StringSet>::ChildNode & inputNode) { const DerivedPathMap<StringSet>::ChildNode & inputNode) {
if (!inputNode.value.empty()) if (!inputNode.value.empty())
pathsToBuild.push_back(DerivedPath::Built{ pathsToBuild.push_back(
DerivedPath::Built{
.drvPath = inputDrv, .drvPath = inputDrv,
.outputs = OutputsSpec::Names{inputNode.value}, .outputs = OutputsSpec::Names{inputNode.value},
}); });
@ -687,7 +689,8 @@ static void main_nix_build(int argc, char ** argv)
if (outputName == "") if (outputName == "")
throw Error("derivation '%s' lacks an 'outputName' attribute", store->printStorePath(drvPath)); throw Error("derivation '%s' lacks an 'outputName' attribute", store->printStorePath(drvPath));
pathsToBuild.push_back(DerivedPath::Built{ pathsToBuild.push_back(
DerivedPath::Built{
.drvPath = makeConstantStorePathRef(drvPath), .drvPath = makeConstantStorePathRef(drvPath),
.outputs = OutputsSpec::Names{outputName}, .outputs = OutputsSpec::Names{outputName},
}); });

View file

@ -467,7 +467,8 @@ static void printMissing(EvalState & state, PackageInfos & elems)
}; };
targets.emplace_back(std::move(path)); targets.emplace_back(std::move(path));
} else } else
targets.emplace_back(DerivedPath::Opaque{ targets.emplace_back(
DerivedPath::Opaque{
.path = i.queryOutPath(), .path = i.queryOutPath(),
}); });

View file

@ -70,7 +70,8 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)
std::vector<DerivedPath> context2; std::vector<DerivedPath> context2;
for (auto & c : context) { for (auto & c : context) {
context2.emplace_back(std::visit( context2.emplace_back(
std::visit(
overloaded{ overloaded{
[&](const NixStringContextElem::DrvDeep & d) -> DerivedPath { [&](const NixStringContextElem::DrvDeep & d) -> DerivedPath {
/* We want all outputs of the drv */ /* We want all outputs of the drv */

View file

@ -402,7 +402,8 @@ void mainWrapped(int argc, char ** argv)
self-aware. That is, it has to know where it is installed. We self-aware. That is, it has to know where it is installed. We
don't think it's sentient. don't think it's sentient.
*/ */
settings.buildHook.setDefault(Strings{ settings.buildHook.setDefault(
Strings{
getNixBin({}).string(), getNixBin({}).string(),
"__build-remote", "__build-remote",
}); });

View file

@ -15,7 +15,8 @@ void runNix(Path program, const Strings & args, const std::optional<std::string>
auto subprocessEnv = getEnv(); auto subprocessEnv = getEnv();
subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue(); subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue();
// isInteractive avoid grabling interactive commands // isInteractive avoid grabling interactive commands
runProgram2(RunOptions{ runProgram2(
RunOptions{
.program = getNixBin(program).string(), .program = getNixBin(program).string(),
.args = args, .args = args,
.environment = subprocessEnv, .environment = subprocessEnv,

View file

@ -34,7 +34,8 @@ struct CmdSearch : InstallableValueCommand, MixJSON
CmdSearch() CmdSearch()
{ {
expectArgs("regex", &res); expectArgs("regex", &res);
addFlag(Flag{ addFlag(
Flag{
.longName = "exclude", .longName = "exclude",
.shortName = 'e', .shortName = 'e',
.description = "Hide packages whose attribute path, name or description contain *regex*.", .description = "Hide packages whose attribute path, name or description contain *regex*.",