Services
Every self-hosted service is a module in
modules/nixos/services/
that a host switches on from
fleet.toml.
The services page lists what each host actually runs.
The shape of a service
Section titled “The shape of a service”garden.services.<name> is a submodule with four options, plus anything else a
service wants to add (it’s freeform):
- enable
- host: the address it binds. Defaults to
127.0.0.1when it has a port, otherwisenull - port: the port it listens on, or
null - domain: where it’s served, or
null
A module declares its own defaults with
mkService, which sets them at mkOptionDefault so the host
can still override any of them:
{ lib, self, config, ... }:let inherit (lib.modules) mkIf; inherit (self.lib) mkService;
cfg = config.garden.services.vaultwarden;in{ imports = [ (mkService "vaultwarden" { port = 3013; domain = "vault.${config.networking.domain}"; }) ];
config = mkIf cfg.enable { services.vaultwarden.config = { ROCKET_ADDRESS = cfg.host; ROCKET_PORT = cfg.port; };
services.nginx.virtualHosts.${cfg.domain}.locations."/".proxyPass = "http://${cfg.host}:${toString cfg.port}"; };}Read the port and domain back from cfg rather than repeating them, so an
override in fleet.toml reaches everything that uses them. Other services do
the same, so vaultwarden finds its mail server at
config.garden.services.mailserver.domain.
Switching it on
Section titled “Switching it on”In fleet.toml, under the host’s services table:
[minerva.services]vaultwarden.enable = true
[freyja.services]# bind every interface, for the relay or the tailnet to reachimmich = { enable = true, host = "0.0.0.0" }What nginx adds
Section titled “What nginx adds”Every virtual host gets these defaults from
nginx.nix,
so a service only says where to proxy:
- HTTPS forced, an ACME certificate, and QUIC
- a
403for AI crawlers, matched on user agent - the security headers
Referrer-Policy,Content-Security-Policy: frame-ancestors 'self'andX-Content-Type-Options, unless the vhost setssecurityHeaders = false
Hosts behind NAT
Section titled “Hosts behind NAT”A host that can’t take public traffic, like freyja at home, names a relay in its fleet entry:
[freyja]relay = { via = "minerva", services = ["grafana", "immich", "jellyfin"] }The relay then serves each listed service’s domain and proxies it over
tailscale to the port the home host gives it. The fleet name is the tailscale
name, so nothing else needs wiring. Evaluation fails if a relayed service isn’t
enabled on the host it points at. Bind those services to 0.0.0.0 so the
tailnet can reach them.
Backups, secrets and bans
Section titled “Backups, secrets and bans”- Backups: add the service’s state to
garden.backups.jobs.<name>.paths. On a host runningborgbackup, each job becomes a nightly borg backup to rsync.net. See restoring backups. - Secrets:
mkSecretwires a key fromsecrets/services/<file>.yamlintosops.secrets. See secrets. - Bans:
journalJailbuilds a fail2ban jail that reads the service’s journal and bans on both TCP and UDP web ports, since QUIC is on.
Getting it documented
Section titled “Getting it documented”Nothing to do. The services page and each host’s page are
generated from the evaluated configs on every docs build. To give a service a
proper name or logo in those pages and the topology diagram, add it to
modules/flake/packages/topology/catalog.nix.
Built from ef8c592 on 2026-11-24