diff --git a/common/pc/default.nix b/common/pc/default.nix index 84145b4..74cb457 100644 --- a/common/pc/default.nix +++ b/common/pc/default.nix @@ -12,6 +12,7 @@ in { ./audio.nix # ./torbrowser.nix ./pithos.nix + ./spotify.nix ./vscodium.nix ./discord.nix ./steam.nix @@ -29,8 +30,19 @@ in { # Applications users.users.googlebot.packages = with pkgs; [ - chromium keepassxc mumble tigervnc bluez-tools vscodium element-desktop mpv - nextcloud-client signal-desktop minecraft sauerbraten gnome.file-roller spotify + chromium + keepassxc + mumble + tigervnc + bluez-tools + vscodium + element-desktop + mpv + nextcloud-client + signal-desktop + minecraft + sauerbraten + gnome.file-roller gparted ]; diff --git a/common/pc/spotify.nix b/common/pc/spotify.nix new file mode 100644 index 0000000..e41305b --- /dev/null +++ b/common/pc/spotify.nix @@ -0,0 +1,84 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.services.spotifyd; + toml = pkgs.formats.toml {}; + spotifydConf = toml.generate "spotify.conf" cfg.settings; +in +{ + disabledModules = [ + "services/audio/spotifyd.nix" + ]; + + options = { + services.spotifyd = { + enable = mkEnableOption "spotifyd, a Spotify playing daemon"; + + settings = mkOption { + default = {}; + type = toml.type; + example = { global.bitrate = 320; }; + description = '' + Configuration for Spotifyd. For syntax and directives, see + . + ''; + }; + + users = mkOption { + type = with types; listOf str; + default = []; + description = '' + Usernames to be added to the "spotifyd" group, so that they + can start and interact with the userspace daemon. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + + # username specific stuff because i'm lazy... + services.spotifyd.users = [ "googlebot" ]; + users.users.googlebot.packages = with pkgs; [ + spotify + spotify-tui + ]; + + users.groups.spotifyd = { + members = cfg.users; + }; + + age.secrets.spotifyd = { + file = ../../secrets/spotifyd.age; + group = "spotifyd"; + }; + + # spotifyd to read secrets and run as user service + services.spotifyd = { + settings.global = { + username_cmd = "sed '1q;d' /run/agenix/spotifyd"; + password_cmd = "sed '2q;d' /run/agenix/spotifyd"; + bitrate = 320; + backend = "pulseaudio"; + device_name = config.networking.hostName; + device_type = "computer"; + # on_song_change_hook = "command_to_run_on_playback_events" + autoplay = true; + }; + }; + + systemd.user.services.spotifyd-daemon = { + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" "sound.target" ]; + description = "spotifyd, a Spotify playing daemon"; + environment.SHELL = "/bin/sh"; + serviceConfig = { + ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --config-path ${spotifydConf}"; + Restart = "always"; + CacheDirectory = "spotifyd"; + }; + }; + }; +} \ No newline at end of file diff --git a/machines/ray/configuration.nix b/machines/ray/configuration.nix index 606a22f..7528e0a 100644 --- a/machines/ray/configuration.nix +++ b/machines/ray/configuration.nix @@ -54,6 +54,8 @@ in publicCreateSnapshots = true; }; + services.spotifyd.enable = true; + services.zerotierone.enable = true; de.enable = true; diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 27df09b..6d2bb60 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -14,4 +14,5 @@ in "email-pw.age".publicKeys = all; "nextcloud-pw.age".publicKeys = all; "iodine.age".publicKeys = all; + "spotifyd.age".publicKeys = all; } \ No newline at end of file diff --git a/secrets/spotifyd.age b/secrets/spotifyd.age new file mode 100644 index 0000000..f03cc62 Binary files /dev/null and b/secrets/spotifyd.age differ