2019-10-18 21:04:08 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.spotifyd;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "spotifyd.conf" ''
|
2020-02-02 00:39:17 +01:00
|
|
|
${generators.toINI { } cfg.settings}
|
2019-10-18 21:04:08 +02:00
|
|
|
'';
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-10-18 21:04:08 +02:00
|
|
|
options.services.spotifyd = {
|
|
|
|
enable = mkEnableOption "SpotifyD connect";
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = types.attrsOf (types.attrsOf types.str);
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2019-10-18 21:04:08 +02:00
|
|
|
description = "Configuration for spotifyd";
|
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
global = {
|
|
|
|
user = "Alex";
|
|
|
|
password = "foo";
|
|
|
|
device_name = "nix";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ pkgs.spotifyd ];
|
|
|
|
|
|
|
|
systemd.user.services.spotifyd = {
|
|
|
|
Unit = {
|
|
|
|
Description = "spotify daemon";
|
|
|
|
Documentation = "https://github.com/Spotifyd/spotifyd";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
|
|
|
|
|
|
Service = {
|
2020-02-02 00:39:17 +01:00
|
|
|
ExecStart =
|
|
|
|
"${pkgs.spotifyd}/bin/spotifyd --no-daemon --config-path ${configFile}";
|
2019-10-18 21:04:08 +02:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 12;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|