git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #112971 from lovesegfault/roon-bridge

roon-bridge: init at 1.8-795

commit2d29f4f2e79342c2dd1ee95cdd47683059652e27 authorBernardo Meurer <bernardo@meurer.org> dateMon 14 Jun 2021, 19:57 (5 years ago) parent687c03ac8f95fd
3 files changed+142
nixos/modules/services/audio/roon-bridge.nix+74 pkgs/servers/roon-bridge/default.nix+66 pkgs/top-level/all-packages.nix+2
nixos/modules/services/audio/roon-bridge.nixnew file+74
@@ -0,0 +1,74 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ name = "roon-bridge";
7+ cfg = config.services.roon-bridge;
8+in {
9+ options = {
10+ services.roon-bridge = {
11+ enable = mkEnableOption "Roon Bridge";
12+ openFirewall = mkOption {
13+ type = types.bool;
14+ default = false;
15+ description = ''
16+ Open ports in the firewall for the bridge.
17+
18+ UDP: 9003
19+ TCP: 9100 - 9200
20+ '';
21+ };
22+ user = mkOption {
23+ type = types.str;
24+ default = "roon-bridge";
25+ description = ''
26+ User to run the Roon bridge as.
27+ '';
28+ };
29+ group = mkOption {
30+ type = types.str;
31+ default = "roon-bridge";
32+ description = ''
33+ Group to run the Roon Bridge as.
34+ '';
35+ };
36+ };
37+ };
38+
39+ config = mkIf cfg.enable {
40+ systemd.services.roon-bridge = {
41+ after = [ "network.target" ];
42+ description = "Roon Bridge";
43+ wantedBy = [ "multi-user.target" ];
44+
45+ environment.ROON_DATAROOT = "/var/lib/${name}";
46+
47+ serviceConfig = {
48+ ExecStart = "${pkgs.roon-bridge}/start.sh";
49+ LimitNOFILE = 8192;
50+ User = cfg.user;
51+ Group = cfg.group;
52+ StateDirectory = name;
53+ };
54+ };
55+
56+ networking.firewall = mkIf cfg.openFirewall {
57+ allowedTCPPortRanges = [
58+ { from = 9100; to = 9200; }
59+ ];
60+ allowedUDPPorts = [ 9003 ];
61+ };
62+
63+
64+ users.groups.${cfg.group} = {};
65+ users.users.${cfg.user} =
66+ if cfg.user == "roon-bridge" then {
67+ isSystemUser = true;
68+ description = "Roon Bridge user";
69+ group = cfg.group;
70+ extraGroups = [ "audio" ];
71+ }
72+ else {};
73+ };
74+}
pkgs/servers/roon-bridge/default.nixnew file+66
@@ -0,0 +1,66 @@
1+{ alsa-lib
2+, alsa-utils
3+, autoPatchelfHook
4+, fetchurl
5+, lib
6+, makeWrapper
7+, stdenv
8+, zlib
9+}:
10+
11+stdenv.mkDerivation rec {
12+ pname = "roon-bridge";
13+ version = "1.8-795";
14+
15+ # N.B. The URL is unstable. I've asked for them to provide a stable URL but
16+ # they have ignored me. If this package fails to build for you, you may need
17+ # to update the version and sha256.
18+ # c.f. https://community.roonlabs.com/t/latest-roon-server-is-not-available-for-download-on-nixos/118129
19+ src = fetchurl {
20+ url = "https://web.archive.org/web/20210610172810/http://download.roonlabs.com/builds/RoonBridge_linuxx64.tar.bz2";
21+ sha256 = "sha256-ahdy0/TBOyMfCt4VTkcDTZGAFmwQJT2KvZuMtFcAY3w=";
22+ };
23+
24+ buildInputs = [
25+ alsa-lib
26+ alsa-utils
27+ zlib
28+ ];
29+
30+ nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
31+
32+ installPhase = ''
33+ runHook preInstall
34+ mkdir -p $out
35+ mv * $out
36+ runHook postInstall
37+ '';
38+
39+ postFixup =
40+ let
41+ linkFix = bin: ''
42+ sed -i '/ulimit/d' ${bin}
43+ sed -i '/ln -sf/d' ${bin}
44+ ln -sf $out/RoonMono/bin/mono-sgen $out/RoonMono/bin/${builtins.baseNameOf bin}
45+ '';
46+ wrapFix = bin: ''
47+ wrapProgram ${bin} --prefix PATH : ${lib.makeBinPath [ alsa-utils ]}
48+ '';
49+ in
50+ ''
51+ ${linkFix "$out/Bridge/RAATServer"}
52+ ${linkFix "$out/Bridge/RoonBridge"}
53+ ${linkFix "$out/Bridge/RoonBridgeHelper"}
54+
55+ ${wrapFix "$out/check.sh"}
56+ ${wrapFix "$out/start.sh"}
57+ '';
58+
59+ meta = with lib; {
60+ description = "The music player for music lovers";
61+ homepage = "https://roonlabs.com";
62+ license = licenses.unfree;
63+ maintainers = with maintainers; [ lovesegfault ];
64+ platforms = platforms.linux;
65+ };
66+}
pkgs/top-level/all-packages.nix+2
@@ -19890,6 +19890,8 @@ in
1989019890 boost = boost17x;
1989119891 };
1989219892
19893+ roon-bridge = callPackage ../servers/roon-bridge { };
19894+
1989319895 roon-server = callPackage ../servers/roon-server { };
1989419896
1989519897 s6 = skawarePackages.s6;