Fix build spotify_player for macos

- Add require Apple SDK libraries
- Fix dynamic linking to the sixel lib
- Only include alsa for linux builds, as this is not supported on MacOS
This commit is contained in:
Tom Cammann 2023-08-14 21:28:30 +01:00
parent c2f3ec47aa
commit 34f8d53996

View file

@ -24,6 +24,9 @@
, withImage ? true
, withNotify ? true
, withSixel ? true
, stdenv
, darwin
, makeBinaryWrapper
}:
assert lib.assertOneOf "withAudioBackend" withAudioBackend [ "" "alsa" "pulseaudio" "rodio" "portaudio" "jackaudio" "rodiojack" "sdl" "gstreamer" ];
@ -44,6 +47,9 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [
pkg-config
cmake
rustPlatform.bindgenHook
] ++ lib.optionals stdenv.isDarwin [
makeBinaryWrapper
];
buildInputs = [
@ -59,7 +65,13 @@ rustPlatform.buildRustPackage rec {
++ lib.optionals (withAudioBackend == "jackaudio") [ libjack2 ]
++ lib.optionals (withAudioBackend == "rodiojack") [ alsa-lib libjack2 ]
++ lib.optionals (withAudioBackend == "sdl") [ SDL2 ]
++ lib.optionals (withAudioBackend == "gstreamer") [ gst_all_1.gstreamer gst_all_1.gst-devtools gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good ];
++ lib.optionals (withAudioBackend == "gstreamer") [ gst_all_1.gstreamer gst_all_1.gst-devtools gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good ]
++ lib.optionals (stdenv.isDarwin && withMediaControl) [ darwin.apple_sdk.frameworks.MediaPlayer ]
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
AppKit
AudioUnit
Cocoa
]);
buildNoDefaultFeatures = true;
@ -73,6 +85,12 @@ rustPlatform.buildRustPackage rec {
++ lib.optionals withStreaming [ "streaming" ]
++ lib.optionals withSixel [ "sixel" ];
# sixel-sys is dynamically linked to libsixel
postInstall = lib.optionals (stdenv.isDarwin && withSixel) ''
wrapProgram $out/bin/spotify_player \
--prefix DYLD_LIBRARY_PATH : "${lib.makeLibraryPath [libsixel]}"
'';
meta = {
description = "A terminal spotify player that has feature parity with the official client";
homepage = "https://github.com/aome510/spotify-player";