modules/prometheus: run alertmanager as a static user

nixpkgs' alertmanager uses DynamicUser, so the `alertmanager` user only
exists while the service is running. The matrix-alertmanager-urlfile
secret is owned by that user; at boot sops-install-secrets cannot resolve
it and rejects the whole manifest, leaving /run/secrets empty (no ssh
host key, yggdrasil key, tor key, ...). Deploys masked it because the
dynamic user was resolvable via nss-systemd at switch time.

Create a static alertmanager user/group and disable DynamicUser.
This commit is contained in:
kurogeek committed 2026-10-26 09:27:42 +00:00
1 parent 452bd5f686
commit 37496b974e
1 file changed
+15
+15
View File
@@ -256,6 +256,21 @@
];
};
# nixpkgs runs alertmanager with DynamicUser; that user only exists
# while the service runs, so sops-install-secrets cannot resolve the
# owner of matrix-alertmanager-urlfile at boot and rejects the whole
# manifest (no secrets installed). Use a static user instead.
users.users.alertmanager = {
isSystemUser = true;
group = "alertmanager";
};
users.groups.alertmanager = { };
systemd.services.alertmanager.serviceConfig = {
DynamicUser = lib.mkForce false;
User = "alertmanager";
Group = "alertmanager";
};
services.matrix-alertmanager = lib.mkIf settings.matrix-alertmanager.enable {
enable = true;
tokenFile = config.clan.core.vars.generators.prometheus.files.matrix-alertmanager-token.path;