aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-21 15:29:05 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-21 15:29:05 +0200
commitd132d057a85aa1812c4133feed6c9b34ca70671d (patch)
tree69183af3a8c0ea2469d1e2908cffb67177f32b9f /src/libexpr/flake
parent4f6a7c86218c748df2a8700eca8ba9edbedd9ca5 (diff)
Handle store symlinks in flake directories
E.g. 'nix path-info ./result' inside a flake directory now works again.
Diffstat (limited to 'src/libexpr/flake')
-rw-r--r--src/libexpr/flake/flakeref.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc
index 24af09124..7631cd53a 100644
--- a/src/libexpr/flake/flakeref.cc
+++ b/src/libexpr/flake/flakeref.cc
@@ -143,6 +143,14 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
IsPath d;
if (allowRelative) {
d.path = absPath(uri);
+ try {
+ if (!S_ISDIR(lstat(d.path).st_mode))
+ throw BadFlakeRef("path '%s' is not a flake (sub)directory");
+ } catch (SysError & e) {
+ if (e.errNo == ENOENT || e.errNo == EISDIR)
+ throw BadFlakeRef("flake '%s' does not exist");
+ throw;
+ }
while (true) {
if (pathExists(d.path + "/.git")) break;
subdir = baseNameOf(d.path) + (subdir.empty() ? "" : "/" + subdir);