nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 config,
5 alsa-lib,
6 cmake,
7 dbus,
8 fetchFromGitHub,
9 libjack2,
10 libpulseaudio,
11 nix-update-script,
12 openssl,
13 pkg-config,
14 portaudio,
15 rustPlatform,
16 testers,
17 withALSA ? stdenv.hostPlatform.isLinux,
18 withJack ? stdenv.hostPlatform.isLinux,
19 withMpris ? stdenv.hostPlatform.isLinux,
20 withPortAudio ? stdenv.hostPlatform.isDarwin,
21 withPulseAudio ? config.pulseaudio or stdenv.hostPlatform.isLinux,
22}:
23
24rustPlatform.buildRustPackage (finalAttrs: {
25 pname = "spotifyd";
26 version = "0.4.2";
27
28 src = fetchFromGitHub {
29 owner = "Spotifyd";
30 repo = "spotifyd";
31 tag = "v${finalAttrs.version}";
32 hash = "sha256-+t6z2cenw0fU5onl5F5vtk7Hr24IzTCAee+Lcnd7aT4=";
33 };
34
35 cargoHash = "sha256-rv4FWyciv6vDKtD7moJppY3tOJb0B3ezE9HgCLNhIo8=";
36
37 nativeBuildInputs = [
38 cmake
39 pkg-config
40 rustPlatform.bindgenHook
41 ];
42
43 buildInputs =
44 lib.optionals stdenv.hostPlatform.isLinux [ openssl ]
45 # The `dbus_mpris` feature works on other platforms, but only requires `dbus` on Linux
46 ++ lib.optional (withMpris && stdenv.hostPlatform.isLinux) dbus
47 ++ lib.optional (withALSA || withJack) alsa-lib
48 ++ lib.optional withJack libjack2
49 ++ lib.optional withPulseAudio libpulseaudio
50 ++ lib.optional withPortAudio portaudio;
51
52 # `aws-lc-sys` fails with this enabled
53 hardeningDisable = [ "strictoverflow" ];
54
55 buildNoDefaultFeatures = true;
56 buildFeatures =
57 lib.optional withALSA "alsa_backend"
58 ++ lib.optional withJack "rodiojack_backend"
59 ++ lib.optional withMpris "dbus_mpris"
60 ++ lib.optional withPortAudio "portaudio_backend"
61 ++ lib.optional withPulseAudio "pulseaudio_backend";
62
63 checkFlags = lib.optionals stdenv.hostPlatform.isDarwin [
64 # `assertion failed: shell.is_some()`
65 # Internally it's trying to query the user's shell through `dscl`. This is bad
66 # https://github.com/Spotifyd/spotifyd/blob/8777c67988508d3623d3f6b81c9379fb071ac7dd/src/utils.rs#L45-L47
67 "--skip=utils::tests::test_ffi_discovery"
68 ];
69
70 passthru = {
71 tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
72 updateScript = nix-update-script { };
73 };
74
75 meta = {
76 description = "Open source Spotify client running as a UNIX daemon";
77 homepage = "https://spotifyd.rs/";
78 changelog = "https://github.com/Spotifyd/spotifyd/releases/tag/${toString finalAttrs.src.tag}";
79 license = lib.licenses.gpl3Plus;
80 maintainers = with lib.maintainers; [
81 anderslundstedt
82 getchoo
83 ];
84 platforms = lib.platforms.unix;
85 mainProgram = "spotifyd";
86 };
87})