Skip to content

schrenker/raspberry-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RaspberryNix: RaspberryPi4 based homelab, powered by NixOs

Overview

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.

Why

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.

Features

  • 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.

Usage

Build an image

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

Build all images based on available nixosConfigurations in flake.nix

./scripts/build-all-sd-aarch64.sh

Rebuild a live system

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).

Rebuild Cluster

This rebuilds an entire cluster, starting from master, then going on to nodes from 01 to N.

./scripts/rebuild-cluster.sh

Initialize k3s cluster

Script that initializes cluster in following order:

  1. Install cilium as kube-proxy replacement for networking
  2. Install argocd for gitops.
  3. Install argocd-apps which initializes ApplicationSet, taking over the cluster, including already installed cilium and argocd.
  4. Run open-argo.sh script
./scripts/init.sh

Open Argo

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

Structure

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.

To do

  • [ ] 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

Credits

About

K3s RaspberryPi 4 homelab powered by NixOs

Topics

Resources

Stars

Watchers

Forks