base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / sp / spotify-player / package.nix
blob7adc58d48e991b31c9997cf4a59b8ebfc4580f65
1 { lib
2 , rustPlatform
3 , fetchFromGitHub
4 , pkg-config
5 , openssl
6 , cmake
7 # deps for audio backends
8 , alsa-lib
9 , libpulseaudio
10 , portaudio
11 , libjack2
12 , SDL2
13 , gst_all_1
14 , dbus
15 , fontconfig
16 , libsixel
18 # build options
19 , withStreaming ? true
20 , withDaemon ? true
21 , withAudioBackend ? "rodio" # alsa, pulseaudio, rodio, portaudio, jackaudio, rodiojack, sdl
22 , withMediaControl ? true
23 , withLyrics ? true
24 , withImage ? true
25 , withNotify ? true
26 , withSixel ? true
27 , withFuzzy ? true
28 , stdenv
29 , darwin
30 , makeBinaryWrapper
32 # passthru
33 , nix-update-script
36 assert lib.assertOneOf "withAudioBackend" withAudioBackend [ "" "alsa" "pulseaudio" "rodio" "portaudio" "jackaudio" "rodiojack" "sdl" "gstreamer" ];
38 rustPlatform.buildRustPackage rec {
39   pname = "spotify-player";
40   version = "0.20.1";
42   src = fetchFromGitHub {
43     owner = "aome510";
44     repo = pname;
45     rev = "refs/tags/v${version}";
46     hash = "sha256-SKlESIw8eAyAqR1HVW004yyL2nNVEnb4/xmf0ch3ZMo=";
47   };
49   cargoHash = "sha256-VlJ8Bz4EY2rERyOn6ifC7JAL5Mvjt0ZOzlPBOwiH6WA=";
51   nativeBuildInputs = [
52     pkg-config
53     cmake
54     rustPlatform.bindgenHook
55   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
56     makeBinaryWrapper
57   ];
59   buildInputs = [
60     openssl
61     dbus
62     fontconfig
63   ]
64     ++ lib.optionals withSixel [ libsixel ]
65     ++ lib.optionals (withAudioBackend == "alsa") [ alsa-lib ]
66     ++ lib.optionals (withAudioBackend == "pulseaudio") [ libpulseaudio ]
67     ++ lib.optionals (withAudioBackend == "rodio" && stdenv.hostPlatform.isLinux) [ alsa-lib ]
68     ++ lib.optionals (withAudioBackend == "portaudio") [ portaudio ]
69     ++ lib.optionals (withAudioBackend == "jackaudio") [ libjack2 ]
70     ++ lib.optionals (withAudioBackend == "rodiojack") [ alsa-lib libjack2 ]
71     ++ lib.optionals (withAudioBackend == "sdl") [ SDL2 ]
72     ++ 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 ]
73     ++ lib.optionals (stdenv.hostPlatform.isDarwin && withMediaControl) [ darwin.apple_sdk.frameworks.MediaPlayer ]
74     ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
75       AppKit
76       AudioUnit
77       Cocoa
78     ]);
80   buildNoDefaultFeatures = true;
82   buildFeatures = [ ]
83     ++ lib.optionals (withAudioBackend != "") [ "${withAudioBackend}-backend" ]
84     ++ lib.optionals withMediaControl [ "media-control" ]
85     ++ lib.optionals withImage [ "image" ]
86     ++ lib.optionals withLyrics [ "lyric-finder" ]
87     ++ lib.optionals withDaemon [ "daemon" ]
88     ++ lib.optionals withNotify [ "notify" ]
89     ++ lib.optionals withStreaming [ "streaming" ]
90     ++ lib.optionals withSixel [ "sixel" ]
91     ++ lib.optionals withFuzzy [ "fzf" ];
93   # sixel-sys is dynamically linked to libsixel
94   postInstall = lib.optionals (stdenv.hostPlatform.isDarwin && withSixel) ''
95     wrapProgram $out/bin/spotify_player \
96       --prefix DYLD_LIBRARY_PATH : "${lib.makeLibraryPath [libsixel]}"
97   '';
99   passthru = {
100     updateScript = nix-update-script { };
101   };
103   meta = {
104     description = "Terminal spotify player that has feature parity with the official client";
105     homepage = "https://github.com/aome510/spotify-player";
106     changelog = "https://github.com/aome510/spotify-player/releases/tag/v${version}";
107     mainProgram = "spotify_player";
108     license = lib.licenses.mit;
109     maintainers = with lib.maintainers; [ dit7ya xyven1 _71zenith caperren ];
110   };