Merge pull request #1027 from nix-community/lock-isvalid

lock: expose lock.isValid...
This commit is contained in:
Paul Haerle 2024-07-23 14:03:38 +02:00 committed by GitHub
commit 959d6f9678
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -18,6 +18,7 @@
invalidationHashCurrent = l.hashString "sha256" (l.toJSON cfg.invalidationData);
invalidationHashLocked = fileContent.invalidationHash or null;
isValid = invalidationHashCurrent == invalidationHashLocked;
# script to remove the lock file if no fields are defined
removeLockFileScript = config.deps.writePython3Bin "refresh" {} ''
@ -182,7 +183,7 @@
else throw (errorOutdatedField field);
loadedContent =
if invalidationHashCurrent != invalidationHashLocked
if !isValid
then throw errorOutdated
else l.mapAttrs loadField cfg.fields;
@ -217,6 +218,7 @@ in {
lock.content = mkLazy loadedContent;
lock.isValid = isValid;
lock.lib = {inherit computeFODHash;};
deps = {nixpkgs, ...}:

View File

@ -83,6 +83,14 @@ in {
readOnly = true;
};
isValid = l.mkOption {
type = t.bool;
description = ''
Check whether the current lock file is valid, which means we don't need to lock again.
'';
readOnly = true;
};
lib.computeFODHash = l.mkOption {
type = t.functionTo t.path;
description = ''