Skip to content

Add first-class flake-edit follow support - #133

Merged
vic merged 2 commits into
denful:mainfrom
dnlzro:feat/flake-edit-follows
Aug 31, 2026
Merged

Add first-class flake-edit follow support#133
vic merged 2 commits into
denful:mainfrom
dnlzro:feat/flake-edit-follows

Conversation

@dnlzro

@dnlzro dnlzro commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an opt-in auto-follow feature powered by flake-edit follow:

{
  flake-file.auto-follow.enable = true;
}

When enabled, write-flake updates the lock file, runs flake-edit follow, formats the resulting flake.nix, and updates the lock file a second time. I don't love that the lockfile has to be generated twice, but...

  • The first lock creates the lockfile that flake-edit follow needs in order to determine which follows entries to produce.
  • The second lock reconciles with the changes that flake-edit follow made to flake.nix.

check-flake-file now 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 treat flake-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 follow using flake-file.write-hooks and get the expected output, check-flake-file doesn't account for write-hooks that that re-write flake.nix itself, so the check fails.


Automatic following can be disabled for a particular nested input:

{
  flake-file.inputs.crane.inputs.nixpkgs.autoFollow = false;
}

An input cannot have both a follows entry and autoFollow = false configured, since those settings request contradictory behavior.

Auto-follow requires pkgs.flake-edit 0.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.

@vic
vic marked this pull request as ready for review August 31, 2026 20:43
@vic
vic merged commit c460df7 into denful:main Aug 31, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake-edit follow as prune lock option

2 participants