I had to reinstall Nix and home-manager recently on my Mac, because for some reason home-manager switch
stopped working.
After a bit of searching and trying out a bunch of fixes I found what worked. The working solution started with a full reinstall of Nix, and that starts with emptying the generated Nix volume with disk utility. The workflow was roughly as follows:
Empty nix volume with disk utility
Install multi-user Nix
bash <(curl -L https://nixos.org/nix/install) --daemon
Do the following permission modifications. First creates directories that fit the new user directory model in Nix, and the second one fixes their ownership so that home-manager can access them. Here’s the issue that I found:
sudo mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER
sudo chown -R $USER:nixbld /nix/var/nix/profiles/per-user/$USER
Run home-manager install (standalone)
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
`
Remove old configuration symlink
rm -rf /Users/$USER/.config/home-manager
Add a new symlink to your existing config (assuming your config lives in /Users/$USER/dev/personal/nixfiles
, be sure to replace this with your own configuration location.
ln -s /Users/$USER/dev/personal/nixfiles /Users/$USER/.config/home-manager
Run home-manager switch
and the thing should work!
The point of this blog was to gather my solution to a single location, hope it helps anyone who comes across the same issues I did.