about summary refs log tree commit diff
path: root/pkgs/by-name/sl/slimserver/package.nix
blob: b88f72b0d1181ad3d18314040fcb5d44142153f1 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
{
  faad2,
  fetchFromGitHub,
  flac,
  lame,
  lib,
  makeWrapper,
  monkeysAudio,
  nixosTests,
  perlPackages,
  sox,
  stdenv,
  wavpack,
  zlib,
  enableUnfreeFirmware ? false,
}:

let
  binPath = lib.makeBinPath (
    [
      lame
      flac
      faad2
      sox
      wavpack
    ]
    ++ (lib.optional stdenv.isLinux monkeysAudio)
  );
  libPath = lib.makeLibraryPath [
    zlib
    stdenv.cc.cc.lib
  ];
in
perlPackages.buildPerlPackage rec {
  pname = "slimserver";
  version = "8.5.2";

  src = fetchFromGitHub {
    owner = "LMS-Community";
    repo = "slimserver";
    rev = version;
    hash = "sha256-262SHaxt5ow3nJtNVk10sbiPUfDb/U+Ab97DRjkJZFI=";
  };

  nativeBuildInputs = [ makeWrapper ];

  buildInputs =
    with perlPackages;
    [
      AnyEvent
      ArchiveZip
      AsyncUtil
      AudioScan
      CarpClan
      CGI
      ClassAccessor
      ClassAccessorChained
      ClassC3
      # ClassC3Componentised # Error: DBIx::Class::Row::throw_exception(): DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join condition for track
      ClassDataInheritable
      ClassInspector
      ClassISA
      ClassMember
      ClassSingleton
      ClassVirtual
      ClassXSAccessor
      CompressRawZlib
      CryptOpenSSLRSA
      DataDump
      DataPage
      DataURIEncode
      DBDSQLite
      DBI
      # DBIxClass # https://github.com/LMS-Community/slimserver/issues/138
      DigestSHA1
      EncodeDetect
      EV
      ExporterLite
      FileBOM
      FileCopyRecursive
      # FileNext # https://github.com/LMS-Community/slimserver/pull/1140
      FileReadBackwards
      FileSlurp
      FileWhich
      HTMLParser
      HTTPCookies
      HTTPDaemon
      HTTPMessage
      ImageScale
      IOAIO
      IOInterface
      IOSocketSSL
      IOString
      JSONXS
      JSONXSVersionOneAndTwo
      # LogLog4perl # Internal error: Root Logger not initialized.
      LWP
      LWPProtocolHttps
      MP3CutGapless
      NetHTTP
      NetHTTPSNB
      PathClass
      ProcBackground
      # SQLAbstract # DBI Exception: DBD::SQLite::db prepare_cached failed: no such function: ARRAY
      SQLAbstractLimit
      SubName
      TemplateToolkit
      TextUnidecode
      TieCacheLRU
      TieCacheLRUExpires
      TieRegexpHash
      TimeDate
      URI
      URIFind
      UUIDTiny
      XMLParser
      XMLSimple
      YAMLLibYAML
    ]
    # ++ (lib.optional stdenv.isDarwin perlPackages.MacFSEvents)
    ++ (lib.optional stdenv.isLinux perlPackages.LinuxInotify2);

  prePatch = ''
    # remove vendored binaries
    rm -rf Bin

    # remove most vendored modules, keeping necessary ones
    mkdir -p CPAN_used/Class/C3/ CPAN_used/SQL/ CPAN_used/File/
    rm -r CPAN/SQL/Abstract/Limit.pm
    cp -rv CPAN/Class/C3/Componentised.pm CPAN_used/Class/C3/
    cp -rv CPAN/DBIx CPAN_used/
    cp -rv CPAN/File/Next.pm CPAN_used/File/
    cp -rv CPAN/Log CPAN_used/
    cp -rv CPAN/SQL/* CPAN_used/SQL/
    rm -r CPAN
    mv CPAN_used CPAN

    # another set of vendored/modified modules exist in lib, more selectively cleaned for now
    rm -rf lib/Audio

    ${lib.optionalString (!enableUnfreeFirmware) ''
      # remove unfree firmware
      rm -rf Firmware
    ''}

    touch Makefile.PL
  '';

  doCheck = false;

  installPhase = ''
    cp -r . $out
    wrapProgram $out/slimserver.pl --prefix LD_LIBRARY_PATH : "${libPath}" --prefix PATH : "${binPath}"
    wrapProgram $out/scanner.pl --prefix LD_LIBRARY_PATH : "${libPath}" --prefix PATH : "${binPath}"
    mkdir $out/bin
    ln -s $out/slimserver.pl $out/bin/slimserver
  '';

  outputs = [ "out" ];

  passthru = {
    tests = {
      inherit (nixosTests) slimserver;
    };

    updateScript = ./update.nu;
  };

  meta = with lib; {
    homepage = "https://lyrion.org/";
    changelog = "https://github.com/LMS-Community/slimserver/blob/${version}/Changelog${lib.versions.major version}.html";
    description = "Lyrion Music Server (formerly Logitech Media Server) is open-source server software which controls a wide range of Squeezebox audio players";
    # the firmware is not under a free license, so we do not include firmware in the default package
    # https://github.com/LMS-Community/slimserver/blob/public/8.3/License.txt
    license = if enableUnfreeFirmware then licenses.unfree else licenses.gpl2Only;
    mainProgram = "slimserver";
    maintainers = with maintainers; [
      adamcstephens
      jecaro
    ];
    platforms = platforms.unix;
    broken = stdenv.isDarwin;
  };
}