Services
Platforms: SSH, Tailscale and Mosh run on NixOS and nix-darwin. Every other service is NixOS only. See Darwin.
Service modules under othrys.services.*.
Available Modules
| Module | Option | Description |
|---|---|---|
| Docs | othrys.services.docs | MdBook documentation server (darkhttpd) |
| SSH | othrys.services.ssh | OpenSSH server, client defaults and known hosts |
| Tailscale | othrys.services.tailscale | VPN mesh network |
| Mosh | othrys.services.mosh | Mobile shell server and client |
| WireGuard | othrys.services.wireguard | Raw WireGuard interfaces (site-to-site, exit nodes) |
| DDNS | othrys.services.ddns | Dynamic DNS updates (inadyn) |
| Headscale | othrys.services.headscale | Self-hosted Tailscale control server |
| Monitoring | othrys.services.monitoring | Prometheus server and node exporter |
| VictoriaMetrics | othrys.services.victoriametrics | Time-series database (Prometheus-compatible) |
| VictoriaLogs | othrys.services.victorialogs | Log database (LogsQL, journald ingestion) |
| Grafana | othrys.services.grafana | Dashboards (datasources auto-provisioned) |
| Scrutiny | othrys.services.scrutiny | S.M.A.R.T. disk health with history (web UI, InfluxDB, collector) |
| Alerting | othrys.services.alerting | vmalert rule evaluation with ntfy delivery |
| Ntfy | othrys.services.ntfy | Self-hosted push-notification server |
| Notify | othrys.services.notify | Host notification dispatch + failure hooks |
| Automount | othrys.services.automount | USB automounting through udiskie |
| Firewall | othrys.services.firewall | Turns on the NixOS firewall and sets nothing else |
| Router | othrys.services.router | L3 router firewall + NAT (nftables), optional NFQUEUE hook |
| Suricata | othrys.services.suricata | IDS/IPS (NFQUEUE or AF_PACKET inline) |
| Kea | othrys.services.kea | Kea DHCPv4/DHCPv6 server |
| Unbound | othrys.services.unbound | Recursive DNS (DoT upstream, RPZ blocklists) |
| Traefik | othrys.services.traefik | Reverse proxy with DNS-01 ACME, a TLS floor, security headers and TCP routers |
| soju | othrys.services.soju | IRC bouncer on loopback, reached over its own TLS or through Traefik |
| Restic | othrys.services.restic | Scheduled restic backups (secrets via file paths) |
| Virtual Camera | othrys.services.virtualcamera | v4l2loopback devices, numbered from videoNr, enabled by othrys.apps.obs |
| Printing | othrys.services.printing | CUPS printing |
| Mounts (Disks) | othrys.services.mounts.disks | Additional disk mounts (NTFS, ext4, btrfs) |
| Mounts (CIFS) | othrys.services.mounts.cifs | CIFS/SMB network share mounts |
See also: Security, Containerization
Documentation Server
Builds the MdBook documentation at Nix evaluation time and serves it via darkhttpd.
Options
options.othrys.services.docs = {
enable = lib.mkEnableOption "MdBook documentation server";
package = lib.mkOption {
type = lib.types.package;
default = docsPackage;
defaultText = lib.literalMD "the MdBook built from `docs/` of the flake source that `nixosModules.default` injects";
description = "The built documentation package to serve. Required when this module is imported on its own through `nixosModules.docs`, where no flake source is injected to build the default from.";
};
port = lib.mkOption {
type = lib.types.port;
default = 3000;
description = "Port to serve documentation on.";
};
interface = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Interface to bind to (use 0.0.0.0 for all interfaces).";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open firewall port for documentation server.";
};
desktopEntry = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Create a desktop entry to open docs in the default browser.";
};
};
Usage
othrys.services.docs = {
enable = true;
port = 3000; # default
interface = "127.0.0.1"; # default, use "0.0.0.0" for all interfaces
openFirewall = false; # default
desktopEntry = false; # default, creates XDG desktop entry to open in browser
};
The docs are built from the flake source as a derivation, with no runtime build step. The built package is also accessible as config.othrys.services.docs.package.
When desktopEntry is enabled, an “othrys.nix Docs” entry appears in application launchers, opening the docs in the default browser via xdg-open.
SSH
othrys.services.ssh configures the client for the primary user and, with
server.enable, the OpenSSH server with password login off.
server.ports sets the ports the server listens on, [22] by default, and
server.openFirewall opens them, which it does by default. Both are written to
services.openssh as defaults, so a host that sets the upstream options
directly gets the same result. The firewall and the fail2ban sshd jail read
services.openssh.ports, so a server moved to another port has that port
opened and watched while 22 stays closed.
The server settings are all written with lib.mkDefault, and a plain assignment
under services.openssh.settings replaces any one of them.
| Directive | Default here |
|---|---|
PermitRootLogin | no |
PasswordAuthentication, KbdInteractiveAuthentication | no |
X11Forwarding | no |
AllowTcpForwarding, AllowAgentForwarding | no |
MaxAuthTries | 3 |
LoginGraceTime | 30 |
MaxSessions | 4 |
ClientAliveInterval, ClientAliveCountMax | 300, 2 |
UsePAM | yes |
LogLevel | VERBOSE |
KexAlgorithms | sntrup761x25519-sha512@openssh.com, mlkem768x25519-sha256, curve25519-sha256, curve25519-sha256@libssh.org |
Ciphers | chacha20-poly1305@openssh.com, aes256-gcm@openssh.com, aes128-gcm@openssh.com, aes256-ctr |
Macs | hmac-sha2-512-etm@openssh.com, hmac-sha2-256-etm@openssh.com |
Four of these change what a working host does. With forwarding off, ssh -L,
ssh -R, ssh -J through the host and remote editors that tunnel over the
connection are refused, and so is ssh -A. A jump host or a development machine
turns AllowTcpForwarding back on. MaxAuthTries 3 counts every key the client
offers, so a client whose agent holds more than three keys is disconnected
before it reaches the right one unless it names the key with IdentityFile and
IdentitiesOnly yes. The algorithm lists are narrower than the set nixpkgs
recommends, and a client older than OpenSSH 6.5 negotiates nothing from them.
UsePAM stays on because sshd opens the login session and applies limits
through the PAM account and session stacks, and with password and
keyboard-interactive login off it authenticates nobody.
othrys.services.ssh.server = {
enable = true;
ports = [2222];
};
services.openssh.settings.AllowTcpForwarding = "yes";
knownHosts passes host keys to programs.ssh.knownHosts, which writes
/etc/ssh/ssh_known_hosts for every user. A listed host is verified against its
listed key on the first connection, so nobody accepts it on trust. An entry
takes publicKey or publicKeyFile, and optionally hostNames,
extraHostNames and certAuthority, and any other key is rejected.
includeForgeKeys is on by default and adds the published ed25519 keys of
github.com, gitlab.com, codeberg.org and git.sr.ht. An entry in knownHosts
with the same name replaces a forge entry.
The client defaults under "*" are StrictHostKeyChecking ask,
HashKnownHosts yes and UpdateHostKeys ask, so an unknown host prompts and is
never accepted silently. A directive set through settings replaces that one
default and leaves the rest. Once knownHosts covers every host the machine
connects to, this ends trust on first use. The client does not ask for
compression, which slows transfers on a fast link. A host reached over a slow
one sets Compression for that host through settings.
othrys.services.ssh = {
knownHosts."nas.example.com".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...";
settings."*".StrictHostKeyChecking = "yes";
};
There is no host certificate authority option. A CA needs a signing key whose custody belongs with the host configuration and not with a module library.
On nix-darwin
darwinModules.default carries the module, and the known hosts and the
client configuration are the same as on NixOS. server.enable turns on the
macOS Remote Login service through nix-darwin’s services.openssh, which
takes sshd_config text in place of settings. The directives above are
rendered into /etc/ssh/sshd_config.d/100-nix-darwin.conf, and sshd keeps
the first value it reads, so they win over the defaults macOS ships.
mlkem768x25519-sha256 is left out of KexAlgorithms there, since Apple’s
OpenSSH build follows the macOS release and one older than 9.9 refuses the
whole line over a name it does not know.
nix-darwin declares no services.openssh.settings, so a darwin host
loosens a directive with a line in services.openssh.extraConfig placed
ahead of the othrys lines. A line at normal priority comes after them and
loses.
services.openssh.extraConfig = lib.mkBefore "AllowTcpForwarding yes";
launchd starts that sshd on port 22, so a server.ports other than [22]
is refused. The firewall nix-darwin manages filters by application and
takes no port list, so server.openFirewall has nothing to open on a Mac.
A login from Ghostty or kitty sets TERM to xterm-ghostty or
xterm-kitty, and the terminfo database macOS ships has neither entry, so
the server also puts the terminfo output of ghostty-bin and kitty on the
system path. nix-darwin adds that to TERMINFO_DIRS, so clear, backspace
and full-screen programs work in the session. Another terminal’s entry goes
in environment.systemPackages the same way, or
environment.enableAllTerminfo installs eleven of them at once.
Router
An L3 router firewall + NAT built on networking.nftables. It generates a
default-drop inet filter (input/forward) and an ip masquerade from the WAN
and LAN interface options. LAN interfaces are trusted (input accepted, forwarded
to the WAN), while the WAN is default-drop except established/related. Interface names
and subnets are identity and come from the fleet host. Port forwards are
declared through portForwards, which renders the dnat rule in the NAT
prerouting chain and the forward accept the rewritten connection needs.
Anything else the generated ruleset doesn’t cover goes through
extraInputRules / extraForwardRules / extraPrerouting / extraNat.
extraNat is the postrouting chain, after the masquerade, and a dnat verb is
invalid there. nft --check accepts it, so the build passes, and the kernel
refuses the whole ruleset at load, so the router comes up forwarding with no
filter table at all. A dnat or redirect rule goes in extraPrerouting.
With suricata.enable, forwarded traffic is handed to Suricata via NFQUEUE
(queue num 0-<N-1> bypass) instead of plain accept. Pair it with
othrys.services.suricata (mode = "nfqueue", matching nfqueue.queues).
Suricata inspects forwarded traffic only. The queue verdict is written in the
forward chain and nowhere else, so connections to the router itself, which the
input chain decides, and connections the router opens are never queued.
The router disables networking.firewall (and asserts othrys.services.firewall is
off), and still reads the firewall’s port lists. A port a module opens through
openFirewall lands in networking.firewall.allowedTCPPorts or the UDP list,
and the input chain accepts it on every interface but the WAN, so SSH,
headscale, WireGuard and the rest work on a router as on any host without
reaching the internet. A port that must reach the WAN is opened by naming the
interface, networking.firewall.interfaces.<wan>.allowedTCPPorts, which the
chain renders for that interface alone; the tailscale module does this for its
own UDP port so direct paths work from outside. Reverse-path filtering is
strict on the WAN interface and loose on the LAN interfaces and on any
interface created later, so routes that Tailscale installs and multi-homed
replies are not dropped. conf.all stays at 0, since the kernel applies the
higher of that value and the interface’s own.
Two separate mechanisms decide what happens when inspection stops, and they are
easy to confuse. The bypass flag above accepts packets when no process is bound
to the queue, so a dead or stopped Suricata does not take the link down, and it
is set unconditionally. othrys.services.suricata.nfqueue.failOpen covers the
other case, a running Suricata whose queue is full. Setting failOpen = false
therefore does not make a dead Suricata block traffic.
The unit’s pre-check, suricata -T, treats any rule that fails to load as
fatal, so a ruleset with one bad rule keeps the engine from starting. Because of
bypass the network shows no sign of that, so watch the unit and not the link.
A start that keeps failing does not loop for ever. The unit retries thirty
seconds apart, and after five starts within fifteen minutes it stays in
failed, where systemctl --failed and monitoring can see it. With
othrys.services.notify enabled, that failure is sent through
notify-failure@. suricata-recover.service runs after every successful
suricata-update, which is at least daily, and starts the engine again if it
was left in failed. When the cause is still there, the unit fails and reports
again, once per rule update.
The module states modbus and dnp3 as enabled = "no", which is Suricata’s
own default, so that suricata-update drops the rules naming them. Set either
to "yes" through settings to get the parser and its rules back. A running
engine reloads its rules after every suricata-update run, through upstream’s
blocking reload, so a fetched ruleset is live without a restart. dropRules
lists the rules suricata-update turns from alert into drop. With the router’s
NFQUEUE hook on, the module refuses an af-packet Suricata and a queue count
that differs from the router’s, since a queue nobody listens on accepts its
packets uninspected.
On this NFQUEUE path a stopped Suricata always fails open, since bypass is
unconditional. An overloaded one fails open by default and drops what does not
fit its queue once nfqueue.failOpen is false. The default is deliberate,
since an IPS crash on a router should not sever the network it protects. While
Suricata is down, forwarded traffic is uninspected rather than blocked, so the
link stays up with no IPS behind it.
An af-packet IPS fails the other way. With mode = "af-packet" and
posture = "ips" Suricata copies frames between the two interfaces itself, and
the module sets up no other path between them, so the link is down whenever
the engine is.
IPv6 is forwarded and filtered when ipv6 is on, and the WAN interface accepts
router advertisements so it keeps its default route. The module does no more
for IPv6 than that. There is no NATv6, so the LAN needs a routed prefix, and
requesting a delegated prefix from the uplink and sending router
advertisements on the LAN are the host’s job. systemd-networkd does both
through DHCPPrefixDelegation and IPv6SendRA, and dhcpcd with radvd is the
other common pair.
Options
options.othrys.services.router = {
enable = lib.mkEnableOption "L3 router firewall + NAT (nftables)";
wan.interface = lib.mkOption {
type = lib.types.str;
example = "enp1s0f0";
description = "Uplink (WAN) interface. Input is default-drop except established/related; LAN is masqueraded out this interface.";
};
lan.interfaces = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["br-lan"];
description = "Trusted (LAN) interfaces: their input is accepted and they are forwarded to the WAN.";
};
nat.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "IPv4 masquerade (SNAT) for traffic leaving the WAN interface.";
};
forwarding = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable IP forwarding and rp_filter anti-spoofing sysctls.";
};
ipv6 = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Forward IPv6 as well. There is no NATv6, so the LAN needs a routed
prefix of its own. This module forwards and filters IPv6 and
configures no addressing. Requesting a delegated prefix from the
uplink and sending router advertisements on the LAN are the host's
job, through systemd-networkd's `DHCPPrefixDelegation` and
`IPv6SendRA`, or through dhcpcd and radvd.
'';
};
suricata = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Send forwarded traffic to Suricata via NFQUEUE. Pair with othrys.services.suricata (mode = \"nfqueue\").";
};
queues = lib.mkOption {
type = lib.types.ints.positive;
default = 1;
description = "NFQUEUE count; must match othrys.services.suricata.nfqueue.queues.";
};
};
logDrops = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Log every packet the input and forward chains drop, through the
kernel log with a `router input drop:` or `router forward drop:`
prefix. The counters on those rules are always on; this adds the
packets themselves, which is useful while bringing a host up and
noisy on a WAN link afterwards.
'';
};
extraInputRules = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Raw nftables rules appended to the filter input chain. A port that a
module opens through `openFirewall` needs nothing here, since the
firewall's port lists are rendered into this chain for every interface
but the WAN. A port that must reach the WAN is opened with
`networking.firewall.interfaces.<wan>.allowedTCPPorts` or the UDP
list, which this chain renders for that interface alone.
'';
};
extraForwardRules = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Raw nftables rules appended to the filter forward chain (e.g. port forwards, inter-VLAN policy).";
};
portForwards = lib.mkOption {
type = lib.types.listOf (lib.types.submodule {
options = {
protocol = lib.mkOption {
type = lib.types.enum ["tcp" "udp"];
default = "tcp";
description = "Transport protocol of the forwarded connections.";
};
port = lib.mkOption {
type = lib.types.port;
description = "Port on the WAN interface the connections arrive on.";
};
destination = lib.mkOption {
type = lib.types.str;
example = "10.0.0.42";
description = "LAN address the connections are sent to.";
};
destinationPort = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = null;
description = "Port on the destination. The WAN port when null.";
};
};
});
default = [];
example = lib.literalExpression ''
[
{
port = 25565;
destination = "10.0.0.42";
}
]
'';
description = ''
Connections arriving on the WAN interface that are sent on to a LAN
host. Each entry renders the dnat rule in the NAT prerouting chain and
the accept in the forward chain that the rewritten connection needs,
through Suricata when the IPS hook is on.
'';
};
extraPrerouting = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Raw nftables rules appended to the NAT prerouting chain, where a
`dnat` or `redirect` verb belongs. A connection rewritten here still
needs its accept in `extraForwardRules` unless `portForwards` made
it.
'';
};
extraNat = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Raw nftables rules appended to the NAT postrouting chain, after the
masquerade, for source rewrites such as an exception to it. A `dnat`
verb is invalid in this chain: `nft --check` accepts it, the kernel
refuses the whole ruleset at load, and the router comes up with no
firewall at all. Port forwards go in `portForwards` or
`extraPrerouting`.
'';
example = ''oifname "enp1s0f0" ip saddr 10.0.0.42 snat to 203.0.113.42'';
};
};
Usage
othrys.services.router = {
enable = true;
wan.interface = "enp1s0f0";
lan.interfaces = ["br-lan"];
nat.enable = true; # IPv4 masquerade
# Inline IPS: feed forwarded traffic to Suricata's NFQUEUE
suricata = { enable = true; queues = 4; };
# A port forward: the dnat rule and the forward accept it needs, through
# the IPS like any other forwarded traffic.
portForwards = [{ port = 25565; destination = "10.0.0.42"; }];
# Raw escape hatches for policy the options do not express:
extraForwardRules = "iifname \"br-lan\" oifname \"br-iot\" drop";
};
Suricata
Suricata IDS/IPS, wrapping the upstream
services.suricata. Two inline deliveries via mode:
nfqueue(default) keeps the box an L3 router/NAT, since an nftablesqueuerule (the router/firewall module’s job) hands packets to Suricata, which the module runs in NFQUEUE runmode.nfqueue.queuessets-q 0 … -q N-1, andnfqueue.failOpenaccepts packets when a running Suricata’s queue is full.af-packetcaptures on an interface;posture = "ips"builds a transparent L2 bridge acrossafPacket.interface+afPacket.copyInterface.
posture (ids/ips) selects alert-only against drop. Start in IDS, tune, then
flip. offloadInterfaces disables GRO/GSO/TSO/LRO (required for inline
correctness). Rules come from enabledSources (default et/open) via
suricata-update; deep tuning (threading/CPU-affinity, mpm-algo = "hs",
outputs) goes through settings. Host-specific values (interface names,
isolcpus, core sets) stay in the fleet.
The fetched sources and the compiled suricata.rules live under
/var/lib/suricata, which the module persists under impermanence for the
suricata account. Without that entry a rebooted host runs with no rules
until the first update after boot succeeds.
Options
options.othrys.services.suricata = {
enable = lib.mkEnableOption "Suricata IDS/IPS";
package = lib.mkOption {
type = lib.types.nullOr lib.types.package;
default = null;
defaultText = lib.literalExpression "pkgs.suricata";
description = "Suricata package to use.";
};
mode = lib.mkOption {
type = lib.types.enum ["nfqueue" "af-packet"];
default = "nfqueue";
description = ''
Inline delivery. `nfqueue` keeps the box an L3 router/NAT (packets are
queued to Suricata by an nftables `queue` rule). `af-packet` captures on
an interface (a transparent L2 bridge when posture = ips).
'';
};
posture = lib.mkOption {
type = lib.types.enum ["ids" "ips"];
default = "ids";
description = "IDS alerts only; IPS can drop. Start in IDS, tune, then flip to IPS.";
};
enabledSources = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = ["et/open"];
description = "suricata-update rule sources to enable (sources needing a secret code are unsupported upstream).";
};
disabledRules = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "Rule SIDs/patterns to disable (noisy signatures).";
example = ["2013504" "2100498"];
};
offloadInterfaces = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
Interfaces on which to disable NIC offloads (GRO/GSO/TSO/LRO) before
Suricata starts. Required for inline correctness, since offloads create
super-sized datagrams the inspection path drops.
'';
example = ["enp1s0f0" "enp1s0f1"];
};
nfqueue = {
queues = lib.mkOption {
type = lib.types.ints.positive;
default = 1;
description = "Number of NFQUEUE queues (Suricata runs `-q 0 .. -q N-1`); pair with `queue num 0-<N-1>` in nftables and one worker per queue.";
};
failOpen = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Suricata's `nfq.fail-open`. Lets the kernel accept packets when the
queue is full, which is the overloaded case, instead of dropping them.
This does not govern what happens when Suricata is not running. That
is the `bypass` flag on the nftables `queue` verdict, which
`othrys.services.router` sets unconditionally, so a dead IPS passes
traffic regardless of this option. Setting it to false does not make a
dead Suricata block the link.
Either way the failure mode is uninspected traffic rather than blocked
traffic, which is deliberate for a router in the forwarding path.
'';
};
};
afPacket = {
interface = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "enp1s0f0";
description = "Capture interface for af-packet mode.";
};
copyInterface = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "enp1s0f1";
description = "Peer interface for the af-packet IPS bridge (posture = ips).";
};
clusterId = lib.mkOption {
type = lib.types.ints.positive;
default = 99;
description = "af-packet cluster-id (must be unique per Suricata instance on the host).";
};
clusterType = lib.mkOption {
type = lib.types.enum ["cluster_flow" "cluster_cpu" "cluster_qm" "cluster_ebpf"];
default = "cluster_flow";
description = "af-packet cluster-type, which decides how packets are spread over the capture threads.";
};
};
dropRules = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["re:trojan" "2019401"];
description = ''
Rules that `suricata-update` turns from alert into drop, one
`drop.conf` line each: a signature id, or a `re:` regular expression
over the rule text. Only an IPS posture drops; in IDS they stay
alerts.
'';
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra suricata.yaml settings, deep-merged over (and overriding) the generated config, e.g. threading/affinity, outputs, mpm-algo.";
example = lib.literalExpression ''
{
mpm-algo = "hs";
threading.set-cpu-affinity = true;
}
'';
};
};
Usage
# Router (NFQUEUE), start in IDS and feed it from nftables (`… queue num 0-3`)
othrys.services.suricata = {
enable = true;
mode = "nfqueue"; # default
posture = "ids"; # alert-only until tuned
nfqueue.queues = 4;
offloadInterfaces = ["enp1s0f0" "enp1s0f1"];
enabledSources = ["et/open"];
};
# Transparent bridge IPS (AF_PACKET)
othrys.services.suricata = {
enable = true;
mode = "af-packet";
posture = "ips";
afPacket = { interface = "enp1s0f0"; copyInterface = "enp1s0f1"; };
offloadInterfaces = ["enp1s0f0" "enp1s0f1"];
};
Kea
Kea DHCPv4/DHCPv6, a thin wrapper over
services.kea with sane defaults (bound interfaces + a persistent memfile lease
database). Subnets, reservations, and options are identity and come from the
fleet through settings, which is deep-merged over the defaults.
Gotcha (Kea 2.6+): every subnet needs a unique mandatory
id.
The lease database is persisted at /var/lib/private/kea, where a
DynamicUser service keeps it. /var/lib/kea, which the default leasesFile
paths go through, is systemd’s symlink to it. A host that moves leasesFile
elsewhere persists that path itself.
Options
options.othrys.services.kea = {
enable = lib.mkEnableOption "Kea DHCP server";
dhcp4 = mkPool "4";
dhcp6 = mkPool "6";
};
Usage
othrys.services.kea = {
enable = true;
dhcp4 = {
interfaces = ["br-lan"];
settings.subnet4 = [{
id = 1;
subnet = "10.0.0.0/24";
pools = [{ pool = "10.0.0.100 - 10.0.0.240"; }];
option-data = [
{ name = "routers"; data = "10.0.0.1"; }
{ name = "domain-name-servers"; data = "10.0.0.1"; }
];
}];
};
};
Unbound
Unbound recursive DNS, a thin wrapper
over services.unbound with helpers for listen interfaces, per-subnet access
control, DNS-over-TLS upstream forwarding, and RPZ blocklists. Anything else
goes through settings (freeform unbound.conf), deep-merged over the generated
config.
Each rpz zone is given a zonefile in the state directory, so the fetched
blocklist is written to disk and loaded from there at the next start rather
than transferred again. The state directory, /var/lib/unbound by default,
holds those zonefiles and the root trust anchor and is persisted under
impermanence for the unbound account.
accessControl defaults to loopback plus the subnet of every address in
interfaces, a /24 for IPv4 and a /64 for IPv6, so a resolver bound to a LAN
address answers that LAN without a second option. Upstream’s own default
allows loopback alone. A wildcard address or an interface name derives
nothing, and a host that listens on one sets accessControl itself.
Every rpz source must use https://, and an assertion refuses any other
scheme, since the zone rewrites answers for every client of the resolver. A
non-empty rpz also sets server.module-config to
respip validator iterator, because Unbound serves a response policy zone
through the respip module and unbound-checkconf rejects the configuration
without it. The value is set with mkDefault, so a host’s own
module-config wins.
Options
options.othrys.services.unbound = {
enable = lib.mkEnableOption "Unbound recursive DNS";
interfaces = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["10.0.0.1" "127.0.0.1"];
description = "Addresses Unbound listens on (server.interface). Replaces upstream's loopback default, so list loopback when it should stay.";
};
accessControl = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = derivedAccessControl;
defaultText = lib.literalMD "loopback, then the /24 of each IPv4 address and the /64 of each IPv6 address in `interfaces`";
example = ["10.0.0.0/24 allow"];
description = ''
server.access-control entries (subnet + action). The default is
derived from `interfaces`, so a host that listens on `10.0.0.1`
answers `10.0.0.0/24` without further setup. A wildcard address or an
interface name in `interfaces` derives nothing, so a host using one
sets this itself.
'';
};
forwardTls = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Forward all queries to the DoT upstreams over TLS (port 853), instead of recursing.";
};
upstreams = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"1.1.1.1@853#cloudflare-dns.com"
"1.0.0.1@853#cloudflare-dns.com"
"9.9.9.9@853#dns.quad9.net"
];
description = "DoT upstream resolvers (addr@853#hostname).";
};
};
rpz = lib.mkOption {
type = lib.types.listOf rpzType;
default = [];
description = "RPZ blocklist zones (ad/malware blocking). Each `url` must use `https://`, and the respip module is added to server.module-config when the list is non-empty.";
example = lib.literalExpression ''
[{ name = "hagezi"; url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/rpz/pro.txt"; }]
'';
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra unbound.conf settings, deep-merged over (and overriding) the generated config.";
};
};
Usage
othrys.services.unbound = {
enable = true;
interfaces = ["10.0.0.1" "127.0.0.1"];
accessControl = ["10.0.0.0/24 allow"];
forwardTls.enable = true; # DoT to Cloudflare + Quad9 by default
rpz = [{
name = "hagezi";
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/rpz/pro.txt";
}];
};
Restic
Scheduled restic backups, one entry per named backup
(maps to services.restic.backups.<name>). Every credential-bearing field is a
runtime file path sourced from a secrets provider (e.g. sops), never an
inline value or a /nix/store path. Use passwordFile, repositoryFile,
environmentFile, and rcloneConfigFile. Use plain repository only for
non-sensitive locations (a local disk path). The value is written to the
unit file in the store, so an assertion refuses a repository URL that carries
a credential. That is user:password@ under any scheme, anything before the
@ of an http or https URL, where a lone token is a credential too, and a
query parameter named for a token, a key, a secret, a password or a signature.
An sftp://user@host URL names a login and no secret, and is accepted.
initialize is on by default and creates the repository on the first run when
none exists. Where several hosts share one repository, one host keeps it on
and the rest set initialize = false. Two first runs can otherwise both
initialise the repository, and a host pointed at the wrong location creates an
empty repository there instead of failing.
Options
options.othrys.services.restic = {
enable = lib.mkEnableOption "Restic backups";
backups = lib.mkOption {
type = lib.types.attrsOf backupType;
default = {};
description = "Named restic backups (maps to services.restic.backups.<name>).";
};
};
Usage
othrys.services.restic.enable = true;
othrys.services.restic.backups.headscale = {
paths = ["/var/lib/headscale"];
# Repository URL and password come from sops (runtime files, not the store):
repositoryFile = config.sops.secrets."backup/repo-url".path;
passwordFile = config.sops.secrets."backup/repo-password".path;
# Backend credentials (S3/B2/SFTP key, etc.):
environmentFile = config.sops.secrets."backup/env".path;
timerConfig = { OnCalendar = "daily"; RandomizedDelaySec = "1h"; Persistent = true; };
pruneOpts = ["--keep-daily 7" "--keep-weekly 4" "--keep-monthly 6"];
# Application-consistent snapshot (quiesce before, resume after):
backupPrepareCommand = "systemctl stop myservice";
backupCleanupCommand = "systemctl start myservice";
};
Secrets themselves are declared by the consuming fleet (via othrys.system.secrets
and sops), and this module only accepts the resulting file paths.
Integrity checking
runCheck is on by default, so every backup ends with restic check and a
damaged repository fails the backup unit. The default checkOpts is
--read-data-subset=5%, which reads a random twentieth of the pack data on
each run. That read is billed by remote backends, so set runCheck = false or
change checkOpts where it costs too much.
Plain restic check, which is what an empty checkOpts runs, verifies repository
structure, meaning index consistency and pack existence and size, but never reads
pack contents, so in-place bit corruption of backed-up data passes it
silently. Content verification requires --read-data, which downloads and
cryptographically verifies every pack. For repositories where a full read per
run is too expensive (remote backends, large repos), --read-data-subset
verifies a rotating fraction each run and still covers the whole repository
over time:
othrys.services.restic.backups.headscale = {
# ...
# Verify a random 10% of pack data on each run, at a tenth of the
# download cost of a full read:
checkOpts = ["--read-data-subset=10%"];
};
On a fast local repository, checkOpts = ["--read-data"] buys full content
verification on every run.
With Notify on, a failed unit is reported through
restic-notify-failure@, and the message says which part failed. A failed
check after a completed backup is reported as a failed repository check, which
means the new snapshot exists. Anything earlier is reported as a failed backup.
The module runs the check as a step of its own to tell the two apart, and that
step exits with status 90 when restic check fails.
Tailscale
The Tailscale client, wrapping services.tailscale, with a persisted state
directory under impermanence and the UDP port open by default so peers reach
the host directly. Two of upstream’s hooks carry the options.
baseURL is the control server, passed as --login-server to tailscale up
by the automatic registration that authKeyFile turns on. A host registered
by hand passes the same URL to tailscale up itself, and the module warns when
baseURL is set with no key file so that step is not forgotten. The key file
is a secrets-provider path holding a pre-auth key from the control server.
acceptRoutes, acceptDns, ssh and operator are passed to tailscale set
by a unit that runs on every host after the daemon is up, so they apply
however the host was registered. acceptRoutes is off by default, since
installing routes advertised by other nodes trusts those nodes with this
host’s traffic.
On a router host the module also opens its port on the WAN interface by name, since the router accepts the global firewall lists on every interface but the WAN.
On nix-darwin
darwinModules.default carries the module, and it runs tailscaled through
nix-darwin’s services.tailscale. nix-darwin has no unit that runs
tailscale up with a key or tailscale set after the daemon starts, so a
darwin host refuses authKeyFile, baseURL, ssh, acceptRoutes,
operator, ephemeral and acceptDns = false. tailscaled keeps the
settings in its state, so the host passes the matching flags to
tailscale up once by hand. The firewall nix-darwin manages takes no port
list, so openFirewall has nothing to open, and there is no impermanence
to persist the state through.
Options
options.othrys.services.tailscale = {
enable = lib.mkEnableOption "Tailscale VPN mesh networking";
authKeyFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
description = "Path to auth key file for automatic registration.";
};
baseURL = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Control server the node registers with, passed as `--login-server`
to `tailscale up` by the automatic registration, which `authKeyFile`
turns on. A host registered by hand passes the same URL to
`tailscale up` itself, and the module warns when this is set with no
key file so that is not forgotten.
'';
example = "https://headscale.example.com";
};
ssh = lib.mkEnableOption "Tailscale SSH server (note: bypasses OpenSSH hardening and fail2ban)";
acceptRoutes = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Pass --accept-routes: install subnet routes advertised by OTHER
tailnet nodes. A trust decision, since a compromised or misconfigured
peer can redirect this host's traffic, which is why it is off until a
host that needs advertised subnets turns it on.
'';
};
operator = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "alice";
description = ''
User allowed to drive `tailscale` without root, passed as
`--operator`. Null leaves the CLI to root.
'';
};
acceptDns = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Pass --accept-dns=true: let the tailnet control the host's DNS
configuration (MagicDNS). Set to false on hosts running their own
resolver (unbound, the router module) or needing split-horizon DNS, since
tailnet DNS would override it.
'';
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Open the Tailscale UDP port for direct (non-relayed) connections.";
};
ephemeral = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Register as an ephemeral node (deregistered when offline). Usually
false for persistent machines. Applies to a node on Tailscale's own
control plane, where it is a parameter of an OAuth client key; with
`baseURL` set, the pre-auth key minted on that server decides.
'';
};
};
Usage
othrys.services.tailscale = {
enable = true;
baseURL = "https://headscale.example.com";
authKeyFile = config.sops.secrets."tailscale/preauth".path;
acceptDns = false; # the host runs its own resolver
};
Mosh
othrys.services.mosh installs Mosh, the mobile shell,
which keeps a session open through sleep and a change of network. A client
logs in over SSH and starts mosh-server on the remote host, and the session
then runs over UDP. enable is the same on a server and on a client.
othrys.services.mosh.enable = true;
On NixOS the module turns on programs.mosh, and with openFirewall, which
is on by default, it opens UDP 60000 to 61000 in the NixOS firewall. That is
the range mosh-server picks its port from. The module turns on no SSH
server. The client reaches mosh-server through SSH, so a server host also
runs sshd, which othrys.services.ssh.server.enable provides.
A client host enables the same option to get the mosh command, and then
connects with mosh alice@host.example.com. A host that only connects out
sets openFirewall = false and keeps the UDP range closed.
On nix-darwin
darwinModules.default carries the module, and it puts mosh on the system
path. sshd runs mosh-server through the account’s shell with -c, a shell
that is neither a login nor interactive. zsh reads nix-darwin’s
/etc/zshenv even then, and that file puts the system profile on PATH, so
for an account whose shell is zsh nothing else runs on the Mac. A
non-interactive bash reads no such file, so a client reaching an account
with another shell passes
mosh --server=/run/current-system/sw/bin/mosh-server. The firewall
nix-darwin manages takes no port list, so openFirewall is unread there. A
host that turns on the macOS application firewall allows mosh-server
through it.
Options
options.othrys.services.mosh = {
enable = lib.mkEnableOption "Mosh server and client";
openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Open UDP 60000 to 61000, the range mosh-server picks its port from,
in the NixOS firewall. A host that only connects out to other hosts
turns it off. nix-darwin's firewall takes no port list, so it is
unread there.
'';
};
};
Headscale
Headscale is a self-hosted implementation of the
Tailscale control server, the coordination plane the Tailscale
module points its baseURL at. A thin wrapper over services.headscale with
helpers for the public URL, listen socket, MagicDNS and OIDC, while anything else
goes through settings (freeform config.yaml), deep-merged over the generated
config. The OIDC client secret is a runtime file path from a secrets
provider, never an inline value.
An optional web UI (Headplane) is bundled under ui.
Headplane was chosen over the static-SPA UIs (headscale-ui, headscale-admin) on
two axes: nixpkgs ships a native services.headplane module (no extra flake
input to carry), and it holds the Headscale API key, cookie secret, and OIDC
secret server-side as file paths, since the SPAs park a full-privilege API key in
browser localStorage. Enabling ui reuses this instance’s generated config,
port, and user automatically, so you supply only the listen socket and a couple of
secret paths. OIDC SSO is the recommended (server-side-custody) login mode,
without it Headplane falls back to its in-browser API-key login.
Options
options.othrys.services.headscale = {
enable = lib.mkEnableOption "Headscale self-hosted Tailscale control server";
serverUrl = lib.mkOption {
type = lib.types.str;
example = "https://headscale.example.com";
description = ''
Public URL clients register against (settings.server_url). Mandatory, with
no default.
Must resolve to this host (typically via a TLS-terminating reverse proxy)
and must differ from the MagicDNS `baseDomain`.
'';
};
address = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address Headscale listens on. Defaults to loopback, expecting a reverse proxy in front; set to 0.0.0.0 to expose it directly.";
};
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = "Port Headscale listens on.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts Headscale (the default).";
};
magicDns = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable MagicDNS (settings.dns.magic_dns).";
};
baseDomain = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "tailnet.example.com";
description = "MagicDNS base domain (settings.dns.base_domain), an FQDN without a trailing dot. Must differ from the `serverUrl` host. Null leaves it unset.";
};
nameservers = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["1.1.1.1" "9.9.9.9"];
description = "Global nameservers pushed to clients (settings.dns.nameservers.global).";
};
oidc = {
enable = lib.mkEnableOption "OIDC authentication for node registration";
issuer = lib.mkOption {
type = lib.types.str;
default = "";
example = "https://auth.example.com/realms/main";
description = "OIDC issuer URL (settings.oidc.issuer).";
};
clientId = lib.mkOption {
type = lib.types.str;
default = "";
example = "headscale";
description = "OIDC client ID (settings.oidc.client_id).";
};
clientSecretFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."headscale/oidc-secret".path'';
description = ''
Path to a runtime file holding the OIDC client secret (a
secrets-provider path). Never inline the secret. Headscale reads it
as its own user, so the file must be readable by `headscale`; with
sops-nix that is `owner = "headscale"` on the secret.
'';
};
allowedDomains = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["example.com"];
description = "Email domains whose accounts may register (settings.oidc.allowed_domains).";
};
allowedUsers = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["alice@example.com"];
description = "Accounts that may register (settings.oidc.allowed_users).";
};
allowedGroups = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["tailnet"];
description = ''
Groups whose members may register (settings.oidc.allowed_groups).
The issuer has to put a groups claim in the token for this to apply.
With none of the three lists set, every account the issuer knows
can register a node, and the module warns about it.
'';
};
};
policy = lib.mkOption {
type = lib.types.nullOr (lib.types.either lib.types.path (lib.types.attrsOf lib.types.anything));
default = null;
example = lib.literalExpression ''
{
acls = [
{
action = "accept";
src = ["group:admins"];
dst = ["*:*"];
}
];
groups."group:admins" = ["alice@example.com"];
}
'';
description = ''
The tailnet ACL policy (settings.policy), as a path to a HuJSON file
or as an attribute set written out as JSON. Null leaves Headscale on
its default, which lets every node reach every other node. The
policy is not a secret and lives in the store.
'';
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra config.yaml settings, deep-merged over (and overriding) the generated config.";
};
ui = {
enable = lib.mkEnableOption "Headplane web UI for this Headscale instance (server-side API-key custody, OIDC SSO)";
package = lib.mkOption {
type = lib.types.nullOr lib.types.package;
default = null;
defaultText = lib.literalExpression "pkgs.headplane";
description = "Headplane package override. Null uses pkgs.headplane (the nixpkgs default for services.headplane).";
};
host = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address Headplane listens on. Loopback by default, expecting a reverse proxy in front.";
};
port = lib.mkOption {
type = lib.types.port;
default = 3000;
description = "Port Headplane listens on.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open the UI `port` in the firewall. Leave off when a reverse proxy fronts Headplane (the default).";
};
apiKeyFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."headscale/headplane-apikey".path'';
description = ''
Path to a runtime file holding a Headscale API key (from
`headscale apikeys create`). Written to Headplane's
`headscale.api_key_path`, which it uses server-side to mint OIDC
sessions, so it is required when `ui.oidc` is enabled. Without it,
Headplane authenticates via its in-browser API-key login and this
is unused. Use a secrets-provider path readable by the `headscale`
user, which Headplane runs as.
'';
};
cookieSecretFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."headscale/headplane-cookie".path'';
description = "Path to a runtime file holding the cookie-signing secret (a random string). Required when the UI is enabled. Use a secrets-provider path readable by the `headscale` user.";
};
configPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
defaultText = lib.literalExpression "config.services.headscale.configFile";
description = "Path to the Headscale config.yaml Headplane reads. Null uses the NixOS-generated config file for this instance.";
};
oidc = {
enable = lib.mkEnableOption "OIDC SSO for Headplane admin login";
issuer = lib.mkOption {
type = lib.types.str;
default = "";
example = "https://auth.example.com/realms/main";
description = "OIDC issuer URL for Headplane login.";
};
clientId = lib.mkOption {
type = lib.types.str;
default = "";
example = "headplane";
description = "OIDC client ID for Headplane.";
};
clientSecretFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."headscale/headplane-oidc".path'';
description = "Path to a runtime file holding Headplane's OIDC client secret. Never inline the secret. Readable by the `headscale` user.";
};
disableApiKeyLogin = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Disable the fallback API-key login form once OIDC is configured, enforcing SSO-only admin access.";
};
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra Headplane settings, deep-merged over (and overriding) the generated config.";
};
};
};
Usage
othrys.services.headscale = {
enable = true;
serverUrl = "https://headscale.example.com"; # public URL, behind a TLS reverse proxy
baseDomain = "tailnet.example.com"; # MagicDNS suffix (must differ from serverUrl)
nameservers = ["1.1.1.1" "9.9.9.9"];
# Optional OIDC, client secret comes from sops (a runtime file, not the store):
oidc = {
enable = true;
issuer = "https://auth.example.com/realms/main";
clientId = "headscale";
clientSecretFile = config.sops.secrets."headscale/oidc-secret".path;
};
# Optional Headplane web UI (server-side secret custody, OIDC SSO):
ui = {
enable = true;
cookieSecretFile = config.sops.secrets."headscale/headplane-cookie".path;
apiKeyFile = config.sops.secrets."headscale/headplane-apikey".path; # `headscale apikeys create`
oidc = {
enable = true;
issuer = "https://auth.example.com/realms/main";
clientId = "headplane";
clientSecretFile = config.sops.secrets."headscale/headplane-oidc".path;
};
};
};
Put a TLS-terminating reverse proxy in front of both Headscale (serverUrl) and
Headplane (which listens on 127.0.0.1:3000 by default); behind a proxy set
ui.settings.server.base_url to Headplane’s public URL so OIDC redirects
resolve. A node then registers against this server through the Tailscale
module’s baseURL and authKeyFile, with a pre-auth key from
headscale preauthkeys create; see Tailscale.
With OIDC on and none of oidc.allowedDomains, allowedUsers or
allowedGroups set, every account the issuer knows can register a node, and
the module warns about it. Set at least one. policy is the tailnet ACL, as
a HuJSON file or an attribute set written out as JSON; without it every node
reaches every other node.
Headscale and Headplane both run as the headscale user, so every secret
file named above has to be readable by it, which with sops-nix is
owner = "headscale" on the secret. Headscale’s default port, 8080, is also
the default of Scrutiny’s web UI and of the CrowdSec local API, and
Headplane’s default, 3000, is the documentation server’s; the module refuses
each clash on the same host.
Printing
CUPS with the Gutenprint drivers, and optionally Avahi for printer discovery.
CUPS listens on localhost:631 unless listenAddresses names another
address, and openFirewall opens the TCP ports of those addresses. A print
server reached from other hosts also sets services.printing.allowFrom, which
the module leaves at upstream’s localhost.
Options
options.othrys.services.printing = {
enable = lib.mkEnableOption "CUPS printing service";
avahi = lib.mkEnableOption "Avahi for network printer discovery";
listenAddresses = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = ["localhost:631"];
example = ["*:631"];
description = ''
Addresses and ports CUPS listens on (services.printing.listenAddresses).
The default is loopback only. A print server reached from other
hosts lists an address here and also sets
`services.printing.allowFrom`, which stays at upstream's `localhost`.
'';
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open the TCP ports named in `listenAddresses` in the firewall (services.printing.openFirewall).";
};
};
Mounts
Non-system filesystem mounts, grouped under othrys.services.mounts.*.
Disks
Additional local disk mounts (NTFS, ext4, btrfs, xfs, vfat).
NTFS and vfat store no Unix owner, so both are mounted with uid, gid,
dmask and fmask from the device’s options. The defaults are uid 1000 and
gid 100, which is the first account on a NixOS host and the users group. The
two masks are octal strings of three or four digits, and anything else is a
type error. ext4, btrfs and xfs carry their own ownership and take none of the
four.
Every filesystem type is mounted with nosuid and nodev, since these are
data disks and a data disk is not where a setuid binary or a device node
belongs. A disk that does hold them, such as one carrying a container store or
a chroot, sets allowSuid or allowDev on its device.
othrys.services.mounts.disks.devices.containers = {
device = "/dev/disk/by-uuid/abcd1234-5678-90ab-cdef";
mountPoint = "/var/lib/containers";
fsType = "ext4";
allowSuid = true;
allowDev = true;
};
Options
options.othrys.services.mounts.disks = {
enable = lib.mkEnableOption "additional disk mounts";
devices = lib.mkOption {
type = lib.types.attrsOf diskType;
default = {};
description = "Disk mount configurations.";
example = lib.literalExpression ''
{
data = {
device = "/dev/disk/by-uuid/0123456789ABCDEF";
mountPoint = "/mnt/data";
fsType = "ntfs-3g";
};
backup = {
device = "/dev/disk/by-uuid/abcd1234-5678-90ab-cdef";
mountPoint = "/mnt/backup";
fsType = "ext4";
};
}
'';
};
};
CIFS
CIFS/SMB network share mounts. Credentials files are generated from sops templates containing username/password pairs.
The files of a share belong to the primary user and that user’s group on a
host with othrys.system.users.enable. The account’s uid is passed when the
host declares one, and its name otherwise, which mount.cifs resolves at mount
time. uid and gid on a share replace either, as a number or a name. A host
that manages no account has nothing to default to, and an assertion asks for
both there.
Every share is mounted with nosuid and nodev. Three options set what
crosses the network:
versdefaults to"3.1.1", which pins the newest SMB dialect so a server cannot negotiate the mount down. An older NAS needs the dialect it speaks, and"default"hands the choice back to the kernel.sealdefaults totrueand encrypts the session. Authentication protects the password only, and withoutsealfile contents travel in the clear. Encryption needs SMB 3.0 or newer, sosealwithversbelow"3.0"fails evaluation.sectakes one ofnone,krb5,krb5i,ntlmv2,ntlmv2i,ntlmsspandntlmsspi, and any other value is a type error.
Options
options.othrys.services.mounts.cifs = {
enable = lib.mkEnableOption "CIFS/SMB network share mounts";
shares = lib.mkOption {
type = lib.types.attrsOf shareType;
default = {};
description = "CIFS/SMB shares to mount, keyed by mount name.";
};
};
Monitoring
A Prometheus server and a node exporter on one host. The exporter runs a
curated set of collectors covering systemd units, processes, CPU, memory,
disks, filesystems and the network, and extraCollectors adds to that set.
Prometheus scrapes the exporter under the job name node-exporter and itself
under prometheus, each labelled with the host name as instance.
Both listeners bind listenAddress, which is loopback by default, and the
scrape targets follow it when it names one interface. openFirewall opens
both ports for a Grafana that runs on another host. On an impermanence host
the TSDB under /var/lib is persisted, since retentionTime describes a
window a wiped root would otherwise empty at every boot.
Options
options.othrys.services.monitoring = {
enable = lib.mkEnableOption "Prometheus monitoring";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address Prometheus and the node exporter bind to.";
};
port = lib.mkOption {
type = lib.types.port;
default = 9090;
description = "Prometheus server port.";
};
nodePort = lib.mkOption {
type = lib.types.port;
default = 9100;
description = "Node exporter port.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open firewall ports for external Grafana access.";
};
retentionTime = lib.mkOption {
type = lib.types.str;
default = "15d";
example = "90d";
description = "Prometheus metric retention (dedicated monitoring hosts usually want more than the 15d default).";
};
extraCollectors = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["ethtool" "smartctl"];
description = "Node-exporter collectors enabled in addition to the curated base set.";
};
};
Usage
othrys.services.monitoring = {
enable = true;
retentionTime = "90d";
extraCollectors = ["ethtool"];
};
VictoriaMetrics
VictoriaMetrics is a fast, resource-efficient
time-series database with a Prometheus-compatible API (scrape, remote-write,
MetricsQL). A thin wrapper over services.victoriametrics: loopback by default
(reverse proxy in front), retention exposed as policy, and an optional scrape
of the node exporter the Monitoring module runs, so enabling both
wires them together automatically.
The stores, Grafana, alerting and the journal upload all run on one host and
find each other through listenAddress. A store moved to one interface is
scraped and queried at that address, while a store on every interface
(0.0.0.0 or ::) is reached over loopback, so the scrape targets and
datasources follow the listener wherever it is bound. The node exporter is
scraped under the job name node-exporter, which is the job label the
starter alert rules and any dashboard see.
Options
options.othrys.services.victoriametrics = {
enable = lib.mkEnableOption "VictoriaMetrics single-node time-series database (Prometheus-compatible)";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address VictoriaMetrics listens on. Loopback by default, expecting a reverse proxy in front; set to 0.0.0.0 to expose it directly.";
};
port = lib.mkOption {
type = lib.types.port;
default = 8428;
description = "Port VictoriaMetrics listens on (HTTP API: scrape, remote-write, query).";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts VictoriaMetrics (the default).";
};
retentionPeriod = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "1y";
description = "How long to retain samples (suffixes s/h/d/w/y, a bare number is months). Null uses the upstream default (1 month), and long-term storage hosts usually want more.";
};
scrapeNodeExporter = lib.mkOption {
type = lib.types.bool;
default = monitoringCfg.enable;
defaultText = lib.literalExpression "config.othrys.services.monitoring.enable";
description = "Scrape the local node exporter (at othrys.services.monitoring.nodePort). Follows the monitoring module by default so enabling both wires them together.";
};
scrapeConfigs = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [];
example = lib.literalExpression ''
[
{
job_name = "headscale";
static_configs = [{targets = ["127.0.0.1:9090"];}];
}
]
'';
description = "Additional Prometheus-style scrape configs appended to the generated set.";
};
extraFlags = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["-dedup.minScrapeInterval=15s"];
description = "Extra command-line flags passed to VictoriaMetrics.";
};
};
Usage
othrys.services.victoriametrics = {
enable = true;
retentionPeriod = "1y";
scrapeConfigs = [
{
job_name = "headscale";
static_configs = [{targets = ["127.0.0.1:9090"];}];
}
];
};
VictoriaLogs
VictoriaLogs is the log
database from the VictoriaMetrics family (LogsQL queries, minimal footprint).
The host’s systemd journal ships to it natively via systemd-journal-upload
with no extra agent.
The log store is persisted at /var/lib/private/victorialogs, where a
DynamicUser service keeps it. The uploader’s cursor is persisted beside it
at /var/lib/private/systemd/journal-upload when collectJournal is on.
The journal itself survives a reboot, so a lost cursor would have the
uploader send every entry a second time.
Options
options.othrys.services.victorialogs = {
enable = lib.mkEnableOption "VictoriaLogs log database (LogsQL, journald ingestion)";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address VictoriaLogs listens on. Loopback by default, expecting a reverse proxy in front.";
};
port = lib.mkOption {
type = lib.types.port;
default = 9428;
description = "Port VictoriaLogs listens on (HTTP API: ingestion and LogsQL queries).";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts VictoriaLogs (the default).";
};
retentionPeriod = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "12w";
description = "How long to retain logs (suffixes: h/d/w/y; a bare number is months). Null uses the upstream default (7 days).";
};
collectJournal = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Ship this host's systemd journal into VictoriaLogs via systemd-journal-upload.";
};
extraFlags = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "Extra command-line flags passed to VictoriaLogs.";
};
};
Grafana
Dashboards over the othrys stores. Datasources are auto-provisioned from whichever stores are enabled on the same host (Monitoring’s Prometheus, VictoriaMetrics, and VictoriaLogs, the last with its datasource plugin installed, since that type is not built into Grafana). Enabling Grafana beside any of them wires them together with zero configuration.
Two secrets arrive as runtime file paths, both readable by the grafana
user, which with sops-nix is owner = "grafana" on each. secretKeyFile is required, since Grafana encrypts stored credentials
with it and upstream ships no default. adminPasswordFile is read on first
start only, after which the hash lives in the database. Without it Grafana
serves the stock admin/admin credential, which the module warns about on
a loopback listener and refuses once the listener leaves loopback or
openFirewall is on.
A host that exposes Grafana, by setting listenAddress off loopback, must
also set rootUrl to the public URL, as https://grafana.example.com/.
Grafana builds redirects and OIDC callbacks from it, and the secure flag on
the session cookie follows its scheme, so an https:// URL marks the cookie
secure and a plain http:// one leaves it off. Sign-up from the login page
is off on every host.
Options
options.othrys.services.grafana = {
enable = lib.mkEnableOption "Grafana dashboards (datasources auto-provisioned from enabled othrys metrics stores)";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address Grafana listens on. Loopback by default, expecting a reverse proxy in front.";
};
port = lib.mkOption {
type = lib.types.port;
default = 3001;
description = "Port Grafana listens on (3001, since the docs server claims 3000 by default).";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts Grafana (the default).";
};
rootUrl = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "https://grafana.example.com/";
description = "Public URL Grafana is reached at, written to `server.root_url`. Redirects, OIDC callbacks and the secure flag on the session cookie follow it, so it must be set when `listenAddress` is not loopback. Null keeps Grafana's default, which names localhost.";
};
adminPasswordFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."grafana/admin-password".path'';
description = ''
Path to a runtime file holding the admin password (a secrets-provider
path). Grafana reads it as the `grafana` user, so with sops-nix set
`owner = "grafana"` on the secret. The value is applied when the
database is first created and ignored afterwards, and the password of
an existing instance changes with
`grafana cli admin reset-admin-password`. Null keeps the stock
admin/admin credential, which the module warns about on loopback and
refuses when `listenAddress` is not loopback or `openFirewall` is on.
'';
};
secretKeyFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
defaultText = lib.literalMD "none, and an assertion rejects an unset value once the module is enabled";
example = lib.literalExpression ''config.sops.secrets."grafana/secret-key".path'';
description = ''
Path to a runtime file holding Grafana's secret_key (encrypts stored
credentials, so generate a random string). Must be set when this
module is enabled, since upstream no longer ships a default. Use a
secrets-provider path, readable by the `grafana` user, which with
sops-nix is `owner = "grafana"` on the secret.
'';
};
extraDatasources = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [];
description = "Datasources provisioned in addition to the auto-detected othrys metrics stores.";
};
dashboardsDir = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = "Directory of dashboard JSON files to provision (fleet-provided).";
};
};
Scrutiny
Scrutiny keeps every S.M.A.R.T.
reading in InfluxDB and judges disks against observed failure rates, which is
how a slowly dying disk shows months before smartd alarms. The module has a
hub-and-spoke shape: a hub (enable) runs the web UI, InfluxDB and a
collector for its own disks; a satellite runs collector.enable with
collector.endpoint pointing at the hub.
The hub’s web UI and collector API have no authentication of their own:
anyone who reaches the port reads every disk and can post readings. The hub
listens on loopback by default, and the module warns when it is moved off
loopback or its port is opened. Its default port, 8080, is also the CrowdSec
local API’s and Headscale’s, and the module refuses that clash on one host.
Failures of the collector are routed to notify-failure@ when notify is on.
collector.endpoint is written to the collector’s unit and configuration in
the store, so a URL with a user, a password or a token ahead of the host fails
an assertion. Upstream types the endpoint as a plain string and has no file
form for it. A satellite whose hub sits behind a proxy that asks for
credentials sets collector.environmentFile to a secrets-provider file with
the line COLLECTOR_API_ENDPOINT=https://user:password@scrutiny.example.com,
which replaces endpoint when the collector runs.
othrys.services.scrutiny.collector = {
enable = true;
endpoint = "https://scrutiny.example.com";
environmentFile = config.sops.secrets."scrutiny/collector-env".path;
};
The state directory is persisted at /var/lib/private/scrutiny, where a
DynamicUser service keeps it.
Options
options.othrys.services.scrutiny = {
enable = lib.mkEnableOption "the Scrutiny hub: web UI + InfluxDB, and a collector for this host's own disks";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address the web UI listens on. Loopback by default, expecting a reverse proxy in front; satellites then report in through the proxied URL.";
};
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = "Port the web UI (and collector API) listens on.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts the web UI (the default).";
};
notifyUrls = lib.mkOption {
type = lib.types.listOf lib.types.str;
default =
lib.optional (notifyCfg.enable && notifyCfg.url != null && notifyCfg.tokenFile == null && !config.othrys.internal.notifyRefusedLocally)
(ntfyShoutrrr notifyCfg.url notifyCfg.topic);
defaultText = lib.literalExpression "the othrys.services.notify endpoint as a shoutrrr ntfy URL, when notify is enabled, unauthenticated and not refused by the ntfy server on this host; else []";
example = ["ntfy://ntfy.example.com/alerts"];
description = "shoutrrr URLs Scrutiny pushes device-failure notifications to. Follows the fleet notify channel by default. A token-authenticated notify endpoint is NOT auto-wired (the token would end up world-readable in the rendered config). Pass an explicit URL instead. Nothing is wired either when notify points at the ntfy server on this host with no token while that server denies anonymous clients, since every push would be refused.";
};
collector = {
enable = lib.mkOption {
type = lib.types.bool;
default = cfg.enable;
defaultText = lib.literalExpression "config.othrys.services.scrutiny.enable";
description = "Run the smartctl collector on this host. Follows `enable` (a hub watches its own disks); set alone on satellite hosts, with `endpoint`.";
};
endpoint = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "https://scrutiny.example.com";
description = ''
Scrutiny API base URL the collector reports to. Null means the local
web UI, which suits a hub, and a satellite must set it. The value
is written to the collector's unit and configuration in the store,
so a URL with a user, password or token before the host is refused.
A hub behind a proxy that asks for credentials is reached through
`environmentFile`.
'';
};
environmentFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."scrutiny/collector-env".path'';
description = ''
Environment file read by the collector unit, a secrets-provider
path. A line `COLLECTOR_API_ENDPOINT=https://user:password@scrutiny.example.com`
in it replaces `endpoint` at run time, which is how the collector
authenticates to a hub behind a proxy without the credentials
entering the store. Upstream types the endpoint as a plain string
and has no file form for it.
'';
};
schedule = lib.mkOption {
type = lib.types.str;
default = "daily";
description = "systemd calendar expression for collector runs. Daily is enough, since smartd covers the fast alarms and this feeds the trend history.";
};
hostId = lib.mkOption {
type = lib.types.str;
default = config.networking.hostName;
defaultText = lib.literalExpression "config.networking.hostName";
description = "Label the web UI groups this host's disks under.";
};
};
};
Alerting
Rule evaluation via vmalert, datasource-agnostic (any Prometheus-compatible API, with the local VictoriaMetrics or Prometheus auto-discovered). Delivery flows to Notify through an internal alertmanager → alertmanager-ntfy chain (loopback implementation details, while the consumer surface is rules in, phone notifications out). Ships curated starter rules (instance down, disk space, memory pressure) that can be disabled or extended.
The internal chain’s alertmanager keeps its silences and notification log at
/var/lib/private/alertmanager, where a DynamicUser service keeps it, and
the module persists that directory under impermanence. A host that names its
own notifierUrls runs no alertmanager and persists nothing here.
The rendered rule file is parsed with vmalert -dryRun while the system is
built, so a rule group, an expression or an annotation template that does not
parse fails the build instead of stopping the unit on the host. No datasource
is contacted. checkRules = false turns the check off.
Options
options.othrys.services.alerting = {
enable = lib.mkEnableOption "alert rule evaluation (vmalert) with ntfy delivery";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address vmalert's HTTP interface listens on.";
};
port = lib.mkOption {
type = lib.types.port;
default = 8880;
description = "Port vmalert's HTTP interface listens on.";
};
datasourceUrl = lib.mkOption {
type = lib.types.nullOr lib.types.str;
# The store runs on this host, so the URL is its listener seen from here
# (modules/lib/net.nix). 0.0.0.0 is a bind address and not a destination.
default =
if vmCfg.enable
then "http://${local vmCfg.listenAddress}:${toString vmCfg.port}"
else if monitoringCfg.enable
then "http://${local monitoringCfg.listenAddress}:${toString monitoringCfg.port}"
else null;
defaultText = lib.literalExpression "the local VictoriaMetrics instance when enabled, else the local Prometheus, else null";
description = "Prometheus-compatible datasource rules are evaluated against. Auto-discovered from the enabled othrys metrics store.";
};
notifierUrls = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["http://127.0.0.1:9093"];
description = "Alertmanager endpoints alerts are sent to. Empty with othrys.services.notify enabled runs the internal alertmanager -> ntfy delivery chain.";
};
starterRules = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Include the curated starter rules (instance down, disk space, memory pressure).";
};
ruleGroups = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [];
description = "Additional Prometheus-style rule groups appended to the starter set.";
};
checkRules = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Parse the rendered rule file with `vmalert -dryRun` at build time, so
a rule that does not parse fails the build instead of the service.
Set to `false` where vmalert cannot run on the build host.
'';
};
};
Ntfy
Self-hosted ntfy push-notification server, the implementation-named server half of the notification pair, related to Notify the way Headscale relates to Tailscale.
Anonymous clients are denied by default (defaultAccess = "deny-all").
ntfy’s own default is read-write, which lets anyone who reaches the port
publish to and read every topic, the alert topic included. Access comes from
users (name, bcrypt hash from ntfy user hash, role), access (user,
topic, permission) and tokensFile, an environment file from the secrets
provider holding NTFY_AUTH_TOKENS=user:tk_token:label. A publisher then
sets othrys.services.notify.tokenFile to a file holding its token. The
same can be done on the host with ntfy user, ntfy access and
ntfy token, which write the auth database the module persists.
othrys.services.ntfy = {
enable = true;
users = ["fleet:$2a$10$...:user"];
access = ["fleet:alerts:write-only"];
tokensFile = config.sops.secrets."ntfy/tokens".path;
};
The state directory is persisted at /var/lib/private/ntfy-sh, which is
where a DynamicUser service keeps it; /var/lib/ntfy-sh is systemd’s
symlink to it.
Options
options.othrys.services.ntfy = {
enable = lib.mkEnableOption "self-hosted ntfy push-notification server";
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address ntfy listens on. Loopback by default, expecting a reverse proxy in front; set to 0.0.0.0 to expose it directly.";
};
port = lib.mkOption {
type = lib.types.port;
default = 2586;
description = "Port ntfy listens on.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open `port` in the firewall. Leave off when a reverse proxy fronts ntfy (the default).";
};
baseUrl = lib.mkOption {
type = lib.types.str;
default = "http://${cfg.listenAddress}:${toString cfg.port}";
defaultText = lib.literalExpression ''"http://''${listenAddress}:''${port}"'';
example = "https://ntfy.example.com";
description = "Base URL (upstream requires it; used for attachments and web-app links). The loopback default serves internal notify hosts. Set the public URL when a reverse proxy fronts it.";
};
defaultAccess = lib.mkOption {
type = lib.types.enum ["deny-all" "read-only" "write-only" "read-write"];
default = "deny-all";
description = ''
What a client with no credentials may do on any topic
(`auth-default-access`). ntfy's own default is `read-write`, which
lets anyone who reaches the port publish to and read every topic,
the alert topic included. Access is granted through `users`,
`access` and `tokensFile`, or through `ntfy user` and `ntfy access`
on the host.
'';
};
users = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["alice:$2a$10$examplehash:user" "fleet:$2a$10$otherhash:user"];
description = ''
Accounts to provision, one `name:bcrypt-hash:role` entry each
(`auth-users`). The hash comes from `ntfy user hash`, and the role is
`user` or `admin`. A hash is not a password, so it may sit in the
store; the password itself never goes here.
'';
};
access = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["fleet:alerts:write-only" "alice:*:read-write"];
description = "Access rules, one `user:topic:permission` entry each (`auth-access`), where the user is a name from `users` or `*` for anonymous clients.";
};
tokensFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."ntfy/tokens".path'';
description = ''
Environment file holding `NTFY_AUTH_TOKENS=user:tk_token:label,...`,
which provisions access tokens for the accounts in `users`. A token
is a credential, so it comes from a secrets provider and never from
the store. The publishers then set `othrys.services.notify.tokenFile`
to a file holding their token.
'';
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra services.ntfy-sh settings (server.yml), deep-merged over (and overriding) the generated config.";
};
};
Notify
Host notification dispatch: the othrys-notify CLI and a
notify-failure@.service template that modules hook via onFailure, so
failing backups, SMART warnings, and UPS events reach a phone instead of
dying in the journal. Points at the local Ntfy server automatically
when both are enabled, at whatever address that server binds.
With tokenFile set, othrys-notify sends nothing unless it can read the
token, and it exits naming the file instead of posting unauthenticated. The
token travels as a bearer header, so the module warns when url is plain
http:// and not on this host, since every notification then carries the
token across the network in clear. Use https:// for a remote server.
The local Ntfy server denies clients without credentials by default,
so a notify that points at it with tokenFile unset delivers nothing. The
module warns in that case. Either set tokenFile to a token provisioned
through othrys.services.ntfy.tokensFile, or give anonymous clients the topic
with an othrys.services.ntfy.access entry such as "*:alerts:write-only".
Scrutiny leaves the notify URL out of its own configuration while
the warning stands.
Options
options.othrys.services.notify = {
enable = lib.mkEnableOption "host notification dispatch (othrys-notify + systemd failure hooks)";
url = lib.mkOption {
type = lib.types.nullOr lib.types.str;
# The local server is reached at its listener as seen from this host
# (modules/lib/net.nix), so an ntfy moved to one interface still works.
default =
if ntfyCfg.enable
then "http://${local ntfyCfg.listenAddress}:${toString ntfyCfg.port}"
else null;
defaultText = lib.literalExpression "the local othrys.services.ntfy instance when enabled, else null";
example = "https://ntfy.example.com";
description = "ntfy endpoint notifications are published to. Follows the local ntfy server by default; point it at a fleet-central instance otherwise.";
};
topic = lib.mkOption {
type = lib.types.str;
default = "alerts";
description = "ntfy topic notifications are published to (on public instances the topic is effectively a password, so use tokenFile or a private server).";
};
tokenFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."notify/token".path'';
description = "Path to a runtime file holding an ntfy access token (a secrets-provider path). Null sends unauthenticated.";
};
};
WireGuard
Raw WireGuard interfaces for site-to-site links and exit nodes, the
coordination-server-free complement to Tailscale. Private keys
are secrets-provider paths, and per-interface openFirewall opens the listen
port.
mtu, fwMark and table are passed to the upstream interface, and each
peer takes an optional presharedKeyFile. A peer whose allowedIPs covers
the default route needs the last two together. table moves the tunnel’s
routes out of main, and fwMark lets an ip rule send everything except
the tunnel’s own encrypted packets to that table. allowedIPsAsRoutes is on
by default and adds a route for every peer’s allowedIPs. An interface whose
routes come from a routing daemon or from the host’s own rules sets it to
false, and allowedIPs then only says which sources a peer may send from.
othrys.services.wireguard.interfaces.wg0 = {
privateKeyFile = config.sops.secrets."wireguard/wg0".path;
ips = ["10.100.0.2/24"];
mtu = 1380;
fwMark = "0x6e6978";
table = "51820";
peers = [{
publicKey = "<peer public key>";
allowedIPs = ["0.0.0.0/0"];
endpoint = "vpn.example.com:51820";
presharedKeyFile = config.sops.secrets."wireguard/wg0-psk".path;
}];
};
Options
options.othrys.services.wireguard = {
enable = lib.mkEnableOption "raw WireGuard interfaces (coordination-server-free VPN links)";
interfaces = lib.mkOption {
default = {};
description = "WireGuard interfaces (maps to networking.wireguard.interfaces).";
example = lib.literalExpression ''
{
wg0 = {
privateKeyFile = config.sops.secrets."wireguard/wg0".path;
ips = ["10.100.0.2/24"];
listenPort = 51820;
openFirewall = true;
peers = [
{
publicKey = "<peer public key>";
allowedIPs = ["10.100.0.0/24"];
endpoint = "vpn.example.com:51820";
persistentKeepalive = 25;
}
];
};
}
'';
type = lib.types.attrsOf (lib.types.submodule {
options = {
privateKeyFile = lib.mkOption {
type = othrysTypes.secretPath;
description = "Path to a runtime file holding the interface private key (a secrets-provider path).";
};
ips = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Addresses (CIDR) assigned to the interface.";
};
listenPort = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = null;
description = "UDP listen port. Null picks a random port (fine for outbound-only peers).";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open listenPort in the firewall (requires listenPort).";
};
mtu = lib.mkOption {
type = lib.types.nullOr lib.types.ints.positive;
default = null;
example = 1280;
description = "MTU of the interface in bytes. Null leaves the WireGuard default of 1420, which is too large where the path underneath carries less than 1500.";
};
fwMark = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "0x6e6978";
description = "Firewall mark set on the encrypted packets this interface sends. Policy routing uses it to keep the tunnel's own packets out of the tunnel when `allowedIPs` covers the default route.";
};
table = lib.mkOption {
type = lib.types.str;
default = "main";
example = "51820";
description = "Routing table the routes for `allowedIPs` are added to, by name or number. Anything but `main` leaves the default route alone until an `ip rule` selects the table.";
};
allowedIPsAsRoutes = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Add a route for every peer's `allowedIPs` to `table`. Set to
`false` where the routes are managed elsewhere, by a routing
daemon or by the host's own rules, and `allowedIPs` should only
say which sources a peer may send from.
'';
};
peers = lib.mkOption {
default = [];
description = "Peers for this interface.";
type = lib.types.listOf (lib.types.submodule {
options = {
publicKey = lib.mkOption {
type = lib.types.str;
description = "Peer public key.";
};
allowedIPs = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Networks routed to (and accepted from) this peer.";
};
endpoint = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "vpn.example.com:51820";
description = "Peer endpoint. Null for peers that dial in.";
};
persistentKeepalive = lib.mkOption {
type = lib.types.nullOr lib.types.ints.positive;
default = null;
example = 25;
description = "Keepalive interval in seconds (needed behind NAT).";
};
presharedKeyFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = lib.literalExpression ''config.sops.secrets."wireguard/wg0-psk".path'';
description = "Path to a runtime file holding the preshared key for this peer, from `wg genpsk` (a secrets-provider path). Both ends must hold the same key.";
};
};
});
};
};
});
};
};
Traefik
Traefik as the edge reverse proxy, a wrapper over
services.traefik. The module builds the static configuration for the web
and websecure entrypoints, the HTTPS redirect and a DNS-01 ACME resolver.
Routers, services and further middlewares go through dynamicConfigOptions,
which is merged on top of what the module generates.
Two sets of defaults apply to every router behind websecure.
The default TLS options set minVersion = "VersionTLS12", since Traefik itself
still admits TLS 1.0 and 1.1. With ACME on they also set sniStrict, so a
connection whose server name matches no certificate is refused instead of being
answered with the self-signed default certificate. A request to the bare IP
address is refused for the same reason.
A headers middleware named othrys-security-headers is attached at the
entrypoint. It sends Strict-Transport-Security for one year, without
subdomains or preload, X-Content-Type-Options: nosniff, and
X-Frame-Options: SAMEORIGIN. The frame header breaks a dashboard that another
host name embeds in an iframe. Give that router its own headers middleware, or
change securityHeaders.frameOptions.
openFirewall opens 80 and 443 and nothing else. The API and dashboard port,
8080, stays closed even with dashboard.insecure, because that listener
carries no authentication. A host that wants it reachable opens the port in
its own firewall configuration. Scrutiny, Headscale and the CrowdSec local API
default to 8080 as well, and the module refuses dashboard.insecure beside any
of them on that port.
acme.storage has to sit under dataDir, which is the directory the module
persists under impermanence, and an assertion refuses any other path. An
acme.json lost at reboot means every certificate is ordered again until the
CA rate limit refuses the host. acme.caServer sets the ACME directory of the
resolver, which is where the Let’s Encrypt staging URL goes while a host is
being brought up.
othrys.services.traefik.acme.caServer =
"https://acme-staging-v02.api.letsencrypt.org/directory";
Public deployment
A host exposed to the internet has more to set than the module’s defaults cover. Each item below states what the module writes and what is left to the host.
- Dashboard.
dashboard.enableis off by default. On, it enables the Traefik API and dashboard and creates no router for them, so the host defines a router toapi@internalindynamicConfigOptions, on an entrypoint and host name of its choosing and behind an authentication middleware.dashboard.insecureserves the dashboard on:8080with no authentication. The module never opens that port in the firewall, and a public host leaves the option off, so the dashboard is never on a public entrypoint without authentication. - Forwarded headers.
forwardedHeaders.trustedIPsis empty by default, so Traefik discards theX-Forwarded-*headers of every request and the client address it logs and passes on is the peer’s. That is right for a host that faces the internet directly. Behind a CDN or a load balancer the list holds that proxy’s ranges and nothing wider, because a listed peer can state any client address. The option writes the list to both entrypoints. - Log level.
logLevelsetslog.levelfor Traefik’s own log and is null by default, which leaves Traefik atERROR. A host being brought up usually wants"INFO"or"DEBUG"until its routers and certificates work. - Access log. The module writes no
accessLog, and Traefik then logs no requests. A host that wants them setsstaticConfigOptions.accessLog.othrys.services.security.crowdsecturns the log on in JSON when both modules are enabled, because its Traefik parser reads those lines from the journal. - TLS floor and ciphers.
tls.minVersionis"VersionTLS12". The module sets nocipherSuites, so TLS 1.2 connections negotiate from Traefik’s own list. A host narrows it throughdynamicConfigOptions.tls.options.default.cipherSuites, or setstls.minVersion = "VersionTLS13", where the suites are fixed by the protocol. - Certificate matching.
tls.sniStrictfollowsacme.enable. A public host with certificates from another source sets it totrueitself. - Rate limiting. The module defines no
rateLimitorinFlightReqmiddleware and attaches none. A host declares them indynamicConfigOptions.http.middlewaresand names them on each public router. - Headers.
othrys-security-headerscarries HSTS,nosniffand the frame option and nothing else. A content security policy or a referrer policy belongs to each application and goes in that router’s own middleware. - ACME.
acme.caServerpoints the resolver at the Let’s Encrypt staging directory during bring-up, as shown above, since production rate-limits failed orders. With the option unset the resolver uses the production directory. - Firewall.
openFirewallis on by default and opens 80 and 443 on every interface.
othrys.services.traefik = {
enable = true;
acme = {
enable = true;
email = "admin@example.com";
dnsProvider = "cloudflare";
};
environmentFiles = [config.sops.secrets."traefik/env".path];
# Only behind a proxy, and only that proxy's ranges.
forwardedHeaders.trustedIPs = ["192.0.2.0/24"];
logLevel = "INFO";
staticConfigOptions.accessLog.format = "json";
dynamicConfigOptions = {
tls.options.default.cipherSuites = [
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305"
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
];
# A router names this one as `public-rate-limit@file`.
http.middlewares.public-rate-limit.rateLimit = {
average = 100;
burst = 200;
};
};
};
TCP routers
tcpRouters puts a TCP service behind Traefik and routes it by the TLS server
name the client sends. Each entry writes an entrypoint, a router and a service
under its own name, and a servers transport as well when proxyProtocol is
set. The entrypoint is named after the entry unless entryPoint.name says
otherwise, and its port is opened when the entry’s openFirewall is on, which
follows the module’s own openFirewall.
othrys.services.traefik.tcpRouters.soju = {
entryPoint.address = ":6697";
domain = "irc.example.com";
backend = "[::1]:6667";
proxyProtocol = 2;
};
Every entry has an entrypoint of its own, so the module refuses two entries on
one port or with one entrypoint name. It also refuses the entrypoint names
web, websecure and traefik, ports 80 and 443, and port 8080 while the
insecure dashboard is on and the host has not moved the traefik entrypoint.
The rule is a strict HostSNI(`<domain>`). A client that sends no server
name matches nothing, and Traefik closes the TCP connection before any
handshake, with no TLS alert. The wildcard rule HostSNI(`*`) does not
help such a client. Under tls.sniStrict it is refused all the same, and with
sniStrict off it is answered with Traefik’s self-signed default certificate.
Serving the ACME certificate as the default takes defaultGeneratedCert, which
changes the default certificate for every HTTPS router too.
A router terminates TLS by default, with the certificate the ACME resolver
issues, and the module refuses a terminating router while acme.enable is off.
It uses the default TLS options, so tls.sniStrict and tls.minVersion apply
to it as they do to the HTTPS routers. The router names its domain in
tls.domains, and that list decides what the resolver requests.
passthrough = true forwards the TLS stream unopened to a backend that
terminates TLS itself. Traefik reads only the server name from the client’s
hello, and the router needs no ACME.
proxyProtocol sends a PROXY protocol header, so the backend sees the client’s
address and not Traefik’s. The header goes on a servers transport named after
the entry, since loadBalancer.proxyProtocol has been deprecated since Traefik
3.5.2. A backend has to trust the header from Traefik’s address alone, because
a peer it trusts can state any client address. soju is the worked
example.
Switches
Each default has its own switch.
othrys.services.traefik = {
tls.minVersion = null; # Traefik's own default
tls.sniStrict = false;
securityHeaders.hstsSeconds = 0; # no HSTS header
securityHeaders.contentTypeNosniff = false;
securityHeaders.frameOptions = null; # no X-Frame-Options header
securityHeaders.enable = false; # attach no middleware at all
};
Options
options.othrys.services.traefik = {
enable = lib.mkEnableOption "Traefik reverse proxy";
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/traefik";
description = "Persistent data directory (holds acme.json).";
};
group = lib.mkOption {
type = lib.types.str;
default = "traefik";
description = "Group Traefik runs under (set to \"docker\" for the Docker provider).";
};
httpsRedirect = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Redirect the web (:80) entrypoint to websecure (:443).";
};
dashboard = {
enable = lib.mkEnableOption "the Traefik dashboard/API";
insecure = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Expose the dashboard on :8080 without auth. Convenient but unsafe, so prefer a secured router. The firewall port stays closed whatever openFirewall says.";
};
};
acme = {
enable = lib.mkEnableOption "automatic TLS via Let's Encrypt (DNS-01)";
email = lib.mkOption {
type = lib.types.str;
default = "";
description = "Contact email for the ACME account.";
};
dnsProvider = lib.mkOption {
type = lib.types.str;
default = "";
example = "cloudflare";
description = "lego DNS provider name. Its credentials are supplied via environmentFiles.";
};
resolver = lib.mkOption {
type = lib.types.str;
default = "letsencrypt";
description = "Name of the certificate resolver referenced by routers.";
};
dnsResolvers = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["1.1.1.1:53" "8.8.8.8:53"];
description = "DNS servers used to check record propagation.";
};
storage = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = "Path to acme.json. Defaults to <dataDir>/acme.json, and must stay under dataDir, which is the directory persisted under impermanence.";
};
caServer = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "https://acme-staging-v02.api.letsencrypt.org/directory";
description = ''
ACME directory URL written to the certificate resolver. Null leaves
Traefik on the Let's Encrypt production directory. Point it at the
staging directory while bringing a host up, since production
rate-limits failed orders.
'';
};
};
tls = {
minVersion = lib.mkOption {
type = lib.types.nullOr (lib.types.enum ["VersionTLS12" "VersionTLS13"]);
default = "VersionTLS12";
description = ''
Lowest TLS version the default TLS options accept. Traefik's own
default admits TLS 1.0 and 1.1. `null` leaves Traefik's default in
place.
'';
};
sniStrict = lib.mkOption {
type = lib.types.bool;
default = cfg.acme.enable;
defaultText = lib.literalExpression "config.othrys.services.traefik.acme.enable";
description = ''
Refuse a TLS connection whose server name matches no certificate,
instead of answering with Traefik's self-signed default certificate.
A request made to the bare IP address is refused as well.
On by default when ACME issues the certificates, since every routed
host then has one. Off by default otherwise, because a proxy with no
certificate of its own would refuse every connection.
'';
};
};
securityHeaders = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Attach a headers middleware to the websecure entrypoint, so every
router behind it sends the headers below. A router that needs
different values sets its own headers middleware, which runs after
this one and wins. Set to `false` to attach nothing.
'';
};
hstsSeconds = lib.mkOption {
type = lib.types.ints.unsigned;
default = 31536000;
description = ''
`max-age` of the `Strict-Transport-Security` header, one year by
default. Subdomains are not included and preload is not requested,
since both reach past the hosts this proxy serves. `0` sends no HSTS
header.
'';
};
contentTypeNosniff = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Send `X-Content-Type-Options: nosniff`.";
};
frameOptions = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "SAMEORIGIN";
example = "DENY";
description = ''
Value of the `X-Frame-Options` header. The default lets a site frame
its own pages and stops other origins from framing them, which breaks
a dashboard embedded from a different host name. `null` sends no such
header.
'';
};
};
forwardedHeaders.trustedIPs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = ["192.0.2.0/24"];
description = ''
Addresses or CIDR ranges of the proxies in front of Traefik whose
`X-Forwarded-*` headers are kept, written to the `web` and
`websecure` entrypoints. With the list empty Traefik discards those
headers from every peer, which is right for a host that faces the
internet directly. Behind a CDN or a load balancer the list holds that
proxy's ranges and nothing wider, since a listed peer can state any
client address it likes.
'';
};
logLevel = lib.mkOption {
type = lib.types.nullOr (lib.types.enum ["TRACE" "DEBUG" "INFO" "WARN" "ERROR" "FATAL" "PANIC"]);
default = null;
example = "INFO";
description = ''
Level of Traefik's own log, written as `log.level`. Null leaves
Traefik's default of `ERROR`. This is the log of the proxy itself,
and requests go to the access log, which is a separate setting.
'';
};
environmentFiles = lib.mkOption {
type = lib.types.listOf othrysTypes.secretPath;
default = [];
example = lib.literalExpression ''[ config.sops.secrets."traefik/env".path ]'';
description = ''
EnvironmentFiles for the service (e.g. the DNS provider token like
CF_DNS_API_TOKEN). Substituted into the static config via envsubst.
'';
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Open the web (:80) and websecure (:443) ports. It is also the default of tcpRouters.<name>.openFirewall. The API and dashboard port, :8080, is never opened here, since the insecure dashboard carries no authentication.";
};
staticConfigOptions = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra static configuration, merged on top of the generated static config.";
};
dynamicConfigOptions = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Dynamic configuration (routers, services, middlewares, TLS), merged on top of the generated TLS options and headers middleware.";
};
tcpRouters = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
options = {
entryPoint = {
name = lib.mkOption {
type = lib.types.str;
default = name;
defaultText = lib.literalExpression "<router name>";
example = "ircs";
description = "Name of the entrypoint the router listens on. Each router gets its own.";
};
address = lib.mkOption {
type = lib.types.strMatching ".*:[0-9]+";
example = ":6697";
description = ''
Address of the entrypoint, `:<port>` for every address or
`<address>:<port>` for one. Ports 80 and 443 belong to `web`
and `websecure`, and 8080 to the insecure dashboard.
'';
};
};
domain = lib.mkOption {
type = lib.types.str;
example = "irc.example.com";
description = ''
Name the router answers to, matched as `HostSNI` against the
name the client sends. A client that sends no name is not
routed. A terminating router asks the ACME resolver for a
certificate for this name.
'';
};
backend = lib.mkOption {
type = lib.types.str;
example = "[::1]:6667";
description = "Address and port Traefik forwards the connection to.";
};
proxyProtocol = lib.mkOption {
type = lib.types.nullOr (lib.types.enum [1 2]);
default = null;
example = 2;
description = ''
Version of the PROXY protocol header Traefik sends to the
backend, so the backend sees the client's address. Null sends
none. The backend has to expect the header from Traefik's
address and from no other peer.
'';
};
passthrough = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Forward the TLS stream unopened to a backend that terminates TLS
itself. Traefik reads only the name from the client's hello, and
requests no certificate. Off by default, so Traefik terminates TLS
with the certificate `acme.resolver` issues.
'';
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = cfg.openFirewall;
defaultText = lib.literalExpression "config.othrys.services.traefik.openFirewall";
description = "Open the entrypoint's port in the NixOS firewall.";
};
};
}));
default = {};
example = lib.literalExpression ''
{
soju = {
entryPoint.address = ":6697";
domain = "irc.example.com";
backend = "[::1]:6667";
proxyProtocol = 2;
};
}
'';
description = ''
TCP services behind Traefik, each on an entrypoint of its own and
reached by the TLS server name. Each entry writes an entrypoint, a
router, a service and, with `proxyProtocol`, a servers transport,
under its own name. A terminating router uses the default TLS
options, so `tls.sniStrict` and `tls.minVersion` apply to it as they
do to the HTTPS routers.
'';
};
};
soju
soju is an IRC bouncer, and the module is a wrapper over
services.soju. soju holds the connections to the upstream networks and keeps
their history while clients come and go. Clients reach it over TLS in one of
two ways, through a Traefik TCP router or through soju’s own TLS
listener. senpai is the client module, and
IRC with soju and senpai sets up both.
othrys.services.soju = {
enable = true;
traefik = {
enable = true;
domain = "irc.example.com";
};
};
Upstream’s default listen is :6697, which soju reads as ircs, and soju
exits with missing TLS configuration when no certificate is set. The module
listens on irc+insecure://127.0.0.1:6667 instead, at port, and never opens
that port in the firewall.
Both TLS paths serve port 6697, so the module refuses traefik.enable beside
tls.certificateFile.
Through Traefik. traefik.enable writes
othrys.services.traefik.tcpRouters.soju, an entrypoint named ircs at
:6697 that forwards to [::1]:<port> with a PROXY protocol version 2 header.
It needs traefik.domain, and Traefik with ACME on. soju trusts a PROXY header
by the peer’s address, on every listener at once, and accepts a trusted peer
that sends none. The module adds a second plaintext listener on [::1] for
Traefik to dial, and ::1/128 is the only trusted range, so a header sent from
127.0.0.1, where a local client connects, is not read. networking.enableIPv6 = false removes ::1 from
lo, and the module refuses it beside traefik.enable. The port Traefik
listens on is opened by othrys.services.traefik.tcpRouters.soju.openFirewall
and not by soju’s own openFirewall.
Direct TLS. tls.certificateFile and tls.keyFile are set together and
add an ircs://:6697 listener, which openFirewall opens. The service runs
under DynamicUser and cannot read a certificate another user owns, so both
files reach it through LoadCredential. systemd reads them as root when the
service starts, and the ACME files can stay owned by the acme user. The copy
is taken once per start, so a renewed certificate is read at the next restart
of soju.service and not at a reload. security.acme.certs.<name>.reloadServices
runs systemctl try-reload-or-restart, and the upstream unit answers a reload
with SIGHUP, so soju would reload against the stale copy. A host using
security.acme restarts the service after renewal instead.
security.acme.certs."irc.example.com".postRun = "systemctl restart soju.service";
othrys.services.soju = {
enable = true;
tls = {
certificateFile = "/var/lib/acme/irc.example.com/fullchain.pem";
keyFile = "/var/lib/acme/irc.example.com/key.pem";
};
openFirewall = true;
};
The module declares no accounts. An account is created on the host, and
sojuctl takes the password only as an argument, so the password is visible in
the process list while the command runs. A declarative account would put it
there at every activation.
sudo sojuctl user create -username alice -password 'change-me' -admin true
messageStore defaults to db, which is soju’s own default and differs from
the fs that upstream NixOS sets. History then sits in soju.db beside the
accounts and the passwords soju sends to the networks it joins. The state
directory is persisted at /var/lib/private/soju, where a DynamicUser
service keeps it, and /var/lib/soju is systemd’s symlink to it.
hostName is the name soju gives itself as an IRC server. It follows
traefik.domain while traefik.enable is on, and networking.hostName
otherwise. soju warns at start when the name has no dot, and it never compares
the name with the TLS name a client uses.
Options
options.othrys.services.soju = {
enable = lib.mkEnableOption "the soju IRC bouncer";
port = lib.mkOption {
type = lib.types.port;
default = 6667;
description = ''
Port of the plaintext listener on loopback, `irc+insecure://`, which
a client on the same host uses and which Traefik forwards to. It is
never opened in the firewall.
'';
};
hostName = lib.mkOption {
type = lib.types.str;
default =
if cfg.traefik.enable && cfg.traefik.domain != null
then cfg.traefik.domain
else config.networking.hostName;
defaultText = lib.literalExpression "traefik.domain when traefik.enable is on, config.networking.hostName otherwise";
example = "irc.example.com";
description = ''
Name soju gives itself as an IRC server, in the prefix of its own
messages and in its welcome replies. soju warns at start when the
name has no dot. It is not compared with the TLS name a client uses.
'';
};
messageStore = lib.mkOption {
type = lib.types.enum ["db" "fs" "memory"];
default = "db";
description = ''
Where soju keeps message history. `db` writes it to the same sqlite
database that holds the accounts, `soju.db` in the state directory,
and gives soju's message search. `fs` writes plain-text logs under
`logs` in the state directory, and `memory` keeps nothing across a
restart. Upstream NixOS defaults to `fs`, while soju itself
defaults to `db`.
'';
};
tls = {
certificateFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = "/var/lib/acme/irc.example.com/fullchain.pem";
description = ''
Runtime path to the certificate chain for soju's own TLS listener,
`ircs://` on port 6697. Set together with `tls.keyFile`. The file
is loaded into the service as a credential, so it can stay owned
by root. A renewed certificate is read at the next restart of
`soju.service`.
'';
};
keyFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
example = "/var/lib/acme/irc.example.com/key.pem";
description = "Runtime path to the private key for `tls.certificateFile`.";
};
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Open port 6697 for soju's own TLS listener. It has an effect only
with `tls.certificateFile` set. The plaintext listener is never
opened, and the port Traefik listens on is opened by
`othrys.services.traefik.tcpRouters.soju.openFirewall`.
'';
};
traefik = {
enable = lib.mkEnableOption ''
a Traefik TCP router for soju. Traefik terminates TLS on port 6697
with its ACME resolver and forwards to soju over `[::1]` with a PROXY
protocol header, so soju sees each client's own address
'';
domain = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "irc.example.com";
description = ''
Name clients connect to. Traefik requests its certificate and
routes on it, and a client that sends no such name is not routed.
It becomes the default of `hostName`.
'';
};
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example = "max-user-networks 5";
description = "Lines appended to `soju.conf`. See {manpage}`soju(1)` for the directives.";
};
};
DDNS
Dynamic DNS via inadyn, keeping hostnames pointing at a dynamic residential
IP, pairing with Traefik’s DNS-01 ACME. Credentials arrive as an
inadyn include snippet (password = <token>) from a secrets provider. inadyn
reads it as its own user, so the secret needs owner = "inadyn".
provider is an enum of the names inadyn registers, which inadyn -L lists.
It takes the full name, such as default@cloudflare.com or ipv6@dynv6.com,
or the service name after the @, such as cloudflare.com. inadyn itself
accepts any substring of a name, so a misspelt provider would otherwise reach
the daemon and fail at its first run.
Options
options.othrys.services.ddns = {
enable = lib.mkEnableOption "dynamic DNS updates (inadyn)";
provider = lib.mkOption {
type = lib.types.nullOr (lib.types.enum providerNames);
default = null;
defaultText = lib.literalMD "none, and an assertion rejects an unset value once the module is enabled";
example = "cloudflare.com";
description = ''
DDNS provider, one of the names inadyn registers (`inadyn -L` lists
them). Either the full name, such as `default@cloudflare.com` or
`ipv6@dynv6.com`, or the service name after the `@`, which inadyn
resolves to the first plugin that carries it. Must be set when this
module is enabled.
'';
};
hostnames = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
defaultText = lib.literalMD "none, and an assertion rejects an empty list once the module is enabled";
example = ["home.example.com"];
description = "Hostnames to keep updated. Identity-shaped, set from the consuming host. Must be non-empty when this module is enabled.";
};
username = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "example.com";
description = "Provider username/account (for Cloudflare: the zone name). Null for token-only providers.";
};
credentialsFile = lib.mkOption {
type = lib.types.nullOr othrysTypes.secretPath;
default = null;
defaultText = lib.literalMD "none, and an assertion rejects an unset value once the module is enabled";
example = lib.literalExpression ''config.sops.secrets."ddns/credentials".path'';
description = ''
Path to a runtime file included into the provider block, since inadyn.conf
syntax, typically a single `password = <token>` line. A
secrets-provider path; never inline the token. Must be set when this
module is enabled.
inadyn opens the file at run time as its own user inside a private
user namespace, so a file that is root-owned and mode 0400 is
unreadable and the service fails at its first update. With sops-nix
set `owner = "inadyn"` on the secret.
'';
};
extraSettings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = "Extra per-provider inadyn settings merged into the provider block.";
};
};