[repo] NixOS and docs: Caddy admin socket for changes under Caddy, polkit start/stop only, edge never stops restarting, openssl in the VM tests, beside-Caddy without secrets in argv, pinned Ianitor rev, X-Served-By trial marker

This commit is contained in:
2026-11-08 10:49:42 +01:00
parent e84eb1ba74
commit bc336d1188
7 changed files with 86 additions and 38 deletions
+12 -3
View File
@@ -4,7 +4,9 @@
# services.ianitor: ianitor-edge (the only public listener), ianitor-control (loopback),
# caddy-fallback (the same routes as Caddy JSON), the engine-select unit, the per-boot UI proof,
# and a polkit rule that lets control start, stop and restart exactly the two engine units.
# and a polkit rule that lets control start and stop exactly the two engine units. While Caddy
# serves, control loads changes into it through its admin socket (/run/caddy-fallback/admin.sock,
# group ianitor, 0660).
#
# Secrets never enter the Nix store: every credential is a *path string* to a file outside the
# store (sops-nix, agenix, Custos provisioning, ...), loaded with systemd LoadCredential; an
@@ -66,6 +68,8 @@ let
compile_caddy = compile // {
state_dir = "${stateRoot}/caddy-state";
access_log = "/var/log/ianitor/caddy-access.log";
# Changes keep working under Caddy: control loads them through this socket.
caddy_admin_socket = "/run/caddy-fallback/admin.sock";
};
ui =
{
@@ -298,6 +302,8 @@ in
systemd.services.ianitor-edge = {
description = "Ianitor edge (Pingora)";
# Never give up restarting the only public listener.
startLimitIntervalSec = 0;
after = [ "network-online.target" "ianitor-control.service" "ianitor-ui-proof.service" ];
wants = [ "network-online.target" ];
requires = [ "ianitor-ui-proof.service" ];
@@ -342,6 +348,8 @@ in
Group = "ianitor";
ExecStart = "${cfg.caddyPackage}/bin/caddy run --config ${stateRoot}/caddy/caddy.json";
LoadCredential = loadCreds cfg.credentials ++ [ "ui-proof:${runProof}/ui-proof" ];
RuntimeDirectory = "caddy-fallback";
RuntimeDirectoryMode = "0750";
ReadWritePaths = [ "${stateRoot}/caddy-state" "/var/log/ianitor" ];
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
@@ -370,7 +378,8 @@ in
'';
};
# Control may start, stop and restart exactly the two engine units, nothing else.
# Control may start and stop exactly the two engine units, nothing else. (polkit is new on a
# server that had no other use for it.)
security.polkit.enable = true;
security.polkit.extraConfig = ''
polkit.addRule(function (action, subject) {
@@ -378,7 +387,7 @@ in
var unit = action.lookup("unit");
var verb = action.lookup("verb");
if ((unit == "ianitor-edge.service" || unit == "caddy-fallback.service") &&
(verb == "start" || verb == "stop" || verb == "restart")) {
(verb == "start" || verb == "stop")) {
return polkit.Result.YES;
}
}