Nix on macOS Catalina
Installing Nix on macOS Catalina isn’t hard if you know a little about APFS.
I’m the only user on my MacBook Pro so I don’t install using daemon mode, you can easily custom it (last step).
Step 1: synthetic.conf
It’s the way to create a folder in /
|
Step 2: reboot
We need to reboot to apply the change about synthetic.
After reboot, you have /nix created
Step 3: creating a new volume
It’s the magic about APFS and attaches it to /nix
I’m the owner of the new volume
We hide /nix and auto-mount the new volume to /nix at boot
|
Disable spotlight (indexing) on /nix
Step 4: install
|
Step 5: user config
We can replace and standardize each nix-env -i pkg_name
with a config file: $HOME/.config/nixpkgs/config.nix
An example:
{
allowUnfree = true;
packageOverrides = pkgs: with pkgs; {
all = pkgs.buildEnv {
name = "all";
paths = [
ansible
ansible-lint
cloc
colordiff
dos2unix
ffmpeg-full
htop
httpie
jq
mtr
pwgen
silver-searcher
tmux
tree
watch
wget
whois
yq
zsh
zstd
];
};
};
}
And to apply this config file: nix-env -i all
Step 6: my alias to upgrade and clean the old version
nixupgrade='nix-channel --update && nix-env -u && nix-collect-garbage -d'