This repository contains NixOS flake configurations for managing multiple hosts in a homelab environment.
There are two ways to bootstrap the new host:
From an existing NixOS host, you can remotely install to a machine booted from a livecd.
On the target machine (livecd):
passwd # Set root password
ip a # Note the IP addressOn the source machine:
nix run github:nix-community/nixos-anywhere -- \
--flake .#<hostname> \
--target-host nixos@<TARGET_IP>Replace <TARGET_IP> with the IP address from the target machine.
Boot the target machine from a livecd and run:
# Partition and format disk using disko
sudo nix --experimental-features "nix-command flakes" run \
github:nix-community/disko/latest -- \
--mode destroy,format,mount \
--flake github:mechanicalbot-homelab/nix#<hostname>
# Install NixOS
sudo nixos-install --flake github:mechanicalbot-homelab/nix#<hostname>
# After reboot, clone the repo and link the flake
git clone <repo-url> /path/to/repo
cd /path/to/repo
sudo ln -s $(realpath ./flake.nix) /etc/nixos/flake.nixsudo nixos-rebuild switch --flake .#<hostname>nixos-rebuild switch --flake .#<hostname> --target-host <user>@<host>nix flake updatenix run github:serokell/deploy-rsnix fmt