Explicit error in flake init/new when not in store

This commit is contained in:
Guillaume Desforges 2022-03-07 17:57:52 +01:00
parent c28e2b1b29
commit 436c6e900f

View file

@ -706,9 +706,15 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
auto [cursor, attrPath] = installable.getCursor(*evalState); auto [cursor, attrPath] = installable.getCursor(*evalState);
auto templateDir = cursor->getAttr("path")->getString(); auto templateDirAttr = cursor->getAttr("path");
auto templateDir = templateDirAttr->getString();
assert(store->isInStore(templateDir)); if (!store->isInStore(templateDir)) {
throw TypeError(
std::string("'%s' was not found in the Nix store\n") +
"If you've set '%s' to a string, try using a path instead.",
templateDir, templateDirAttr->getAttrPathStr());
}
std::vector<Path> files; std::vector<Path> files;