- Elm 57%
- Haskell 28.3%
- Nix 6.1%
- JavaScript 5.2%
- TypeScript 1.9%
- Other 1.3%
| .forgejo/workflows | ||
| docs | ||
| features | ||
| home | ||
| images | ||
| network | ||
| nodes | ||
| packages | ||
| parts | ||
| people | ||
| secrets | ||
| templates | ||
| topology | ||
| .envrc | ||
| .gitignore | ||
| .sops.yaml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
Nick's NixOS Dotfiles
A single flake that builds every machine I own: a desktop, a laptop, a server, a NAS, the NixOS firewall that is the house's gateway, my parents' PC, two installer images, the microVM guests that run my self-hosted services, and the first-party applications those guests serve.
It is a flake-parts repository. Host configurations, Home Manager profiles, NixOS modules, Haskell and Elm packages, deployment nodes, dev shells and formatter hooks are all outputs of the same evaluation, so a change to shared data propagates to every consumer at build time instead of drifting.
- Structure: flake-parts, dendritic: every file is a module, features push themselves
into declared classes, and a machine is the classes it imports. The network is data under
network/that the firewall, the hosts and the guests all read. Inputs are flat: nofollows, so each input builds against the nixpkgs it was made with, andflake.nixis the inputs plus oneimport-treecall - Deployment:
deploy-rsover SSH as root, key only, to each machine's link address - Isolation:
microvm.nixguests, one service per guest, each on its own VLAN - Secrets:
sops-nixwith age - Nix implementation: Determinate Nix
- CI: Forgejo Actions, self-hosted runner, seven hosts built per run
docs/architecture.md describes the model in full.
Hosts
Naming follows a celestial convention: desktops are planets, laptops are moons, servers are dwarf planets.
| Host | Role | Notable |
|---|---|---|
mars |
Main desktop | Hyprland, Niri and Plasma, ollama, local PostgreSQL, hosts the dev guests of both web apps behind a local TLS name |
deimos |
Laptop | Hyprland, full GUI profile; roams, and reaches home through the firewall's WireGuard |
ceres |
Primary server | The ingress Caddy (its own guest), Forgejo plus runner, Jellyfin, Mastodon, Minecraft, torrenting stack, the Grafana observability stack, production web apps |
eris |
NAS and secondary server | NFS exports, Vaultwarden, PhotoPrism, Restic |
firewall |
Gateway | nftables, Unbound, DHCP, the WireGuard tunnels and the switch's config, all from network/ |
mx |
Mail relay | The MX the internet talks to, outside the house, relaying for the Stalwart guest |
lamdagibson |
Parents' desktop | Plasma, two local users, no sops and no account for me, managed as root over SSH |
iso, firewall-installer |
Installer images | A Calamares desktop installer, and an offline installer for the firewall |
Each machine is nodes/<kind>/<name>/: a default.nix that builds its system from its
classes, declares its row in machines (its type and its link), and opens its own class, and
a config/ directory of boot, filesystem, hardware, networking and sops fragments that push
into that class.
Layout
flake.nix Inputs, each at the revision it ships with (no `follows`), and one import-tree call
parts/ The class declarations, deploy-rs nodes, dev shell, pre-commit hooks, treefmt, flake checks
nodes/ The machines table, one directory per machine, and one per guest service
network/ The network as data: links, dials, sites, tunnels, forwards, the switch
features/ One directory per feature, pushing into the classes that run it
people/ The people's names and details, and one directory per person: the account, secrets, files
images/ The Calamares ISO and the firewall's offline installer
home/ Home Manager modules, one directory per program, each pushing into its home classes
topology/ The network drawing, generated from the same data
packages/ First-party applications and tools
secrets/ sops-encrypted secrets
templates/ `nix flake init -t` starters for new projects
docs/ The network runbook, the architecture, and plans
Classes
A class is one NixOS (nixos.<class>) or Home Manager (hm.<class>) module that many files
add to, declared in parts/classes.nix, so pushing into one that doesn't exist fails
evaluation. base is every machine, pc the five real computers, owner wherever I have an
account, server ceres and eris, desktop the three desktops, workstation mine, microvm
the guest hosts, guest every VM, and each machine has a class of its own. Nothing is
implicit: nix, determinate, locale and sudo push into base; nh, ssh (deploy-rs
access and the known hosts), sops (the module, the age key and the root-owned secrets) and
environment push into owner, and the firewall and mx take nh and ssh through their
own classes. gnome, wireless, logrotate, defenseioGpu and a few more have classes
nothing imports, kept as they were found.
nodes/ and network/
network/ holds the facts the firewall is built from and everything else reads: a link per
machine and per guest, each a /31 on its own VLAN written out by hand, with named ports
that become firewall rules when another link dials them; the sites Caddy serves and where
each one goes; the WireGuard tunnels; the port forwards; the switch's port map. Naming a port
on a link is a firewall change, so no module invents ports of its own. docs/network.md is
the runbook.
machines (nodes/machines.nix) and microvm.vms are flake-level tables. A row names its
link, and the rest comes from the network as read-only defaults: address, gateway, VLAN tag,
named ports, the public names the ingress serves for it, and for a guest its host, the
machine whose link its row names. Inside a system the machine's own row is
config.my.machine. Every machine's evaluation asserts the tables agree: a link claimed
twice, a name used by a machine and a VM, a guest with no host, a MAC on two guests.
A service is nodes/guests/<service>/: record.nix declaring its VMs by name
(peertube-prod on ceres, peertube-dev on mars), guest.nix for the guest itself, and
host.nix for what it asks of its host, such as extra shares, the secrets it lends, or a
Caddy vhost on mars's dev name. Roughly two dozen run today: Forgejo, Jellyfin, Mastodon,
Minecraft, Vaultwarden, PhotoPrism, OpenCloud, Stalwart, the torrent stack, Grafana, Loki,
Mimir, Tempo, and the dev and prod instances of the web apps. Firefly III, Syncthing, Open
WebUI and the project site are declared but disabled, which keeps their links drawn.
features/guestHost is the host side of every guest. For each VM on the machine it emits
the microvm.vms entry, the systemd-networkd unit matched by MAC, the tap vm<tag> on the
host's VLAN bridge, the virtiofs shares for state and secrets, and the tmpfiles rules behind
them. A VLAN tag is unique, so taps cannot collide. It also ships microvm-sync, which
restarts exactly the guests whose booted and current symlinks have diverged. A host
rebuild moves those symlinks but does not restart the VMs, so without it a memory or CPU
change looks applied while the running guest still holds its old allocation.
features/
A feature is a directory under features/ whose files push into the classes that run it,
and whose per-machine settings are NixOS options under my.<feature> that the machine's class
sets: restic's schedule and paths, nfs's exports and clients, caddy's extra sites. A
feature reads the other machines from machines and microvm.vms in the flake-parts module
that defines it, so a feature that spans machines, such as NFS exports to the clients a host
names, or restic over every guest a host runs, is one filter over the tables.
Shared data that isn't a machine is flake-level options too: mail (the Stalwart server,
its domains and mailboxes, and the relay), labHelpers (paths under /mnt/storage, Caddy
snippets), people and aesthetics (the palette, fonts and sizes, cursor, window manager
gaps, borders and rounding).
parts/deploy.nix maps machines into deploy-rs nodes at their links' addresses, with
activation and confirmation timeouts raised well past the defaults because microvm@ units
take minutes to finish activating on a host with several guests.
Caddy refuses to start if it would serve a domain whose ACME certificate has never actually been issued, since the placeholder in that case is a self-signed minica cert.
home/
Home Manager modules, one directory per program, grouped as cli/ (dev tooling, file
utilities, shell, general utilities) and gui/ (browsers, editors, crypto, terminals,
gaming, media, messaging, file sharing, tools). There's one home class per machine
(hm.ceres, hm.mars, hm.lamdagibson, …), and each program pushes into every home that
has it, with no groups in between, so a program's file says exactly where it lands. A
machine's class gives each person their home there.
The shell is Nushell with Starship, the editor set is Helix and Zed, and theming is driven
from aesthetics.themes so palettes stay consistent across the terminal, window manager and
applications.
people/
people/options.nix names the people by slot (user0 is me) and holds their details. Each
person's directory pushes their account into the classes of the machines they use (me into
owner, my parents into lamdagibson): the user and its groups. Mine also carries
declarative users with mutableUsers = false, a sops-provided password hash, my own secrets
(the SSH key pair, tokens, signing keys), home directory structure via systemd.tmpfiles,
and a generated justfile giving every machine local and remote rebuild recipes, SSH
shortcuts and a vms-<host> recipe that calls microvm-sync remotely.
packages/
First-party code, exposed as flake packages with a matching dev shell each:
| Package | What it is |
|---|---|
uproot-backend |
upRootNutrition backend, Haskell |
uproot-frontend |
upRootNutrition frontend, Elm, built with mkElmDerivation |
uproot-android |
Capacitor and Gradle orchestrator for the upRootNutrition Android app, nix run .#build-android -- [release|debug|compile-only] |
haskeww |
Haskell library and scripts backing the status bar: audio, brightness, battery, GPU, time, weather, workspaces |
btrfs |
btrfs-cleaner, snapshot pruning |
resume |
Typst résumé, two variants, built to PDF |
The Android packages pin their own nixpkgs instance with android_sdk.accept_license,
since the repo-wide allowUnfree only covers NixOS and Home Manager evaluation.
Haskell packages use committed cabal2nix output rather than callCabal2nix, so nothing in
the tree needs import-from-derivation. Regenerate the sibling <pkg>.nix when .cabal
dependencies change.
templates/
nix flake init -t starters, each with a flake, a dev shell, a .envrc and a formatter
config:
nix flake init -t github:<this-repo>#haskell # Haskell with cabal and HLS
nix flake init -t github:<this-repo>#elm # Elm Land frontend with a Haskell backend
nix flake init -t github:<this-repo>#typst # Typst documents
Development
direnv allow drops you into the default shell, which carries sops, age, ssh-to-age,
deploy-rs, nixfmt, nil, just and the rest of the day-to-day tooling, and installs the
pre-commit hooks on entry.
Two formatting layers, deliberately kept in agreement:
- pre-commit runs
nixfmton staged Nix files andcommitizenon the commit message, so commits follow Conventional Commits. - treefmt (
nix fmt) covers the whole tree: nixfmt, deadnix, statix, ormolu, hlint, cabal-fmt, elm-format, rustfmt, taplo, typstyle, yamlfmt, mdformat. Itsnix flake checkgate is off, because the tree is not yet treefmt-clean across every language.nixfmtwidth is pinned to 100 in both layers so the two never fight.
Per-project shells are available for each package, for example nix develop .#uproot-backend
or nix develop .#uproot-frontend.
Secrets
Everything sensitive lives in secrets/secrets.yaml, encrypted with age through sops-nix
and decrypted to /run/secrets at activation. .sops.yaml holds the recipient list. Guests
receive secrets through a read-only virtiofs share from the host rather than holding their
own keys.
Note that evaluating this flake requires SSH access to a private forge, because one input is
an out-of-tree project flake. Both the workstation and the CI runner get the host key from
programs.ssh.knownHosts in features/ssh/default.nix.
Building and deploying
# Local host
nixos-rebuild switch --sudo --flake .#mars
# Remote host, over deploy-rs
deploy .#ceres
# Remote host, over nixos-rebuild, at its link's address (network/links.nix)
nixos-rebuild switch --flake .#ceres --target-host 10.0.20.1 --sudo --ask-sudo-password
# Restart only the guests whose configuration actually changed
ssh -t ceres sudo microvm-sync
# Build without switching
nix build .#nixosConfigurations.ceres.config.system.build.toplevel
# Evaluate everything
nix flake check
The generated justfile on each machine wraps most of these: just rebuild,
just rebuild-<host>, just <host> for SSH, just vms-<host> for the guest sync.
CI
.forgejo/workflows/ci.yml runs on a self-hosted runner. A cheap nix flake check --no-build
gates an expensive matrix that builds all seven host toplevels, so a flake that does not even
evaluate never burns seven serial builds. Runs supersede each other per ref, since Nix keeps
whatever a cancelled run already realised.
The main branch is ignored on push by design: this repo is the development fork and pushes
to main are constant, while upstream only ever sees already-tested merges. The real gate is
the pull request.
Credits
Not everything here is original. The material below belongs to other people, is used with attribution, and carries its own terms rather than the repository's.
| What | Where | Whose |
|---|---|---|
haskeww, the EWW status bar library and scripts |
packages/haskeww/ |
Originates from the AskYourself project, AGPL-3.0-or-later, same as this repository |
| Many of the SVG icons in the Elm frontends | src/Config/Style/Icons/ in each Elm package, and templates/elm/ |
Font Awesome Free, Fonticons Inc., CC BY 4.0 |
| Notification sounds | packages/upRootNutrition/uproot-frontend/static/alerts/ |
akx/Notifications, Aarni Koskela and contributors, CC BY 4.0 |
| OBS Studio themes | home/gui/apps/media/video/obsStudio/themes/*.qss |
Philippe Groarke, GPL-2.0-or-later |
| OBS Studio and Thunderbird themes | .../obsStudio/themes/Catppuccin/, .../thunderbird/themes/*.xpi |
Catppuccin contributors, MIT |
Acknowledgements
The upRootNutrition branding, including Enaychi, and the compatIQ branding are the work
of ardlak on Discord (user ID 91007151513825280).
Licence
AGPL-3.0-or-later for everything original to this repository. AGPL over GPL deliberately: both web applications are hosted services, and §13 is what keeps a modified hosted copy from being a private fork. The GPL-2.0-or-later OBS themes credited above are why the project licence has to stay GPL-compatible.
Two paths are present in the tree but are not granted under the AGPL, because they are not mine to relicense. Strip them before redistributing, or satisfy yourself independently that you hold the rights:
| Path | What it is |
|---|---|
home/gui/apps/browsers/firefox/_config/search/_config/icons/ |
Search-engine logos and trademarks, reproduced to identify the engines they belong to — the same nominative use a browser's own search settings make of them |
packages/resume/ |
Personal résumé content and contact details |
"upRootNutrition", as well as its logos and wordmarks, are not licensed by the AGPL grant either. The licence covers the software; it does not grant permission to run a service under these names or to present a fork as the original.