summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/um/ums/package.nix
blob: 1fb6f1bcf9b3cfaa5be72433560b968138d12513 (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
{
  lib,
  stdenv,
  fetchurl,
  makeWrapper,
  libzen,
  libmediainfo,
  jdk17,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "ums";
  version = "13.2.1";

  src =
    let
      selectSystem =
        attrs:
        attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
      arch = selectSystem {
        x86_64-linux = "x86_64";
        aarch64-linux = "arm64";
      };
    in
    fetchurl {
      url = "mirror://sourceforge/project/unimediaserver/${finalAttrs.version}/UMS-${finalAttrs.version}-${arch}.tgz";
      hash = selectSystem {
        x86_64-linux = "sha256-MGi5S0jA9WVh7PuNei5hInUVZLcypJu8izwWJpDi42s=";
        aarch64-linux = "sha256-9x1M1rZxwg65RdMmxQ2geeF0yXrukQ3dQPXKfQ2GRIw=";
      };
    };

  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    runHook preInstall

    cp -a . $out
    mkdir $out/bin
    mv $out/documentation /$out/doc

    # ums >= 9.0.0 ships its own JRE in the package. if we remove it, the `UMS.sh`
    # script will correctly fall back to the JRE specified by JAVA_HOME
    rm -rf $out/jre17

    makeWrapper $out/UMS.sh $out/bin/ums \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          libzen
          libmediainfo
        ]
      } \
      --set JAVA_HOME ${jdk17}

    runHook postInstall
  '';

  meta = {
    description = "Universal Media Server: a DLNA-compliant UPnP Media Server";
    license = lib.licenses.gpl2Only;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [
      thall
      snicket2100
    ];
    mainProgram = "ums";
  };
})