Merge pull request #133603 from lovesegfault/hqplayerd-settings

nixos/hqplayerd: allow configuration from Nix
This commit is contained in:
Bernardo Meurer 2021-08-12 19:30:23 +00:00 committed by GitHub
commit d11ed5661e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,17 +14,6 @@ in
services.hqplayerd = { services.hqplayerd = {
enable = mkEnableOption "HQPlayer Embedded"; 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 = { auth = {
username = mkOption { username = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -49,11 +38,32 @@ 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 { openFirewall = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
Open TCP port 8088 in the firewall for the server. 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 = { environment = {
etc = { 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; }; "hqplayer/hqplayerd4-key.xml" = mkIf (cfg.licenseFile != null) { source = cfg.licenseFile; };
"modules-load.d/taudio2.conf".source = "${pkg}/etc/modules-load.d/taudio2.conf"; "modules-load.d/taudio2.conf".source = "${pkg}/etc/modules-load.d/taudio2.conf";
}; };
@ -77,7 +88,7 @@ in
}; };
networking.firewall = mkIf cfg.openFirewall { networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 8088 ]; allowedTCPPorts = [ 8088 4321 ];
}; };
services.udev.packages = [ pkg ]; services.udev.packages = [ pkg ];
@ -99,6 +110,8 @@ in
unitConfig.ConditionPathExists = [ configDir stateDir ]; unitConfig.ConditionPathExists = [ configDir stateDir ];
restartTriggers = [ config.environment.etc."hqplayer/hqplayerd.xml".source ];
preStart = '' preStart = ''
cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}" cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}"
chmod -R u+wX "${stateDir}/web" chmod -R u+wX "${stateDir}/web"