1 { config, lib, pkgs, ... }:
6 cfg = config.services.icecast;
7 configFile = pkgs.writeText "icecast.xml" ''
9 <hostname>${cfg.hostname}</hostname>
12 <admin-user>${cfg.admin.user}</admin-user>
13 <admin-password>${cfg.admin.password}</admin-password>
17 <logdir>${cfg.logDir}</logdir>
18 <adminroot>${pkgs.icecast}/share/icecast/admin</adminroot>
19 <webroot>${pkgs.icecast}/share/icecast/web</webroot>
20 <alias source="/" dest="/status.xsl"/>
24 <port>${toString cfg.listen.port}</port>
25 <bind-address>${cfg.listen.address}</bind-address>
31 <user>${cfg.user}</user>
32 <group>${cfg.group}</group>
47 enable = mkEnableOption (lib.mdDoc "Icecast server");
50 type = types.nullOr types.str;
51 description = lib.mdDoc "DNS name or IP address that will be used for the stream directory lookups or possibily the playlist generation if a Host header is not provided.";
52 default = config.networking.domain;
53 defaultText = literalExpression "config.networking.domain";
59 description = lib.mdDoc "Username used for all administration functions.";
65 description = lib.mdDoc "Password used for all administration functions.";
71 description = lib.mdDoc "Base directory used for logging.";
72 default = "/var/log/icecast";
78 description = lib.mdDoc "TCP port that will be used to accept client connections.";
84 description = lib.mdDoc "Address Icecast will listen on.";
91 description = lib.mdDoc "User privileges for the server.";
97 description = lib.mdDoc "Group privileges for the server.";
101 extraConf = mkOption {
103 description = lib.mdDoc "icecast.xml content.";
112 ###### implementation
114 config = mkIf cfg.enable {
116 systemd.services.icecast = {
117 after = [ "network.target" ];
118 description = "Icecast Network Audio Streaming Server";
119 wantedBy = [ "multi-user.target" ];
121 preStart = "mkdir -p ${cfg.logDir} && chown ${cfg.user}:${cfg.group} ${cfg.logDir}";
124 ExecStart = "${pkgs.icecast}/bin/icecast -c ${configFile}";
125 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";