For a while now, I’ve been frustrated by how long my home-manager configuration took to build. Waiting 30 seconds for nixvim to rebuild every time I made a one-line change to my git config got really old, really fast. Having heard that flakes always use pure evaluation and are thus able to cache everything and rebuild only the changed parts, I spent half an hour looking up how to convert my home-manager configuration to a flake and to my shock, nothing is cached! Typing home-manager switch twice in a row without touching any files in its config directory still takes 30 seconds! On a device that doesn’t have a third-gen Ryzen, it’s much worse than that!
Is there something I can do to speed this up or is this just how home-manager is?
Should not be like that. Can you share your output and your flake.nix ?
LattePanda Sigmai5-1340P:
$ time home-manager switch
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
No change so reusing latest profile generation
Activating createGpgHomedir
Activating linkGeneration
Cleaning up orphan links from /home/xx
Creating home file links in /home/xx
Activating createXdgUserDirectories
Activating installPackages
nix profile remove /nix/store/bf3lnym30ry9qb2mz9m0kz93qnrqmwdc-home-manager-path
removing 'home-manager-path'
Activating onFilesChange
Activating reloadSystemd
real 0m1.791s
user 0m0.592s
sys 0m0.676s
FriendlyElec NanoPi R6CRockchip RK3588S:
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
No change so reusing latest profile generation
Activating createGpgHomedir
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /home/xx
Creating home file links in /home/xx
Activating onFilesChange
Activating reloadSystemd
real 0m4.315s
user 0m1.564s
sys 0m1.175s
Building is cached the very same way as without flakes, what flakes do cache though is evaluation. And they cache that on the flake level. So as soon as you change something in the flake, you also do invalidate the previously cached evaluation.
And evaluation is usually what feels long and staling.
Most users do not complain about long build times when they see the progress of new software downloading.
They complain when nix seems to do nothing for a minute and then prints “done”…
When running hmrice rice, it replaces the Nix-store symlinks with an temporary editable copy of all the files for debugging and ricing purposes. When your finished, and backported the changes into the nix-files in home-manager, the command hmrice unrise restores the original nix-symlinks.
I haven’t tried it yet but I’m certainly going to next time I want to faster trial-and-error feedback, because I also find it painful sometimes.
You might want to check out lix, seems like a plug-in-replacement and I saw huge speedups in evaluation time for home manager. I went from ~ 1 minute to just a few seconds, ymmv