Nix Config for 0xpetersatoshi
My NixOS, Darwin, and Nix Home Manager Config.
Install nix (preferably) using the Determinate Systems Installer.
If running on MacOS, you'll need nix-darwin
which won't initially be installed. Instructions for that are included
in the next section.
NOTE: The architecture of the target machine must match the architecture of the local machine for this option.
- Use netboot or the nix usb installer to initiate the installer on the target machine
- Run
passwd
to create new password for the installer user - Copy public ssh keys to the installer user
mkdir -p ~/.ssh
curl https://github.com/0xpetersatoshi.keys >> ~/.ssh/authorized_keys
- Note the IP address of the target machine using
ip addr
- Test connection from local machine:
ssh -i ~/.ssh/vms.pub -v nixos@<ip>
- Run:
nix run github:nix-community/nixos-anywhere -- --flake '.#nixbox' -i ~/.ssh/vms.pub --target-host nixos@10.19.90.224
# New machine without git
nix-shell -p git
# Clone
git clone https://github.com/0xpetersatoshi/nix-config.git
cd nix-config
# Linux
sudo nixos-rebuild switch --flake .#<hostname>
# MacOS
# On the first run, you'll need to install nix-darwin
nix run nix-darwin -- switch --flake .
# On subsequent runs, just run
darwin-rebuild switch --flake .
You can optionally use disko to configure the disk partitioning by running:
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount ./path/to/disko.nix
Then, to verify successful configuration, you can run the following commands:
mount | grep /mnt
sudo fdisk -l /dev/sda
# This only updates the `flake.lock` file but does not apply the changes
nix flake update
# Run nixos-rebuild or darwin-rebuild to apply the changes
darwin-rebuild switch --flake .
I drew heavy inspiration from the following repos: