Awesome
NixOS config for my personal computer and servers
Presentation
I have three NixOS machines:
- carokann: personal computer (Framework laptop).
- najdorf: server where I deploy my self-hosted apps.
- grunfeld: main RaspberryPi that serves as a snapcast server and a local backup.
The hosts communicate through Tailscale.
This repo is structured with the digga flake library.
Software I use on my personal computer (carokann)
- Wayland compositor: sway
- Wayland bar: Waybar (style copied from @KubquoA's config)
- Notification manager: mako
- Editor: kakoune
- Terminal: alacritty
- Terminal multiplexer: tmux
- Shell: fish
- Browser: firefox
Self-hosted apps on my server (najdorf)
I deploy most services as Docker containers through Arion
Important data is backed up with Restic to a local disk connected to my RaspberryPi.
Bootstrap
To create a bootstrap ISO for a personal computer run:
$ nixos-generate --flake '.#bootstrap' --format iso
To create a ready-to-boot SD card for a RaspberryPi, do the following:
$ nixos-generate --flake '.#grunfeld' --format sd-aarch64 --system aarch64-linux
$ unzstd -d {the output path from the command above} -o nixos-sd-image.img
$ sudo dd if=nixos-sd-image.img of=/dev/sda bs=64K status=progress
To deploy the server config to a new machine:
# First, comment all services imported in hosts/najdorf/default.nix and uncomment the ts-oneshot-login service line.
# Then run:
$ nixos-anywhere --copy-host-keys --flake '.#najdorf' root@<ip-address>
# Copy the old server's host key
$ scp 'root@najdorf:/etc/ssh/ssh_host_*' root@najdorf-1:/etc/ssh/
# Stop all running services, then:
$ ssh root@najdorf 'ssh-keyscan -H najdorf-1 >> ~/.ssh/known_hosts'
$ ssh -f root@najdorf 'rsync -avz /opt root@najdorf-1:/opt > /home/sweenu/rsync.log 2>&1 &'
# I made all Docker volumes bind mounts in /opt in order for this command to be enough for migrating everything important.
# Uncomment services in hosts/najdorf/default.nix and comment the tailscale-login service line.
# Remove najdorf from tailscale and change the tailscale name from najdorf-1 to najdorf.
# Change DNS records to point to the new server (on Cloudflare, change the IP scope of the API token to the new IP).
# Finally:
$ deploy '.#najdorf'
# All done!
Acknowledgment:
- Thanks to @KubquoA for making this reddit post from which I discovered NixOS and from which I stole the Waybar style.
- Thanks to the digga people for making my life easier when I first started to use NixOS.