Skip to content
cramtPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

nixconf

My personal NixOS configuration, managing a fleet of machines using flake-parts, Home Manager, and a custom module system.

Hosts

Host Type Description
saturn Desktop AMD gaming PC with Wayland/COSMIC, Secure Boot (lanzaboote)
luna Server Home server with NAS, game servers, Caddy, fleet Prometheus
mars Desktop Secondary desktop, AMD gaming PC with COSMIC
ganymede Laptop TV box: boots straight into emrakul with Firefox (YouTube's TV UI, Nebula) and Chromium (Jellyfin) web apps, always-on (lid-close ignored)
eros SBC Raspberry Pi (aarch64), SD card image

Common Commands

# Deploy the fleet: builds and activates on every host answering right now,
# skipping the ones that are powered off. Runs from any host, and the machine
# you run it on is just another target.
just deploy
just deploy luna ganymede   # ...or narrow it to named hosts

# Builds are capped at nproc/4 parallel jobs x 2 cores so the machine stays
# usable mid-deploy. Lift the cap when nothing else needs the CPU:
just jobs=8 cores=8 deploy

# Apply config to the current host only, without the network
nh os switch

just update           # Merge the newest CI-green `update` commit into main (see below)
just hard_update      # Bump flake inputs, gems, npins, and packages in place
just update_flake     # Update flake.lock only
just update_gems      # Update Ruby gem lockfile

# Infrastructure (uses 1Password for secrets)
just tf <args>        # Run OpenTofu on the Cloudflare infra (just tf plan); `just deploy` applies it

# Flake management
nix flake update
npins update          # Update non-flake pinned sources

Updating

Every 6 hours a GitHub Actions workflow (update.yml) merges main into the long-lived update branch, runs just hard_update on top, commits, and triggers the build workflow there, so every package and host toplevel lands in cachix. The build posts a Build & Cache commit status on each commit.

To update: just update merges the newest green commit on update into main and pushes. If the tip is red or still building it warns and falls back to the newest green commit, so you never end up building something uncached. Then just deploy (or nh os switch) substitutes everything from the cache.

Architecture

Flake Structure

flake.nix is a thin wrapper around flake-parts.lib.mkFlake that imports modules from modules/:

Path Purpose
modules/flake/lib.nix Instantiates myLib and exposes it as _module.args.myLib
modules/flake/hosts.nix Discovers hosts from hosts/ and builds nixosConfigurations
modules/flake/deploy.nix Derives the deploy-rs node set from those hosts
modules/flake/packages.nix Per-system packages (e.g. eros-img)
modules/flake/hm-modules.nix Typed accumulators for the Home Manager module outputs

Module System

Both nixosModules/ and homeManagerModules/ use extendModules to auto-generate enable options for every file in their subdirectories.

NixOS modules (accessed as myNixOS.* in host configs):

  • nixosModules/features/<name>.nix → myNixOS.<name>.enable = true
  • nixosModules/bundles/<name>.nix → myNixOS.bundles.<name>.enable = true
  • nixosModules/services/<name>.nix → myNixOS.services.<name>.enable = true

Home Manager modules (accessed as myHomeManager.* in home configs):

  • homeManagerModules/features/<name>.nix → myHomeManager.<name>.enable = true
  • homeManagerModules/bundles/<name>.nix → myHomeManager.bundles.<name>.enable = true
  • homeManagerModules/fixes/ — unconditional fixes, always imported

Adding a New Host

Create hosts/<name>/ — that's it. modules/flake/hosts.nix reads hosts/, so a directory there becomes a nixosConfigurations.<name> and a just deploy target with no list to edit. Everything is derived from the folder name:

derived as
entrypoint hosts/<name>/configuration.nix
networking.hostName <name> (mkDefault, so a host can override)
user's Home Manager config hosts/<name>/home.nix, if present
SSH keys (user + root) myLib/keys.nix
deploy address <name>, resolved over LAN DNS

Add hosts/<name>/host.nix only to deviate — it takes nixpkgs (build from a vendor cache, as eros does), address (if DNS can't find the host) and builder (join the distributed build pool; needs ssh_host_ed25519_key.pub next to it). See hosts/eros/host.nix.

Phones

Rooted Android phones are managed by Nixup, not NixOS, so they live in phones/<name>/configuration.nix instead of hosts/. modules/flake/phones.nix discovers them into nixupConfigurations.<name>, each with every nixupModules.* entry (modules/phone/: tailscale on headscale, ssh with myLib/keys.nix, and 1Password secrets rendered on the phone by the same op-secrets.sh as hosts). just phone <name> applies one over adb or ssh; they aren't part of just deploy.

Key Subsystems

Subsystem Description
Theming stylix — dark theme with Iosevka Nerd Font. stylixAsset accepts an image or .mp4
Secrets 1Password via the op CLI (modules/security/secrets.nix)
Port assignment portselector.nix — deterministically assigns ports by hashing service names
Fleet metrics Push-based Prometheus on luna; agents remote_write through Caddy (modules/services/metrics.nix). Services register loopback scrapes via localJobs: Caddy per-vhost requests, cli-proxy-api (cpa-prometheus plugin), exportarr, nvidia-gpu
Non-flake pins npins/ — for sources without flake support
Gems gems/ — Ruby gems used by scripts, locked with bundle lock
Packages packages/ — custom packages

Home Manager Bundles

Bundle Purpose
general Core user tools
graphical Wayland/desktop apps
development Dev toolchain (Go, Rust, Node, Ruby, Java, Zig, etc.)
gaming Steam and game-related tools
work Work-specific config

Infrastructure

Cloudflare (DNS, email routing, workers) is Nix in infra/, rendered by terranix with every resource typed against the cloudflare provider's schema. Secrets come from 1Password. State is a file in /vault on luna, and tofu always runs there (over ssh, wherever you start it).

just deploy infra   # apply it (a bare `just deploy` does this before the hosts)
just tf plan        # any other OpenTofu command

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages