2021-03-11 04:20:00 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.spotifyd;
|
|
|
|
|
|
|
|
format = pkgs.formats.toml { };
|
|
|
|
configFile = format.generate "spotifyd.conf" {
|
|
|
|
global = {
|
|
|
|
backend = "portaudio";
|
|
|
|
};
|
|
|
|
spotifyd = cfg.settings;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.spotifyd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2021-03-11 04:20:00 +00:00
|
|
|
Whether to enable the spotifyd service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = pkgs.spotifyd;
|
|
|
|
defaultText = "pkgs.spotifyd";
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2021-03-11 04:20:00 +00:00
|
|
|
The spotifyd package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = types.nullOr format.type;
|
|
|
|
default = null;
|
|
|
|
example = {
|
|
|
|
bitrate = 160;
|
|
|
|
volume_normalisation = true;
|
|
|
|
};
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2023-06-22 11:21:32 +00:00
|
|
|
Configuration for spotifyd, see <https://spotifyd.github.io/spotifyd/config/File.html>
|
2021-03-11 04:20:00 +00:00
|
|
|
for supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
launchd.user.agents.spotifyd = {
|
|
|
|
serviceConfig.ProgramArguments = [ "${cfg.package}/bin/spotifyd" "--no-daemon" ]
|
|
|
|
++ optionals (cfg.settings != null) [ "--config-path=${configFile}" ];
|
|
|
|
serviceConfig = {
|
|
|
|
KeepAlive = true;
|
|
|
|
RunAtLoad = true;
|
|
|
|
ThrottleInterval = 30;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|