1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-19 00:09:48 +01:00
home-manager/modules/services/spotifyd.nix

70 lines
1.5 KiB
Nix
Raw Normal View History

2019-10-18 21:04:08 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.spotifyd;
tomlFormat = pkgs.formats.toml { };
configFile = tomlFormat.generate "spotifyd.conf" 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";
package = mkOption {
type = types.package;
default = pkgs.spotifyd;
defaultText = literalExpression "pkgs.spotifyd";
example =
literalExpression "(pkgs.spotifyd.override { withKeyring = true; })";
description = ''
The <literal>spotifyd</literal> package to use.
Can be used to specify extensions.
'';
};
2019-10-18 21:04:08 +02:00
settings = mkOption {
type = tomlFormat.type;
2020-02-02 00:39:17 +01:00
default = { };
2019-10-18 21:04:08 +02:00
description = "Configuration for spotifyd";
example = literalExpression ''
2019-10-18 21:04:08 +02:00
{
global = {
2020-04-17 22:18:33 +02:00
username = "Alex";
2019-10-18 21:04:08 +02:00
password = "foo";
device_name = "nix";
};
}
'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.spotifyd" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ];
2019-10-18 21:04:08 +02:00
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 =
"${cfg.package}/bin/spotifyd --no-daemon --config-path ${configFile}";
2019-10-18 21:04:08 +02:00
Restart = "always";
RestartSec = 12;
};
};
};
}