From 7c122d687b196cd87112cc92a1bfb7f908480fd5 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 12 Aug 2021 00:37:36 -0700 Subject: [PATCH 1/3] nixos/hqplayerd: sort options --- nixos/modules/services/audio/hqplayerd.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/audio/hqplayerd.nix b/nixos/modules/services/audio/hqplayerd.nix index 6eeaffce1b1..3da3635eb98 100644 --- a/nixos/modules/services/audio/hqplayerd.nix +++ b/nixos/modules/services/audio/hqplayerd.nix @@ -14,17 +14,6 @@ in services.hqplayerd = { enable = mkEnableOption "HQPlayer Embedded"; - licenseFile = mkOption { - type = types.nullOr types.path; - default = null; - description = '' - Path to the HQPlayer license key file. - - Without this, the service will run in trial mode and restart every 30 - minutes. - ''; - }; - auth = { username = mkOption { type = types.nullOr types.str; @@ -49,6 +38,17 @@ in }; }; + licenseFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Path to the HQPlayer license key file. + + Without this, the service will run in trial mode and restart every 30 + minutes. + ''; + }; + openFirewall = mkOption { type = types.bool; default = false; From b43049dbd7e6a4effac6257d264fb2e1107df4b6 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 12 Aug 2021 02:36:42 -0700 Subject: [PATCH 2/3] nixos/hqplayerd: also open controller port --- nixos/modules/services/audio/hqplayerd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/audio/hqplayerd.nix b/nixos/modules/services/audio/hqplayerd.nix index 3da3635eb98..64a6436e670 100644 --- a/nixos/modules/services/audio/hqplayerd.nix +++ b/nixos/modules/services/audio/hqplayerd.nix @@ -53,7 +53,7 @@ in type = types.bool; default = false; description = '' - Open TCP port 8088 in the firewall for the server. + Opens ports needed for the WebUI and controller API. ''; }; }; @@ -77,7 +77,7 @@ in }; networking.firewall = mkIf cfg.openFirewall { - allowedTCPPorts = [ 8088 ]; + allowedTCPPorts = [ 8088 4321 ]; }; services.udev.packages = [ pkg ]; From e5aa9403053aec8b9aafe38acd4aeb79a6c86490 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 12 Aug 2021 02:37:38 -0700 Subject: [PATCH 3/3] nixos/hqplayerd: allow configuration from Nix --- nixos/modules/services/audio/hqplayerd.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nixos/modules/services/audio/hqplayerd.nix b/nixos/modules/services/audio/hqplayerd.nix index 64a6436e670..ed8de390417 100644 --- a/nixos/modules/services/audio/hqplayerd.nix +++ b/nixos/modules/services/audio/hqplayerd.nix @@ -56,6 +56,16 @@ in Opens ports needed for the WebUI and controller API. ''; }; + + config = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + HQplayer daemon configuration, written to /etc/hqplayer/hqplayerd.xml. + + Refer to ${pkg}/share/doc/hqplayerd/readme.txt for possible values. + ''; + }; }; }; @@ -70,6 +80,7 @@ in environment = { etc = { + "hqplayer/hqplayerd.xml" = mkIf (cfg.config != null) { source = pkgs.writeText "hqplayerd.xml" cfg.config; }; "hqplayer/hqplayerd4-key.xml" = mkIf (cfg.licenseFile != null) { source = cfg.licenseFile; }; "modules-load.d/taudio2.conf".source = "${pkg}/etc/modules-load.d/taudio2.conf"; }; @@ -99,6 +110,8 @@ in unitConfig.ConditionPathExists = [ configDir stateDir ]; + restartTriggers = [ config.environment.etc."hqplayer/hqplayerd.xml".source ]; + preStart = '' cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}" chmod -R u+wX "${stateDir}/web"