nix-config
My personal Nix flake for home-manager on macOS.
Install
-
Install Nix package manager:
curl -L https://nixos.org/nix/install | bash -s -- --daemon
You can also replace the install URL with a specific version such as
https://releases.nixos.org/nix/nix-2.10.3/install
(this setup has been verified to work on at least2.10.3
). -
Install home-manager and activate the
personal
config (while in this directory):$( nix build \ --extra-experimental-features "nix-command flakes" \ --no-link \ --print-out-paths \ ".#homeConfigurations.personal.activationPackage" )/activate
Rebuild
After making changes to config, you can rebuild with:
home-manager switch --flake ".#personal"
To apply changes without being in this directory, replace .
with the path to
this directory.
Note the --extra-experimental-features
flag isn't needed because our
home-manager config (via the flakes module) adds the relevant lines to
~/.config/nix/nix.conf
.
Updating dependencies
Dependencies are defined in flake.nix
and versions are pinned in flake.lock
.
-
To update all dependencies:
nix flake update
-
To update a specific depedency (such as
nixpkgs
):nix flake lock --update-input nixpkgs
Errors
If you get the following error when trying to switch
:
cannot fetch input 'path:./overlays/vim-plugins?...' because it uses a relative path
It's likely because changes were made to vim-plugins-overlay
without updating
the lock file. You may need to update it with the following command:
nix flake lock --update-input vim-plugins-overlay
Garbage collection
There are various levels of cleanup you can do:
# Clean up files not used by any generations of the current profile
nix-collect-garbage
# Clean up files not used by the current generation of the current profile
nix-collect-garbage -d
# Clean up files not used by the current generation for any profile
sudo nix-collect-garbage -d
Notes
In the past, it has been recommended to also run sudo mdutil -i off /nix
after installation to disable spotlight indexing, but recent versions of the
installer set the nobrowse
option in the mount options, accomplishing the
same thing. See the macOS installation section of the documentation for
details.
Resources
Some resources I found useful during setup: