diff options
author | koral <koral@mailoo.org> | 2015-03-16 14:10:16 +0000 |
---|---|---|
committer | koral <koral@mailoo.org> | 2015-03-17 14:21:57 +0000 |
commit | 54857abfc971489aa1ce584bae0aa0d01f002c48 (patch) | |
tree | fd17d5ab09404ff3deea34b3728e53afe5e583ff /nixos/modules/services/audio | |
parent | 1d9d0312546bd680834a1ec83974e10ac8ee60b0 (diff) | |
download | nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar.gz nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar.bz2 nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar.lz nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar.xz nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.tar.zst nixlib-54857abfc971489aa1ce584bae0aa0d01f002c48.zip |
Added icecast module.
Diffstat (limited to 'nixos/modules/services/audio')
-rw-r--r-- | nixos/modules/services/audio/icecast.nix | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/nixos/modules/services/audio/icecast.nix b/nixos/modules/services/audio/icecast.nix new file mode 100644 index 000000000000..6a8a0f9975b3 --- /dev/null +++ b/nixos/modules/services/audio/icecast.nix @@ -0,0 +1,130 @@ +{ 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> + </listen-socket> + + <security> + <chroot>0</chroot> + <changeowner> + <user>${cfg.user}</user> + <group>${cfg.group}</group> + </changeowner> + </security> + + ${cfg.extraConf} + </icecast> + ''; +in { + + ###### interface + + options = { + + services.icecast = { + + enable = mkEnableOption "Icecast server"; + + hostname = mkOption { + type = types.str; + description = "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."; + default = config.networking.domain; + }; + + admin = { + user = mkOption { + type = types.str; + description = "Username used for all administration functions."; + default = "admin"; + }; + + password = mkOption { + type = types.str; + description = "Password used for all administration functions."; + }; + }; + + logDir = mkOption { + type = types.path; + description = "Base directory used for logging."; + default = "/var/log/icecast"; + }; + + listen = { + port = mkOption { + type = types.int; + description = "TCP port that will be used to accept client connections."; + default = 8000; + }; + + address = mkOption { + type = types.str; + description = "Address Icecast will listen on."; + default = "::"; + }; + }; + + user = mkOption { + type = types.str; + description = "User privileges for the server."; + default = "nobody"; + }; + + group = mkOption { + type = types.str; + description = "Group privileges for the server."; + default = "nogroup"; + }; + + extraConf = mkOption { + type = types.lines; + description = "icecast.xml content."; + 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"; + }; + }; + + }; + +} |