2024-08-24 19:18:07 -04:00
|
|
|
lib:
|
|
|
|
|
2025-04-01 20:10:43 +02:00
|
|
|
{
|
|
|
|
cert,
|
|
|
|
groups,
|
|
|
|
services,
|
|
|
|
}:
|
2024-08-24 19:18:07 -04:00
|
|
|
let
|
|
|
|
catSep = builtins.concatStringsSep;
|
|
|
|
|
2024-12-05 20:15:25 -05:00
|
|
|
svcUser = svc: svc.serviceConfig.User or "root";
|
2025-04-01 20:10:43 +02:00
|
|
|
svcGroups =
|
|
|
|
svc:
|
2024-08-24 19:18:07 -04:00
|
|
|
(lib.optional (svc.serviceConfig ? Group) svc.serviceConfig.Group)
|
2024-11-14 19:19:46 -05:00
|
|
|
++ lib.toList (svc.serviceConfig.SupplementaryGroups or [ ]);
|
2024-08-24 19:18:07 -04:00
|
|
|
in
|
|
|
|
{
|
2025-04-01 20:10:43 +02:00
|
|
|
assertion = builtins.all (
|
|
|
|
svc:
|
2024-12-05 20:15:25 -05:00
|
|
|
svcUser svc == "root"
|
|
|
|
|| builtins.elem (svcUser svc) groups.${cert.group}.members
|
2024-08-24 19:18:07 -04:00
|
|
|
|| builtins.elem cert.group (svcGroups svc)
|
|
|
|
) services;
|
|
|
|
|
|
|
|
message = "Certificate ${cert.domain} (group=${cert.group}) must be readable by service(s) ${
|
2025-04-01 20:10:43 +02:00
|
|
|
catSep ", " (
|
|
|
|
map (svc: "${svc.name} (user=${svcUser svc} groups=${catSep "," (svcGroups svc)})") services
|
|
|
|
)
|
2024-08-24 19:18:07 -04:00
|
|
|
}";
|
2022-01-08 15:05:34 -05:00
|
|
|
}
|