nixos: comin deploys only signed commits
All checks were successful
nixos / nixos (push) Successful in 20s

The head of main must carry the admin's GPG signature or Renovate's SSH
signature (nixos/keys), so write access to the repository alone, such
as renovate-bot's API token, no longer reaches root on the hosts.

comin skips an unsigned head without a metric of its own, so a timer
exports whether the head is signed and whether it still waits for
evaluation; both alert.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 11:54:15 +04:00
commit 0137dec4fb
Signed by: asxpi
GPG key ID: 4F8851660FA4121B

View file

@ -3,7 +3,18 @@
# evaluates. A branch testing-<hostname> on top of main is applied with
# `test` (not the boot default) to that host alone: try a change there,
# then merge it. `comin status` on the host shows what it is doing.
{ config, ... }:
#
# Only a signed head is deployed: the admin's GPG key or Renovate's SSH
# key (../keys). Anything else on main waits, and alerts (comin.prom).
{
config,
lib,
pkgs,
...
}:
let
textfile = "/var/lib/node_exporter/textfile";
in
{
services.comin = {
enable = true;
@ -14,6 +25,8 @@
}
];
repositorySubdir = "nixos";
gpgPublicKeyPaths = [ "${../keys/asxpi.asc}" ];
sshAllowedSignersPath = "${../keys/allowed_signers}";
# Prometheus on ops scrapes it over the private network
exporter = {
listen_address = config.asxpio.privateIPv4;
@ -21,5 +34,34 @@
};
};
# What comin's own metrics leave out: whether the head of main is
# signed, and whether it is still waiting to be evaluated
systemd.services.comin-metrics = {
description = "comin state for Prometheus";
after = [ "comin.service" ];
path = [
config.services.comin.package
pkgs.jq
];
serviceConfig.Type = "oneshot";
script = ''
comin status --json | jq -r '
.fetcher.repository_status as $r
| ([$r.remotes[] | select(.name == "origin") | .main.commit_id][0]) as $head
| "# HELP comin_main_signed Head of main carries a trusted signature (1) or not (0).",
"# TYPE comin_main_signed gauge",
"comin_main_signed \(if ($r.selected_commit_should_be_signed | not) or $r.selected_commit_signed then 1 else 0 end)",
"# HELP comin_main_pending Head of main differs from the last evaluated commit.",
"# TYPE comin_main_pending gauge",
"comin_main_pending \(if $head == .builder.generation.selected_commit_id then 0 else 1 end)"
' > ${textfile}/comin.prom.tmp
mv ${textfile}/comin.prom.tmp ${textfile}/comin.prom
'';
};
systemd.timers.comin-metrics = {
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "*:0/2";
};
asxpio.security.ports = [ "tcp/4243/comin" ];
}