about summary refs log tree commit diff
path: root/pkgs/applications/video/streamlink-twitch-gui/bin.nix
blob: ac1490345c29c14316e185ee97697d4f9594ce00 (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
{ autoPatchelfHook
, fetchurl
, lib
, copyDesktopItems
, makeDesktopItem
, makeWrapper
, stdenv
, wrapGAppsHook3
, at-spi2-core
, atk
, alsa-lib
, cairo
, cups
, dbus
, expat
, gcc-unwrapped
, gdk-pixbuf
, glib
, pango
, gtk3-x11
, libudev0-shim
, libuuid
, mesa
, nss
, nspr
, xorg
, streamlink
}:
let
  basename = "streamlink-twitch-gui";
  runtimeLibs = lib.makeLibraryPath [ gtk3-x11 libudev0-shim ];
  runtimeBins = lib.makeBinPath [ streamlink ];

in
stdenv.mkDerivation rec {
  pname = "${basename}-bin";
  version = "2.4.1";

  src = {
    x86_64-linux = fetchurl {
      url = "https://github.com/streamlink/${basename}/releases/download/v${version}/${basename}-v${version}-linux64.tar.gz";
      hash = "sha256-uzD61Q1XIthAwoJHb0H4sTdYkUj0qGeGs1h0XFeV03E=";
    };
    i686-linux = fetchurl {
      url = "https://github.com/streamlink/${basename}/releases/download/v${version}/${basename}-v${version}-linux32.tar.gz";
      hash = "sha256-akJEd94PmH9YeBud+l5+5QpbnzXAD0jDBKJM4h/t2EA=";
    };
  }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  nativeBuildInputs = with xorg; [
    at-spi2-core
    atk
    alsa-lib
    autoPatchelfHook
    cairo
    copyDesktopItems
    cups.lib
    dbus.lib
    expat
    gcc-unwrapped
    gdk-pixbuf
    glib
    pango
    gtk3-x11
    mesa
    nss
    nspr
    libuuid
    libX11
    libxcb
    libXcomposite
    libXcursor
    libXdamage
    libXext
    libXfixes
    libXi
    libXrandr
    libXrender
    libXScrnSaver
    libXtst
    makeWrapper
    wrapGAppsHook3
  ];

  buildInputs = [ streamlink ];

  dontBuild = true;
  dontConfigure = true;

  installPhase = ''
    runHook preInstall
    mkdir -p $out/{bin,opt/${basename},share}

    # Install all files, remove unnecessary ones
    cp -a . $out/opt/${basename}/
    rm -r $out/opt/${basename}/{{add,remove}-menuitem.sh,credits.html,icons/}
    ln -s $out/opt/${basename}/${basename} $out/bin/
    for res in 16 32 48 64 128 256; do
      install -Dm644 \
        icons/icon-"$res".png \
        $out/share/icons/hicolor/"$res"x"$res"/apps/${basename}.png
    done
    runHook postInstall
  '';

  preFixup = ''
    gappsWrapperArgs+=(
      --add-flags "--no-version-check" \
      --prefix LD_LIBRARY_PATH : ${runtimeLibs} \
      --prefix PATH : ${runtimeBins}
    )
  '';

  desktopItems = [(makeDesktopItem {
    name = basename;
    exec = basename;
    icon = basename;
    desktopName = "Streamlink Twitch GUI";
    genericName = meta.description;
    categories = [ "AudioVideo" "Network" ];
  })];

  meta = with lib; {
    description = "Twitch.tv browser for Streamlink";
    longDescription = "Browse Twitch.tv and watch streams in your videoplayer of choice";
    homepage = "https://streamlink.github.io/streamlink-twitch-gui/";
    downloadPage = "https://github.com/streamlink/streamlink-twitch-gui/releases";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.mit;
    mainProgram = "streamlink-twitch-gui";
    maintainers = with maintainers; [ rileyinman ];
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}