From 8fab6c9520f3c4e304e9740ae4977ad6efe3425d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rostislav=20Bene=C5=A1?= Date: Sun, 12 Nov 2017 21:18:31 +0100 Subject: [PATCH] firefox: support for native messaging hosts in wrapper --- .../browsers/firefox/env_var_for_system_dir.patch | 14 ++++++++++++++ .../networking/browsers/firefox/packages.nix | 8 +++++++- .../networking/browsers/firefox/wrapper.nix | 11 ++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/networking/browsers/firefox/env_var_for_system_dir.patch diff --git a/pkgs/applications/networking/browsers/firefox/env_var_for_system_dir.patch b/pkgs/applications/networking/browsers/firefox/env_var_for_system_dir.patch new file mode 100644 index 000000000000..a0f581d84733 --- /dev/null +++ b/pkgs/applications/networking/browsers/firefox/env_var_for_system_dir.patch @@ -0,0 +1,14 @@ +diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp +index 380c1c1..255539f 100644 +--- a/toolkit/xre/nsXREDirProvider.cpp ++++ b/toolkit/xre/nsXREDirProvider.cpp +@@ -306,7 +306,8 @@ GetSystemParentDirectory(nsIFile** aFile) + "/usr/lib/mozilla" + #endif + ); +- rv = NS_NewNativeLocalFile(dirname, false, getter_AddRefs(localDir)); ++ const char* pathVar = PR_GetEnv("MOZ_SYSTEM_DIR"); ++ rv = NS_NewNativeLocalFile((pathVar && *pathVar) ? nsDependentCString(pathVar) : reinterpret_cast(dirname), false, getter_AddRefs(localDir)); + #endif + + if (NS_SUCCEEDED(rv)) { diff --git a/pkgs/applications/networking/browsers/firefox/packages.nix b/pkgs/applications/networking/browsers/firefox/packages.nix index a1d5df5029c1..e17fa342455b 100644 --- a/pkgs/applications/networking/browsers/firefox/packages.nix +++ b/pkgs/applications/networking/browsers/firefox/packages.nix @@ -13,7 +13,7 @@ rec { }; patches = - [ ./no-buildconfig.patch ] + [ ./no-buildconfig.patch ./env_var_for_system_dir.patch ] ++ lib.optional stdenv.isi686 (fetchpatch { url = "https://hg.mozilla.org/mozilla-central/raw-rev/15517c5a5d37"; sha256 = "1ba487p3hk4w2w7qqfxgv1y57vp86b8g3xhav2j20qd3j3phbbn7"; @@ -38,6 +38,9 @@ rec { sha512 = "d80c7219548391d8a47b6e404662ea41e6acfa264a67d69365e76dd8943077e388ab24b030850919f8fc6681c11486bdbaaf170d441c861f4a12cedbe08955ab"; }; + patches = + [ ./env_var_for_system_dir.patch ]; + meta = firefox.meta // { description = "A web browser built from Firefox Extended Support Release source tree"; }; @@ -128,6 +131,9 @@ in rec { rev = "tor-browser-52.3.0esr-7.0-1-slnos"; sha256 = "0szbf8gjbl4dnrb4igy4mq5858i1y6ki4skhdw63iqqdd8w9v4yv"; }; + + patches = + [ ./env_var_for_system_dir.patch ]; } // commonAttrs) {}; tor-browser = tor-browser-7-0; diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 7a7d1368cb23..7daa96ed8733 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, makeDesktopItem, makeWrapper, config +{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config ## various stuff that can be plugged in , flashplayer, hal-flash @@ -47,6 +47,9 @@ let ++ lib.optional (cfg.enableEsteid or false) esteidfirefoxplugin ++ lib.optional (cfg.enableVLC or false) vlc_npapi ); + nativeMessagingHosts = + ([ ] + ); libs = (if ffmpegSupport then [ ffmpeg ] else with gst_all; [ gstreamer gst-plugins-base ]) ++ lib.optional gssSupport kerberos ++ lib.optionals (cfg.enableQuakeLive or false) @@ -98,6 +101,7 @@ in stdenv.mkDerivation { --prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))" \ --suffix PATH ':' "$out/bin" \ --set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}" \ + --set MOZ_SYSTEM_DIR "$out/lib/mozilla" \ ${lib.optionalString (!ffmpegSupport) ''--prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"'' + lib.optionalString (browser ? gtk3) @@ -117,6 +121,11 @@ in stdenv.mkDerivation { install -D -t $out/share/applications $desktopItem/share/applications/* + mkdir -p $out/lib/mozilla + for ext in ${toString nativeMessagingHosts}; do + ${lndir}/bin/lndir -silent $ext/lib/mozilla $out/lib/mozilla + done + # For manpages, in case the program supplies them mkdir -p $out/nix-support echo ${browser} > $out/nix-support/propagated-user-env-packages