2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.icecast;
|
|
|
|
configFile = pkgs.writeText "icecast.xml" ''
|
|
|
|
<icecast>
|
|
|
|
<hostname>${cfg.hostname}</hostname>
|
|
|
|
|
|
|
|
<authentication>
|
|
|
|
<admin-user>${cfg.admin.user}</admin-user>
|
|
|
|
<admin-password>${cfg.admin.password}</admin-password>
|
|
|
|
</authentication>
|
|
|
|
|
|
|
|
<paths>
|
|
|
|
<logdir>${cfg.logDir}</logdir>
|
|
|
|
<adminroot>${pkgs.icecast}/share/icecast/admin</adminroot>
|
|
|
|
<webroot>${pkgs.icecast}/share/icecast/web</webroot>
|
|
|
|
<alias source="/" dest="/status.xsl"/>
|
|
|
|
</paths>
|
|
|
|
|
|
|
|
<listen-socket>
|
|
|
|
<port>${toString cfg.listen.port}</port>
|
|
|
|
<bind-address>${cfg.listen.address}</bind-address>
|
2020-08-20 17:08:02 +00:00
|
|
|
</listen-socket>
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
<security>
|
|
|
|
<chroot>0</chroot>
|
|
|
|
<changeowner>
|
|
|
|
<user>${cfg.user}</user>
|
|
|
|
<group>${cfg.group}</group>
|
|
|
|
</changeowner>
|
|
|
|
</security>
|
|
|
|
|
|
|
|
${cfg.extraConf}
|
|
|
|
</icecast>
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.icecast = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Icecast server");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hostname = mkOption {
|
2020-09-25 04:45:31 +00:00
|
|
|
type = types.nullOr types.str;
|
2022-12-28 21:21:41 +00:00
|
|
|
description = lib.mdDoc "DNS name or IP address that will be used for the stream directory lookups or possibly the playlist generation if a Host header is not provided.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = config.networking.domain;
|
2021-12-06 16:07:01 +00:00
|
|
|
defaultText = literalExpression "config.networking.domain";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
admin = {
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Username used for all administration functions.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "admin";
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Password used for all administration functions.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
logDir = mkOption {
|
|
|
|
type = types.path;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Base directory used for logging.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "/var/log/icecast";
|
|
|
|
};
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
listen = {
|
|
|
|
port = mkOption {
|
2022-12-17 10:02:37 +00:00
|
|
|
type = types.port;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "TCP port that will be used to accept client connections.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 8000;
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Address Icecast will listen on.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "::";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "User privileges for the server.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "nobody";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Group privileges for the server.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "nogroup";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConf = mkOption {
|
|
|
|
type = types.lines;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "icecast.xml content.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.icecast = {
|
|
|
|
after = [ "network.target" ];
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|