about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/audio/squeezelite/default.nix
blob: c6a78f090058f33801fade8f3b1e5dee5db62a26 (plain) (blame)
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
{ stdenv, fetchFromGitHub
, alsaLib, flac, libmad, libvorbis, mpg123
, dsdSupport ? true
, faad2Support ? true, faad2
, ffmpegSupport ? true, ffmpeg_3
, opusSupport ? true, opusfile
, resampleSupport ? true, soxr
, sslSupport ? true, openssl
}:

let
  concatStringsSep = stdenv.lib.concatStringsSep;
  optional = stdenv.lib.optional;
  opts = [ "-DLINKALL" ]
    ++ optional dsdSupport "-DDSD"
    ++ optional (!faad2Support) "-DNO_FAAD"
    ++ optional ffmpegSupport "-DFFMPEG"
    ++ optional opusSupport "-DOPUS"
    ++ optional resampleSupport "-DRESAMPLE"
    ++ optional sslSupport "-DUSE_SSL";

in stdenv.mkDerivation {
  pname = "squeezelite";

  # versions are specified in `squeezelite.h`
  # see https://github.com/ralph-irving/squeezelite/issues/29
  version = "1.9.6.1196";

  src = fetchFromGitHub {
    owner  = "ralph-irving";
    repo   = "squeezelite";
    rev    = "2b508464dce2cbdb2a3089c58df2a6fbc36328c0";
    sha256 = "024ypr1da2r079k3hgiifzd3d3wcfprhbl5zdm40zm0c7frzmr8i";
  };

  buildInputs = [ alsaLib flac libmad libvorbis mpg123 ]
    ++ optional faad2Support faad2
    ++ optional ffmpegSupport ffmpeg_3
    ++ optional opusSupport opusfile
    ++ optional resampleSupport soxr
    ++ optional sslSupport openssl;

  enableParallelBuilding = true;

  postPatch = ''
    substituteInPlace opus.c \
      --replace "<opusfile.h>" "<opus/opusfile.h>"
  '';

  preBuild = ''
    export OPTS="${concatStringsSep " " opts}"
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin                   squeezelite
    install -Dm644 -t $out/share/doc/squeezelite *.txt *.md

    runHook postInstall
  '';

  meta = with stdenv.lib; {
    description = "Lightweight headless squeezebox client emulator";
    homepage = "https://github.com/ralph-irving/squeezelite";
    license = with licenses; [ gpl3 ] ++ optional dsdSupport bsd2;
    maintainers = with maintainers; [ samdoshi ];
    platforms = platforms.linux;
  };
}