nixos-rebuild switch --use-remote-sudoThere's a 2-step process to building a Nix Darwin machine from a flake:
nix build ./#darwinConfigurations.asdfPro.system./result/sw/bin/darwin-rebuild switch --flake ./sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist Shared_Net_Address -string 192.168.64.1Restart the DHCP server:
sudo /bin/launchctl kickstart -kp system/com.apple.bootpdNote the MAC address of the VM's network interface. Then, add an entry to /etc/bootptab:
%%
# hostname hwtype hwaddr ipaddr bootfile
nixos 1 0A:1E:0E:51:29:4C 192.168.64.2
Restart the DHCP server:
sudo /bin/launchctl kickstart -kp system/com.apple.bootpdReduce the lease time for DHCP leases. The default is 86400 seconds (24 hours). The following command will reduce it to 600 seconds (10 minutes):
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.InternetSharing.default.plist bootpd -dict DHCPLeaseTimeSecs -int 600
Eventually, the boot drive will fill up with older generations. This is particularly a problem when using a custom kernel version. To delete the older generations, run the following:
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +5
sudo /run/current-system/bin/switch-to-configuration switchThese are not currently automatically removed. See nix-community/home-manager#3450.
home-manager expire-generations "-180 days"sudo nix-collect-garbage --delete-older-than 180d