Nix configuration flake for my personal machines (macOS and NixOS).
💡Inspired by buntec's setup
After installing NixOS from a USB drive, follow these steps:
-
Clone this repo and
cdinto it. -
Copy
/etc/nixos/hardware-configuration.nixinto./system(OK to overwrite existing dummy file). -
Finally, to build and activate in one step using the
appsprovided by the flake
nix run .#rebuild-nixos # system configuration
nix run .#hm-switch-nixos # dotfiles and home configuration(Heavily inspired by this gist)
To bootstrap a fresh macOS install, follow these steps:
- Install Homebrew (only needed for managing GUI apps via casks)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- Install Nix:
curl -L https://nixos.org/nix/install | sh- Enable flakes
mkdir -p ~/.config/nix
cat <<EOF > ~/.config/nix/nix.conf
experimental-features = nix-command flakes
EOF- To work around this issue
sudo mv /etc/nix/nix.conf /etc/nix/.nix-darwin.bkp.nix.conf- Clone this repo,
cdinto it, then build and activate with the following commands:
nix run .#rebuild-macbook-air-m2 # system configuration
nix run .#hm-switch-macbook-air-m2 # dotfiles and home configuration- Install WSL from PowerShell:
wsl --install- Set the hostname to
wslby editing/etc/wsl.confinside the WSL distro:
[network]
hostname=wsl
generateHosts=falseAfter editing /etc/wsl.conf, run wsl --shutdown from PowerShell and restart WSL for the changes to take effect.
- Install Nix:
curl -L https://nixos.org/nix/install | sh- Enable flakes:
mkdir -p ~/.config/nix
cat <<EOF > ~/.config/nix/nix.conf
experimental-features = nix-command flakes
EOF- Clone this repo and apply the configuration:
nix run .#hm-switch-wsl- Clone this repo, then launch a VM (cloud-init installs Nix automatically):
multipass launch -n nix -c 2 -m 8G -d 64G --cloud-init extras\multipass-cloud-init-x86.yml- Wait for cloud-init to finish, shell in, and switch to the
xxxuser:
multipass exec nix -- sudo su - xxx- Clone this repo inside the VM and apply the configuration:
nix run .#hm-multipass-guest-x86- Uninstall Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
-
Delete everything under
~/.configand any other "dot files" in your home directory. -
Delete all applications that are listed as Homebrew casks in
./system/configuration-darwin.nix -
Follow the steps for a fresh macOS install.