No description
  • Nix 49.6%
  • Shell 44%
  • Python 6.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-08 20:44:05 +02:00
docs feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
hosts feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
keys feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
modules feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
scripts fix: bootstrap idempotency (regenerate hosts/<host>), backup-cred gate, sops staleness check, persist ntfy admin password 2026-10-08 20:44:05 +02:00
secrets feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
.gitignore feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
.sops.yaml feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
flake.lock feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
flake.nix feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00
README.md feat: selfhosting starter (bootstrap.sh standalone, fleet-add-host.sh, service registry modules, docs) 2026-10-08 14:49:30 +02:00

nix-selfhost — selfhosting on NixOS, made a one-liner

A selfhosting starter for anyone running NixOS on a VM, LXC or VPS. Declarative, hardened, reproducible: clone the repo on the machine, run one interactive script, pick your services — done.

Quick start (standalone mode — this machine only)

# on a fresh NixOS machine
git clone <this-repo> nix-selfhost && cd nix-selfhost
sudo ./scripts/bootstrap.sh

The script asks you:

Prompt Meaning
hostname / admin user / timezone identität of the box
ssh keys login keys for the admin user (reuse local keys or paste)
services numbered multi-select from modules/services/ — grows as new modules land
reverse proxy (Caddy)? optional wildcard cert via ACME DNS-01; prints a DNS checklist (wildcard A record + provider API token)
Dashy dashboard? auto-lists every enabled service at https://<service>.<domain>
ntfy alerts? failed-units push notifications, declarative users
uptime-kuma? web monitoring; monitors are synced automatically from the same service list
restic backups? NAS (sftp) and/or S3 targets

Then it:

  • generates hosts/<hostname>/default.nix + facts,
  • creates sops-encrypted secrets on this machine (age key in /var/lib/sops/age/keys.txt; nothing leaves the host),
  • validates (nix flake check, preflight build),
  • activates locally with nixos-rebuild switch --flake .#<host>,
  • verifies units and URLs.

Every service lands in Caddy (only 22/80/443 firewalled) and in the dashboard automatically; all modules stay host-agnostic so the same code powers 1 or 50 machines.

Fleet mode (laptop-managed, multi-host)

If you manage several machines from a laptop:

nix develop -c $SHELL
./scripts/fleet-add-host.sh     # interactive, per host
nix develop -c deploy .#<host>  # deploy-rs push w/ magic rollback

Same modules, same registry; deploy-rs is keeping rollback safety here.

Repo layout

modules/base/       baseline for every host: packages, users, ssh, hardening
modules/homelab/    service registry -> Caddy vhosts + ACME wildcard certs
modules/services/   one .nix per service; enable via homelab.services.<x>.enable
hosts/<name>/       per-host config (bootstrap.sh / fleet-add-host.sh generate it)
hosts/facts.json    registry of hosts -> deploy targets
secrets/            sops-encrypted age files; plaintext never committed
scripts/            bootstrap.sh (on-machine), fleet-add-host.sh (laptop)

Documentation

Principles

  • least exposure: services bind 127.0.0.1, Caddy is the only public entry
  • secrets via sops; the nix store is immutable and credentials never leak
  • every service module is a small self-contained .nix file — add yours by copying an existing one
  • no flakes-in-the-dark: every decision visible in plain config files