I’ll preface this all by saying I don’t like monorepos, and I’ve been down the road of trying to convince our org to use submodules; for the purpose of this thread let’s just focus on “best practices and tricks to get flakes optimized in a monorepo”.
For context the tree is ~2Gb with nearly a thousand branches, and master
sees about 50-100 commits/day and about 500 CI runs for PR checks.
I’ve isolated flakes for clusters of projects with much smaller sizes. But as you probably know, Nix still processes the top level git dir to do just about anything. For local dev in a dirty it’s painful. Any eval, even without builds ( nix flake show
for example ) takes over a minute. I survive by using a REPL, nix eval
, and nix build -f
but from a UX perspective having nix build
and nix flake check
run at a reasonable speed is important for adoption.
In CI I’ve used locking and building from URIs with no checkout to help speed things up; but there’s no such luxury for local dev.
A goofy trick I’ve used in wrapper script is maintaining a shadow tree that will use git diff
to override unchanged subtrees with the base
; but this is a hideous workaround and the minor improvement isn’t worth the trouble.
What tricks have y’all picked up; and just for posterity : what’s your usual flake usage look like is subdirectories?
As an example let’s say as a local checkout with staged files wants to run consecutive evaluations. Maybe build 50 targets and tests in a loop. Currently I use linkFarmFromDrvs
as a way to skip multiple executions, but I hit max open file on fresh VMs, so being able to do multiple runs without the lag would be really nice. How can I get Nix to stop attempting to copy or checksum between these runs?