2019-10-18 19:04:08 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.spotifyd;
|
|
|
|
|
2021-01-29 18:44:03 +00:00
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
configFile = tomlFormat.generate "spotifyd.conf" cfg.settings;
|
2019-10-18 19:04:08 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2019-10-18 19:04:08 +00:00
|
|
|
options.services.spotifyd = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "SpotifyD connect";
|
2019-10-18 19:04:08 +00:00
|
|
|
|
2020-07-15 12:01:01 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.spotifyd;
|
2021-10-09 09:14:08 +00:00
|
|
|
defaultText = literalExpression "pkgs.spotifyd";
|
2020-07-15 12:01:01 +00:00
|
|
|
example =
|
2021-10-09 09:14:08 +00:00
|
|
|
literalExpression "(pkgs.spotifyd.override { withKeyring = true; })";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
The `spotifyd` package to use.
|
2020-07-15 12:01:01 +00:00
|
|
|
Can be used to specify extensions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-10-18 19:04:08 +00:00
|
|
|
settings = mkOption {
|
2021-01-29 18:44:03 +00:00
|
|
|
type = tomlFormat.type;
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Configuration for spotifyd";
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2019-10-18 19:04:08 +00:00
|
|
|
{
|
|
|
|
global = {
|
2020-04-17 20:18:33 +00:00
|
|
|
username = "Alex";
|
2019-10-18 19:04:08 +00:00
|
|
|
password = "foo";
|
|
|
|
device_name = "nix";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 21:24:27 +00:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.spotifyd" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2020-07-15 12:01:01 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2019-10-18 19:04:08 +00:00
|
|
|
|
|
|
|
systemd.user.services.spotifyd = {
|
|
|
|
Unit = {
|
|
|
|
Description = "spotify daemon";
|
|
|
|
Documentation = "https://github.com/Spotifyd/spotifyd";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
|
|
|
|
|
|
Service = {
|
2020-02-01 23:39:17 +00:00
|
|
|
ExecStart =
|
2020-07-15 12:01:01 +00:00
|
|
|
"${cfg.package}/bin/spotifyd --no-daemon --config-path ${configFile}";
|
2019-10-18 19:04:08 +00:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 12;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|