All checks were successful
nixos / nixos (push) Successful in 20s
The process listening on 4243 is .comin-wrapped, so the baseline flagged it as unknown. After a restart comin reports an empty status until the next commit arrives; count the head as pending only when it differs from both the evaluated and the deployed commit. Assisted-by: Claude:opus-5-5
67 lines
2.4 KiB
Nix
67 lines
2.4 KiB
Nix
# Deploys: each host pulls main of this repository and switches to
|
|
# nixosConfigurations.<its hostname> (comin, polling every minute). CI only
|
|
# 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.
|
|
#
|
|
# 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;
|
|
remotes = [
|
|
{
|
|
name = "origin";
|
|
url = "https://git.asxp.io/asxpi/iac.git";
|
|
}
|
|
];
|
|
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;
|
|
port = 4243;
|
|
};
|
|
};
|
|
|
|
# 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 // "") == "" or $head == .builder.generation.selected_commit_id or $head == .deployer.deployment.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-wrapped" ];
|
|
}
|