88 lines
2.4 KiB
Nix
Raw Normal View History

2021-06-14 23:31:09 +03:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.spotifyd-user;
tomlFormat = pkgs.formats.toml { };
configFile = tomlFormat.generate "spotifyd.conf" cfg.settings;
in {
options.services.spotifyd-user = {
enable = mkEnableOption "SpotifyD connect";
2021-02-07 02:38:11 +03:00
2021-06-14 23:31:09 +03:00
package = mkOption {
type = types.package;
default = pkgs.spotifyd;
defaultText = literalExample "pkgs.spotifyd";
example =
literalExample "(pkgs.spotifyd.override { withKeyring = true; })";
description = ''
The <literal>spotifyd</literal> package to use.
Can be used to specify extensions.
'';
};
settings = mkOption {
type = tomlFormat.type;
default = { };
description = "Configuration for spotifyd";
example = literalExample ''
{
global = {
username = "Alex";
password = "foo";
device_name = "nix";
};
}
'';
2021-02-17 01:00:52 +03:00
};
2021-02-07 02:38:11 +03:00
};
2021-06-14 23:31:09 +03:00
config = mkMerge [
2021-10-24 23:28:03 +03:00
(lib.mkIf cfg.enable {
2021-06-14 23:31:09 +03:00
systemd.user.services.spotifyd = {
2021-06-27 20:44:49 +03:00
path = [ pkgs.zsh pkgs.pass-nodmenu ];
unitConfig = {
Description = "Spotify daemon";
Requires = [ "pipewire-pulse.service" ];
After = [ "easyeffects.service" ];
};
wantedBy = [ "multi-user.target" ];
2021-06-14 23:31:09 +03:00
serviceConfig = {
ExecStart =
"${cfg.package}/bin/spotifyd --no-daemon --config-path ${configFile}";
Restart = "always";
RestartSec = 12;
};
};
})
{
2021-06-16 23:42:44 +03:00
secrets.spotify = {
owner = "alukard";
services = [ "spotifyd" ];
};
2021-06-14 23:31:09 +03:00
services.spotifyd-user = {
2021-10-24 23:14:54 +03:00
# enable = true;
package = (pkgs.spotifyd.override { withALSA = false; withPulseAudio = true; withPortAudio = false; withMpris = true; });
2021-06-14 23:31:09 +03:00
settings = {
global = {
2021-06-16 23:42:44 +03:00
username = "alukard.files@gmail.com";
2021-06-27 20:44:49 +03:00
password_cmd = "pass spotify";
2021-06-14 23:31:09 +03:00
backend = "pulseaudio";
volume_controller = "softvol";
2021-08-17 23:38:13 +03:00
device_name = "${config.device}";
2021-06-14 23:31:09 +03:00
bitrate = 320;
no_audio_cache = true;
volume_normalisation = false;
device_type = "computer";
cache_path = "${config.users.users.alukard.home}/.cache/spotifyd";
};
};
};
2021-10-24 23:14:54 +03:00
home-manager.users.alukard.home.packages = with pkgs; [
spotify-tui
spotifywm
];
2021-06-14 23:31:09 +03:00
}
];
2021-09-15 23:17:00 +03:00
}