aboutsummaryrefslogtreecommitdiff
path: root/src/nix/flake.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/flake.cc')
-rw-r--r--src/nix/flake.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 144f8f886..47a380238 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -706,9 +706,14 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
auto [cursor, attrPath] = installable.getCursor(*evalState);
- auto templateDir = cursor->getAttr("path")->getString();
-
- assert(store->isInStore(templateDir));
+ auto templateDirAttr = cursor->getAttr("path");
+ auto templateDir = templateDirAttr->getString();
+
+ if (!store->isInStore(templateDir))
+ throw TypeError(
+ "'%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;