Skip to content

Instantly share code, notes, and snippets.

@ethnt
Last active October 2, 2022 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethnt/cfed3027f3676b110bf1df444ef1f30a to your computer and use it in GitHub Desktop.
Save ethnt/cfed3027f3676b110bf1df444ef1f30a to your computer and use it in GitHub Desktop.
Nix install on macOS

Nix install

1. Run Nix install

with fish

sh (curl -L https://nixos.org/nix/install | psub) --darwin-use-unencrypted-nix-store-volume

for zsh with multi user

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon

2. Install foreign-env for Fish

omf install foreign-env

3. Add to config.fish file

echo "fenv source $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.config/fish/config.fish

4. Install nix-darwin

nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer

5. Add to PATH

echo "set -U fish_user_paths $fish_user_paths /run/current-system/sw/bin" >> ~/.config/fish/config.fish

6. Install home-manager

nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install

Results:

  • ~/.nixpkgs/darwin-configuration.nix
  • `~/.config/nixpkgs/home.nix

Nix install

1. Run Nix install

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon

2. Enable flakes

Edit either ~/.config/nix/nix.conf or /etc/nix/nix.conf and add:

experimental-features = nix-command flakes

3. Install nix-darwin

nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer

Results:

  • ~/.nixpkgs/darwin-configuration.nix
  • `~/.config/nixpkgs/home.nix

Nix uninstall on macOS

  1. Remove the entry from fstab using 'sudo vifs'
  2. Destroy the data volume using 'diskutil apfs deleteVolume'
  3. Remove the 'nix' line from /etc/synthetic.conf or the file

multi-user destroy

sudo rm -rf /etc/profile/nix.sh /etc/nix /nix ~root/.nix-profile ~root/.nix-defexpr ~root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels

# If you are on Linux with systemd, you will need to run:
sudo systemctl stop nix-daemon.socket
sudo systemctl stop nix-daemon.service
sudo systemctl disable nix-daemon.socket
sudo systemctl disable nix-daemon.service
sudo systemctl daemon-reload

# If you are on macOS, you will need to run:
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
@ethnt
Copy link
Author

ethnt commented Dec 24, 2020

Need to source . /Users/ethan/.nix-profile/etc/profile.d/nix.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment