From 725e2793dd1c3e57e46d1a282d6d623c285bb95f Mon Sep 17 00:00:00 2001 From: Steve Elliott <1699155+Steell@users.noreply.github.com> Date: Fri, 21 Jun 2019 14:58:20 -0400 Subject: [PATCH] roon-server: init at 100600401 --- nixos/modules/module-list.nix | 1 + nixos/modules/services/audio/roon-server.nix | 49 +++++++++++++++ pkgs/servers/roon-server/default.nix | 65 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 117 insertions(+) create mode 100644 nixos/modules/services/audio/roon-server.nix create mode 100644 pkgs/servers/roon-server/default.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 50e3078d9770..ea072aa885ee 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -190,6 +190,7 @@ ./services/audio/liquidsoap.nix ./services/audio/mpd.nix ./services/audio/mopidy.nix + ./services/audio/roon-server.nix ./services/audio/slimserver.nix ./services/audio/snapserver.nix ./services/audio/squeezelite.nix diff --git a/nixos/modules/services/audio/roon-server.nix b/nixos/modules/services/audio/roon-server.nix new file mode 100644 index 000000000000..9562ad1b164e --- /dev/null +++ b/nixos/modules/services/audio/roon-server.nix @@ -0,0 +1,49 @@ +{ 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. + + UDP: 9003 + TCP: 9100 - 9200 + ''; + }; + }; + }; + + 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 = { + ExecStart = "${pkgs.roon-server}/opt/start.sh"; + LimitNOFILE = 8192; + DynamicUser = true; + SupplementaryGroups = "audio"; + StateDirectory = name; + }; + }; + + networking.firewall = mkIf cfg.openFirewall { + allowedTCPPortRanges = [ + { from = 9100; to = 9200; } + ]; + allowedUDPPorts = [ 9003 ]; + }; + }; +} diff --git a/pkgs/servers/roon-server/default.nix b/pkgs/servers/roon-server/default.nix new file mode 100644 index 000000000000..64b212eb49fb --- /dev/null +++ b/pkgs/servers/roon-server/default.nix @@ -0,0 +1,65 @@ +{ alsaLib, alsaUtils, cifs-utils, fetchurl, ffmpeg, libav, mono, stdenv }: + +with stdenv.lib; +stdenv.mkDerivation rec { + name = "roon-server"; + version = "100600401"; + + src = fetchurl { + url = "http://download.roonlabs.com/updates/stable/RoonServer_linuxx64_${version}.tar.bz2"; + sha256 = "121mmdh35q4bpgsqhcps6a6q1f4ld9v4hq9gp181bf2n779pk8sh"; + }; + + installPhase = '' + runHook preInstall + + # Check script + sed -i '3i PATH=$PATH:${makeBinPath [ cifs-utils ffmpeg libav ]}' check.sh + sed -i '/check_ulimit$/d' check.sh + + # Start script + sed -i '3i PATH=$PATH:${makeBinPath [ alsaUtils cifs-utils ffmpeg libav ]}' start.sh + + # Debug logging + sed -i '/--debug--gc=sgen --server/exec "$HARDLINK" --debug --gc=sgen --server "$SCRIPT.exe" "$@" -storagetrace -watchertrace' Appliance/RoonAppliance + + # Binaries + sed -i '/# boost ulimit/,+2 d' Appliance/RAATServer + sed -i '/# boost ulimit/,+2 d' Appliance/RoonAppliance + sed -i '/# boost ulimit/,+2 d' Server/RoonServer + sed -i '/ln -sf/ d' Appliance/RAATServer + sed -i '/ln -sf/ d' Appliance/RoonAppliance + sed -i '/ln -sf/ d' Server/RoonServer + mkdir -p $out/opt + mv * $out/opt + ln -sf $out/opt/RoonMono/bin/mono-sgen $out/opt/RoonMono/bin/RoonServer + ln -sf $out/opt/RoonMono/bin/mono-sgen $out/opt/RoonMono/bin/RoonAppliance + ln -sf $out/opt/RoonMono/bin/mono-sgen $out/opt/RoonMono/bin/RAATServer + + runHook postInstall + ''; + + preFixup = '' + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${alsaLib}/lib" \ + $out/opt/RoonMono/bin/mono-sgen + + # Checkers + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${alsaLib}/lib" \ + $out/opt/Appliance/check_alsa + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + $out/opt/Appliance/check_bincompat + ''; + + meta = { + description = "The music player for music lovers."; + homepage = https://roonlabs.com; + license = licenses.unfree; + maintainers = with maintainers; [ steell ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fca009a43387..65b5c6868785 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14715,6 +14715,8 @@ in }; }; + roon-server = callPackage ../servers/roon-server { }; + s6 = skawarePackages.s6; s6-rc = skawarePackages.s6-rc;