From 29049d26533fb9077b0214fad276804784e02e45 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 4 Mar 2024 19:21:31 +0100 Subject: [PATCH] Implement getFingerprint() for store paths --- src/libfetchers/path.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index 276fd1b36..8231492e8 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -147,6 +147,20 @@ struct PathInputScheme : InputScheme return {std::move(*storePath), input}; } + std::optional getFingerprint(ref store, const Input & input) const override + { + /* If this path is in the Nix store, use the hash of the + store object and the subpath. */ + auto path = getAbsPath(input); + try { + auto [storePath, subPath] = store->toStorePath(path.abs()); + auto info = store->queryPathInfo(storePath); + return fmt("path:%s:%s", info->narHash.to_string(HashFormat::Base16, false), subPath); + } catch (Error &) { + return std::nullopt; + } + } + std::optional experimentalFeature() const override { return Xp::Flakes;