Files
home-manager/modules/services/spotifyd.nix
Austin Horstman 355734d876 treewide: remove literalExpression where unneeded
`literalExpression` is intended just to signify code that needs to stay
a string that gets represented exactly as-is for docs. It has been
misused heavily and people get confused repeatedly on when or not to use
it because of the rampant misuse.
2026-05-17 21:43:25 -05:00

65 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.spotifyd;
tomlFormat = pkgs.formats.toml { };
configFile = tomlFormat.generate "spotifyd.conf" cfg.settings;
in
{
options.services.spotifyd = {
enable = lib.mkEnableOption "SpotifyD connect";
package = lib.mkPackageOption pkgs "spotifyd" {
example = "(pkgs.spotifyd.override { withKeyring = true; })";
extraDescription = ''
Can be used to specify extensions.
'';
};
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
description = "Configuration for spotifyd";
example = {
global = {
username = "Alex";
password = "foo";
device_name = "nix";
};
};
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.spotifyd" pkgs lib.platforms.linux)
];
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;
};
};
};
}