grimm-nixos-laptop/modules/spotify-tui.nix

97 lines
2.8 KiB
Nix
Raw Normal View History

2024-04-10 16:51:28 +02:00
{ config, pkgs, ... }:
2024-02-02 12:59:59 +01:00
let
spotifyd_cache_dir = "/tmp/spotifyd";
2024-04-10 16:51:28 +02:00
in
{
nixpkgs.overlays = [
(final: prev: {
spotifyd = prev.spotifyd.overrideAttrs (old: {
postInstall = ''
mkdir -p $out/share/dbus-1/system.d/
tee $out/share/dbus-1/system.d/org.mpris.MediaPlayer2.spotifyd.conf <<END
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
2024-02-02 12:59:59 +01:00
2024-04-10 16:51:28 +02:00
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="spotifyd">
<allow own_prefix="org.mpris.MediaPlayer2.spotifyd"/>
<allow send_destination_prefix="org.mpris.MediaPlayer2.spotifyd"/>
<allow receive_sender="org.mpris.MediaPlayer2"/>
</policy>
<policy context="default">
<allow send_destination_prefix="org.mpris.MediaPlayer2.spotifyd"/>
<allow receive_sender="org.mpris.MediaPlayer2"/>
</policy>
</busconfig>
END
'';
});
})
2024-02-02 12:59:59 +01:00
];
2023-11-28 23:24:43 +01:00
environment.systemPackages = with pkgs; [
2024-03-24 10:16:04 +01:00
ncspot
2024-02-02 12:59:59 +01:00
spotifyd
];
# decrypt spotify password
age.identityPaths = [ "/home/grimmauld/.ssh/id_rsa" ];
# spotify pass
age.secrets.spotify_pass = {
file = ../secrets/spotify_pass.age;
owner = "spotifyd";
group = "spotifyd";
mode = "700";
};
2024-04-10 16:51:28 +02:00
systemd.services.init-spotifyd-cache-dir = {
2024-02-02 12:59:59 +01:00
description = "Create the spotifyd cache dir";
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
2024-04-10 16:51:28 +02:00
script = ''
2024-02-02 12:59:59 +01:00
mkdir -p ${spotifyd_cache_dir}
chown spotifyd:spotifyd -R ${spotifyd_cache_dir}
2024-04-10 16:51:28 +02:00
'';
2024-02-02 12:59:59 +01:00
};
# spotifyd config
services.spotifyd = {
enable = true;
settings.global = {
bitrate = 320;
username = "3tyhk4i01l54w7co7xm7jvu32";
device_name = "grimm_laptop";
password_cmd = "${pkgs.coreutils-full}/bin/cat ${config.age.secrets.spotify_pass.path}"; # read password secret
device_type = "computer";
dbus_type = "system";
device = "default";
control = "default";
volume_controller = "softvol";
2024-04-10 16:51:28 +02:00
# no_audio_cache = true;
2024-02-02 12:59:59 +01:00
spotifyd_cache_dir = spotifyd_cache_dir;
max_cache_size = 10000000000;
initial_volume = "90";
backend = "alsa"; # fixme
};
};
services.dbus.packages = with pkgs; [
spotifyd # add above dbus code to the config
2023-11-28 23:24:43 +01:00
];
2024-02-02 12:59:59 +01:00
# spotifyd has access to global pipewire
users.users.spotifyd = {
isSystemUser = true;
group = "spotifyd";
extraGroups = [ "audio" "pipewire" ];
};
# spotifyd is also a group
2024-04-10 16:51:28 +02:00
users.groups = { spotifyd = { }; };
2023-11-28 23:24:43 +01:00
}