RaspberryNix is a Nix-based project for building and managing my mini-homelab based on RaspberryPi4 devices. It leverages nixos-generators
to produce initial sd-aarch64 images compatible with RaspberryPi. Devices are then configured remotely by use of nixos-rebuild
utility.
I have a few raspberry pi 4 devices laying around, and I wanted to use them to work on my nix, kubernetes and programming skills.
- Build sd-aarch64 images with
nixos-generators
via nix-flakes. - Rebuild the system remotely without need to reimage the sd card.
- Preconfigured NixOS user with password and SSH key preinstalled.
Build image based on nixosConfiguration in flake.nix.
./scripts/build-sd-aarch64.sh <MACHINE>
<MACHINE>
- Name of the nixosConfiguration (see flake.nix).
Build all images based on available nixosConfigurations in flake.nix
./scripts/build-all-sd-aarch64.sh
This rebuilds a live system with nixos-rebuild
command remotely. Note that if the image is freshly built and deployed, first run of this will take some time, due to nix having to rebuild entire system, including nix store (looking for a way to avoid this long wait). Subsequent runs are fast.
./scripts/rebuild-host.sh <MACHINE>
<NAME>
- Name of the nixosConfiguration (see flake.nix).
This rebuilds an entire cluster, starting from master, then going on to nodes from 01 to N.
./scripts/rebuild-cluster.sh
Script that initializes cluster in following order:
- Install cilium as kube-proxy replacement for networking
- Install argocd for gitops.
- Install argocd-apps which initializes ApplicationSet, taking over the cluster, including already installed cilium and argocd.
- Run open-argo.sh script
./scripts/init.sh
Make sure argocd server deployment is ready, then print the password into stdout, forward 8080:443 on argocd server and open it in background Safari tab.
./scripts/open-argo.sh
flake.nix
- Defines the configurations and flake outputs.
configurations/
- Contains machine configurations.
scripts/
- Scripts used to build images and to manage machines.
workloads/<namespace>/<application>
- Kubernetes applications. Segregated into namespaces, then into applications to leverage ApplicationSet automatic creation of namespaces and workloads.
- [ ] Figure out how to pass k3s master IP as well as IP ranges from nix to cilium values without hardcoding them
- [ ] Observability stack based on OTEL -> prometheus, tempo, loki -> grafana