Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 144 lines 3.7 kB view raw
1{ 2 lib, 3 rustPlatform, 4 fetchFromGitHub, 5 pkg-config, 6 openssl, 7 cmake, 8 installShellFiles, 9 writableTmpDirAsHomeHook, 10 11 # deps for audio backends 12 alsa-lib, 13 libpulseaudio, 14 portaudio, 15 libjack2, 16 SDL2, 17 gst_all_1, 18 dbus, 19 fontconfig, 20 libsixel, 21 22 # build options 23 withStreaming ? true, 24 withDaemon ? true, 25 withAudioBackend ? "rodio", # alsa, pulseaudio, rodio, portaudio, jackaudio, rodiojack, sdl 26 withMediaControl ? true, 27 withImage ? true, 28 withNotify ? true, 29 withSixel ? true, 30 withFuzzy ? true, 31 stdenv, 32 makeBinaryWrapper, 33 34 # passthru 35 nix-update-script, 36}: 37 38assert lib.assertOneOf "withAudioBackend" withAudioBackend [ 39 "" 40 "alsa" 41 "pulseaudio" 42 "rodio" 43 "portaudio" 44 "jackaudio" 45 "rodiojack" 46 "sdl" 47 "gstreamer" 48]; 49 50rustPlatform.buildRustPackage rec { 51 pname = "spotify-player"; 52 version = "0.20.7"; 53 54 src = fetchFromGitHub { 55 owner = "aome510"; 56 repo = "spotify-player"; 57 tag = "v${version}"; 58 hash = "sha256-g+SU6qDnafLiNOzZ75HUPgifuC8A+rb+KoqJoMHBJ04="; 59 }; 60 61 cargoHash = "sha256-rwWSKJMI/4fY60m+vGqTqrTijJN6d0PfQH417Ku9+0E="; 62 63 nativeBuildInputs = [ 64 pkg-config 65 cmake 66 rustPlatform.bindgenHook 67 installShellFiles 68 # Tries to access $HOME when installing shell files, and on Darwin 69 writableTmpDirAsHomeHook 70 ] 71 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 72 makeBinaryWrapper 73 ]; 74 75 buildInputs = [ 76 openssl 77 dbus 78 fontconfig 79 ] 80 ++ lib.optionals withSixel [ libsixel ] 81 ++ lib.optionals (withAudioBackend == "alsa") [ alsa-lib ] 82 ++ lib.optionals (withAudioBackend == "pulseaudio") [ libpulseaudio ] 83 ++ lib.optionals (withAudioBackend == "rodio" && stdenv.hostPlatform.isLinux) [ alsa-lib ] 84 ++ lib.optionals (withAudioBackend == "portaudio") [ portaudio ] 85 ++ lib.optionals (withAudioBackend == "jackaudio") [ libjack2 ] 86 ++ lib.optionals (withAudioBackend == "rodiojack") [ 87 alsa-lib 88 libjack2 89 ] 90 ++ lib.optionals (withAudioBackend == "sdl") [ SDL2 ] 91 ++ lib.optionals (withAudioBackend == "gstreamer") [ 92 gst_all_1.gstreamer 93 gst_all_1.gst-devtools 94 gst_all_1.gst-plugins-base 95 gst_all_1.gst-plugins-good 96 ]; 97 98 buildNoDefaultFeatures = true; 99 100 buildFeatures = 101 [ ] 102 ++ lib.optionals (withAudioBackend != "") [ "${withAudioBackend}-backend" ] 103 ++ lib.optionals withMediaControl [ "media-control" ] 104 ++ lib.optionals withImage [ "image" ] 105 ++ lib.optionals withDaemon [ "daemon" ] 106 ++ lib.optionals withNotify [ "notify" ] 107 ++ lib.optionals withStreaming [ "streaming" ] 108 ++ lib.optionals withSixel [ "sixel" ] 109 ++ lib.optionals withFuzzy [ "fzf" ]; 110 111 postInstall = 112 let 113 inherit (lib.strings) optionalString; 114 in 115 # sixel-sys is dynamically linked to libsixel 116 optionalString (stdenv.hostPlatform.isDarwin && withSixel) '' 117 wrapProgram $out/bin/spotify_player \ 118 --prefix DYLD_LIBRARY_PATH : "${lib.makeLibraryPath [ libsixel ]}" 119 '' 120 + optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 121 installShellCompletion --cmd spotify_player \ 122 --bash <($out/bin/spotify_player generate bash) \ 123 --fish <($out/bin/spotify_player generate fish) \ 124 --zsh <($out/bin/spotify_player generate zsh) 125 ''; 126 127 passthru = { 128 updateScript = nix-update-script { }; 129 }; 130 131 meta = { 132 description = "Terminal spotify player that has feature parity with the official client"; 133 homepage = "https://github.com/aome510/spotify-player"; 134 changelog = "https://github.com/aome510/spotify-player/releases/tag/v${version}"; 135 mainProgram = "spotify_player"; 136 license = lib.licenses.mit; 137 maintainers = with lib.maintainers; [ 138 dit7ya 139 xyven1 140 _71zenith 141 caperren 142 ]; 143 }; 144}