diff options
-rw-r--r-- | doc/manual/src/expressions/language-operators.md | 3 | ||||
-rw-r--r-- | flake.nix | 5 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 12 | ||||
-rw-r--r-- | src/libstore/build/derivation-goal.cc | 29 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 2 | ||||
-rw-r--r-- | src/nix/develop.cc | 2 | ||||
-rw-r--r-- | src/nix/main.cc | 2 | ||||
-rw-r--r-- | src/nix/profile.cc | 2 | ||||
-rw-r--r-- | src/nix/search.cc | 11 | ||||
-rw-r--r-- | tests/init.sh | 1 |
10 files changed, 47 insertions, 22 deletions
diff --git a/doc/manual/src/expressions/language-operators.md b/doc/manual/src/expressions/language-operators.md index 1d787ffe3..b7fd6f4c6 100644 --- a/doc/manual/src/expressions/language-operators.md +++ b/doc/manual/src/expressions/language-operators.md @@ -25,5 +25,4 @@ order of precedence (from strongest to weakest binding). | Inequality | *e1* `!=` *e2* | none | Inequality. | 11 | | Logical AND | *e1* `&&` *e2* | left | Logical AND. | 12 | | Logical OR | *e1* `\|\|` *e2* | left | Logical OR. | 13 | -| Logical Implication | *e1* `->` *e2* | none | Logical implication (equivalent to `!e1 \|\| - e2`). | 14 | +| Logical Implication | *e1* `->` *e2* | none | Logical implication (equivalent to `!e1 \|\| e2`). | 14 | @@ -115,7 +115,7 @@ # 'nix.perl-bindings' packages. overlay = final: prev: { - nix = with final; with commonDeps pkgs; (stdenv.mkDerivation { + nix = with final; with commonDeps pkgs; stdenv.mkDerivation { name = "nix-${version}"; inherit version; @@ -163,9 +163,8 @@ installCheckFlags = "sysconfdir=$(out)/etc"; separateDebugInfo = true; - }) // { - perl-bindings = with final; stdenv.mkDerivation { + passthru.perl-bindings = with final; stdenv.mkDerivation { name = "nix-perl-${version}"; src = self; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 13565b950..1d1afa768 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -696,10 +696,14 @@ static RegisterPrimOp primop_tryEval({ Try to shallowly evaluate *e*. Return a set containing the attributes `success` (`true` if *e* evaluated successfully, `false` if an error was thrown) and `value`, equalling *e* if - successful and `false` otherwise. Note that this doesn't evaluate - *e* deeply, so ` let e = { x = throw ""; }; in (builtins.tryEval - e).success ` will be `true`. Using ` builtins.deepSeq ` one can - get the expected result: `let e = { x = throw ""; }; in + successful and `false` otherwise. `tryEval` will only prevent + errors created by `throw` or `assert` from being thrown. + Errors `tryEval` will not catch are for example those created + by `abort` and type errors generated by builtins. Also note that + this doesn't evaluate *e* deeply, so `let e = { x = throw ""; }; + in (builtins.tryEval e).success` will be `true`. Using + `builtins.deepSeq` one can get the expected result: + `let e = { x = throw ""; }; in (builtins.tryEval (builtins.deepSeq e e)).success` will be `false`. )", diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 179a010d4..190adf31c 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -536,12 +536,12 @@ void DerivationGoal::inputsRealised() if (!optRealizedInput) throw Error( "derivation '%s' requires output '%s' from input derivation '%s', which is supposedly realized already, yet we still don't know what path corresponds to that output", - worker.store.printStorePath(drvPath), j, worker.store.printStorePath(drvPath)); + worker.store.printStorePath(drvPath), j, worker.store.printStorePath(depDrvPath)); worker.store.computeFSClosure(*optRealizedInput, inputPaths); } else throw Error( "derivation '%s' requires non-existent output '%s' from input derivation '%s'", - worker.store.printStorePath(drvPath), j, worker.store.printStorePath(drvPath)); + worker.store.printStorePath(drvPath), j, worker.store.printStorePath(depDrvPath)); } } } @@ -1044,7 +1044,14 @@ HookReply DerivationGoal::tryBuildHook() whether the hook wishes to perform the build. */ string reply; while (true) { - string s = readLine(worker.hook->fromHook.readSide.get()); + auto s = [&]() { + try { + return readLine(worker.hook->fromHook.readSide.get()); + } catch (Error & e) { + e.addTrace({}, "while reading the response from the build hook"); + throw e; + } + }(); if (handleJSONLogMessage(s, worker.act, worker.hook->activities, true)) ; else if (string(s, 0, 2) == "# ") { @@ -1084,7 +1091,12 @@ HookReply DerivationGoal::tryBuildHook() hook = std::move(worker.hook); - machineName = readLine(hook->fromHook.readSide.get()); + try { + machineName = readLine(hook->fromHook.readSide.get()); + } catch (Error & e) { + e.addTrace({}, "while reading the machine name from the build hook"); + throw e; + } /* Tell the hook all the inputs that have to be copied to the remote system. */ @@ -1773,7 +1785,14 @@ void DerivationGoal::startBuilder() /* Check if setting up the build environment failed. */ while (true) { - string msg = readLine(builderOut.readSide.get()); + string msg = [&]() { + try { + return readLine(builderOut.readSide.get()); + } catch (Error & e) { + e.addTrace({}, "while reading the response of setting up the build environment"); + throw e; + } + }(); if (string(msg, 0, 1) == "\2") break; if (string(msg, 0, 1) == "\1") { FdSource source(builderOut.readSide.get()); diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index d4ec1497f..37c11fe86 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -394,7 +394,7 @@ OutputPathMap Store::queryDerivationOutputMap(const StorePath & path) { OutputPathMap result; for (auto & [outName, optOutPath] : resp) { if (!optOutPath) - throw Error("output '%s' has no store path mapped to it", outName); + throw Error("output '%s' of derivation '%s' has no store path mapped to it", outName, printStorePath(path)); result.insert_or_assign(outName, *optOutPath); } return result; diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 578258394..3c44fdb0e 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -239,7 +239,7 @@ struct Common : InstallableCommand, MixProfile out << buildEnvironment.bashFunctions << "\n"; - out << "export NIX_BUILD_TOP=\"$(mktemp -d --tmpdir nix-shell.XXXXXX)\"\n"; + out << "export NIX_BUILD_TOP=\"$(mktemp -d -t nix-shell.XXXXXX)\"\n"; for (auto & i : {"TMP", "TMPDIR", "TEMP", "TEMPDIR"}) out << fmt("export %s=\"$NIX_BUILD_TOP\"\n", i); diff --git a/src/nix/main.cc b/src/nix/main.cc index 58b643cc5..e95b04d85 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -91,7 +91,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs }); addFlag({ - .longName = "no-net", + .longName = "offline", .description = "Disable substituters and consider all previously downloaded files up-to-date.", .handler = {[&]() { useNet = false; }}, }); diff --git a/src/nix/profile.cc b/src/nix/profile.cc index 765d6866e..827f8be5a 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -249,7 +249,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile attrPath, }; - pathsToBuild.push_back({drv.drvPath, StringSet{"out"}}); // FIXME + pathsToBuild.push_back({drv.drvPath, StringSet{drv.outputName}}); manifest.elements.emplace_back(std::move(element)); } else { diff --git a/src/nix/search.cc b/src/nix/search.cc index 9f864b3a4..c52a48d4e 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -81,9 +81,9 @@ struct CmdSearch : InstallableCommand, MixJSON uint64_t results = 0; - std::function<void(eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath)> visit; + std::function<void(eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath, bool initialRecurse)> visit; - visit = [&](eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath) + visit = [&](eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath, bool initialRecurse) { Activity act(*logger, lvlInfo, actUnknown, fmt("evaluating '%s'", concatStringsSep(".", attrPath))); @@ -94,7 +94,7 @@ struct CmdSearch : InstallableCommand, MixJSON auto cursor2 = cursor.getAttr(attr); auto attrPath2(attrPath); attrPath2.push_back(attr); - visit(*cursor2, attrPath2); + visit(*cursor2, attrPath2, false); } }; @@ -150,6 +150,9 @@ struct CmdSearch : InstallableCommand, MixJSON || (attrPath[0] == "packages" && attrPath.size() <= 2)) recurse(); + else if (initialRecurse) + recurse(); + else if (attrPath[0] == "legacyPackages" && attrPath.size() > 2) { auto attr = cursor.maybeGetAttr(state->sRecurseForDerivations); if (attr && attr->getBool()) @@ -163,7 +166,7 @@ struct CmdSearch : InstallableCommand, MixJSON }; for (auto & [cursor, prefix] : installable->getCursors(*state)) - visit(*cursor, parseAttrPath(*state, prefix)); + visit(*cursor, parseAttrPath(*state, prefix), true); if (!json && !results) throw Error("no results for the given search term(s)!"); diff --git a/tests/init.sh b/tests/init.sh index 63cf895e2..1a6ccb6fe 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -21,6 +21,7 @@ experimental-features = nix-command flakes gc-reserved-space = 0 substituters = flake-registry = $TEST_ROOT/registry.json +show-trace = true include nix.conf.extra EOF |