Add first-class flake-edit follow support - #133
Merged
Conversation
vic
approved these changes
Aug 31, 2026
vic
marked this pull request as ready for review
August 31, 2026 20:43
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
Add an opt-in auto-follow feature powered by
flake-edit follow:When enabled,
write-flakeupdates the lock file, runsflake-edit follow, formats the resultingflake.nix, and updates the lock file a second time. I don't love that the lockfile has to be generated twice, but...flake-edit followneeds in order to determine whichfollowsentries to produce.flake-edit followmade toflake.nix.check-flake-filenow performs the same operation on a temporary copy (to detect missing or stale automatic follows). I needed to make changes so that the check did not treatflake-edit's changes as an unexplained diff.Note
This was my primary motivation for making this PR. Although it is possible to wire up
flake-edit followusingflake-file.write-hooksand get the expected output,check-flake-filedoesn't account forwrite-hooksthat that re-writeflake.nixitself, so the check fails.Automatic following can be disabled for a particular nested input:
An input cannot have both a
followsentry andautoFollow = falseconfigured, since those settings request contradictory behavior.Auto-follow requires
pkgs.flake-edit0.3.5 or newer, and reports an error when that requirement is not met.The code is tested, but maybe not as extensively as you'd like. I'm happy to improve on that if necessary.
I also added some documentation for this new feature, and included trade-offs between it and the lock-flattening approach already supported by
flake-file. I will refine the docs a bit if you're interested in getting this merged.Closes #131.