You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.9 KiB
77 lines
1.9 KiB
5 years ago
|
{ config, lib, pkgs, ... }:
|
||
|
|
||
|
with lib;
|
||
|
|
||
|
let
|
||
|
name = "roon-server";
|
||
|
cfg = config.services.roon-server;
|
||
|
in {
|
||
|
options = {
|
||
|
services.roon-server = {
|
||
|
enable = mkEnableOption "Roon Server";
|
||
|
openFirewall = mkOption {
|
||
|
type = types.bool;
|
||
|
default = false;
|
||
|
description = ''
|
||
|
Open ports in the firewall for the server.
|
||
|
'';
|
||
|
};
|
||
5 years ago
|
user = mkOption {
|
||
5 years ago
|
type = types.str;
|
||
5 years ago
|
default = "roon-server";
|
||
|
description = ''
|
||
|
User to run the Roon Server as.
|
||
|
'';
|
||
|
};
|
||
|
group = mkOption {
|
||
5 years ago
|
type = types.str;
|
||
5 years ago
|
default = "roon-server";
|
||
|
description = ''
|
||
|
Group to run the Roon Server as.
|
||
|
'';
|
||
|
};
|
||
5 years ago
|
};
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
systemd.services.roon-server = {
|
||
|
after = [ "network.target" ];
|
||
|
description = "Roon Server";
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
|
||
|
environment.ROON_DATAROOT = "/var/lib/${name}";
|
||
|
|
||
|
serviceConfig = {
|
||
3 years ago
|
ExecStart = "${pkgs.roon-server}/bin/RoonServer";
|
||
5 years ago
|
LimitNOFILE = 8192;
|
||
5 years ago
|
User = cfg.user;
|
||
5 years ago
|
Group = cfg.group;
|
||
5 years ago
|
StateDirectory = name;
|
||
5 years ago
|
};
|
||
|
};
|
||
4 years ago
|
|
||
5 years ago
|
networking.firewall = mkIf cfg.openFirewall {
|
||
3 years ago
|
allowedTCPPortRanges = [{ from = 9100; to = 9200; }];
|
||
5 years ago
|
allowedUDPPorts = [ 9003 ];
|
||
3 years ago
|
extraCommands = ''
|
||
|
iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
|
||
|
iptables -A INPUT -d 224.0.0.0/4 -j ACCEPT
|
||
|
iptables -A INPUT -s 240.0.0.0/5 -j ACCEPT
|
||
|
iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
|
||
|
iptables -A INPUT -m pkttype --pkt-type broadcast -j ACCEPT
|
||
|
'';
|
||
5 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
|
||
5 years ago
|
users.groups.${cfg.group} = {};
|
||
|
users.users.${cfg.user} =
|
||
5 years ago
|
if cfg.user == "roon-server" then {
|
||
|
isSystemUser = true;
|
||
|
description = "Roon Server user";
|
||
5 years ago
|
group = cfg.group;
|
||
|
extraGroups = [ "audio" ];
|
||
5 years ago
|
}
|
||
|
else {};
|
||
5 years ago
|
};
|
||
|
}
|