diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 23809796878f..c8cf5bfa7981 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -91,8 +91,9 @@ ./services/amqp/activemq/default.nix ./services/amqp/rabbitmq.nix ./services/audio/alsa.nix - # Disabled as fuppes it does no longer builds. + # Disabled as fuppes no longer builds. # ./services/audio/fuppes.nix + ./services/audio/icecast.nix ./services/audio/liquidsoap.nix ./services/audio/mpd.nix ./services/audio/mopidy.nix 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" '' + + ${cfg.hostname} + + + ${cfg.admin.user} + ${cfg.admin.password} + + + + ${cfg.logDir} + ${pkgs.icecast}/share/icecast/admin + ${pkgs.icecast}/share/icecast/web + + + + + ${toString cfg.listen.port} + ${cfg.listen.address} + + + + 0 + + ${cfg.user} + ${cfg.group} + + + + ${cfg.extraConf} + + ''; +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"; + }; + }; + + }; + +}