Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lock: expose lock.isValid... #1027

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/dream2nix/core/lock/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" {} ''
Expand Down Expand Up @@ -182,7 +183,7 @@
else throw (errorOutdatedField field);

loadedContent =
if invalidationHashCurrent != invalidationHashLocked
if !isValid
then throw errorOutdated
else l.mapAttrs loadField cfg.fields;

Expand Down Expand Up @@ -217,6 +218,7 @@ in {

lock.content = mkLazy loadedContent;

lock.isValid = isValid;
lock.lib = {inherit computeFODHash;};

deps = {nixpkgs, ...}:
Expand Down
8 changes: 8 additions & 0 deletions modules/dream2nix/core/lock/interface.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down