diff --git a/home/all.nix b/home/all.nix index a54d557..b9a767f 100755 --- a/home/all.nix +++ b/home/all.nix @@ -42,6 +42,24 @@ colloid-icon-theme ]; + services = { + spotifyd = { + enable = true; + settings = { + global = { + device_type = "computer"; + dbus_type = "session"; + disable_discovery = true; + use_mpris = true; + bitrate = 320; + initial_volume = 100; + volume_normalisation = true; + normalisation_pregain = -10; + }; + }; + }; + }; + catppuccin = { enable = true; cursors.enable = false; diff --git a/packages/overlay.nix b/packages/overlay.nix index 29ca5e0..71bf926 100644 --- a/packages/overlay.nix +++ b/packages/overlay.nix @@ -24,5 +24,7 @@ final: prev: { inherit helium-widevine; }; + spotifyd = prev.callPackage (builtins.path { path = ./spotifyd/package.nix; }) { }; + widevine-firefox = prev.callPackage (builtins.path { path = ./widevine-firefox/package.nix; }) { }; } diff --git a/packages/spotifyd/package.nix b/packages/spotifyd/package.nix new file mode 100644 index 0000000..1966d28 --- /dev/null +++ b/packages/spotifyd/package.nix @@ -0,0 +1,88 @@ +{ + lib, + stdenv, + config, + alsa-lib, + cmake, + dbus, + fetchFromGitHub, + libjack2, + libpulseaudio, + nix-update-script, + openssl, + pkg-config, + portaudio, + rustPlatform, + testers, + withALSA ? stdenv.hostPlatform.isLinux, + withJack ? stdenv.hostPlatform.isLinux, + withMpris ? stdenv.hostPlatform.isLinux, + withPortAudio ? stdenv.hostPlatform.isDarwin, + withPulseAudio ? config.pulseaudio or stdenv.hostPlatform.isLinux, +}: + +rustPlatform.buildRustPackage (finalAttrs: { + pname = "spotifyd"; + version = "0.4.2"; + + src = fetchFromGitHub { + owner = "Spotifyd"; + repo = "spotifyd"; + tag = "v${finalAttrs.version}"; + hash = "sha256-+t6z2cenw0fU5onl5F5vtk7Hr24IzTCAee+Lcnd7aT4="; + }; + + cargoHash = "sha256-rv4FWyciv6vDKtD7moJppY3tOJb0B3ezE9HgCLNhIo8="; + + nativeBuildInputs = [ + cmake + pkg-config + rustPlatform.bindgenHook + ]; + + buildInputs = + lib.optionals stdenv.hostPlatform.isLinux [ openssl ] + # The `dbus_mpris` feature works on other platforms, but only requires `dbus` on Linux + ++ lib.optional (withMpris && stdenv.hostPlatform.isLinux) dbus + ++ lib.optional (withALSA || withJack) alsa-lib + ++ lib.optional withJack libjack2 + ++ lib.optional withPulseAudio libpulseaudio + ++ lib.optional withPortAudio portaudio; + + # `aws-lc-sys` fails with this enabled + hardeningDisable = [ "strictoverflow" ]; + + buildNoDefaultFeatures = true; + buildFeatures = + lib.optional withALSA "alsa_backend" + ++ lib.optional withJack "rodiojack_backend" + ++ lib.optional withMpris "dbus_mpris" + ++ lib.optional withPortAudio "portaudio_backend" + ++ lib.optional withPulseAudio "pulseaudio_backend"; + + checkFlags = lib.optionals stdenv.hostPlatform.isDarwin [ + # `assertion failed: shell.is_some()` + # Internally it's trying to query the user's shell through `dscl`. This is bad + # https://github.com/Spotifyd/spotifyd/blob/8777c67988508d3623d3f6b81c9379fb071ac7dd/src/utils.rs#L45-L47 + "--skip=utils::tests::test_ffi_discovery" + ]; + + passthru = { + tests.version = testers.testVersion { package = finalAttrs.finalPackage; }; + updateScript = nix-update-script { }; + }; + + meta = { + description = "Open source Spotify client running as a UNIX daemon"; + homepage = "https://spotifyd.rs/"; + changelog = "https://github.com/Spotifyd/spotifyd/releases/tag/${toString finalAttrs.src.tag}"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ + anderslundstedt + Br1ght0ne + getchoo + ]; + platforms = lib.platforms.unix; + mainProgram = "spotifyd"; + }; +})