diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 26c54914e..b31075180 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -505,8 +505,9 @@ Installables SourceExprCommand::parseInstallables(ref store, std::vector< for (auto & s : ss) { auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(s); - result.push_back(make_ref( - InstallableAttrPath::parse(state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec)))); + result.push_back( + make_ref(InstallableAttrPath::parse( + state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec)))); } } else { @@ -521,8 +522,9 @@ Installables SourceExprCommand::parseInstallables(ref store, std::vector< if (prefix.find('/') != std::string::npos) { try { - result.push_back(make_ref( - InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw))); + result.push_back( + make_ref( + InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw))); continue; } catch (BadStorePath &) { } catch (...) { @@ -534,15 +536,16 @@ Installables SourceExprCommand::parseInstallables(ref store, std::vector< try { auto [flakeRef, fragment] = parseFlakeRefWithFragment(fetchSettings, std::string{prefix}, absPath(getCommandBaseDir())); - result.push_back(make_ref( - this, - getEvalState(), - std::move(flakeRef), - fragment, - std::move(extendedOutputsSpec), - getDefaultFlakeAttrPaths(), - getDefaultFlakeAttrPathPrefixes(), - lockFlags)); + result.push_back( + make_ref( + this, + getEvalState(), + std::move(flakeRef), + fragment, + std::move(extendedOutputsSpec), + getDefaultFlakeAttrPaths(), + getDefaultFlakeAttrPathPrefixes(), + lockFlags)); continue; } catch (...) { ex = std::current_exception(); @@ -610,10 +613,11 @@ static void throwBuildErrors(std::vector & buildResults, const StringSet failedPaths; for (; failedResult != failed.end(); failedResult++) { if (!failedResult->errorMsg.empty()) { - logError(ErrorInfo{ - .level = lvlError, - .msg = failedResult->errorMsg, - }); + logError( + ErrorInfo{ + .level = lvlError, + .msg = failedResult->errorMsg, + }); } failedPaths.insert(failedResult->path.to_string(store)); } diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 8aaa59f1d..9d686acd7 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -650,7 +650,7 @@ ProcessLineResult NixRepl::processLine(std::string line) for (auto & arg : args) arg = "*" + arg + "*"; - markdown += "**Synopsis:** `builtins." + (std::string)(*doc->name) + "` " + concatStringsSep(" ", args) + markdown += "**Synopsis:** `builtins." + (std::string) (*doc->name) + "` " + concatStringsSep(" ", args) + "\n\n"; } diff --git a/src/libexpr-tests/trivial.cc b/src/libexpr-tests/trivial.cc index 7c6774a7b..e72ba56a3 100644 --- a/src/libexpr-tests/trivial.cc +++ b/src/libexpr-tests/trivial.cc @@ -220,25 +220,28 @@ INSTANTIATE_TEST_SUITE_P( // expanded. #define X_EXPAND_IF0(k, v) k "." v #define X_EXPAND_IF1(k, v) k " = { " v " };" -#define X4(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( \ - "a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " }"); \ - ASSERT_THAT(v, IsTrue()); \ - }; \ - TEST_F(TrivialExpressionTest, nestedAttrsetMergeDup##w##x##y##z) \ - { \ - ASSERT_THROW( \ - 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;")) " }"), \ - Error); \ - }; \ - TEST_F(TrivialExpressionTest, nestedAttrsetMergeLet##w##x##y##z) \ - { \ - 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)"); \ - ASSERT_THAT(v, IsTrue()); \ +#define X4(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( \ + "a", X_EXPAND_IF##x("b", "c = 1;")) " " X_EXPAND_IF##y("a", X_EXPAND_IF##z("b", "d = 2;")) " }"); \ + ASSERT_THAT(v, IsTrue()); \ + }; \ + TEST_F(TrivialExpressionTest, nestedAttrsetMergeDup##w##x##y##z) \ + { \ + ASSERT_THROW( \ + 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;")) " }"), \ + Error); \ + }; \ + TEST_F(TrivialExpressionTest, nestedAttrsetMergeLet##w##x##y##z) \ + { \ + 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)"); \ + ASSERT_THAT(v, IsTrue()); \ }; #define X3(...) X4(__VA_ARGS__, 0) X4(__VA_ARGS__, 1) #define X2(...) X3(__VA_ARGS__, 0) X3(__VA_ARGS__, 1) diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index 435f398d2..e2593e366 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -123,13 +123,13 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::FullAttrs)(0, false).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::FullAttrs) (0, false).exec(); AttrId rowId = state->db.getLastInsertedRowId(); assert(rowId); for (auto & attr : attrs) - state->insertAttribute.use()(rowId)(symbols[attr])(AttrType::Placeholder)(0, false).exec(); + state->insertAttribute.use()(rowId)(symbols[attr])(AttrType::Placeholder) (0, false).exec(); return rowId; }); @@ -147,10 +147,10 @@ struct AttrDb ctx.push_back(' '); ctx.append(*p); } - state->insertAttributeWithContext.use()(key.first)(symbols[key.second])(AttrType::String)(s) (ctx) + state->insertAttributeWithContext.use()(key.first)(symbols[key.second])(AttrType::String) (s) (ctx) .exec(); } else { - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::String)(s).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::String) (s).exec(); } return state->db.getLastInsertedRowId(); @@ -162,7 +162,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Bool)(b ? 1 : 0).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Bool) (b ? 1 : 0).exec(); return state->db.getLastInsertedRowId(); }); @@ -173,7 +173,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Int)(n).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Int) (n).exec(); return state->db.getLastInsertedRowId(); }); @@ -185,8 +185,8 @@ struct AttrDb auto state(_state->lock()); state->insertAttribute - .use()(key.first)(symbols[key.second])(AttrType::ListOfStrings)( - dropEmptyInitThenConcatStringsSep("\t", l)) + .use()(key.first)(symbols[key.second])( + AttrType::ListOfStrings) (dropEmptyInitThenConcatStringsSep("\t", l)) .exec(); return state->db.getLastInsertedRowId(); @@ -198,7 +198,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Placeholder)(0, false).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Placeholder) (0, false).exec(); return state->db.getLastInsertedRowId(); }); @@ -209,7 +209,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Missing)(0, false).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Missing) (0, false).exec(); return state->db.getLastInsertedRowId(); }); @@ -220,7 +220,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Misc)(0, false).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Misc) (0, false).exec(); return state->db.getLastInsertedRowId(); }); @@ -231,7 +231,7 @@ struct AttrDb return doSQLite([&]() { auto state(_state->lock()); - state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Failed)(0, false).exec(); + state->insertAttribute.use()(key.first)(symbols[key.second])(AttrType::Failed) (0, false).exec(); return state->db.getLastInsertedRowId(); }); diff --git a/src/libexpr/eval-error.cc b/src/libexpr/eval-error.cc index 247a1efd4..83360d5ff 100644 --- a/src/libexpr/eval-error.cc +++ b/src/libexpr/eval-error.cc @@ -44,12 +44,13 @@ EvalErrorBuilder & EvalErrorBuilder::withFrame(const Env & env, const Expr // NOTE: This is abusing side-effects. // TODO: check compatibility with nested debugger calls. // TODO: What side-effects?? - error.state.debugTraces.push_front(DebugTrace{ - .pos = expr.getPos(), - .expr = expr, - .env = env, - .hint = HintFmt("Fake frame for debugging purposes"), - .isError = true}); + error.state.debugTraces.push_front( + DebugTrace{ + .pos = expr.getPos(), + .expr = expr, + .env = env, + .hint = HintFmt("Fake frame for debugging purposes"), + .isError = true}); return *this; } diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index bd3e96189..c4a5fcff1 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -795,8 +795,9 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & printError("%s\n", error->what()); if (trylevel > 0 && error->info().level != lvlInfo) - printError("This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL - " to skip these.\n"); + printError( + "This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL + " to skip these.\n"); } auto se = getStaticEnv(expr); diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 6abfb312b..6d8c8477d 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -68,10 +68,11 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS std::visit( overloaded{ [&](const NixStringContextElem::Built & b) { - drvs.push_back(DerivedPath::Built{ - .drvPath = b.drvPath, - .outputs = OutputsSpec::Names{b.output}, - }); + drvs.push_back( + DerivedPath::Built{ + .drvPath = b.drvPath, + .outputs = OutputsSpec::Names{b.output}, + }); ensureValid(b.drvPath->getBaseStorePath()); }, [&](const NixStringContextElem::Opaque & o) { @@ -117,10 +118,11 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS /* Get all the output paths corresponding to the placeholders we had */ if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) { res.insert_or_assign( - DownstreamPlaceholder::fromSingleDerivedPathBuilt(SingleDerivedPath::Built{ - .drvPath = drv.drvPath, - .output = outputName, - }) + DownstreamPlaceholder::fromSingleDerivedPathBuilt( + SingleDerivedPath::Built{ + .drvPath = drv.drvPath, + .output = outputName, + }) .render(), buildStore->printStorePath(outputPath)); } @@ -297,10 +299,11 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v } } -static RegisterPrimOp primop_scopedImport(PrimOp{ - .name = "scopedImport", .arity = 2, .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) { - import(state, pos, *args[1], args[0], v); - }}); +static RegisterPrimOp primop_scopedImport( + PrimOp{ + .name = "scopedImport", .arity = 2, .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) { + import(state, pos, *args[1], args[0], v); + }}); static RegisterPrimOp primop_import( {.name = "import", @@ -806,11 +809,12 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar v.mkList(list); } -static RegisterPrimOp primop_genericClosure(PrimOp{ - .name = "__genericClosure", - .args = {"attrset"}, - .arity = 1, - .doc = R"( +static RegisterPrimOp primop_genericClosure( + PrimOp{ + .name = "__genericClosure", + .args = {"attrset"}, + .arity = 1, + .doc = R"( `builtins.genericClosure` iteratively computes the transitive closure over an arbitrary relation defined by a function. It takes *attrset* with two attributes named `startSet` and `operator`, and returns a list of attribute sets: @@ -860,8 +864,8 @@ static RegisterPrimOp primop_genericClosure(PrimOp{ > [ { key = 5; } { key = 16; } { key = 8; } { key = 4; } { key = 2; } { key = 1; } ] > ``` )", - .fun = prim_genericClosure, -}); + .fun = prim_genericClosure, + }); static RegisterPrimOp primop_break( {.name = "break", @@ -872,11 +876,12 @@ static RegisterPrimOp primop_break( )", .fun = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) { if (state.canDebug()) { - auto error = Error(ErrorInfo{ - .level = lvlInfo, - .msg = HintFmt("breakpoint reached"), - .pos = state.positions[pos], - }); + auto error = Error( + ErrorInfo{ + .level = lvlInfo, + .msg = HintFmt("breakpoint reached"), + .pos = state.positions[pos], + }); state.runDebugRepl(&error); } @@ -940,13 +945,14 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value ** a } } -static RegisterPrimOp primop_addErrorContext(PrimOp{ - .name = "__addErrorContext", - .arity = 2, - // The normal trace item is redundant - .addTrace = false, - .fun = prim_addErrorContext, -}); +static RegisterPrimOp primop_addErrorContext( + PrimOp{ + .name = "__addErrorContext", + .arity = 2, + // The normal trace item is redundant + .addTrace = false, + .fun = prim_addErrorContext, + }); static void prim_ceil(EvalState & state, const PosIdx pos, Value ** args, Value & v) { @@ -1656,11 +1662,12 @@ static void derivationStrictInternal(EvalState & state, const std::string & drvN v.mkAttrs(result); } -static RegisterPrimOp primop_derivationStrict(PrimOp{ - .name = "derivationStrict", - .arity = 1, - .fun = prim_derivationStrict, -}); +static RegisterPrimOp primop_derivationStrict( + PrimOp{ + .name = "derivationStrict", + .arity = 1, + .fun = prim_derivationStrict, + }); /* Return a placeholder string for the specified output that will be substituted by the corresponding output path at build time. For @@ -1898,9 +1905,10 @@ static void prim_readFile(EvalState & state, const PosIdx pos, Value ** args, Va } NixStringContext context; for (auto && p : std::move(refs)) { - context.insert(NixStringContextElem::Opaque{ - .path = std::move((StorePath &&) p), - }); + context.insert( + NixStringContextElem::Opaque{ + .path = std::move((StorePath &&) p), + }); } v.mkString(s, context); } @@ -1956,10 +1964,11 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va .debugThrow(); } - lookupPath.elements.emplace_back(LookupPath::Elem{ - .prefix = LookupPath::Prefix{.s = prefix}, - .path = LookupPath::Path{.s = path}, - }); + lookupPath.elements.emplace_back( + LookupPath::Elem{ + .prefix = LookupPath::Prefix{.s = prefix}, + .path = LookupPath::Path{.s = path}, + }); } auto path = @@ -1968,10 +1977,11 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va v.mkPath(state.findFile(lookupPath, path, pos)); } -static RegisterPrimOp primop_findFile(PrimOp{ - .name = "__findFile", - .args = {"search-path", "lookup-path"}, - .doc = R"( +static RegisterPrimOp primop_findFile( + PrimOp{ + .name = "__findFile", + .args = {"search-path", "lookup-path"}, + .doc = R"( Find *lookup-path* in *search-path*. [Lookup path](@docroot@/language/constructs/lookup-path.md) expressions are [desugared](https://en.wikipedia.org/wiki/Syntactic_sugar) using this and [`builtins.nixPath`](#builtins-nixPath): @@ -2099,8 +2109,8 @@ static RegisterPrimOp primop_findFile(PrimOp{ > > makes `` refer to a particular branch of the `NixOS/nixpkgs` repository on GitHub. )", - .fun = prim_findFile, -}); + .fun = prim_findFile, + }); /* Return the cryptographic hash of a file in base-16. */ static void prim_hashFile(EvalState & state, const PosIdx pos, Value ** args, Value & v) @@ -2871,11 +2881,12 @@ static void prim_unsafeGetAttrPos(EvalState & state, const PosIdx pos, Value ** state.mkPos(v, i->pos); } -static RegisterPrimOp primop_unsafeGetAttrPos(PrimOp{ - .name = "__unsafeGetAttrPos", - .arity = 2, - .fun = prim_unsafeGetAttrPos, -}); +static RegisterPrimOp primop_unsafeGetAttrPos( + PrimOp{ + .name = "__unsafeGetAttrPos", + .arity = 2, + .fun = prim_unsafeGetAttrPos, + }); // access to exact position information (ie, line and colum numbers) is deferred // due to the cost associated with calculating that information and how rarely diff --git a/src/libexpr/primops/context.cc b/src/libexpr/primops/context.cc index 4c0561b78..351e440ac 100644 --- a/src/libexpr/primops/context.cc +++ b/src/libexpr/primops/context.cc @@ -276,9 +276,10 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg if (auto attr = i.value->attrs()->get(sPath)) { if (state.forceBool(*attr->value, attr->pos, "while evaluating the `path` attribute of a string context")) - context.emplace(NixStringContextElem::Opaque{ - .path = namePath, - }); + context.emplace( + NixStringContextElem::Opaque{ + .path = namePath, + }); } if (auto attr = i.value->attrs()->get(sAllOutputs)) { @@ -291,9 +292,10 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg .atPos(i.pos) .debugThrow(); } - context.emplace(NixStringContextElem::DrvDeep{ - .drvPath = namePath, - }); + context.emplace( + NixStringContextElem::DrvDeep{ + .drvPath = namePath, + }); } } @@ -309,10 +311,11 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg for (auto elem : attr->value->listItems()) { auto outputName = state.forceStringNoCtx(*elem, attr->pos, "while evaluating an output name within a string context"); - context.emplace(NixStringContextElem::Built{ - .drvPath = makeConstantStorePathRef(namePath), - .output = std::string{outputName}, - }); + context.emplace( + NixStringContextElem::Built{ + .drvPath = makeConstantStorePathRef(namePath), + .output = std::string{outputName}, + }); } } } diff --git a/src/libfetchers/git-lfs-fetch.cc b/src/libfetchers/git-lfs-fetch.cc index dbf4b1eb9..97f10f0c6 100644 --- a/src/libfetchers/git-lfs-fetch.cc +++ b/src/libfetchers/git-lfs-fetch.cc @@ -44,10 +44,11 @@ static void downloadToSink( static std::string getLfsApiToken(const ParsedURL & url) { - auto [status, output] = runProgram(RunOptions{ - .program = "ssh", - .args = {*url.authority, "git-lfs-authenticate", url.path, "download"}, - }); + auto [status, output] = runProgram( + RunOptions{ + .program = "ssh", + .args = {*url.authority, "git-lfs-authenticate", url.path, "download"}, + }); if (output.empty()) throw Error( diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index aff628bb4..fb5fe1bba 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -389,11 +389,12 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this continue; std::string key2(key, 0, key.size() - 5); auto path = CanonPath(value); - result.push_back(Submodule{ - .path = path, - .url = entries[key2 + ".url"], - .branch = entries[key2 + ".branch"], - }); + result.push_back( + Submodule{ + .path = path, + .url = entries[key2 + ".url"], + .branch = entries[key2 + ".branch"], + }); } return result; @@ -533,14 +534,15 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this append(gitArgs, {"--depth", "1"}); append(gitArgs, {std::string("--"), url, refspec}); - runProgram(RunOptions{ - .program = "git", - .lookupPath = true, - // FIXME: git stderr messes up our progress indicator, so - // we're using --quiet for now. Should process its stderr. - .args = gitArgs, - .input = {}, - .isInteractive = true}); + runProgram( + RunOptions{ + .program = "git", + .lookupPath = true, + // FIXME: git stderr messes up our progress indicator, so + // we're using --quiet for now. Should process its stderr. + .args = gitArgs, + .input = {}, + .isInteractive = true}); } void verifyCommit(const Hash & rev, const std::vector & publicKeys) override @@ -566,17 +568,18 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this writeFile(allowedSignersFile, allowedSigners); // Run verification command - auto [status, output] = runProgram(RunOptions{ - .program = "git", - .args = - {"-c", - "gpg.ssh.allowedSignersFile=" + allowedSignersFile, - "-C", - path.string(), - "verify-commit", - rev.gitRev()}, - .mergeStderrToStdout = true, - }); + auto [status, output] = runProgram( + RunOptions{ + .program = "git", + .args = + {"-c", + "gpg.ssh.allowedSignersFile=" + allowedSignersFile, + "-C", + path.string(), + "verify-commit", + rev.gitRev()}, + .mergeStderrToStdout = true, + }); /* Evaluate result through status code and checking if public key fingerprints appear on stderr. This is neccessary diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 70a2a0f05..cc79e9437 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -56,12 +56,13 @@ Path getCachePath(std::string_view key, bool shallow) // ... std::optional readHead(const Path & path) { - auto [status, output] = runProgram(RunOptions{ - .program = "git", - // FIXME: use 'HEAD' to avoid returning all refs - .args = {"ls-remote", "--symref", path}, - .isInteractive = true, - }); + auto [status, output] = runProgram( + RunOptions{ + .program = "git", + // FIXME: use 'HEAD' to avoid returning all refs + .args = {"ls-remote", "--symref", path}, + .isInteractive = true, + }); if (status != 0) return std::nullopt; @@ -325,17 +326,18 @@ struct GitInputScheme : InputScheme writeFile(*repoPath / path.rel(), contents); - auto result = runProgram(RunOptions{ - .program = "git", - .args = - {"-C", - repoPath->string(), - "--git-dir", - repoInfo.gitDir, - "check-ignore", - "--quiet", - std::string(path.rel())}, - }); + auto result = runProgram( + RunOptions{ + .program = "git", + .args = + {"-C", + repoPath->string(), + "--git-dir", + repoInfo.gitDir, + "check-ignore", + "--quiet", + std::string(path.rel())}, + }); auto exitCode = #ifndef WIN32 // TODO abstract over exit status handling on Windows WEXITSTATUS(result.first) diff --git a/src/libfetchers/registry.cc b/src/libfetchers/registry.cc index 8a2932e24..763bbd98e 100644 --- a/src/libfetchers/registry.cc +++ b/src/libfetchers/registry.cc @@ -35,11 +35,12 @@ std::shared_ptr Registry::read(const Settings & settings, const Path & toAttrs.erase(j); } auto exact = i.find("exact"); - registry->entries.push_back(Entry{ - .from = Input::fromAttrs(settings, jsonToAttrs(i["from"])), - .to = Input::fromAttrs(settings, std::move(toAttrs)), - .extraAttrs = extraAttrs, - .exact = exact != i.end() && exact.value()}); + registry->entries.push_back( + Entry{ + .from = Input::fromAttrs(settings, jsonToAttrs(i["from"])), + .to = Input::fromAttrs(settings, std::move(toAttrs)), + .extraAttrs = extraAttrs, + .exact = exact != i.end() && exact.value()}); } } diff --git a/src/libstore-test-support/outputs-spec.cc b/src/libstore-test-support/outputs-spec.cc index 0a74e4aac..d5128a8bd 100644 --- a/src/libstore-test-support/outputs-spec.cc +++ b/src/libstore-test-support/outputs-spec.cc @@ -14,8 +14,9 @@ Gen Arbitrary::arbitrary() return gen::just((OutputsSpec) OutputsSpec::All{}); case 1: return gen::map( - gen::nonEmpty(gen::container( - gen::map(gen::arbitrary(), [](StorePathName n) { return n.name; }))), + gen::nonEmpty( + gen::container( + gen::map(gen::arbitrary(), [](StorePathName n) { return n.name; }))), [](StringSet names) { return (OutputsSpec) OutputsSpec::Names{names}; }); default: assert(false); diff --git a/src/libstore-tests/worker-protocol.cc b/src/libstore-tests/worker-protocol.cc index b50d1c785..7c898c105 100644 --- a/src/libstore-tests/worker-protocol.cc +++ b/src/libstore-tests/worker-protocol.cc @@ -82,15 +82,17 @@ VERSIONED_CHARACTERIZATION_TEST( .path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"}, }, DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(StorePath{ - "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", - }), + .drvPath = makeConstantStorePathRef( + StorePath{ + "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", + }), .outputs = OutputsSpec::All{}, }, DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(StorePath{ - "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", - }), + .drvPath = makeConstantStorePathRef( + StorePath{ + "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", + }), .outputs = OutputsSpec::Names{"x", "y"}, }, })) @@ -108,15 +110,17 @@ VERSIONED_CHARACTERIZATION_TEST( .path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"}, }, DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(StorePath{ - "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", - }), + .drvPath = makeConstantStorePathRef( + StorePath{ + "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", + }), .outputs = OutputsSpec::All{}, }, DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(StorePath{ - "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", - }), + .drvPath = makeConstantStorePathRef( + StorePath{ + "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", + }), .outputs = OutputsSpec::Names{"x", "y"}, }, })) @@ -369,9 +373,10 @@ VERSIONED_CHARACTERIZATION_TEST(WorkerProtoTest, keyedBuildResult_1_29, "keyed-b }, /* .path = */ DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(StorePath{ - "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", - }), + .drvPath = makeConstantStorePathRef( + StorePath{ + "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv", + }), .outputs = OutputsSpec::Names{"out"}, }, }, diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 147955838..eb9ac7f9c 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -1456,10 +1456,11 @@ std::pair DerivationGoal::checkPathValidity() // derivation, and the output path is valid, but we don't have // its realisation stored (probably because it has been built // without the `ca-derivations` experimental flag). - worker.store.registerDrvOutput(Realisation{ - drvOutput, - info.known->path, - }); + worker.store.registerDrvOutput( + Realisation{ + drvOutput, + info.known->path, + }); } } if (info.known && info.known->isValid()) @@ -1551,10 +1552,11 @@ void DerivationGoal::waiteeDone(GoalPtr waitee, ExitCode result) auto & outputs = nodeP->value; for (auto & outputName : outputs) { - auto buildResult = dg->getBuildResult(DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(dg->drvPath), - .outputs = OutputsSpec::Names{outputName}, - }); + auto buildResult = dg->getBuildResult( + DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(dg->drvPath), + .outputs = OutputsSpec::Names{outputName}, + }); if (buildResult.success()) { auto i = buildResult.builtOutputs.find(outputName); if (i != buildResult.builtOutputs.end()) diff --git a/src/libstore/build/entry-points.cc b/src/libstore/build/entry-points.cc index 1fd76c2fd..f0263ca88 100644 --- a/src/libstore/build/entry-points.cc +++ b/src/libstore/build/entry-points.cc @@ -68,10 +68,11 @@ std::vector Store::buildPathsWithResults( results.reserve(state.size()); for (auto & [req, goalPtr] : state) - results.emplace_back(KeyedBuildResult{ - goalPtr->getBuildResult(req), - /* .path = */ req, - }); + results.emplace_back( + KeyedBuildResult{ + goalPtr->getBuildResult(req), + /* .path = */ req, + }); return results; } @@ -88,10 +89,11 @@ BuildResult Store::buildDerivation(const StorePath & drvPath, const BasicDerivat try { worker.run(Goals{goal}); - return goal->getBuildResult(DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(drvPath), - .outputs = OutputsSpec::All{}, - }); + return goal->getBuildResult( + DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(drvPath), + .outputs = OutputsSpec::All{}, + }); } catch (Error & e) { return BuildResult{ .status = BuildResult::MiscFailure, diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 26314b251..e52275578 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -279,10 +279,11 @@ void Worker::run(const Goals & _topGoals) for (auto & i : _topGoals) { topGoals.insert(i); if (auto goal = dynamic_cast(i.get())) { - topPaths.push_back(DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(goal->drvPath), - .outputs = goal->wantedOutputs, - }); + topPaths.push_back( + DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(goal->drvPath), + .outputs = goal->wantedOutputs, + }); } else if (auto goal = dynamic_cast(i.get())) { topPaths.push_back(DerivedPath::Opaque{goal->storePath}); } diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index ccc05fc71..d3f7ee07b 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -39,10 +39,11 @@ LegacySSHStore::LegacySSHStore(std::string_view scheme, std::string_view host, c , CommonSSHStoreConfig(scheme, host, params) , LegacySSHStoreConfig(scheme, host, params) , Store(params) - , connections(make_ref>( - std::max(1, (int) maxConnections), - [this]() { return openConnection(); }, - [](const ref & r) { return r->good; })) + , connections( + make_ref>( + std::max(1, (int) maxConnections), + [this]() { return openConnection(); }, + [](const ref & r) { return r->good; })) , master(createSSHMaster( // Use SSH master only if using more than 1 connection. connections->capacity() > 1, diff --git a/src/libstore/machines.cc b/src/libstore/machines.cc index 119d7c3ad..1f1a2b29d 100644 --- a/src/libstore/machines.cc +++ b/src/libstore/machines.cc @@ -15,15 +15,16 @@ Machine::Machine( decltype(supportedFeatures) supportedFeatures, decltype(mandatoryFeatures) mandatoryFeatures, decltype(sshPublicHostKey) sshPublicHostKey) - : storeUri(StoreReference::parse( - // Backwards compatibility: if the URI is schemeless, is not a path, - // and is not one of the special store connection words, prepend - // ssh://. - storeUri.find("://") != std::string::npos || storeUri.find("/") != std::string::npos || storeUri == "auto" - || storeUri == "daemon" || storeUri == "local" || hasPrefix(storeUri, "auto?") - || hasPrefix(storeUri, "daemon?") || hasPrefix(storeUri, "local?") || hasPrefix(storeUri, "?") - ? storeUri - : "ssh://" + storeUri)) + : storeUri( + StoreReference::parse( + // Backwards compatibility: if the URI is schemeless, is not a path, + // and is not one of the special store connection words, prepend + // ssh://. + storeUri.find("://") != std::string::npos || storeUri.find("/") != std::string::npos || storeUri == "auto" + || storeUri == "daemon" || storeUri == "local" || hasPrefix(storeUri, "auto?") + || hasPrefix(storeUri, "daemon?") || hasPrefix(storeUri, "local?") || hasPrefix(storeUri, "?") + ? storeUri + : "ssh://" + storeUri)) , systemTypes(systemTypes) , sshKey(sshKey) , maxJobs(maxJobs) @@ -171,22 +172,23 @@ static Machine parseBuilderLine(const std::set & defaultSystems, co // TODO use designated initializers, once C++ supports those with // custom constructors. - return {// `storeUri` - tokens[0], - // `systemTypes` - isSet(1) ? tokenizeString>(tokens[1], ",") : defaultSystems, - // `sshKey` - isSet(2) ? tokens[2] : "", - // `maxJobs` - isSet(3) ? parseUnsignedIntField(3) : 1U, - // `speedFactor` - isSet(4) ? parseFloatField(4) : 1.0f, - // `supportedFeatures` - isSet(5) ? tokenizeString>(tokens[5], ",") : std::set{}, - // `mandatoryFeatures` - isSet(6) ? tokenizeString>(tokens[6], ",") : std::set{}, - // `sshPublicHostKey` - isSet(7) ? ensureBase64(7) : ""}; + return { + // `storeUri` + tokens[0], + // `systemTypes` + isSet(1) ? tokenizeString>(tokens[1], ",") : defaultSystems, + // `sshKey` + isSet(2) ? tokens[2] : "", + // `maxJobs` + isSet(3) ? parseUnsignedIntField(3) : 1U, + // `speedFactor` + isSet(4) ? parseFloatField(4) : 1.0f, + // `supportedFeatures` + isSet(5) ? tokenizeString>(tokens[5], ",") : std::set{}, + // `mandatoryFeatures` + isSet(6) ? tokenizeString>(tokens[6], ",") : std::set{}, + // `sshPublicHostKey` + isSet(7) ? ensureBase64(7) : ""}; } static Machines diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index e88450a3b..80b18ca5c 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -27,25 +27,26 @@ namespace nix { RemoteStore::RemoteStore(const Params & params) : RemoteStoreConfig(params) , Store(params) - , connections(make_ref>( - std::max(1, (int) maxConnections), - [this]() { - auto conn = openConnectionWrapper(); - try { - initConnection(*conn); - } catch (...) { - failed = true; - throw; - } - return conn; - }, - [this](const ref & r) { - return r->to.good() && r->from.good() - && std::chrono::duration_cast( - std::chrono::steady_clock::now() - r->startTime) - .count() - < maxConnectionAge; - })) + , connections( + make_ref>( + std::max(1, (int) maxConnections), + [this]() { + auto conn = openConnectionWrapper(); + try { + initConnection(*conn); + } catch (...) { + failed = true; + throw; + } + return conn; + }, + [this](const ref & r) { + return r->to.good() && r->from.good() + && std::chrono::duration_cast( + std::chrono::steady_clock::now() - r->startTime) + .count() + < maxConnectionAge; + })) { } @@ -655,12 +656,13 @@ std::vector RemoteStore::buildPathsWithResults( std::visit( overloaded{ [&](const DerivedPath::Opaque & bo) { - results.push_back(KeyedBuildResult{ - { - .status = BuildResult::Substituted, - }, - /* .path = */ bo, - }); + results.push_back( + KeyedBuildResult{ + { + .status = BuildResult::Substituted, + }, + /* .path = */ bo, + }); }, [&](const DerivedPath::Built & bfd) { KeyedBuildResult res{ diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index 3538b3c36..03b9dfed9 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -93,19 +93,21 @@ static void initAWS() S3Helper::S3Helper( const std::string & profile, const std::string & region, const std::string & scheme, const std::string & endpoint) : config(makeConfig(region, scheme, endpoint)) - , client(make_ref( - profile == "" ? std::dynamic_pointer_cast( - std::make_shared()) - : std::dynamic_pointer_cast( - std::make_shared(profile.c_str())), - *config, + , client( + make_ref( + profile == "" + ? std::dynamic_pointer_cast( + std::make_shared()) + : std::dynamic_pointer_cast( + std::make_shared(profile.c_str())), + *config, // FIXME: https://github.com/aws/aws-sdk-cpp/issues/759 # if AWS_SDK_VERSION_MAJOR == 1 && AWS_SDK_VERSION_MINOR < 3 - false, + false, # else - Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, + Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, # endif - endpoint.empty())) + endpoint.empty())) { } diff --git a/src/libstore/unix/build/local-derivation-goal.cc b/src/libstore/unix/build/local-derivation-goal.cc index 8f89a415a..88c82e063 100644 --- a/src/libstore/unix/build/local-derivation-goal.cc +++ b/src/libstore/unix/build/local-derivation-goal.cc @@ -88,13 +88,14 @@ void handleDiffHook( if (diffHookOpt && settings.runDiffHook) { auto & diffHook = *diffHookOpt; try { - auto diffRes = runProgram(RunOptions{ - .program = diffHook, - .lookupPath = true, - .args = {tryA, tryB, drvPath, tmpDir}, - .uid = uid, - .gid = gid, - .chdir = "/"}); + auto diffRes = runProgram( + RunOptions{ + .program = diffHook, + .lookupPath = true, + .args = {tryA, tryB, drvPath, tmpDir}, + .uid = uid, + .gid = gid, + .chdir = "/"}); if (!statusOk(diffRes.first)) throw ExecError(diffRes.first, "diff-hook program '%1%' %2%", diffHook, statusToString(diffRes.first)); @@ -2715,10 +2716,11 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() std::filesystem::rename(tmpOutput, actualPath); - auto newInfo0 = newInfoFromCA(DerivationOutput::CAFloating{ - .method = dof.ca.method, - .hashAlgo = wanted.algo, - }); + auto newInfo0 = newInfoFromCA( + DerivationOutput::CAFloating{ + .method = dof.ca.method, + .hashAlgo = wanted.algo, + }); /* Check wanted hash */ assert(newInfo0.ca); @@ -2754,10 +2756,11 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() }, [&](const DerivationOutput::Impure & doi) { - return newInfoFromCA(DerivationOutput::CAFloating{ - .method = doi.method, - .hashAlgo = doi.hashAlgo, - }); + return newInfoFromCA( + DerivationOutput::CAFloating{ + .method = doi.method, + .hashAlgo = doi.hashAlgo, + }); }, }, diff --git a/src/libutil-tests/config.cc b/src/libutil-tests/config.cc index d488a2ad6..5fb2229b6 100644 --- a/src/libutil-tests/config.cc +++ b/src/libutil-tests/config.cc @@ -314,9 +314,10 @@ TEST(Config, applyConfigFailsOnMissingIncludes) Setting setting{&config, "", "name-of-the-setting", "description"}; ASSERT_THROW( - config.applyConfig("name-of-the-setting = value-from-file\n" - "# name-of-the-setting = foo\n" - "include /nix/store/does/not/exist.nix"), + config.applyConfig( + "name-of-the-setting = value-from-file\n" + "# name-of-the-setting = foo\n" + "include /nix/store/does/not/exist.nix"), Error); } diff --git a/src/libutil-tests/json-utils.cc b/src/libutil-tests/json-utils.cc index 489501598..dc97c9b33 100644 --- a/src/libutil-tests/json-utils.cc +++ b/src/libutil-tests/json-utils.cc @@ -31,10 +31,11 @@ TEST(to_json, vectorOfOptionalInts) TEST(to_json, optionalVectorOfInts) { - std::optional> val = std::make_optional(std::vector{ - -420, - 420, - }); + std::optional> val = std::make_optional( + std::vector{ + -420, + 420, + }); ASSERT_EQ(nlohmann::json(val), nlohmann::json::parse("[-420,420]")); val = std::nullopt; ASSERT_EQ(nlohmann::json(val), nlohmann::json(nullptr)); diff --git a/src/libutil/suggestions.cc b/src/libutil/suggestions.cc index 7754892c0..578a5b43b 100644 --- a/src/libutil/suggestions.cc +++ b/src/libutil/suggestions.cc @@ -41,10 +41,11 @@ Suggestions Suggestions::bestMatches(const std::set & allMatches, s { std::set res; for (const auto & possibleMatch : allMatches) { - res.insert(Suggestion{ - .distance = levenshteinDistance(query, possibleMatch), - .suggestion = possibleMatch, - }); + res.insert( + Suggestion{ + .distance = levenshteinDistance(query, possibleMatch), + .suggestion = possibleMatch, + }); } return Suggestions{res}; } diff --git a/src/libutil/unix/processes.cc b/src/libutil/unix/processes.cc index bae7423dc..9582ff840 100644 --- a/src/libutil/unix/processes.cc +++ b/src/libutil/unix/processes.cc @@ -253,8 +253,13 @@ pid_t startProcess(std::function fun, const ProcessOptions & options) std::string runProgram( Path program, bool lookupPath, const Strings & args, const std::optional & input, bool isInteractive) { - auto res = runProgram(RunOptions{ - .program = program, .lookupPath = lookupPath, .args = args, .input = input, .isInteractive = isInteractive}); + auto res = runProgram( + RunOptions{ + .program = program, + .lookupPath = lookupPath, + .args = args, + .input = input, + .isInteractive = isInteractive}); if (!statusOk(res.first)) throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first)); diff --git a/src/libutil/windows/processes.cc b/src/libutil/windows/processes.cc index 8adadd0a3..f8f2900e5 100644 --- a/src/libutil/windows/processes.cc +++ b/src/libutil/windows/processes.cc @@ -84,8 +84,13 @@ int Pid::wait() std::string runProgram( Path program, bool lookupPath, const Strings & args, const std::optional & input, bool isInteractive) { - auto res = runProgram(RunOptions{ - .program = program, .lookupPath = lookupPath, .args = args, .input = input, .isInteractive = isInteractive}); + auto res = runProgram( + RunOptions{ + .program = program, + .lookupPath = lookupPath, + .args = args, + .input = input, + .isInteractive = isInteractive}); if (!statusOk(res.first)) throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first)); diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 2e750b71f..75ff2f01d 100644 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -480,10 +480,11 @@ static void main_nix_build(int argc, char ** argv) throw Error("the 'bashInteractive' attribute in did not evaluate to a derivation"); auto bashDrv = drv->requireDrvPath(); - pathsToBuild.push_back(DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(bashDrv), - .outputs = OutputsSpec::Names{"out"}, - }); + pathsToBuild.push_back( + DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(bashDrv), + .outputs = OutputsSpec::Names{"out"}, + }); pathsToCopy.insert(bashDrv); shellDrv = bashDrv; @@ -499,10 +500,11 @@ static void main_nix_build(int argc, char ** argv) accumDerivedPath = [&](ref inputDrv, const DerivedPathMap::ChildNode & inputNode) { if (!inputNode.value.empty()) - pathsToBuild.push_back(DerivedPath::Built{ - .drvPath = inputDrv, - .outputs = OutputsSpec::Names{inputNode.value}, - }); + pathsToBuild.push_back( + DerivedPath::Built{ + .drvPath = inputDrv, + .outputs = OutputsSpec::Names{inputNode.value}, + }); for (const auto & [outputName, childNode] : inputNode.childMap) accumDerivedPath( make_ref(SingleDerivedPath::Built{inputDrv, outputName}), childNode); @@ -687,10 +689,11 @@ static void main_nix_build(int argc, char ** argv) if (outputName == "") throw Error("derivation '%s' lacks an 'outputName' attribute", store->printStorePath(drvPath)); - pathsToBuild.push_back(DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(drvPath), - .outputs = OutputsSpec::Names{outputName}, - }); + pathsToBuild.push_back( + DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(drvPath), + .outputs = OutputsSpec::Names{outputName}, + }); pathsToBuildOrdered.push_back({drvPath, {outputName}}); drvsToCopy.insert(drvPath); diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 186203b52..493bc8eee 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -467,9 +467,10 @@ static void printMissing(EvalState & state, PackageInfos & elems) }; targets.emplace_back(std::move(path)); } else - targets.emplace_back(DerivedPath::Opaque{ - .path = i.queryOutPath(), - }); + targets.emplace_back( + DerivedPath::Opaque{ + .path = i.queryOutPath(), + }); printMissing(state.store, targets); } @@ -1108,7 +1109,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) attrs["substitutable"] = hasSubs ? "1" : "0"; } else columns.push_back( - (std::string)(isInstalled ? "I" : "-") + (isValid ? "P" : "-") + (hasSubs ? "S" : "-")); + (std::string) (isInstalled ? "I" : "-") + (isValid ? "P" : "-") + (hasSubs ? "S" : "-")); } if (xmlOutput) diff --git a/src/nix/app.cc b/src/nix/app.cc index 12d5791a0..765d892f8 100644 --- a/src/nix/app.cc +++ b/src/nix/app.cc @@ -70,28 +70,29 @@ UnresolvedApp InstallableValue::toApp(EvalState & state) std::vector context2; for (auto & c : context) { - context2.emplace_back(std::visit( - overloaded{ - [&](const NixStringContextElem::DrvDeep & d) -> DerivedPath { - /* We want all outputs of the drv */ - return DerivedPath::Built{ - .drvPath = makeConstantStorePathRef(d.drvPath), - .outputs = OutputsSpec::All{}, - }; + context2.emplace_back( + std::visit( + overloaded{ + [&](const NixStringContextElem::DrvDeep & d) -> DerivedPath { + /* We want all outputs of the drv */ + return DerivedPath::Built{ + .drvPath = makeConstantStorePathRef(d.drvPath), + .outputs = OutputsSpec::All{}, + }; + }, + [&](const NixStringContextElem::Built & b) -> DerivedPath { + return DerivedPath::Built{ + .drvPath = b.drvPath, + .outputs = OutputsSpec::Names{b.output}, + }; + }, + [&](const NixStringContextElem::Opaque & o) -> DerivedPath { + return DerivedPath::Opaque{ + .path = o.path, + }; + }, }, - [&](const NixStringContextElem::Built & b) -> DerivedPath { - return DerivedPath::Built{ - .drvPath = b.drvPath, - .outputs = OutputsSpec::Names{b.output}, - }; - }, - [&](const NixStringContextElem::Opaque & o) -> DerivedPath { - return DerivedPath::Opaque{ - .path = o.path, - }; - }, - }, - c.raw)); + c.raw)); } return UnresolvedApp{App{ diff --git a/src/nix/main.cc b/src/nix/main.cc index fe7f8325c..8bb974101 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -402,10 +402,11 @@ void mainWrapped(int argc, char ** argv) self-aware. That is, it has to know where it is installed. We don't think it's sentient. */ - settings.buildHook.setDefault(Strings{ - getNixBin({}).string(), - "__build-remote", - }); + settings.buildHook.setDefault( + Strings{ + getNixBin({}).string(), + "__build-remote", + }); #ifdef __linux__ if (isRootUser()) { diff --git a/src/nix/repl.cc b/src/nix/repl.cc index f6d4dd492..e4f96cf13 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -15,13 +15,14 @@ void runNix(Path program, const Strings & args, const std::optional auto subprocessEnv = getEnv(); subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue(); // isInteractive avoid grabling interactive commands - runProgram2(RunOptions{ - .program = getNixBin(program).string(), - .args = args, - .environment = subprocessEnv, - .input = input, - .isInteractive = true, - }); + runProgram2( + RunOptions{ + .program = getNixBin(program).string(), + .args = args, + .environment = subprocessEnv, + .input = input, + .isInteractive = true, + }); return; } diff --git a/src/nix/search.cc b/src/nix/search.cc index 52c947c4b..1cf76bc84 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -34,13 +34,14 @@ struct CmdSearch : InstallableValueCommand, MixJSON CmdSearch() { expectArgs("regex", &res); - addFlag(Flag{ - .longName = "exclude", - .shortName = 'e', - .description = "Hide packages whose attribute path, name or description contain *regex*.", - .labels = {"regex"}, - .handler = {[this](std::string s) { excludeRes.push_back(s); }}, - }); + addFlag( + Flag{ + .longName = "exclude", + .shortName = 'e', + .description = "Hide packages whose attribute path, name or description contain *regex*.", + .labels = {"regex"}, + .handler = {[this](std::string s) { excludeRes.push_back(s); }}, + }); } std::string description() override