From 77b2f5d644f2bf8d81728646ab7b67cc2d4c1dc4 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 1 Jan 2026 20:45:14 +0100 Subject: [PATCH] nixos/icecast: modernize and clean up --- nixos/modules/services/audio/icecast.nix | 66 +++++++++++++----------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/nixos/modules/services/audio/icecast.nix b/nixos/modules/services/audio/icecast.nix index 930b6af004a2..feb78ca8fc5c 100644 --- a/nixos/modules/services/audio/icecast.nix +++ b/nixos/modules/services/audio/icecast.nix @@ -5,8 +5,14 @@ ... }: let + inherit (lib) + mkRemovedOptionModule + mkRenamedOptionModule + ; + cfg = config.services.icecast; configFile = pkgs.writeText "icecast.xml" '' + ${cfg.hostname} @@ -16,7 +22,7 @@ let - ${cfg.logDir} + /var/log/icecast ${pkgs.icecast}/share/icecast/admin ${pkgs.icecast}/share/icecast/web @@ -29,18 +35,27 @@ let 0 - - ${cfg.user} - ${cfg.group} - - ${cfg.extraConf} + ${cfg.extraConfig} ''; in { + imports = [ + (mkRemovedOptionModule [ "services" "icecast" "logDir" ] '' + The log directory is now managed by systemd's LogsDirectory= directive. + '') + (mkRemovedOptionModule [ "services" "icecast" "user" ] '' + The service now runs under the dynamically allocated `icecast` user. + '') + (mkRemovedOptionModule [ "services" "icecast" "group" ] '' + The service now runs under the dynamically allocated `icecast` group. + '') + (mkRenamedOptionModule [ "services" "icecast" "extraConf" ] [ "services" "icecast" "extraConfig" ]) + ]; + ###### interface options = { @@ -69,12 +84,6 @@ in }; }; - logDir = lib.mkOption { - type = lib.types.path; - description = "Base directory used for logging."; - default = "/var/log/icecast"; - }; - listen = { port = lib.mkOption { type = lib.types.port; @@ -89,22 +98,12 @@ in }; }; - user = lib.mkOption { - type = lib.types.str; - description = "User privileges for the server."; - default = "nobody"; - }; - - group = lib.mkOption { - type = lib.types.str; - description = "Group privileges for the server."; - default = "nogroup"; - }; - - extraConf = lib.mkOption { + extraConfig = lib.mkOption { type = lib.types.lines; - description = "icecast.xml content."; default = ""; + description = '' + Extra configuration added to {file}`icecast.xml` inside the `` element. + ''; }; }; @@ -120,11 +119,20 @@ in description = "Icecast Network Audio Streaming Server"; wantedBy = [ "multi-user.target" ]; - preStart = "mkdir -p ${cfg.logDir} && chown ${cfg.user}:${cfg.group} ${cfg.logDir}"; serviceConfig = { Type = "simple"; - ExecStart = "${pkgs.icecast}/bin/icecast -c ${configFile}"; - ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + DynamicUser = true; + ExecStart = toString [ + (lib.getExe pkgs.icecast) + "-c" + configFile + ]; + ExecReload = toString [ + (lib.getExe' pkgs.coreutils "kill") + "-HUP" + "$MAINPID" + ]; + LogsDirectory = "icecast"; }; };