diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-03-21 14:00:54 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-03-24 21:33:33 +0100 |
commit | 41659418cfeb7a33fc76716a1847f79ae13d9b0c (patch) | |
tree | c23b5ef270231f2990fd575beaf63ed030d49de9 | |
parent | f4bafc412fac79ce07c89f8d3ab9bd1c32f7b9cd (diff) |
fetchClosure: Require a CA path in pure mode
-rw-r--r-- | src/libexpr/primops/fetchClosure.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libexpr/primops/fetchClosure.cc b/src/libexpr/primops/fetchClosure.cc index 4bcc716db..22a4649a4 100644 --- a/src/libexpr/primops/fetchClosure.cc +++ b/src/libexpr/primops/fetchClosure.cc @@ -43,12 +43,19 @@ static void prim_fetchClosure(EvalState & state, const Pos & pos, Value * * args copyClosure(*srcStore, *state.store, RealisedPath::Set { *storePath }); - auto storePathS = state.store->printStorePath(*storePath); + /* In pure mode, require a CA path. */ + if (evalSettings.pureEval) { + auto info = state.store->queryPathInfo(*storePath); + if (!info->isContentAddressed(*state.store)) + throw Error({ + .msg = hintfmt("in pure mode, 'fetchClosure' requires a content-addressed path, which '%s' isn't", + state.store->printStorePath(*storePath)), + .errPos = pos + }); + } + auto storePathS = state.store->printStorePath(*storePath); v.mkString(storePathS, {storePathS}); - - // FIXME: in pure mode, require a CA path or a NAR hash of the - // top-level path. } static RegisterPrimOp primop_fetchClosure({ |