nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 flac,
6 libgpiod,
7 libmad,
8 libpulseaudio,
9 libvorbis,
10 mpg123,
11 audioBackend ? if stdenv.hostPlatform.isLinux then "alsa" else "portaudio",
12 alsaSupport ? stdenv.hostPlatform.isLinux,
13 alsa-lib,
14 dsdSupport ? true,
15 faad2Support ? true,
16 faad2,
17 ffmpegSupport ? true,
18 ffmpeg,
19 opusSupport ? true,
20 opusfile,
21 resampleSupport ? true,
22 soxr,
23 sslSupport ? true,
24 openssl,
25 portaudioSupport ? stdenv.hostPlatform.isDarwin,
26 portaudio,
27 slimserver,
28}:
29
30let
31 inherit (lib) optional optionals optionalString;
32
33 pulseSupport = audioBackend == "pulse";
34
35 binName = "squeezelite${optionalString pulseSupport "-pulse"}";
36in
37stdenv.mkDerivation {
38 # the nixos module uses the pname as the binary name
39 pname = binName;
40 # versions are specified in `squeezelite.h`
41 # see https://github.com/ralph-irving/squeezelite/issues/29
42 version = "2.0.0.1556";
43
44 src = fetchFromGitHub {
45 owner = "ralph-irving";
46 repo = "squeezelite";
47 rev = "6d571de8fa6dfff23a5a0cbb2c81b402d2c30c31";
48 hash = "sha256-rwiRZaadku4xAAQiloghnmMtRlflgGJ8prEUQJsuR8c=";
49 };
50
51 buildInputs = [
52 flac
53 libmad
54 libvorbis
55 mpg123
56 ]
57 ++ optional pulseSupport libpulseaudio
58 ++ optional alsaSupport alsa-lib
59 ++ optional portaudioSupport portaudio
60
61 ++ optional faad2Support faad2
62 ++ optional ffmpegSupport ffmpeg
63 ++ optional opusSupport opusfile
64 ++ optional resampleSupport soxr
65 ++ optional sslSupport openssl
66 ++ optional (stdenv.hostPlatform.isAarch32 or stdenv.hostPlatform.isAarch64) libgpiod;
67
68 enableParallelBuilding = true;
69
70 postPatch = ''
71 substituteInPlace opus.c \
72 --replace "<opusfile.h>" "<opus/opusfile.h>"
73 '';
74
75 EXECUTABLE = binName;
76
77 OPTS = [
78 "-DLINKALL"
79 "-DGPIO"
80 ]
81 ++ optional dsdSupport "-DDSD"
82 ++ optional (!faad2Support) "-DNO_FAAD"
83 ++ optional ffmpegSupport "-DFFMPEG"
84 ++ optional opusSupport "-DOPUS"
85 ++ optional portaudioSupport "-DPORTAUDIO"
86 ++ optional pulseSupport "-DPULSEAUDIO"
87 ++ optional resampleSupport "-DRESAMPLE"
88 ++ optional sslSupport "-DUSE_SSL"
89 ++ optional (stdenv.hostPlatform.isAarch32 or stdenv.hostPlatform.isAarch64) "-DRPI";
90
91 env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { LDADD = "-lportaudio -lpthread"; };
92
93 installPhase = ''
94 runHook preInstall
95
96 install -Dm555 -t $out/bin ${binName}
97 install -Dm444 -t $out/share/man/man1 doc/squeezelite.1
98
99 runHook postInstall
100 '';
101
102 passthru = {
103 inherit (slimserver) tests;
104 updateScript = ./update.sh;
105 };
106
107 meta = {
108 description = "Lightweight headless squeezebox client emulator";
109 homepage = "https://github.com/ralph-irving/squeezelite";
110 license = with lib.licenses; [ gpl3Plus ] ++ optional dsdSupport bsd2;
111 mainProgram = binName;
112 maintainers = with lib.maintainers; [ adamcstephens ];
113 platforms =
114 if (audioBackend == "pulse") then
115 lib.platforms.linux
116 else
117 lib.platforms.linux ++ lib.platforms.darwin;
118 };
119}