summary refs log tree commit diff
path: root/pkgs/servers/gerbera/default.nix
blob: 35290de6b24520d9c7d7966c81a79963b1384e56 (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
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
  # required
, fmt
, libiconv
, libupnp
, libuuid
, pugixml
, spdlog
, sqlite
, zlib
  # options
, enableMysql ? false
, libmysqlclient
, enableDuktape ? true
, duktape
, enableCurl ? true
, curl
, enableTaglib ? true
, taglib
, enableLibmagic ? true
, file
, enableLibmatroska ? true
, libmatroska
, libebml
, enableAvcodec ? false
, ffmpeg
, enableLibexif ? true
, libexif
, enableExiv2 ? false
, exiv2
, enableFFmpegThumbnailer ? false
, ffmpegthumbnailer
, enableInotifyTools ? true
, inotify-tools
}:

let
  libupnp' = libupnp.overrideAttrs (super: rec {
    cmakeFlags = super.cmakeFlags or [ ] ++ [
      "-Dblocking_tcp_connections=OFF"
      "-Dreuseaddr=ON"
    ];
  });

  options = [
    { name = "AVCODEC"; enable = enableAvcodec; packages = [ ffmpeg ]; }
    { name = "CURL"; enable = enableCurl; packages = [ curl ]; }
    { name = "EXIF"; enable = enableLibexif; packages = [ libexif ]; }
    { name = "EXIV2"; enable = enableExiv2; packages = [ exiv2 ]; }
    { name = "FFMPEGTHUMBNAILER"; enable = enableFFmpegThumbnailer; packages = [ ffmpegthumbnailer ]; }
    { name = "INOTIFY"; enable = enableInotifyTools; packages = [ inotify-tools ]; }
    { name = "JS"; enable = enableDuktape; packages = [ duktape ]; }
    { name = "MAGIC"; enable = enableLibmagic; packages = [ file ]; }
    { name = "MATROSKA"; enable = enableLibmatroska; packages = [ libmatroska libebml ]; }
    { name = "MYSQL"; enable = enableMysql; packages = [ libmysqlclient ]; }
    { name = "TAGLIB"; enable = enableTaglib; packages = [ taglib ]; }
  ];

  inherit (lib) flatten optionals;

in
stdenv.mkDerivation rec {
  pname = "gerbera";
  version = "1.8.1";

  src = fetchFromGitHub {
    repo = "gerbera";
    owner = "gerbera";
    rev = "v${version}";
    sha256 = "sha256-bJIT/qQOKTy2l0wsumlGNvaGqzb2mK0hHKG0S6mEG3o=";
  };

  postPatch = lib.optionalString enableMysql ''
    substituteInPlace cmake/FindMySQL.cmake \
      --replace /usr/include/mysql ${lib.getDev libmysqlclient}/include/mariadb \
      --replace /usr/lib/mysql     ${lib.getLib libmysqlclient}/lib/mariadb
  '';

  cmakeFlags = [
    # systemd service will be generated alongside the service
    "-DWITH_SYSTEMD=OFF"
  ] ++ map (e: "-DWITH_${e.name}=${if e.enable then "ON" else "OFF"}") options;

  nativeBuildInputs = [ cmake pkg-config ];

  buildInputs = [
    fmt
    libiconv
    libupnp'
    libuuid
    pugixml
    spdlog
    sqlite
    zlib
  ] ++ flatten (builtins.catAttrs "packages" (builtins.filter (e: e.enable) options));

  meta = with lib; {
    homepage = "https://docs.gerbera.io/";
    description = "UPnP Media Server for 2020";
    longDescription = ''
      Gerbera is a Mediatomb fork.
      It allows to stream your digital media through your home network and consume it on all kinds
      of UPnP supporting devices.
    '';
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ ardumont ];
    platforms = platforms.linux;
  };
}