NixOS deployment fleet.
  • Nix 49.2%
  • Python 26.9%
  • CSS 9.5%
  • Go 7.3%
  • HTML 3.4%
  • Other 3.7%
Find a file
forgejo-actions[bot] caee7e496d
All checks were successful
comin/deploy/forgejo-runners-ramiel Deployment succeeded
comin/deploy/dreamflasher Deployment succeeded
comin/deploy/colo-komo Deployment succeeded
comin/deploy/colo-fmt2 Deployment succeeded
nixpkgs, nixpkgs-small: update
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/f4a03c008967841f2a0b3cb7c436fc6fc31671f6?narHash=sha256-ziZn2PvCJE5JEEpqTdxXwJpPB%2BL3YqoCpTAMCzyaP3U%3D' (2026-11-07)
  → 'github:nixos/nixpkgs/177d0540942fb205af6993b1d5fa0b57799e09f8?narHash=sha256-SvB8u5qaJAOwZZyZciqTVOg/rBoUs2w0sFTU6ED51AQ%3D' (2026-11-09)
• Updated input 'nixpkgs-small':
    'github:nixos/nixpkgs/f37ff5c2009e3923aa79378f923f01d5759b6d84?narHash=sha256-BpgtuBhhjZ29znzj/v/oCVUzBOslI/WPK4/7URxkMTM%3D' (2026-11-10)
  → 'github:nixos/nixpkgs/18808198c9047939daaaefad3772c72b4e955116?narHash=sha256-6AV2Z8qpQ3TUQQdFENWTE39iLuf8MFqWO5QM9iXtnpY%3D' (2026-11-11)
2026-11-12 03:10:13 +00:00
.forgejo/workflows ci: fix missing just 2026-10-23 14:10:51 -07:00
images/cloud-init-image secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
machines transit-tracker: add the API VM for the hangout sign 2026-11-10 10:25:19 -08:00
microvms dokuwiki: move to dokuwiki.dma.space 2026-11-03 20:28:58 -08:00
modules transit-tracker: add the API VM for the hangout sign 2026-11-10 10:25:19 -08:00
nix/lib secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
overlays lldpd: patch vendored types.h for 128-bit types on aarch64 2026-11-08 20:43:53 -08:00
scripts ingress: add caddy-tls-prober service 2026-10-31 15:51:28 -07:00
tests transit-tracker: add the API VM for the hangout sign 2026-11-10 10:25:19 -08:00
vars transit-tracker: record the VM's machine-id and host key 2026-11-10 12:30:25 -08:00
.gitattributes secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
.gitignore zulip: add emergency lockdown sidecar and vm tests 2026-10-26 00:42:36 -07:00
.prettierignore secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
.prettierrc.json trac: overhaul theme styling and format tree 2026-10-13 11:53:34 -07:00
.sops.yaml forgejo-runners-ramiel: add amd64 Forgejo Actions runner 2026-10-29 22:48:27 -07:00
authorized_keys suffix usernames in authorized_keys file 2026-10-29 16:41:51 -07:00
deno.json flatten nixos deployment to current dir 2026-10-12 00:05:23 -07:00
deno.lock flatten nixos deployment to current dir 2026-10-12 00:05:23 -07:00
flake.lock nixpkgs, nixpkgs-small: update 2026-11-12 03:10:13 +00:00
flake.nix transit-tracker: add the API VM for the hangout sign 2026-11-10 10:25:19 -08:00
go.mod flatten nixos deployment to current dir 2026-10-12 00:05:23 -07:00
go.sum flatten nixos deployment to current dir 2026-10-12 00:05:23 -07:00
Justfile secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
LICENSE Add MIT License 2026-01-21 11:49:41 -08:00
README.md secrets: migrate from bitwarden to sops 2026-10-29 16:41:51 -07:00
renovate.json5 ci: add renovate config and flake-checker 2026-10-02 14:03:38 -07:00

NixOS deployments for dma.space.

This repository manages bare-metal servers, colocation nodes, IoT devices, and MicroVMs throughout the space.

Structure

  • machines/ - Bare-metal and host machine configurations (colo-komo, colo-fmt2, dreamflasher, space-kiosk, dma-con-sw-0).
  • microvms/ - MicroVM guest and host configurations running under microvm.nix (hosted on dreamflasher).
  • modules/ - Reusable NixOS modules:
    • base.nix (under machines/) - Baseline configuration auto-included in every machine (minimal profile, monitoring exporters, journald limits, flakes).
    • gitops.nix - Automated continuous deployment via Comin.
    • network.nix / netbird.nix - Common network configuration and Netbird mesh overlay.
    • ssh/ - OpenSSH configuration for root and unprivileged networker.
    • Service modules for backup, ingress, monitoring, Netbird, Authentik, DokuWiki, etc. live directly under modules/; secrets are declared alongside consuming modules or microVMs; ingress virtual hosts are centralized in modules/ingress/vhosts.nix.
  • vars/ - Global Nix metadata (machine addresses, host keys, subnets, SR-IOV allocations, MicroVM topology).
  • authorized_keys - Root SSH keys synced from Codeberg.
  • flake.nix - Flake entrypoint exposing nixosConfigurations, diskoConfigurations, and nixosImages.
  • Justfile - Command runner recipes for common operations.

Onboarding Yourself

To get set up to manage these machines:

  1. Network access: Join the Netbird mesh network (https://netbird.dma.space). You can use your dma.space account to log in. Machines are accessible via <machine>.wt0.dma.computer. (Tailscale is retained only as a fallback on select hosts).
  2. SSH access: Add your username (e.g. yourname for Codeberg or username@https://... for external key URLs) to the # allow: ... line at the top of ./authorized_keys. Then run just sync-ssh-keys, commit the changes, and submit a PR or push to git. Once an infra maintainer merges your changes, you will be able to SSH into all machines.
  3. Local environment: Set up Nix and Direnv as described below.

Setting Up Your Local Environment

Install Nix and Direnv.

In the repository root, create and allow the environment:

echo use flake > .envrc && direnv allow

Or manually enter the development shell:

nix develop

Deployment Model & Common Operations

Deployments are managed via GitOps (Comin). Machines periodically poll https://git.dma.space/infra/nixos.git on branch main and deploy updates automatically.

Note

Direct manual deployment via just deploy is blocked by default to prevent state drift against GitOps. Prefer pushing changes to Git. Direct deployments require OVERRIDE_GITOPS=1 for emergency recovery.

Common Recipes

Run just to view all available recipes. Everyday operations include:

  • just watch - Monitor current deployment commit and status across all machines.
  • just eval <machine> - Evaluate a machine's configuration without building.
  • just build <machine> - Build a machine's configuration remotely on the target host.
  • just ssh <machine> - SSH into root@<host> over Netbird.
  • just sync-ssh-keys - Re-sync authorized_keys from Codeberg for allowed users.
  • just update-sops-keys - Regenerate .sops.yaml from the Nix sops manifest and re-key all sops secret files using machine host keys and authorized users.
  • just machines - List all configured NixOS machines.

Ingress & Virtual Hosts

All public reverse proxy routes and domains are declared in a centralized, flat list in modules/ingress/vhosts.nix. Rather than scattering ingress configuration across individual service modules, edge gateway nodes (colo-komo, colo-fmt2) evaluate this single routing table in Caddy to direct incoming traffic to internal backends.

Upstream Targets

vhosts.nix provides target resolution helpers to decouple external hostnames from internal network topology:

  • vmBridgeTarget "<name>" "<portName>": Proxies directly to a MicroVM's internal bridge IP and designated port defined in vars.microvms (e.g. authentik, vaultwarden, dokuwiki).
  • machineNetbirdTarget "<name>" "<portName>": Proxies over the Netbird overlay network to a machine host and port defined in vars.machines (e.g. dreamflasher or colocation nodes).

Common Snippets & Conventions

Virtual hosts in vhosts.nix make use of reusable Caddyfile imports:

  • import cloudflare_dns: Automates wildcard and domain TLS certificate issuance via Cloudflare DNS-01 challenges.
  • import fallback_error_page: Rewrites HTTP 5xx responses to the stylized fallback page if upstream backends are down or unreachable.
  • import forward_auth: Enforces Authentik SSO authentication for protected endpoints and admin consoles (e.g. alerts or admin portals).
  • import reverse_proxy_insecure_https: Proxies upstream services that serve internal or self-signed TLS certificates.

For documentation on using these snippets, see each import's comment block, which can be found in modules/ingress/caddyfiles.

Dynamic DNS & Node-Specific Routes

DNS records are managed dynamically in modules/ingress/default.nix via Caddy's dynamic_dns plugin using Cloudflare credentials loaded from SOPS.

  • Both edge nodes (colo-komo and colo-fmt2) register their public A and AAAA addresses for *.dma.space ("*" = ""). Traffic hitting wildcard subdomains is distributed across both nodes in round-robin.
  • If a service should only route to a single ingress node rather than both in round-robin, the subdomain is mapped under that host's name in domains."dma.space":
    domains."dma.space" = {
      "*" = "";
      "colo-komo" = "colo-komo.alerts ramiel netbird llama-cpp.dreamflasher";
      "colo-fmt2" = "colo-fmt2.alerts";
    };
    
    Cloudflare creates explicit A/AAAA records for those subdomains pointing directly to that single host's IP. Because exact DNS records take precedence over wildcards, incoming traffic routes exclusively to the designated host.

Playbooks

Setting Up a New Machine

  1. Hardware & Configuration:

    • Create machines/<machine>/configuration.nix.
    • Core modules (e.g. machines/base.nix, sops-nix) are imported automatically by self.lib.nixosSystem.
    • Import necessary modules:
      { self, ... }:
      {
        imports = [
          (self.nixosModules.gitops)
          (self.nixosModules.network)
          (self.nixosModules.ssh)
          (self.nixosModules.secrets)
          (self.nixosModules.hardening) # optional
        ];
      
        gitops.enable = true;
      }
      
    • Register the system in flake.nix under nixosConfigurations.<machine> using self.lib.nixosSystem "<machine>".
  2. Disk Layout:

    • Create machines/<machine>/disko.nix using disko (prefer LUKS + Btrfs or ZFS for storage nodes).
    • Register the layout in flake.nix under diskoConfigurations.<machine> = self.lib.diskoConfiguration "<machine>";.
  3. Machine Metadata & Host Key:

    • Add the machine entry to vars/machines.nix:
      <machine> = {
        host = "<machine>.wt0.dma.computer";
        machineID = "<32-character-hex-uuid>"; # openssl rand -hex 16
        hostPubKey = "<ssh-ed25519-public-key>";
      };
      
    • Grab the machine's host public key (/etc/ssh/ssh_host_ed25519_key.pub or ssh-keyscan <machine>).
    • Run just update-sops-keys so the new machine can decrypt relevant secrets.
  4. Installation:

    • Apply disk partitions and install directly from the live environment:
      nix run 'nixpkgs#disko' -- --mode destroy,format,mount --flake '.#<machine>'
      nixos-install --no-channel-copy --flake '.#<machine>'
      
    • If Secure Boot is supported, import (self.nixosModules.secureboot) and configure Lanzaboote with TPM2.

Setting Up a New VM (Proxmox or libvirt)

Use the self-bootstrapping cloud-init image; see images/cloud-init-image/README.md.

Managing Secrets

Secrets are declared alongside consuming modules or microVMs using localized sops secret files.

  1. Declare Secrets in Module or MicroVM:

    • Place a encrypted sops file (e.g. secrets.sops.yaml) in the service or guest directory.
    • Reference secrets with an explicit sopsFile attribute:
      sops.secrets."myservice/secret_token" = {
        sopsFile = ./secrets.sops.yaml;
        owner = "myservice";
      };
      
    • For MicroVM guests, secret forwarding is defined via microvm.secrets:
      microvm.secrets = {
        sopsFile = ./secrets.sops.yaml;
        secrets = [ "myservice/secret_token" ];
      };
      
  2. Update Recipient Keys:

    • Run just update-sops-keys.
    • The script updates .sops.yaml based on the Nix sops manifest and re-keys all sops secret files to the authorized users and machines that consume them.
  3. Commit and Deploy:

    • Commit and push to Git; GitOps will deploy the changes to target nodes.

Exposing a Service via Ingress

  1. Register Port:

    • Ensure the backend service port is declared in vars/microvms.nix (for MicroVM guests) or vars/machines.nix (for bare-metal hosts).
  2. Add Virtual Host:

    • Add the host definition into modules/ingress/vhosts.nix:
      "myservice.dma.space".extraConfig = ''
        import cloudflare_dns
        import fallback_error_page
        reverse_proxy * http://${vmBridgeTarget "myservice" "http"}
      '';
      
    • For protected endpoints, add import forward_auth to require Authentik SSO.
  3. Node Pinning (Optional):

    • If the service should only be handled by a specific edge node instead of round-robin across both nodes, add the subdomain to that node's entry under domains."dma.space" in modules/ingress/default.nix.
  4. Deploy:

    • Commit and push to main; edge gateway nodes will deploy the updated Caddy configuration automatically via GitOps.