summary refs log tree commit diff
path: root/pkgs/servers/tautulli/default.nix
blob: cbcd3c354cb4c775e19d52e7cce26d31157a3f2b (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
{stdenv, fetchFromGitHub, python }:

stdenv.mkDerivation rec {
  version = "2.1.38";
  pname = "Tautulli";

  pythonPath = [ python.pkgs.setuptools ];
  buildInputs = [ python.pkgs.setuptools ];
  nativeBuildInputs = [ python.pkgs.wrapPython ];

  src = fetchFromGitHub {
    owner = "Tautulli";
    repo = pname;
    rev = "v${version}";
    sha256 = "00kxz4i97lk3cb11vcpj894xdi7q9f1jcy29yglya8rcvsqmddwd";
  };

  buildPhase = ":";

  installPhase = ''
    mkdir -p $out
    cp -R * $out/

    # Remove the PlexPy.py compatibility file as it won't work after wrapping.
    # We still have the plexpy executable in bin for compatibility.
    rm $out/PlexPy.py

    # Remove superfluous Python checks from main script;
    # prepend shebang
    echo "#!${python.interpreter}" > $out/Tautulli.py
    tail -n +7 Tautulli.py >> $out/Tautulli.py


    mkdir $out/bin
    # Can't just symlink to the main script, since it uses __file__ to
    # import bundled packages and manage the service
    echo "#!/bin/bash" > $out/bin/tautulli
    echo "$out/Tautulli.py \$*" >> $out/bin/tautulli
    chmod +x $out/bin/tautulli

    # Creat backwards compatibility symlink to bin/plexpy
    ln -s $out/bin/tautulli $out/bin/plexpy

    wrapPythonProgramsIn "$out" "$out $pythonPath"
  '';

  meta  = with stdenv.lib; {
    description = "A Python based monitoring and tracking tool for Plex Media Server.";
    homepage = https://tautulli.com/;
    license = licenses.gpl3;
    platforms = platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ csingley ];
  };
}