Repository navigation
fix(write-flake): warn when flake.lock keeps a stale flake attribute (#114) - #142
Merged
Merged
Conversation
#114) Nix and Lix keep an existing lock node when only an input's `flake` attribute changes, so flipping `flake` never reaches flake.lock. write-flake now compares declared top-level inputs with an existing lock and prints the stale names with the `nix flake update` command. Adds test-flake-stale-lock-flake-attr.
vic
approved these changes
Oct 12, 2026
vic
left a comment
Member
There was a problem hiding this comment.
lgtm, detecting and having a warning is good for UX in the time being. Maybe someone can report these stale values to be fixed at cppnix and lix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #114.
As @mightyiam suspected, flake-file isn't what keeps the old value. Nix and Lix both keep an existing lock node when only an input's
flakeattribute changes, even whenflake = trueis written out explicitly. Reproduced with a localgit+file:input:flake.nixinputnodes.dep.flakeafternix flake lockflake = false;falsefalse(stale)flake = true;false(stale)nix flake update depSame result on Nix 2.34.8 and Lix 2.95.3 (A and C). So writing
flake = trueinto the generatedflake.nixwould not fix it.What flake-file can do is notice. After
write-flakewritesflake.nix, it compares each declared top-level input'sflakevalue with the matching node in an existingflake.lock. If they differ, it prints the stale input names and the command that refreshes them:It only warns; it never touches the lock. Inputs that
followsanother input are skipped. A missing, empty or malformedflake.lockis ignored, so the existingwrite-lockpath (which seedsflake.lockwith{ }) is unaffected.The underlying Nix behaviour is probably worth an upstream report.
Validation
test-flake-stale-lock-flake-attr: a lock recording"flake": falsefor a declared flake input produces the warning naming the input; a matching lock produces none. It fails on main.test-flake,test-flake-publicandtest-write-lock-flakepass.test-allwas not run locally.