1 { config, lib, pkgs, ... }:
7 cfg = config.services.roon-server;
10 services.roon-server = {
11 enable = mkEnableOption "Roon Server";
12 package = lib.mkPackageOption pkgs "roon-server" { };
13 openFirewall = mkOption {
17 Open ports in the firewall for the server.
22 default = "roon-server";
24 User to run the Roon Server as.
29 default = "roon-server";
31 Group to run the Roon Server as.
37 config = mkIf cfg.enable {
38 systemd.services.roon-server = {
39 after = [ "network.target" ];
40 description = "Roon Server";
41 wantedBy = [ "multi-user.target" ];
43 environment.ROON_DATAROOT = "/var/lib/${name}";
44 environment.ROON_ID_DIR = "/var/lib/${name}";
47 ExecStart = "${lib.getExe cfg.package}";
51 StateDirectory = name;
55 networking.firewall = mkIf cfg.openFirewall {
56 allowedTCPPortRanges = [
57 { from = 9100; to = 9200; }
58 { from = 9330; to = 9339; }
59 { from = 30000; to = 30010; }
61 allowedUDPPorts = [ 9003 ];
62 extraCommands = optionalString (!config.networking.nftables.enable) ''
63 ## IGMP / Broadcast ##
64 iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
65 iptables -A INPUT -d 224.0.0.0/4 -j ACCEPT
66 iptables -A INPUT -s 240.0.0.0/5 -j ACCEPT
67 iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
68 iptables -A INPUT -m pkttype --pkt-type broadcast -j ACCEPT
70 extraInputRules = optionalString config.networking.nftables.enable ''
71 ip saddr { 224.0.0.0/4, 240.0.0.0/5 } accept
72 ip daddr 224.0.0.0/4 accept
73 pkttype { multicast, broadcast } accept
78 users.groups.${cfg.group} = {};
79 users.users.${cfg.user} =
80 optionalAttrs (cfg.user == "roon-server") {
82 description = "Roon Server user";
84 extraGroups = [ "audio" ];