From 504e4efad6f0df36265799d6b47dd01f163d8e31 Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Sun, 13 Mar 2022 19:59:17 -0400 Subject: [PATCH] Usermode spotifyd + spotify-tui --- common/pc/default.nix | 16 ++++++- common/pc/spotify.nix | 84 +++++++++++++++++++++++++++++++++ machines/ray/configuration.nix | 2 + secrets/secrets.nix | 1 + secrets/spotifyd.age | Bin 0 -> 1872 bytes 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 common/pc/spotify.nix create mode 100644 secrets/spotifyd.age 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 0000000000000000000000000000000000000000..f03cc62e7357959177d36436a138d889c5126b4c GIT binary patch literal 1872 zcmZYANz3eL83tf?VsNPoQ6U^qXv^;;m7$W*AY`bdGE}NE4{A%2$~;wusth#tvc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