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 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR14F3!+RO))YxHMCTy$al;&FIUKPE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