@@ -1,95 +1,76 @@
1+## FIXME: see ../../../servers/code-server/ for a proper yarn packaging
2+## - export ELECTRON_SKIP_BINARY_DOWNLOAD=1
3+## - jq "del(.scripts.preinstall)" node_modules/shellcheck/package.json | sponge node_modules/shellcheck/package.json
14{
2− alsa-lib, atk, cairo, cups, dbus, dpkg, expat, fetchurl, fetchzip, fontconfig, freetype,
3− gdk-pixbuf, glib, gtk3, libX11, libXScrnSaver, libXcomposite, libXcursor,
4− libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst,
5− libxcb, nspr, nss, lib, stdenv, udev, libuuid, pango, at-spi2-atk, at-spi2-core
5+ lib, stdenv, buildFHSUserEnvBubblewrap, runCommand, writeScript, fetchurl, fetchzip
66}:
7+let
8+ pname = "webtorrent-desktop";
9+ version = "0.21.0";
10+in
11+runCommand "${pname}-${version}" rec {
12+ inherit (stdenv) shell;
13+ inherit pname version;
14+ src =
15+ if stdenv.hostPlatform.system == "x86_64-linux" then
16+ fetchzip {
17+ url = "https://github.com/webtorrent/webtorrent-desktop/releases/download/v${version}/WebTorrent-v${version}-linux.zip";
18+ sha256 = "13gd8isq2l10kibsc1bsc15dbgpnwa7nw4cwcamycgx6pfz9a852";
19+ }
20+ else
21+ throw "Webtorrent is not currently supported on ${stdenv.hostPlatform.system}";
722
8− let
9− rpath = lib.makeLibraryPath ([
10− alsa-lib
11− atk
12− at-spi2-core
13− at-spi2-atk
14− cairo
15− cups
16− dbus
17− expat
18− fontconfig
19− freetype
20− gdk-pixbuf
21− glib
22− gtk3
23− pango
24− libuuid
25− libX11
26− libXScrnSaver
27− libXcomposite
28− libXcursor
29− libXdamage
30− libXext
31− libXfixes
32− libXi
33− libXrandr
34− libXrender
35− libXtst
36− libxcb
37− nspr
38− nss
39− stdenv.cc.cc
40− udev
41− ]);
42− in stdenv.mkDerivation rec {
43− pname = "webtorrent-desktop";
44− version = "0.21.0";
23+ fhs = buildFHSUserEnvBubblewrap rec {
24+ name = "fhsEnterWebTorrent";
25+ runScript = "${src}/WebTorrent";
26+ ## use the trampoline, if you need to shell into the fhsenv
27+ # runScript = writeScript "trampoline" ''
28+ # #!/bin/sh
29+ # exec "$@"
30+ # '';
31+ targetPkgs = pkgs: with pkgs; with xorg; [
32+ alsa-lib atk at-spi2-core at-spi2-atk cairo cups dbus expat
33+ fontconfig freetype gdk-pixbuf glib gtk3 pango libuuid libX11
34+ libXScrnSaver libXcomposite libXcursor libXdamage libXext
35+ libXfixes libXi libXrandr libXrender libXtst libxcb nspr nss
36+ stdenv.cc.cc udev
37+ ];
38+ # extraBwrapArgs = [
39+ # "--ro-bind /run/user/$(id -u)/pulse /run/user/$(id -u)/pulse"
40+ # ];
41+ };
4542
46− src =
47− if stdenv.hostPlatform.system == "x86_64-linux" then
48− fetchzip {
49− url = "https://github.com/webtorrent/webtorrent-desktop/releases/download/v${version}/WebTorrent-v${version}-linux.zip";
50− sha256 = "13gd8isq2l10kibsc1bsc15dbgpnwa7nw4cwcamycgx6pfz9a852";
51− }
52− else
53− throw "Webtorrent is not currently supported on ${stdenv.hostPlatform.system}";
54− desktopFile = fetchurl {
55− url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/applications/webtorrent-desktop.desktop";
56− sha256 = "1v16dqbxqds3cqg3xkzxsa5fyd8ssddvjhy9g3i3lz90n47916ca";
57− };
58− icon256File = fetchurl {
59− url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/256x256/apps/webtorrent-desktop.png";
60− sha256 = "1dapxvvp7cx52zhyaby4bxm4rll9xc7x3wk8k0il4g3mc7zzn3yk";
61− };
62− icon48File = fetchurl {
63− url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/48x48/apps/webtorrent-desktop.png";
64− sha256 = "00y96w9shbbrdbf6xcjlahqd08154kkrxmqraik7qshiwcqpw7p4";
65− };
66− nativeBuildInputs = [ dpkg ];
67− installPhase = ''
68− mkdir -p $out/share/{applications,icons/hicolor/{48x48,256x256}/apps}
69− cp -R . $out/libexec
43+ desktopFile = fetchurl {
44+ url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/applications/webtorrent-desktop.desktop";
45+ sha256 = "1v16dqbxqds3cqg3xkzxsa5fyd8ssddvjhy9g3i3lz90n47916ca";
46+ };
47+ icon256File = fetchurl {
48+ url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/256x256/apps/webtorrent-desktop.png";
49+ sha256 = "1dapxvvp7cx52zhyaby4bxm4rll9xc7x3wk8k0il4g3mc7zzn3yk";
50+ };
51+ icon48File = fetchurl {
52+ url = "https://raw.githubusercontent.com/webtorrent/webtorrent-desktop/v${version}/static/linux/share/icons/hicolor/48x48/apps/webtorrent-desktop.png";
53+ sha256 = "00y96w9shbbrdbf6xcjlahqd08154kkrxmqraik7qshiwcqpw7p4";
54+ };
7055
71− # Patch WebTorrent
72− patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
73− --set-rpath ${rpath}:$out/libexec $out/libexec/WebTorrent
56+ meta = with lib; {
57+ description = "Streaming torrent app for Mac, Windows, and Linux";
58+ homepage = "https://webtorrent.io/desktop";
59+ license = licenses.mit;
60+ maintainers = [ maintainers.flokli maintainers.bendlas ];
61+ platforms = [
62+ "x86_64-linux"
63+ ];
64+ };
7465
75− # Symlink to bin
76− mkdir -p $out/bin
77− ln -s $out/libexec/WebTorrent $out/bin/WebTorrent
66+} ''
67+ mkdir -p $out/{bin,share/{applications,icons/hicolor/{48x48,256x256}/apps}}
7868
79− cp $icon48File $out/share/icons/hicolor/48x48/apps/webtorrent-desktop.png
80− cp $icon256File $out/share/icons/hicolor/256x256/apps/webtorrent-desktop.png
81− ## Fix the desktop link
82− substitute $desktopFile $out/share/applications/webtorrent-desktop.desktop \
83− --replace /opt/webtorrent-desktop $out/libexec
84− '';
69+ cp $fhs/bin/fhsEnterWebTorrent $out/bin/WebTorrent
8570
86− meta = with lib; {
87− description = "Streaming torrent app for Mac, Windows, and Linux";
88− homepage = "https://webtorrent.io/desktop";
89− license = licenses.mit;
90− maintainers = [ maintainers.flokli ];
91− platforms = [
92− "x86_64-linux"
93− ];
94− };
95− }
71+ cp $icon48File $out/share/icons/hicolor/48x48/apps/webtorrent-desktop.png
72+ cp $icon256File $out/share/icons/hicolor/256x256/apps/webtorrent-desktop.png
73+ ## Fix the desktop link
74+ substitute $desktopFile $out/share/applications/webtorrent-desktop.desktop \
75+ --replace /opt/webtorrent-desktop $out/libexec
76+''