summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/li/librespot/package.nix
blob: 8c4a3e7f498f77c1867b61f8f1b69fb38d382844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  lib,
  rustPlatform,
  fetchFromGitHub,
  makeWrapper,
  pkg-config,
  stdenv,
  openssl,
  withALSA ? stdenv.hostPlatform.isLinux,
  alsa-lib,
  alsa-plugins,
  withPortAudio ? stdenv.hostPlatform.isDarwin,
  portaudio,
  withPulseAudio ? config.pulseaudio or stdenv.hostPlatform.isLinux,
  libpulseaudio,
  config,
  withRodio ? true,
  withAvahi ? false,
  withMDNS ? true,
  withDNS-SD ? false,
  avahi-compat,
  tlsBackend ? "native-tls", # "native-tls" "rustls-tls-native-roots" "rustls-tls-webpki-roots"
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "librespot";
  version = "0.8.0";

  src = fetchFromGitHub {
    owner = "librespot-org";
    repo = "librespot";
    rev = "v${finalAttrs.version}";
    hash = "sha256-twWndV6z5Cdivz7pfAJzdlIjddEiZPEFnTzipMczmJo=";
  };

  cargoHash = "sha256-Kf3w6tD/MQaXXegtiCkFbUcYwr4OMw6ipLxNLxJ2NTQ=";

  nativeBuildInputs = [
    pkg-config
    makeWrapper
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    rustPlatform.bindgenHook
  ];

  buildInputs = [
    openssl
  ]
  ++ lib.optional withALSA alsa-lib
  ++ lib.optional withDNS-SD avahi-compat
  ++ lib.optional withPortAudio portaudio
  ++ lib.optional withPulseAudio libpulseaudio;

  buildNoDefaultFeatures = true;
  buildFeatures = [
    tlsBackend
  ]
  ++ lib.optional withRodio "rodio-backend"
  ++ lib.optional withMDNS "with-libmdns"
  ++ lib.optional withDNS-SD "with-dns-sd"
  ++ lib.optional withALSA "alsa-backend"
  ++ lib.optional withAvahi "with-avahi"
  ++ lib.optional withPortAudio "portaudio-backend"
  ++ lib.optional withPulseAudio "pulseaudio-backend";

  postFixup = lib.optionalString withALSA ''
    wrapProgram "$out/bin/librespot" \
      --set ALSA_PLUGIN_DIR '${alsa-plugins}/lib/alsa-lib'
  '';

  meta = {
    description = "Open Source Spotify client library and playback daemon";
    mainProgram = "librespot";
    homepage = "https://github.com/librespot-org/librespot";
    changelog = "https://github.com/librespot-org/librespot/blob/v${finalAttrs.version}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ bennofs ];
  };
})