nixos/hqplayerd: allow configuration from Nix

This commit is contained in:
Bernardo Meurer 2021-08-12 02:37:38 -07:00
parent b43049dbd7
commit e5aa940305
No known key found for this signature in database
GPG Key ID: F4C0D53B8D14C246

View File

@ -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"