Merge pull request #126798 from lovesegfault/nixos-hqplayerd

nixos/hqplayerd: init

authored by

Bernardo Meurer and committed by
GitHub
39bce834 c9f8846d

+174 -5
+2
nixos/modules/misc/ids.nix
··· 348 348 #mailman = 316; # removed 2019-08-30 349 349 zigbee2mqtt = 317; 350 350 # shadow = 318; # unused 351 + hqplayer = 319; 351 352 352 353 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 353 354 ··· 650 651 #mailman = 316; # removed 2019-08-30 651 652 zigbee2mqtt = 317; 652 653 shadow = 318; 654 + hqplayer = 319; 653 655 654 656 # When adding a gid, make sure it doesn't match an existing 655 657 # uid. Users and groups with the same name should have equal
+2 -1
nixos/modules/module-list.nix
··· 244 244 ./services/amqp/rabbitmq.nix 245 245 ./services/audio/alsa.nix 246 246 ./services/audio/botamusique.nix 247 + ./services/audio/hqplayerd.nix 248 + ./services/audio/icecast.nix 247 249 ./services/audio/jack.nix 248 - ./services/audio/icecast.nix 249 250 ./services/audio/jmusicbot.nix 250 251 ./services/audio/liquidsoap.nix 251 252 ./services/audio/mpd.nix
+166
nixos/modules/services/audio/hqplayerd.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.hqplayerd; 7 + pkg = pkgs.hqplayerd; 8 + # XXX: This is hard-coded in the distributed binary, don't try to change it. 9 + stateDir = "/var/lib/hqplayer"; 10 + configDir = "/etc/hqplayer"; 11 + in 12 + { 13 + options = { 14 + services.hqplayerd = { 15 + enable = mkEnableOption "HQPlayer Embedded"; 16 + 17 + licenseFile = mkOption { 18 + type = types.nullOr types.path; 19 + default = null; 20 + description = '' 21 + Path to the HQPlayer license key file. 22 + 23 + Without this, the service will run in trial mode and restart every 30 24 + minutes. 25 + ''; 26 + }; 27 + 28 + auth = { 29 + username = mkOption { 30 + type = types.nullOr types.str; 31 + default = null; 32 + description = '' 33 + Username used for HQPlayer's WebUI. 34 + 35 + Without this you will need to manually create the credentials after 36 + first start by going to http://your.ip/8088/auth 37 + ''; 38 + }; 39 + 40 + password = mkOption { 41 + type = types.nullOr types.str; 42 + default = null; 43 + description = '' 44 + Password used for HQPlayer's WebUI. 45 + 46 + Without this you will need to manually create the credentials after 47 + first start by going to http://your.ip/8088/auth 48 + ''; 49 + }; 50 + }; 51 + 52 + openFirewall = mkOption { 53 + type = types.bool; 54 + default = false; 55 + description = '' 56 + Open TCP port 8088 in the firewall for the server. 57 + ''; 58 + }; 59 + 60 + user = mkOption { 61 + type = types.str; 62 + default = "hqplayer"; 63 + description = '' 64 + User account under which hqplayerd runs. 65 + ''; 66 + }; 67 + 68 + group = mkOption { 69 + type = types.str; 70 + default = "hqplayer"; 71 + description = '' 72 + Group account under which hqplayerd runs. 73 + ''; 74 + }; 75 + }; 76 + }; 77 + 78 + config = mkIf cfg.enable { 79 + assertions = [ 80 + { 81 + assertion = (cfg.auth.username != null -> cfg.auth.password != null) 82 + && (cfg.auth.password != null -> cfg.auth.username != null); 83 + message = "You must set either both services.hqplayer.auth.username and password, or neither."; 84 + } 85 + ]; 86 + 87 + environment = { 88 + etc = { 89 + "hqplayer/hqplayerd4-key.xml" = mkIf (cfg.licenseFile != null) { source = cfg.licenseFile; }; 90 + "modules-load.d/taudio2.conf".source = "${pkg}/etc/modules-load.d/taudio2.conf"; 91 + }; 92 + systemPackages = [ pkg ]; 93 + }; 94 + 95 + networking.firewall = mkIf cfg.openFirewall { 96 + allowedTCPPorts = [ 8088 ]; 97 + }; 98 + 99 + services.udev.packages = [ pkg ]; 100 + 101 + systemd = { 102 + tmpfiles.rules = [ 103 + "d ${configDir} 0755 ${cfg.user} ${cfg.group} - -" 104 + "d ${stateDir} 0755 ${cfg.user} ${cfg.group} - -" 105 + ]; 106 + 107 + services.hqplayerd = { 108 + description = "HQPlayer daemon"; 109 + wantedBy = [ "multi-user.target" ]; 110 + requires = [ "network-online.target" "sound.target" "systemd-udev-settle.service" ]; 111 + after = [ "network-online.target" "sound.target" "systemd-udev-settle.service" "local-fs.target" "remote-fs.target" "systemd-tmpfiles-setup.service" ]; 112 + 113 + unitConfig.ConditionPathExists = [ configDir stateDir ]; 114 + 115 + preStart = 116 + let 117 + blankCfg = pkgs.writeText "hqplayerd.xml" '' 118 + <?xml version="1.0" encoding="utf-8"?> 119 + <xml> 120 + </xml> 121 + ''; 122 + in 123 + '' 124 + cp -r "${pkg}/var/lib/hqplayer/web" "${stateDir}" 125 + chmod -R u+wX "${stateDir}/web" 126 + 127 + if [ ! -f "${configDir}/hqplayerd.xml" ]; then 128 + echo "creating blank config file" 129 + install -m 0644 "${blankCfg}" "${configDir}/hqplayerd.xml" 130 + fi 131 + '' + optionalString (cfg.auth.username != null && cfg.auth.password != null) '' 132 + ${pkg}/bin/hqplayerd -s ${cfg.auth.username} ${cfg.auth.password} 133 + ''; 134 + 135 + serviceConfig = { 136 + ExecStart = "${pkg}/bin/hqplayerd"; 137 + 138 + User = cfg.user; 139 + Group = cfg.group; 140 + 141 + Restart = "on-failure"; 142 + RestartSec = 5; 143 + 144 + Nice = -10; 145 + IOSchedulingClass = "realtime"; 146 + LimitMEMLOCK = "1G"; 147 + LimitNICE = -10; 148 + LimitRTPRIO = 98; 149 + }; 150 + }; 151 + }; 152 + 153 + users.groups = mkIf (cfg.group == "hqplayer") { 154 + hqplayer.gid = config.ids.gids.hqplayer; 155 + }; 156 + 157 + users.users = mkIf (cfg.user == "hqplayer") { 158 + hqplayer = { 159 + description = "hqplayer daemon user"; 160 + extraGroups = [ "audio" ]; 161 + group = cfg.group; 162 + uid = config.ids.uids.hqplayer; 163 + }; 164 + }; 165 + }; 166 + }
+4 -4
pkgs/servers/hqplayerd/default.nix
··· 17 17 18 18 stdenv.mkDerivation rec { 19 19 pname = "hqplayerd"; 20 - version = "4.24.2-63"; 20 + version = "4.25.0-64"; 21 21 22 22 src = fetchurl { 23 23 url = "https://www.signalyst.eu/bins/${pname}/fc34/${pname}-${version}.fc34.x86_64.rpm"; 24 - sha256 = "sha256-6JUgHDO+S73n/IVQhkmC0Nw4GQVzTLtiBbz/wZiflRg="; 24 + sha256 = "sha256-KLP7g1SQzVKu9Hnptb6s0FwmLSjhlAINJoJskja+bDM="; 25 25 }; 26 26 27 27 unpackPhase = '' ··· 70 70 cp ./usr/share/doc/hqplayerd/* $out/share/doc/hqplayerd 71 71 72 72 # misc service support files 73 - mkdir -p $out/var/lib/hqplayerd 74 - cp -r ./var/lib/hqplayer/web $out/var/lib/hqplayer 73 + mkdir -p $out/var/lib/hqplayer 74 + cp -r ./var/lib/hqplayer/web $out/var/lib/hqplayer/web 75 75 76 76 runHook postInstall 77 77 '';