1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

Merge pull request #10149 from edolstra/use-flake-fingerprint

LockedFlake::getFingerprint(): Use Input::getFingerprint()
This commit is contained in:
Eelco Dolstra 2024-03-07 10:18:19 +01:00 committed by GitHub
commit 38b79da100
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 11 deletions

View file

@ -926,18 +926,17 @@ static RegisterPrimOp r4({
}
Fingerprint LockedFlake::getFingerprint() const
std::optional<Fingerprint> LockedFlake::getFingerprint(ref<Store> store) const
{
if (lockFile.isUnlocked()) return std::nullopt;
auto fingerprint = flake.lockedRef.input.getFingerprint(store);
if (!fingerprint) return std::nullopt;
// FIXME: as an optimization, if the flake contains a lock file
// and we haven't changed it, then it's sufficient to use
// flake.sourceInfo.storePath for the fingerprint.
return hashString(HashAlgorithm::SHA256,
fmt("%s;%s;%d;%d;%s",
flake.path.to_string(),
flake.lockedRef.subdir,
flake.lockedRef.input.getRevCount().value_or(0),
flake.lockedRef.input.getLastModified().value_or(0),
lockFile));
return hashString(HashAlgorithm::SHA256, fmt("%s;%s;%s", *fingerprint, flake.lockedRef.subdir, lockFile));
}
Flake::~Flake() { }

View file

@ -119,7 +119,7 @@ struct LockedFlake
*/
std::map<ref<Node>, SourcePath> nodePaths;
Fingerprint getFingerprint() const;
std::optional<Fingerprint> getFingerprint(ref<Store> store) const;
};
struct LockFlags