mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Implement getFingerprint() for store paths
This commit is contained in:
parent
eaa6c26189
commit
29049d2653
1 changed files with 14 additions and 0 deletions
|
@ -147,6 +147,20 @@ struct PathInputScheme : InputScheme
|
||||||
return {std::move(*storePath), input};
|
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
|
std::optional<ExperimentalFeature> experimentalFeature() const override
|
||||||
{
|
{
|
||||||
return Xp::Flakes;
|
return Xp::Flakes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue