diff options
author | Jade Lovelace <software@lfcode.ca> | 2024-03-05 09:14:43 -0800 |
---|---|---|
committer | Jade Lovelace <software@lfcode.ca> | 2024-03-05 09:14:43 -0800 |
commit | a07dd748d9591d00f53d0ea741fc0dd00397a879 (patch) | |
tree | 2d4655ed8407bee0317f3a07aa2f4b3398fe4442 /pkgs/tools/nix | |
parent | e09d2ff9da954e562d81e8cb219b871d8aff48f9 (diff) |
nixos-option: update to nix 2.18
This utility has horrendous code quality, partially due to nix's fault,
and really desperately needs to be rewritten, hopefully to not use the
nix C++ API. Either use the Python bindings to the Nix C API when the
Nix team merges the C API, or just write a clever bit of Nix script to
extract the data from a config, turn it into json, then process it into
good output in a CLI wrapper.
It currently does not support flakes and has many other issues.
(in my testing it did not accept -I nixos-path, it exploded due to
having plugins in /etc/nix/nix.conf with no way to override that, among
other breakage that simply does not exist in the Nix CLI).
Diffstat (limited to 'pkgs/tools/nix')
-rw-r--r-- | pkgs/tools/nix/nixos-option/nixos-option.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pkgs/tools/nix/nixos-option/nixos-option.cc b/pkgs/tools/nix/nixos-option/nixos-option.cc index e2a73866d0ed..d8c3d46c4fa1 100644 --- a/pkgs/tools/nix/nixos-option/nixos-option.cc +++ b/pkgs/tools/nix/nixos-option/nixos-option.cc @@ -368,20 +368,20 @@ std::string describeError(const Error & e) { return "«error: " + e.msg() + "»" void describeDerivation(Context & ctx, Out & out, Value v) { // Copy-pasted from nix/src/nix/repl.cc :( + out << "«derivation "; Bindings::iterator i = v.attrs->find(ctx.state.sDrvPath); - PathSet pathset; - try { - Path drvPath = i != v.attrs->end() ? ctx.state.coerceToPath(i->pos, *i->value, pathset, "while evaluating the drvPath of a derivation") : "???"; - out << "«derivation " << drvPath << "»"; - } catch (Error & e) { - out << describeError(e); - } + nix::NixStringContext strContext; + if (i != v.attrs->end()) + out << ctx.state.store->printStorePath(ctx.state.coerceToStorePath(i->pos, *i->value, strContext, "while evaluating the drvPath of a derivation")); + else + out << "???"; + out << "»"; } Value parseAndEval(EvalState & state, const std::string & expression, const std::string & path) { Value v{}; - state.eval(state.parseExprFromString(expression, absPath(path)), v); + state.eval(state.parseExprFromString(expression, nix::SourcePath(nix::CanonPath::fromCwd(path))), v); return v; } |