diff options
Diffstat (limited to 'src/libexpr/primops/fetchTree.cc')
-rw-r--r-- | src/libexpr/primops/fetchTree.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 43c58485a..9d1f5b8d4 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -3,6 +3,7 @@ #include "store-api.hh" #include "fetchers.hh" #include "filetransfer.hh" +#include "registry.hh" #include <ctime> #include <iomanip> @@ -33,9 +34,11 @@ void emitTreeAttrs( if (tree.info.revCount) mkInt(*state.allocAttr(v, state.symbols.create("revCount")), *tree.info.revCount); - if (tree.info.lastModified) - mkString(*state.allocAttr(v, state.symbols.create("lastModified")), + if (tree.info.lastModified) { + mkInt(*state.allocAttr(v, state.symbols.create("lastModified")), *tree.info.lastModified); + mkString(*state.allocAttr(v, state.symbols.create("lastModifiedDate")), fmt("%s", std::put_time(std::gmtime(&*tree.info.lastModified), "%Y%m%d%H%M%S"))); + } v.attrs->sort(); } @@ -60,8 +63,10 @@ static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, V attrs.emplace(attr.name, attr.value->string.s); else if (attr.value->type == tBool) attrs.emplace(attr.name, attr.value->boolean); + else if (attr.value->type == tInt) + attrs.emplace(attr.name, attr.value->integer); else - throw TypeError("fetchTree argument '%s' is %s while a string or Boolean is expected", + throw TypeError("fetchTree argument '%s' is %s while a string, Boolean or integer is expected", attr.name, showType(*attr.value)); } @@ -72,8 +77,11 @@ static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, V } else input = fetchers::inputFromURL(state.coerceToString(pos, *args[0], context, false, false)); + if (!evalSettings.pureEval && !input->isDirect()) + input = lookupInRegistries(state.store, input).first; + if (evalSettings.pureEval && !input->isImmutable()) - throw Error("in pure evaluation mode, 'fetchTree' requires an immutable input"); + throw Error("in pure evaluation mode, 'fetchTree' requires an immutable input, at %s", pos); // FIXME: use fetchOrSubstituteTree auto [tree, input2] = input->fetchTree(state.store); |