summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerwig Hochleitner <herwig@bendlas.net>2022-02-22 03:01:54 +0100
committerHerwig Hochleitner <herwig@bendlas.net>2022-04-06 20:34:28 +0200
commit3532dfd22c30659f2d48386b57558219dde35446 (patch)
tree3f2b47789a4ab225f853ed2fd0c2d6fda2c9b148
parentMerge pull request #167197 from LibreCybernetics/update-kotlin (diff)
downloadnixpkgs-origin/fix-webtorrent-desktop.tar.gz
webtorrent_desktop: run in fhsenvorigin/fix-webtorrent-desktop
this fixes current breakage, and should be a more durable solution for running the binary distribution
-rw-r--r--pkgs/applications/video/webtorrent_desktop/default.nix155
1 files changed, 68 insertions, 87 deletions
diff --git a/pkgs/applications/video/webtorrent_desktop/default.nix b/pkgs/applications/video/webtorrent_desktop/default.nix
index b4f8af61fca5..8f1353fa83e4 100644
--- a/pkgs/applications/video/webtorrent_desktop/default.nix
+++ b/pkgs/applications/video/webtorrent_desktop/default.nix
@@ -1,95 +1,76 @@
+## FIXME: see ../../../servers/code-server/ for a proper yarn packaging
+## - export ELECTRON_SKIP_BINARY_DOWNLOAD=1
+## - jq "del(.scripts.preinstall)" node_modules/shellcheck/package.json | sponge node_modules/shellcheck/package.json
{
- alsa-lib, atk, cairo, cups, dbus, dpkg, expat, fetchurl, fetchzip, fontconfig, freetype,
- gdk-pixbuf, glib, gtk3, libX11, libXScrnSaver, libXcomposite, libXcursor,
- libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst,
- libxcb, nspr, nss, lib, stdenv, udev, libuuid, pango, at-spi2-atk, at-spi2-core
+ lib, stdenv, buildFHSUserEnvBubblewrap, runCommand, writeScript, fetchurl, fetchzip
}:
+let
+ pname = "webtorrent-desktop";
+ version = "0.21.0";
+in
+runCommand "${pname}-${version}" rec {
+ inherit (stdenv) shell;
+ inherit pname version;
+ 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}";
- let
- rpath = lib.makeLibraryPath ([
- alsa-lib
- atk
- at-spi2-core
- at-spi2-atk
- cairo
- cups
- dbus
- expat
- fontconfig
- freetype
- gdk-pixbuf
- glib
- gtk3
- 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";
+ fhs = buildFHSUserEnvBubblewrap rec {
+ name = "fhsEnterWebTorrent";
+ runScript = "${src}/WebTorrent";
+ ## use the trampoline, if you need to shell into the fhsenv
+ # runScript = writeScript "trampoline" ''
+ # #!/bin/sh
+ # exec "$@"
+ # '';
+ targetPkgs = pkgs: with pkgs; with xorg; [
+ alsa-lib atk at-spi2-core at-spi2-atk cairo cups dbus expat
+ fontconfig freetype gdk-pixbuf glib gtk3 pango libuuid libX11
+ libXScrnSaver libXcomposite libXcursor libXdamage libXext
+ libXfixes libXi libXrandr libXrender libXtst libxcb nspr nss
+ stdenv.cc.cc udev
+ ];
+ # extraBwrapArgs = [
+ # "--ro-bind /run/user/$(id -u)/pulse /run/user/$(id -u)/pulse"
+ # ];
+ };
- 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";
- };
- nativeBuildInputs = [ dpkg ];
- installPhase = ''
- mkdir -p $out/share/{applications,icons/hicolor/{48x48,256x256}/apps}
- cp -R . $out/libexec
+ 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";
+ };
- # Patch WebTorrent
- patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
- --set-rpath ${rpath}:$out/libexec $out/libexec/WebTorrent
+ meta = with lib; {
+ description = "Streaming torrent app for Mac, Windows, and Linux";
+ homepage = "https://webtorrent.io/desktop";
+ license = licenses.mit;
+ maintainers = [ maintainers.flokli maintainers.bendlas ];
+ platforms = [
+ "x86_64-linux"
+ ];
+ };
- # Symlink to bin
- mkdir -p $out/bin
- ln -s $out/libexec/WebTorrent $out/bin/WebTorrent
+} ''
+ mkdir -p $out/{bin,share/{applications,icons/hicolor/{48x48,256x256}/apps}}
- 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
- '';
+ cp $fhs/bin/fhsEnterWebTorrent $out/bin/WebTorrent
- meta = with 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"
- ];
- };
- }
+ 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
+''