From e89d3e0edf50658c33215b7b05bd9fd410369acb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 9 May 2022 14:28:47 +0200 Subject: [PATCH] Fix resolveExprPath() --- src/libexpr/parser.y | 7 ++----- src/libfetchers/input-accessor.cc | 6 ++++++ src/libfetchers/input-accessor.hh | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) 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);