mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
Implement getFingerprint() for store paths
This commit is contained in:
parent
eaa6c26189
commit
29049d2653
@ -147,6 +147,20 @@ struct PathInputScheme : InputScheme
|
||||
return {std::move(*storePath), input};
|
||||
}
|
||||
|
||||
std::optional<std::string> getFingerprint(ref<Store> 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> experimentalFeature() const override
|
||||
{
|
||||
return Xp::Flakes;
|
||||
|
Loading…
Reference in New Issue
Block a user