From 0282499e183c3a7aa4aa263b242f4ddcb401220f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 7 Mar 2024 13:28:52 +0100 Subject: [PATCH] PathInputScheme::getFingerprint(): Don't barf on relative paths This wasn't caught by CI because #10149 and #10152 pass individually... It doesn't happen on lazy-trees either because we never try to fetch relative path flakes (#10089). --- src/libfetchers/path.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index f1910a5dc..0af1bad73 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -89,6 +89,15 @@ struct PathInputScheme : InputScheme writeFile((CanonPath(getAbsPath(input)) / path).abs(), contents); } + std::optional isRelative(const Input & input) const + { + auto path = getStrAttr(input.attrs, "path"); + if (hasPrefix(path, "/")) + return std::nullopt; + else + return path; + } + bool isLocked(const Input & input) const override { return (bool) input.getNarHash(); @@ -151,6 +160,9 @@ struct PathInputScheme : InputScheme std::optional getFingerprint(ref store, const Input & input) const override { + if (isRelative(input)) + return std::nullopt; + /* If this path is in the Nix store, use the hash of the store object and the subpath. */ auto path = getAbsPath(input);