1 { config, lib, pkgs, ... }:
7 cfg = config.services.roon-server;
10 services.roon-server = {
11 enable = mkEnableOption (lib.mdDoc "Roon Server");
12 openFirewall = mkOption {
15 description = lib.mdDoc ''
16 Open ports in the firewall for the server.
21 default = "roon-server";
22 description = lib.mdDoc ''
23 User to run the Roon Server as.
28 default = "roon-server";
29 description = lib.mdDoc ''
30 Group to run the Roon Server as.
36 config = mkIf cfg.enable {
37 systemd.services.roon-server = {
38 after = [ "network.target" ];
39 description = "Roon Server";
40 wantedBy = [ "multi-user.target" ];
42 environment.ROON_DATAROOT = "/var/lib/${name}";
45 ExecStart = "${pkgs.roon-server}/bin/RoonServer";
49 StateDirectory = name;
53 networking.firewall = mkIf cfg.openFirewall {
54 allowedTCPPortRanges = [
55 { from = 9100; to = 9200; }
56 { from = 9330; to = 9339; }
57 { from = 30000; to = 30010; }
59 allowedUDPPorts = [ 9003 ];
61 ## IGMP / Broadcast ##
62 iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
63 iptables -A INPUT -d 224.0.0.0/4 -j ACCEPT
64 iptables -A INPUT -s 240.0.0.0/5 -j ACCEPT
65 iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
66 iptables -A INPUT -m pkttype --pkt-type broadcast -j ACCEPT
71 users.groups.${cfg.group} = {};
72 users.users.${cfg.user} =
73 if cfg.user == "roon-server" then {
75 description = "Roon Server user";
77 extraGroups = [ "audio" ];