aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/applications/video/webtorrent_desktop/default.nix
blob: ef50dad86bcc73dbb6faea695e9c19522b1e6f4c (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
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
{
  alsaLib, atk, cairo, cups, dbus, dpkg, expat, fetchurl, fetchzip, fontconfig, freetype,
  gdk-pixbuf, glib, gnome3, libX11, libXScrnSaver, libXcomposite, libXcursor,
  libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst,
  libxcb, nspr, nss, stdenv, udev, libuuid, pango, at-spi2-atk, at-spi2-core
}:

  let
    rpath = stdenv.lib.makeLibraryPath ([
    alsaLib
    atk
    at-spi2-core
    at-spi2-atk
    cairo
    cups
    dbus
    expat
    fontconfig
    freetype
    gdk-pixbuf
    glib
    gnome3.gtk
    pango
    libuuid
    libX11
    libXScrnSaver
    libXcomposite
    libXcursor
    libXdamage
    libXext
    libXfixes
    libXi
    libXrandr
    libXrender
    libXtst
    libxcb
    nspr
    nss
    stdenv.cc.cc
    udev
    ]);
  in stdenv.mkDerivation rec {
    pname = "webtorrent-desktop";
    version = "0.21.0";

    src =
      if stdenv.hostPlatform.system == "x86_64-linux" then
        fetchzip {
          url = "https://github.com/webtorrent/webtorrent-desktop/releases/download/v${version}/WebTorrent-v${version}-linux.zip";
          sha256 = "13gd8isq2l10kibsc1bsc15dbgpnwa7nw4cwcamycgx6pfz9a852";
        }
        else
          throw "Webtorrent is not currently supported on ${stdenv.hostPlatform.system}";
    desktopFile = fetchurl {
      url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/applications/webtorrent-desktop.desktop";
      sha256 = "1v16dqbxqds3cqg3xkzxsa5fyd8ssddvjhy9g3i3lz90n47916ca";
    };
    icon256File = fetchurl {
      url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/256x256/apps/webtorrent-desktop.png";
      sha256 = "1dapxvvp7cx52zhyaby4bxm4rll9xc7x3wk8k0il4g3mc7zzn3yk";
    };
    icon48File = fetchurl {
      url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/48x48/apps/webtorrent-desktop.png";
      sha256 = "00y96w9shbbrdbf6xcjlahqd08154kkrxmqraik7qshiwcqpw7p4";
    };
    phases = [ "unpackPhase" "installPhase" ];
    nativeBuildInputs = [ dpkg ];
    installPhase = ''
      mkdir -p $out/share/{applications,icons/hicolor/{48x48,256x256}/apps}
      cp -R . $out/libexec

      # Patch WebTorrent
      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
               --set-rpath ${rpath}:$out/libexec $out/libexec/WebTorrent

      # Symlink to bin
      mkdir -p $out/bin
      ln -s $out/libexec/WebTorrent $out/bin/WebTorrent

      cp $icon48File $out/share/icons/hicolor/48x48/apps/webtorrent-desktop.png
      cp $icon256File $out/share/icons/hicolor/256x256/apps/webtorrent-desktop.png
      ## Fix the desktop link
      substitute $desktopFile $out/share/applications/webtorrent-desktop.desktop \
        --replace /opt/webtorrent-desktop $out/libexec
    '';

    meta = with stdenv.lib; {
      description = "Streaming torrent app for Mac, Windows, and Linux.";
      homepage = "https://webtorrent.io/desktop";
      license = licenses.mit;
      maintainers = [ maintainers.flokli ];
      platforms = [
        "x86_64-linux"
      ];
    };
  }