1{
2 faad2,
3 fetchFromGitHub,
4 flac,
5 lame,
6 lib,
7 makeWrapper,
8 monkeysAudio,
9 nixosTests,
10 perlPackages,
11 sox,
12 stdenv,
13 wavpack,
14 zlib,
15 enableUnfreeFirmware ? false,
16}:
17
18let
19 binPath = lib.makeBinPath (
20 [
21 lame
22 flac
23 faad2
24 sox
25 wavpack
26 ]
27 ++ (lib.optional stdenv.hostPlatform.isLinux monkeysAudio)
28 );
29 libPath = lib.makeLibraryPath [
30 zlib
31 stdenv.cc.cc
32 ];
33in
34perlPackages.buildPerlPackage rec {
35 pname = "slimserver";
36 version = "9.0.2";
37
38 src = fetchFromGitHub {
39 owner = "LMS-Community";
40 repo = "slimserver";
41 rev = version;
42 hash = "sha256-rwaHlNM5KGqvk8SAdinvCGT5+UUAU8I2jiN5Ine/eds=";
43 };
44
45 nativeBuildInputs = [ makeWrapper ];
46
47 buildInputs =
48 with perlPackages;
49 [
50 AnyEvent
51 ArchiveZip
52 AsyncUtil
53 AudioScan
54 CarpAssert
55 CarpClan
56 CGI
57 ClassAccessor
58 ClassAccessorChained
59 ClassC3
60 # ClassC3Componentised # Error: DBIx::Class::Row::throw_exception(): DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join condition for track
61 ClassDataInheritable
62 ClassInspector
63 ClassISA
64 ClassMember
65 ClassSingleton
66 ClassVirtual
67 ClassXSAccessor
68 CompressRawZlib
69 CryptOpenSSLRSA
70 DataDump
71 DataPage
72 DataURIEncode
73 DBDSQLite
74 DBI
75 # DBIxClass # https://github.com/LMS-Community/slimserver/issues/138
76 DigestSHA1
77 EncodeDetect
78 EV
79 ExporterLite
80 FileBOM
81 FileCopyRecursive
82 # FileNext # https://github.com/LMS-Community/slimserver/pull/1140
83 FileReadBackwards
84 FileSlurp
85 FileWhich
86 HTMLParser
87 HTTPCookies
88 HTTPDaemon
89 HTTPMessage
90 ImageScale
91 IOAIO
92 IOInterface
93 IOSocketSSL
94 IOString
95 JSONXS
96 JSONXSVersionOneAndTwo
97 # LogLog4perl # Internal error: Root Logger not initialized.
98 LWP
99 LWPProtocolHttps
100 MP3CutGapless
101 NetHTTP
102 NetHTTPSNB
103 PathClass
104 ProcBackground
105 # SQLAbstract # DBI Exception: DBD::SQLite::db prepare_cached failed: no such function: ARRAY
106 SQLAbstractLimit
107 SubName
108 TemplateToolkit
109 TextUnidecode
110 TieCacheLRU
111 TieCacheLRUExpires
112 TieRegexpHash
113 TimeDate
114 URI
115 URIFind
116 UUIDTiny
117 XMLParser
118 XMLSimple
119 YAMLLibYAML
120 ]
121 # ++ (lib.optional stdenv.hostPlatform.isDarwin perlPackages.MacFSEvents)
122 ++ (lib.optional stdenv.hostPlatform.isLinux perlPackages.LinuxInotify2);
123
124 prePatch = ''
125 # remove vendored binaries
126 rm -rf Bin
127
128 # remove most vendored modules, keeping necessary ones
129 mkdir -p CPAN_used/Class/C3/ CPAN_used/SQL/ CPAN_used/File/
130 rm -r CPAN/SQL/Abstract/Limit.pm
131 cp -rv CPAN/Class/C3/Componentised.pm CPAN_used/Class/C3/
132 cp -rv CPAN/DBIx CPAN_used/
133 cp -rv CPAN/File/Next.pm CPAN_used/File/
134 cp -rv CPAN/Log CPAN_used/
135 cp -rv CPAN/SQL/* CPAN_used/SQL/
136 rm -r CPAN
137 mv CPAN_used CPAN
138
139 # another set of vendored/modified modules exist in lib, more selectively cleaned for now
140 rm -rf lib/Audio
141
142 ${lib.optionalString (!enableUnfreeFirmware) ''
143 # remove unfree firmware
144 rm -rf Firmware
145 ''}
146
147 touch Makefile.PL
148 '';
149
150 doCheck = false;
151
152 installPhase = ''
153 cp -r . $out
154 wrapProgram $out/slimserver.pl --prefix LD_LIBRARY_PATH : "${libPath}" --prefix PATH : "${binPath}"
155 chmod +x $out/scanner.pl
156 wrapProgram $out/scanner.pl --prefix LD_LIBRARY_PATH : "${libPath}" --prefix PATH : "${binPath}"
157 mkdir $out/bin
158 ln -s $out/slimserver.pl $out/bin/slimserver
159 '';
160
161 outputs = [ "out" ];
162
163 passthru = {
164 tests = {
165 inherit (nixosTests) slimserver;
166 };
167
168 updateScript = ./update.nu;
169 };
170
171 meta = with lib; {
172 homepage = "https://lyrion.org/";
173 changelog = "https://lyrion.org/getting-started/changelog-lms${lib.versions.major version}";
174 description = "Lyrion Music Server (formerly Logitech Media Server) is open-source server software which controls a wide range of Squeezebox audio players";
175 # the firmware is not under a free license, so we do not include firmware in the default package
176 # https://github.com/LMS-Community/slimserver/blob/public/8.3/License.txt
177 license = if enableUnfreeFirmware then licenses.unfree else licenses.gpl2Only;
178 mainProgram = "slimserver";
179 maintainers = with maintainers; [
180 adamcstephens
181 jecaro
182 ];
183 platforms = platforms.unix;
184 broken = stdenv.hostPlatform.isDarwin;
185 };
186}