From fd38a119dfa0015b6f3a4522c280d5066268d542 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 6 Mar 2019 17:50:43 -0600 Subject: [PATCH 1/7] fx_cast_bridge: init at 0.0.3! --- pkgs/tools/misc/fx_cast/default.nix | 85 +++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 87 insertions(+) create mode 100644 pkgs/tools/misc/fx_cast/default.nix diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix new file mode 100644 index 000000000000..78567da5b9bb --- /dev/null +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -0,0 +1,85 @@ +{ stdenv, fetchurl, dpkg }: + +stdenv.mkDerivation rec { + pname = "fx_cast_bridge"; + version = "0.0.3"; + + src = fetchurl { + url = "https://github.com/hensm/fx_cast/releases/download/v${version}/fx_cast_bridge-${version}-x64.deb"; + sha256 = "0wqm0spmffn31yd23ych6fjxhzfxhj92379h0qdjh2xr3as4yh4n"; + }; + + nativeBuildInputs = [ dpkg ]; + + unpackPhase = '' + runHook preUnpack + dpkg-deb -x $src ./ + runHook postUnpack + ''; + + dontBuild = true; + dontPatchELF = true; + + installPhase = '' + install -DT {opt/fx_cast,$out/bin}/bridge + install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json + + substituteInPlace $out/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json \ + --replace /opt/fx_cast/bridge $out/bin/bridge + ''; + + # See now-cli/default.nix + dontStrip = true; + preFixup = let + libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc]; + bin = "$out/bin/bridge"; + in '' + + orig_size=$(stat --printf=%s ${bin}) + + patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${bin} + patchelf --set-rpath ${libPath} ${bin} + chmod +x ${bin} + + new_size=$(stat --printf=%s ${bin}) + + ###### zeit-pkg fixing starts here. + # we're replacing plaintext js code that looks like + # PAYLOAD_POSITION = '1234 ' | 0 + # [...] + # PRELUDE_POSITION = '1234 ' | 0 + # ^-----20-chars-----^^------22-chars------^ + # ^-- grep points here + # + # var_* are as described above + # shift_by seems to be safe so long as all patchelf adjustments occur + # before any locations pointed to by hardcoded offsets + + var_skip=20 + var_select=22 + shift_by=$(expr $new_size - $orig_size) + + function fix_offset { + # $1 = name of variable to adjust + location=$(grep -obUam1 "$1" ${bin} | cut -d: -f1) + location=$(expr $location + $var_skip) + + value=$(dd if=${bin} iflag=count_bytes,skip_bytes skip=$location \ + bs=1 count=$var_select status=none) + value=$(expr $shift_by + $value) + + echo -n $value | dd of=${bin} bs=1 seek=$location conv=notrunc + } + + fix_offset PAYLOAD_POSITION + fix_offset PRELUDE_POSITION + + ''; + + meta = with stdenv.lib; { + description = "Implementation of the Chrome Sender API (Chromecast) within Firefox"; + homepage = https://hensm.github.io/fx_cast/; + license = licenses.mit; + maintainers = with maintainers; [ dtzWill ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 879daf19b718..a597ddb75473 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1708,6 +1708,8 @@ in fwup = callPackage ../tools/misc/fwup { }; + fx_cast_bridge = callPackage ../tools/misc/fx_cast { }; + fzf = callPackage ../tools/misc/fzf { }; fzf-zsh = callPackage ../shells/zsh/fzf-zsh { }; From c4e9dd4e57935c00c88450e10857c060bf2c45fe Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 6 Mar 2019 18:27:52 -0600 Subject: [PATCH 2/7] firefox: add option to use fx_cast_bridge --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 3ed06717f6a2..f360500ca3d7 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -8,6 +8,7 @@ , google_talk_plugin, fribid, gnome3/*.gnome-shell*/ , browserpass, chrome-gnome-shell, uget-integrator, plasma-browser-integration, bukubrow , tridactyl-native +, fx_cast_bridge , udev , kerberos }: @@ -70,6 +71,7 @@ let ++ lib.optional (cfg.enableGnomeExtensions or false) chrome-gnome-shell ++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator ++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma-browser-integration + ++ lib.optional (cfg.enableFXCastBridge or false) fx_cast_bridge ++ extraNativeMessagingHosts ); libs = lib.optional stdenv.isLinux udev From 2488f6a4a5e23db1a59d90b275f30717878eaafd Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 20 Aug 2019 07:02:46 -0500 Subject: [PATCH 3/7] fx_cast_bridge: 0.0.3 -> 0.0.4 https://github.com/hensm/fx_cast/releases/tag/v0.0.4 (cherry picked from commit c8e255962e89795f50268e1e370fdba31f759994) --- pkgs/tools/misc/fx_cast/default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix index 78567da5b9bb..ff533e7f7237 100644 --- a/pkgs/tools/misc/fx_cast/default.nix +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -2,18 +2,18 @@ stdenv.mkDerivation rec { pname = "fx_cast_bridge"; - version = "0.0.3"; + version = "0.0.4"; src = fetchurl { url = "https://github.com/hensm/fx_cast/releases/download/v${version}/fx_cast_bridge-${version}-x64.deb"; - sha256 = "0wqm0spmffn31yd23ych6fjxhzfxhj92379h0qdjh2xr3as4yh4n"; + sha256 = "1p6d8idbaaqr80vxrmmyfcr5nwb0sk5vwrmizflg39p5zasmmhy2"; }; nativeBuildInputs = [ dpkg ]; unpackPhase = '' runHook preUnpack - dpkg-deb -x $src ./ + dpkg-deb -xv $src ./ runHook postUnpack ''; @@ -21,18 +21,18 @@ stdenv.mkDerivation rec { dontPatchELF = true; installPhase = '' - install -DT {opt/fx_cast,$out/bin}/bridge + install -DT {opt/fx_cast,$out/bin}/fx_cast_bridge install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json substituteInPlace $out/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json \ - --replace /opt/fx_cast/bridge $out/bin/bridge + --replace {opt/fx_cast,$out/bin}/fx_cast_bridge ''; # See now-cli/default.nix dontStrip = true; preFixup = let libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc]; - bin = "$out/bin/bridge"; + bin = "$out/bin/fx_cast_bridge"; in '' orig_size=$(stat --printf=%s ${bin}) From b7c783cfc9576899be4fabecb2d2be1ac4358a05 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 20 Aug 2019 08:26:16 -0500 Subject: [PATCH 4/7] fx_cast_bridge: fix double-slash (cherry picked from commit 61576be9df9f3120dd69f3f5862242212ecc536a) --- pkgs/tools/misc/fx_cast/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix index ff533e7f7237..65f57d96a11b 100644 --- a/pkgs/tools/misc/fx_cast/default.nix +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -25,7 +25,7 @@ stdenv.mkDerivation rec { install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json substituteInPlace $out/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json \ - --replace {opt/fx_cast,$out/bin}/fx_cast_bridge + --replace {/opt/fx_cast,$out/bin}/fx_cast_bridge ''; # See now-cli/default.nix From a21665252d588aa142497a33acb506fa341268e5 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 20 Aug 2019 08:54:26 -0500 Subject: [PATCH 5/7] fx_cast: libc (cherry picked from commit c6d6f636e186b68ae7626dcf611d10a3a50c30a3) --- pkgs/tools/misc/fx_cast/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix index 65f57d96a11b..bb723800f0c5 100644 --- a/pkgs/tools/misc/fx_cast/default.nix +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation rec { # See now-cli/default.nix dontStrip = true; preFixup = let - libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc]; + libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc stdenv.cc.libc]; bin = "$out/bin/fx_cast_bridge"; in '' From b232587833cdf2e1c6a1a13fceebfd62728d06bd Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 7 Sep 2019 13:12:20 -0500 Subject: [PATCH 6/7] fx_cast: use pname a bit more (cherry picked from commit a01a80a52c952bfa70a474cb062e508d3947ca6b) --- pkgs/tools/misc/fx_cast/default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix index bb723800f0c5..e271960d73ef 100644 --- a/pkgs/tools/misc/fx_cast/default.nix +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -5,7 +5,7 @@ stdenv.mkDerivation rec { version = "0.0.4"; src = fetchurl { - url = "https://github.com/hensm/fx_cast/releases/download/v${version}/fx_cast_bridge-${version}-x64.deb"; + url = "https://github.com/hensm/fx_cast/releases/download/v${version}/${pname}-${version}-x64.deb"; sha256 = "1p6d8idbaaqr80vxrmmyfcr5nwb0sk5vwrmizflg39p5zasmmhy2"; }; @@ -21,18 +21,18 @@ stdenv.mkDerivation rec { dontPatchELF = true; installPhase = '' - install -DT {opt/fx_cast,$out/bin}/fx_cast_bridge - install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json + install -DT {opt/fx_cast,$out/bin}/${pname} + install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/${pname}.json - substituteInPlace $out/lib/mozilla/native-messaging-hosts/fx_cast_bridge.json \ - --replace {/opt/fx_cast,$out/bin}/fx_cast_bridge + substituteInPlace $out/lib/mozilla/native-messaging-hosts/${pname}.json \ + --replace {/opt/fx_cast,$out/bin}/${pname} ''; # See now-cli/default.nix dontStrip = true; preFixup = let libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc stdenv.cc.libc]; - bin = "$out/bin/fx_cast_bridge"; + bin = "$out/bin/${pname}"; in '' orig_size=$(stat --printf=%s ${bin}) From 9a80ee245ceeaf7a0c25e8811a09a0b2bd39bd7d Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 27 Jan 2020 12:09:37 -0600 Subject: [PATCH 7/7] fx_cast_bridge: 0.0.4 -> 0.0.5 --- pkgs/tools/misc/fx_cast/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/misc/fx_cast/default.nix b/pkgs/tools/misc/fx_cast/default.nix index e271960d73ef..5fa57e830d22 100644 --- a/pkgs/tools/misc/fx_cast/default.nix +++ b/pkgs/tools/misc/fx_cast/default.nix @@ -2,11 +2,11 @@ stdenv.mkDerivation rec { pname = "fx_cast_bridge"; - version = "0.0.4"; + version = "0.0.5"; src = fetchurl { url = "https://github.com/hensm/fx_cast/releases/download/v${version}/${pname}-${version}-x64.deb"; - sha256 = "1p6d8idbaaqr80vxrmmyfcr5nwb0sk5vwrmizflg39p5zasmmhy2"; + sha256 = "1qmp1d7miq7c2q8i4bhfp5ywxdngvyi7rjl6i82is2g5nhr7gbvv"; }; nativeBuildInputs = [ dpkg ];