nixos/coturn: reindent, unclutter

Make the module slightly easier to browse.
This commit is contained in:
Martin Weinelt 2024-10-14 03:37:03 +02:00
parent 6d9089c67d
commit 72dd22a02d
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759

View File

@ -3,39 +3,39 @@ let
cfg = config.services.coturn; cfg = config.services.coturn;
pidfile = "/run/turnserver/turnserver.pid"; pidfile = "/run/turnserver/turnserver.pid";
configFile = pkgs.writeText "turnserver.conf" '' configFile = pkgs.writeText "turnserver.conf" ''
listening-port=${toString cfg.listening-port} listening-port=${toString cfg.listening-port}
tls-listening-port=${toString cfg.tls-listening-port} tls-listening-port=${toString cfg.tls-listening-port}
alt-listening-port=${toString cfg.alt-listening-port} alt-listening-port=${toString cfg.alt-listening-port}
alt-tls-listening-port=${toString cfg.alt-tls-listening-port} alt-tls-listening-port=${toString cfg.alt-tls-listening-port}
${lib.concatStringsSep "\n" (map (x: "listening-ip=${x}") cfg.listening-ips)} ${lib.concatStringsSep "\n" (map (x: "listening-ip=${x}") cfg.listening-ips)}
${lib.concatStringsSep "\n" (map (x: "relay-ip=${x}") cfg.relay-ips)} ${lib.concatStringsSep "\n" (map (x: "relay-ip=${x}") cfg.relay-ips)}
min-port=${toString cfg.min-port} min-port=${toString cfg.min-port}
max-port=${toString cfg.max-port} max-port=${toString cfg.max-port}
${lib.optionalString cfg.lt-cred-mech "lt-cred-mech"} ${lib.optionalString cfg.lt-cred-mech "lt-cred-mech"}
${lib.optionalString cfg.no-auth "no-auth"} ${lib.optionalString cfg.no-auth "no-auth"}
${lib.optionalString cfg.use-auth-secret "use-auth-secret"} ${lib.optionalString cfg.use-auth-secret "use-auth-secret"}
${lib.optionalString (cfg.static-auth-secret != null) ("static-auth-secret=${cfg.static-auth-secret}")} ${lib.optionalString (cfg.static-auth-secret != null) "static-auth-secret=${cfg.static-auth-secret}"}
${lib.optionalString (cfg.static-auth-secret-file != null) ("static-auth-secret=#static-auth-secret#")} ${lib.optionalString (cfg.static-auth-secret-file != null) "static-auth-secret=#static-auth-secret#"}
realm=${cfg.realm} realm=${cfg.realm}
${lib.optionalString cfg.no-udp "no-udp"} ${lib.optionalString cfg.no-udp "no-udp"}
${lib.optionalString cfg.no-tcp "no-tcp"} ${lib.optionalString cfg.no-tcp "no-tcp"}
${lib.optionalString cfg.no-tls "no-tls"} ${lib.optionalString cfg.no-tls "no-tls"}
${lib.optionalString cfg.no-dtls "no-dtls"} ${lib.optionalString cfg.no-dtls "no-dtls"}
${lib.optionalString cfg.no-udp-relay "no-udp-relay"} ${lib.optionalString cfg.no-udp-relay "no-udp-relay"}
${lib.optionalString cfg.no-tcp-relay "no-tcp-relay"} ${lib.optionalString cfg.no-tcp-relay "no-tcp-relay"}
${lib.optionalString (cfg.cert != null) "cert=${cfg.cert}"} ${lib.optionalString (cfg.cert != null) "cert=${cfg.cert}"}
${lib.optionalString (cfg.pkey != null) "pkey=${cfg.pkey}"} ${lib.optionalString (cfg.pkey != null) "pkey=${cfg.pkey}"}
${lib.optionalString (cfg.dh-file != null) ("dh-file=${cfg.dh-file}")} ${lib.optionalString (cfg.dh-file != null) "dh-file=${cfg.dh-file}"}
no-stdout-log no-stdout-log
syslog syslog
pidfile=${pidfile} pidfile=${pidfile}
${lib.optionalString cfg.secure-stun "secure-stun"} ${lib.optionalString cfg.secure-stun "secure-stun"}
${lib.optionalString cfg.no-cli "no-cli"} ${lib.optionalString cfg.no-cli "no-cli"}
cli-ip=${cfg.cli-ip} cli-ip=${cfg.cli-ip}
cli-port=${toString cfg.cli-port} cli-port=${toString cfg.cli-port}
${lib.optionalString (cfg.cli-password != null) ("cli-password=${cfg.cli-password}")} ${lib.optionalString (cfg.cli-password != null) "cli-password=${cfg.cli-password}"}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
in { in {
options = { options = {
services.coturn = { services.coturn = {
@ -301,7 +301,7 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable (lib.mkMerge ([ config = lib.mkIf cfg.enable (lib.mkMerge [
{ assertions = [ { assertions = [
{ assertion = cfg.static-auth-secret != null -> cfg.static-auth-secret-file == null ; { assertion = cfg.static-auth-secret != null -> cfg.static-auth-secret-file == null ;
message = "static-auth-secret and static-auth-secret-file cannot be set at the same time"; message = "static-auth-secret and static-auth-secret-file cannot be set at the same time";
@ -402,5 +402,5 @@ in {
UMask = "0077"; UMask = "0077";
}; };
}; };
}])); }]);
} }