8 cfg = config.services.hqplayerd;
10 # XXX: This is hard-coded in the distributed binary, don't try to change it.
11 stateDir = "/var/lib/hqplayer";
12 configDir = "/etc/hqplayer";
16 services.hqplayerd = {
17 enable = lib.mkEnableOption "HQPlayer Embedded";
20 username = lib.mkOption {
21 type = lib.types.nullOr lib.types.str;
24 Username used for HQPlayer's WebUI.
26 Without this you will need to manually create the credentials after
27 first start by going to http://your.ip/8088/auth
31 password = lib.mkOption {
32 type = lib.types.nullOr lib.types.str;
35 Password used for HQPlayer's WebUI.
37 Without this you will need to manually create the credentials after
38 first start by going to http://your.ip/8088/auth
43 licenseFile = lib.mkOption {
44 type = lib.types.nullOr lib.types.path;
47 Path to the HQPlayer license key file.
49 Without this, the service will run in trial mode and restart every 30
54 openFirewall = lib.mkOption {
55 type = lib.types.bool;
58 Opens ports needed for the WebUI and controller API.
62 config = lib.mkOption {
63 type = lib.types.nullOr lib.types.lines;
66 HQplayer daemon configuration, written to /etc/hqplayer/hqplayerd.xml.
68 Refer to share/doc/hqplayerd/readme.txt in the hqplayerd derivation for possible values.
74 config = lib.mkIf cfg.enable {
78 (cfg.auth.username != null -> cfg.auth.password != null)
79 && (cfg.auth.password != null -> cfg.auth.username != null);
80 message = "You must set either both services.hqplayer.auth.username and password, or neither.";
86 "hqplayer/hqplayerd.xml" = lib.mkIf (cfg.config != null) {
87 source = pkgs.writeText "hqplayerd.xml" cfg.config;
89 "hqplayer/hqplayerd4-key.xml" = lib.mkIf (cfg.licenseFile != null) { source = cfg.licenseFile; };
91 systemPackages = [ pkg ];
94 networking.firewall = lib.mkIf cfg.openFirewall {
103 "d ${configDir} 0755 hqplayer hqplayer - -"
104 "d ${stateDir} 0755 hqplayer hqplayer - -"
105 "d ${stateDir}/home 0755 hqplayer hqplayer - -"
110 services.hqplayerd = {
111 wantedBy = [ "multi-user.target" ];
112 after = [ "systemd-tmpfiles-setup.service" ];
114 environment.HOME = "${stateDir}/home";
116 unitConfig.ConditionPathExists = [
121 restartTriggers = lib.optionals (cfg.config != null) [
122 config.environment.etc."hqplayer/hqplayerd.xml".source
127 cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}"
128 chmod -R u+wX "${stateDir}/web"
130 if [ ! -f "${configDir}/hqplayerd.xml" ]; then
131 echo "creating initial config file"
132 install -m 0644 "${pkg}/etc/hqplayer/hqplayerd.xml" "${configDir}/hqplayerd.xml"
135 + lib.optionalString (cfg.auth.username != null && cfg.auth.password != null) ''
136 ${pkg}/bin/hqplayerd -s ${cfg.auth.username} ${cfg.auth.password}
142 hqplayer.gid = config.ids.gids.hqplayer;
147 description = "hqplayer daemon user";
153 uid = config.ids.uids.hqplayer;