diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 59f0d2224..2bdb3bd96 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -699,11 +699,8 @@ SourcePath resolveExprPath(const SourcePath & path) #endif // FIXME - auto path2 = path.path + "/default.nix"; - if (path.pathExists()) - return {path.accessor, path2}; - - return path; + auto path2 = path.append("/default.nix"); + return path2.pathExists() ? path2 : path; } diff --git a/src/libfetchers/input-accessor.cc b/src/libfetchers/input-accessor.cc index 10a275857..c4743c201 100644 --- a/src/libfetchers/input-accessor.cc +++ b/src/libfetchers/input-accessor.cc @@ -227,6 +227,12 @@ std::ostream & operator << (std::ostream & str, const SourcePath & path) return str; } +SourcePath SourcePath::append(std::string_view s) const +{ + // FIXME: canonicalize? + return {accessor, path + s}; +} + struct MemoryInputAccessorImpl : MemoryInputAccessor { std::map files; diff --git a/src/libfetchers/input-accessor.hh b/src/libfetchers/input-accessor.hh index 129c1f345..93e891ac2 100644 --- a/src/libfetchers/input-accessor.hh +++ b/src/libfetchers/input-accessor.hh @@ -92,6 +92,8 @@ struct SourcePath { return accessor.dumpPath(path, sink, filter); } std::string to_string() const; + + SourcePath append(std::string_view s) const; }; std::ostream & operator << (std::ostream & str, const SourcePath & path);