diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-03-02 10:57:19 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-03-02 23:58:58 +0100 |
commit | b55d79728ccbd2581fa3aa7b2ec7f498aa2285d6 (patch) | |
tree | 730a2a80d984d557f3ff0c50da8916f97e6c02af /src/libexpr/eval.cc | |
parent | 3e3d0711d4c4409172b3e3f342e204d04d554f4b (diff) |
Add EvalState::coerceToStorePath() helper
This is useful whenever we want to evaluate something to a store path
(e.g. in get-drvs.cc).
Extracted from the lazy-trees branch (where we can require that a
store path must come from a store source tree accessor).
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 8c5888497..193358161 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -2058,6 +2058,18 @@ Path EvalState::coerceToPath(const Pos & pos, Value & v, PathSet & context) } +StorePath EvalState::coerceToStorePath(const Pos & pos, Value & v, PathSet & context) +{ + auto path = coerceToString(pos, v, context, false, false).toOwned(); + if (auto storePath = store->maybeParseStorePath(path)) + return *storePath; + throw EvalError({ + .msg = hintfmt("path '%1%' is not in the Nix store", path), + .errPos = pos + }); +} + + bool EvalState::eqValues(Value & v1, Value & v2) { forceValue(v1, noPos); |