add test for port uniqueness

This commit is contained in:
Simon Gardling 2025-04-10 14:51:29 -04:00
parent 2aa78bfc48
commit 80b66beb54
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -62,7 +62,6 @@
music_dir = "/${zpool_ssds}/music"; music_dir = "/${zpool_ssds}/music";
torrent_group = "media"; torrent_group = "media";
# TODO: add checks to make sure none of these collide
ports = { ports = {
https = 443; https = 443;
jellyfin = 8096; # no services.jellyfin option for this jellyfin = 8096; # no services.jellyfin option for this
@ -170,6 +169,26 @@
}; };
modules = modules =
[ [
# SAFETY! make sure no ports collide
(
{ lib, ... }:
{
config = {
assertions = [
{
assertion =
let
ports = lib.attrValues service_configs.ports;
uniquePorts = lib.unique ports;
in
(lib.length ports) == (lib.length uniquePorts);
message = "Duplicate ports detected in 'ports' configuration";
}
];
};
}
)
./disk-config.nix ./disk-config.nix
disko.nixosModules.disko disko.nixosModules.disko
./configuration.nix ./configuration.nix