mirror of
https://github.com/nix-community/dream2nix.git
synced 2025-01-09 00:08:02 +03:00
Merge pull request #1027 from nix-community/lock-isvalid
lock: expose lock.isValid...
This commit is contained in:
commit
959d6f9678
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
invalidationHashCurrent = l.hashString "sha256" (l.toJSON cfg.invalidationData);
|
invalidationHashCurrent = l.hashString "sha256" (l.toJSON cfg.invalidationData);
|
||||||
invalidationHashLocked = fileContent.invalidationHash or null;
|
invalidationHashLocked = fileContent.invalidationHash or null;
|
||||||
|
isValid = invalidationHashCurrent == invalidationHashLocked;
|
||||||
|
|
||||||
# script to remove the lock file if no fields are defined
|
# script to remove the lock file if no fields are defined
|
||||||
removeLockFileScript = config.deps.writePython3Bin "refresh" {} ''
|
removeLockFileScript = config.deps.writePython3Bin "refresh" {} ''
|
||||||
@ -182,7 +183,7 @@
|
|||||||
else throw (errorOutdatedField field);
|
else throw (errorOutdatedField field);
|
||||||
|
|
||||||
loadedContent =
|
loadedContent =
|
||||||
if invalidationHashCurrent != invalidationHashLocked
|
if !isValid
|
||||||
then throw errorOutdated
|
then throw errorOutdated
|
||||||
else l.mapAttrs loadField cfg.fields;
|
else l.mapAttrs loadField cfg.fields;
|
||||||
|
|
||||||
@ -217,6 +218,7 @@ in {
|
|||||||
|
|
||||||
lock.content = mkLazy loadedContent;
|
lock.content = mkLazy loadedContent;
|
||||||
|
|
||||||
|
lock.isValid = isValid;
|
||||||
lock.lib = {inherit computeFODHash;};
|
lock.lib = {inherit computeFODHash;};
|
||||||
|
|
||||||
deps = {nixpkgs, ...}:
|
deps = {nixpkgs, ...}:
|
||||||
|
@ -83,6 +83,14 @@ in {
|
|||||||
readOnly = true;
|
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 {
|
lib.computeFODHash = l.mkOption {
|
||||||
type = t.functionTo t.path;
|
type = t.functionTo t.path;
|
||||||
description = ''
|
description = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user