These instructions assume you're on osx Catalina or later44, which has the most problematic time when setting up nix because of the restriction on the root filesystem.
In this gist is a script (create-darwin-volume.sh
) which will do the following:
- Create an APFS volume for the nix store
- Update
/etc/fstab
to mount the volume - Use
synthentic.conf
to create/nix
and point it to that volume.
This allows the nix store to exist with SIP enabled, without using a symlink.
- After the script has run, you will need to reboot to allow the
synthentic.conf
changes to persist.
This step is needed if you want to use lorri
(strongly recommended), or if you want to install 'system' nix packages or daemons.
- Create a
darwin-configuration.nix
file in~/.nixpkgs/darwin-configuration.nix
- There is an example config file in this gist which will install
lorri
.
- There is an example config file in this gist which will install
- Install nix-darwin by following its README:
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer
To use lorri
in a given location, type lorri init
. This will create a .envrc
and shell.nix
. If they already exist, they will not be overwritten.
Type direnv allow
in the directory and lorri will automatically (re)build the shell.nix
for you when it's updated.
When you leave a directory, it'll unload the environment for you.
You can also install the direnv
extension in visual studio code and it will make use of the environment too :)
To update, run nix-channel --update
, followed by darwin-rebuild switch
.
Clean out garbage with nix-collect-garbage
once in a while.