2020-10-12 00:22:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.spotifyd;
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
configFile = tomlFormat.generate "spotifyd.conf" cfg.settings;
|
2020-10-12 00:22:58 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
options.services.spotifyd = {
|
|
|
|
enable = mkEnableOption "SpotifyD connect";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.spotifyd;
|
2021-11-04 16:42:44 +00:00
|
|
|
defaultText = literalExpression "pkgs.spotifyd";
|
2020-10-12 00:22:58 +00:00
|
|
|
example =
|
2021-11-04 16:42:44 +00:00
|
|
|
literalExpression "(pkgs.spotifyd.override { withKeyring = true; })";
|
2020-10-12 00:22:58 +00:00
|
|
|
description = ''
|
|
|
|
The <literal>spotifyd</literal> package to use.
|
|
|
|
Can be used to specify extensions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
2021-07-02 22:36:30 +00:00
|
|
|
type = tomlFormat.type;
|
2020-10-12 00:22:58 +00:00
|
|
|
default = { };
|
|
|
|
description = "Configuration for spotifyd";
|
2021-11-04 16:42:44 +00:00
|
|
|
example = literalExpression ''
|
2020-10-12 00:22:58 +00:00
|
|
|
{
|
|
|
|
global = {
|
|
|
|
username = "Alex";
|
|
|
|
password = "foo";
|
|
|
|
device_name = "nix";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-11-04 16:42:44 +00:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.spotifyd" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
systemd.user.services.spotifyd = {
|
|
|
|
Unit = {
|
|
|
|
Description = "spotify daemon";
|
|
|
|
Documentation = "https://github.com/Spotifyd/spotifyd";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart =
|
|
|
|
"${cfg.package}/bin/spotifyd --no-daemon --config-path ${configFile}";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 12;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|