forked from mirrors/nixpkgs
Merge pull request #31743 from ttuegel/firefox/wrapper
wrapFirefox: make overridable, support browserpass
This commit is contained in:
commit
33a736cafa
|
@ -8,148 +8,160 @@
|
||||||
, google_talk_plugin, fribid, gnome3/*.gnome_shell*/
|
, google_talk_plugin, fribid, gnome3/*.gnome_shell*/
|
||||||
, esteidfirefoxplugin
|
, esteidfirefoxplugin
|
||||||
, vlc_npapi
|
, vlc_npapi
|
||||||
|
, browserpass
|
||||||
, libudev
|
, libudev
|
||||||
, kerberos
|
, kerberos
|
||||||
}:
|
}:
|
||||||
|
|
||||||
## configurability of the wrapper itself
|
## configurability of the wrapper itself
|
||||||
|
|
||||||
browser:
|
browser:
|
||||||
{ browserName ? browser.browserName or (builtins.parseDrvName browser.name).name
|
|
||||||
, name ? (browserName + "-" + (builtins.parseDrvName browser.name).version)
|
|
||||||
, desktopName ? # browserName with first letter capitalized
|
|
||||||
(lib.toUpper (lib.substring 0 1 browserName) + lib.substring 1 (-1) browserName)
|
|
||||||
, nameSuffix ? ""
|
|
||||||
, icon ? browserName
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = stdenv.lib.attrByPath [ browserName ] {} config;
|
wrapper =
|
||||||
enableAdobeFlash = cfg.enableAdobeFlash or false;
|
{ browserName ? browser.browserName or (builtins.parseDrvName browser.name).name
|
||||||
ffmpegSupport = browser.ffmpegSupport or false;
|
, name ? (browserName + "-" + (builtins.parseDrvName browser.name).version)
|
||||||
gssSupport = browser.gssSupport or false;
|
, desktopName ? # browserName with first letter capitalized
|
||||||
jre = cfg.jre or false;
|
(lib.toUpper (lib.substring 0 1 browserName) + lib.substring 1 (-1) browserName)
|
||||||
icedtea = cfg.icedtea or false;
|
, nameSuffix ? ""
|
||||||
|
, icon ? browserName
|
||||||
|
, extraPlugins ? []
|
||||||
|
, extraNativeMessagingHosts ? []
|
||||||
|
}:
|
||||||
|
|
||||||
plugins =
|
let
|
||||||
assert !(jre && icedtea);
|
cfg = stdenv.lib.attrByPath [ browserName ] {} config;
|
||||||
([ ]
|
enableAdobeFlash = cfg.enableAdobeFlash or false;
|
||||||
++ lib.optional enableAdobeFlash flashplayer
|
ffmpegSupport = browser.ffmpegSupport or false;
|
||||||
++ lib.optional (cfg.enableDjvu or false) (djview4)
|
gssSupport = browser.gssSupport or false;
|
||||||
++ lib.optional (cfg.enableMPlayer or false) (MPlayerPlugin browser)
|
jre = cfg.jre or false;
|
||||||
++ lib.optional (supportsJDK && jre && jrePlugin ? mozillaPlugin) jrePlugin
|
icedtea = cfg.icedtea or false;
|
||||||
++ lib.optional icedtea icedtea_web
|
|
||||||
++ lib.optional (cfg.enableGoogleTalkPlugin or false) google_talk_plugin
|
|
||||||
++ lib.optional (cfg.enableFriBIDPlugin or false) fribid
|
|
||||||
++ lib.optional (cfg.enableGnomeExtensions or false) gnome3.gnome_shell
|
|
||||||
++ lib.optional (cfg.enableTrezor or false) trezor-bridge
|
|
||||||
++ lib.optional (cfg.enableBluejeans or false) bluejeans
|
|
||||||
++ lib.optional (cfg.enableAdobeReader or false) adobe-reader
|
|
||||||
++ 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)
|
|
||||||
(with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib libudev ])
|
|
||||||
++ lib.optional (enableAdobeFlash && (cfg.enableAdobeFlashDRM or false)) hal-flash
|
|
||||||
++ lib.optional (config.pulseaudio or false) libpulseaudio;
|
|
||||||
gst-plugins = with gst_all; [ gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-ffmpeg ];
|
|
||||||
gtk_modules = [ libcanberra_gtk2 ];
|
|
||||||
|
|
||||||
in stdenv.mkDerivation {
|
plugins =
|
||||||
inherit name;
|
assert !(jre && icedtea);
|
||||||
|
([ ]
|
||||||
|
++ lib.optional enableAdobeFlash flashplayer
|
||||||
|
++ lib.optional (cfg.enableDjvu or false) (djview4)
|
||||||
|
++ lib.optional (cfg.enableMPlayer or false) (MPlayerPlugin browser)
|
||||||
|
++ lib.optional (supportsJDK && jre && jrePlugin ? mozillaPlugin) jrePlugin
|
||||||
|
++ lib.optional icedtea icedtea_web
|
||||||
|
++ lib.optional (cfg.enableGoogleTalkPlugin or false) google_talk_plugin
|
||||||
|
++ lib.optional (cfg.enableFriBIDPlugin or false) fribid
|
||||||
|
++ lib.optional (cfg.enableGnomeExtensions or false) gnome3.gnome_shell
|
||||||
|
++ lib.optional (cfg.enableTrezor or false) trezor-bridge
|
||||||
|
++ lib.optional (cfg.enableBluejeans or false) bluejeans
|
||||||
|
++ lib.optional (cfg.enableAdobeReader or false) adobe-reader
|
||||||
|
++ lib.optional (cfg.enableEsteid or false) esteidfirefoxplugin
|
||||||
|
++ lib.optional (cfg.enableVLC or false) vlc_npapi
|
||||||
|
++ extraPlugins
|
||||||
|
);
|
||||||
|
nativeMessagingHosts =
|
||||||
|
([ ]
|
||||||
|
++ lib.optional (cfg.enableBrowserpass or false) browserpass
|
||||||
|
++ extraNativeMessagingHosts
|
||||||
|
);
|
||||||
|
libs = (if ffmpegSupport then [ ffmpeg ] else with gst_all; [ gstreamer gst-plugins-base ])
|
||||||
|
++ lib.optional gssSupport kerberos
|
||||||
|
++ lib.optionals (cfg.enableQuakeLive or false)
|
||||||
|
(with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib libudev ])
|
||||||
|
++ lib.optional (enableAdobeFlash && (cfg.enableAdobeFlashDRM or false)) hal-flash
|
||||||
|
++ lib.optional (config.pulseaudio or false) libpulseaudio;
|
||||||
|
gst-plugins = with gst_all; [ gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-ffmpeg ];
|
||||||
|
gtk_modules = [ libcanberra_gtk2 ];
|
||||||
|
|
||||||
desktopItem = makeDesktopItem {
|
in stdenv.mkDerivation {
|
||||||
name = browserName;
|
inherit name;
|
||||||
exec = "${browserName}${nameSuffix} %U";
|
|
||||||
inherit icon;
|
|
||||||
comment = "";
|
|
||||||
desktopName = "${desktopName}${nameSuffix}";
|
|
||||||
genericName = "Web Browser";
|
|
||||||
categories = "Application;Network;WebBrowser;";
|
|
||||||
mimeType = stdenv.lib.concatStringsSep ";" [
|
|
||||||
"text/html"
|
|
||||||
"text/xml"
|
|
||||||
"application/xhtml+xml"
|
|
||||||
"application/vnd.mozilla.xul+xml"
|
|
||||||
"x-scheme-handler/http"
|
|
||||||
"x-scheme-handler/https"
|
|
||||||
"x-scheme-handler/ftp"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
buildInputs = [makeWrapper]
|
desktopItem = makeDesktopItem {
|
||||||
++ lib.optional (!ffmpegSupport) gst-plugins
|
name = browserName;
|
||||||
++ lib.optional (browser ? gtk3) browser.gtk3;
|
exec = "${browserName}${nameSuffix} %U";
|
||||||
|
inherit icon;
|
||||||
|
comment = "";
|
||||||
|
desktopName = "${desktopName}${nameSuffix}";
|
||||||
|
genericName = "Web Browser";
|
||||||
|
categories = "Application;Network;WebBrowser;";
|
||||||
|
mimeType = stdenv.lib.concatStringsSep ";" [
|
||||||
|
"text/html"
|
||||||
|
"text/xml"
|
||||||
|
"application/xhtml+xml"
|
||||||
|
"application/vnd.mozilla.xul+xml"
|
||||||
|
"x-scheme-handler/http"
|
||||||
|
"x-scheme-handler/https"
|
||||||
|
"x-scheme-handler/ftp"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
buildCommand = ''
|
buildInputs = [makeWrapper]
|
||||||
if [ ! -x "${browser}/bin/${browserName}" ]
|
++ lib.optional (!ffmpegSupport) gst-plugins
|
||||||
then
|
++ lib.optional (browser ? gtk3) browser.gtk3;
|
||||||
echo "cannot find executable file \`${browser}/bin/${browserName}'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")" \
|
buildCommand = ''
|
||||||
"$out/bin/${browserName}${nameSuffix}" \
|
if [ ! -x "${browser}/bin/${browserName}" ]
|
||||||
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
|
then
|
||||||
--suffix LD_LIBRARY_PATH ':' "$libs" \
|
echo "cannot find executable file \`${browser}/bin/${browserName}'"
|
||||||
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
exit 1
|
||||||
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
|
fi
|
||||||
--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)
|
|
||||||
''--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
|
|
||||||
--suffix XDG_DATA_DIRS : '${gnome3.defaultIconTheme}/share'
|
|
||||||
''
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -e "${browser}/share/icons" ]; then
|
makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")" \
|
||||||
mkdir -p "$out/share"
|
"$out/bin/${browserName}${nameSuffix}" \
|
||||||
ln -s "${browser}/share/icons" "$out/share/icons"
|
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
|
||||||
else
|
--suffix LD_LIBRARY_PATH ':' "$libs" \
|
||||||
mkdir -p "$out/share/icons/hicolor/128x128/apps"
|
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
||||||
ln -s "${browser}/lib/${browserName}-"*"/browser/icons/mozicon128.png" \
|
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
|
||||||
"$out/share/icons/hicolor/128x128/apps/${browserName}.png"
|
--prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))" \
|
||||||
fi
|
--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)
|
||||||
|
''--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
|
||||||
|
--suffix XDG_DATA_DIRS : '${gnome3.defaultIconTheme}/share'
|
||||||
|
''
|
||||||
|
}
|
||||||
|
|
||||||
install -D -t $out/share/applications $desktopItem/share/applications/*
|
if [ -e "${browser}/share/icons" ]; then
|
||||||
|
mkdir -p "$out/share"
|
||||||
|
ln -s "${browser}/share/icons" "$out/share/icons"
|
||||||
|
else
|
||||||
|
mkdir -p "$out/share/icons/hicolor/128x128/apps"
|
||||||
|
ln -s "${browser}/lib/${browserName}-"*"/browser/icons/mozicon128.png" \
|
||||||
|
"$out/share/icons/hicolor/128x128/apps/${browserName}.png"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $out/lib/mozilla
|
install -D -t $out/share/applications $desktopItem/share/applications/*
|
||||||
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/lib/mozilla
|
||||||
mkdir -p $out/nix-support
|
for ext in ${toString nativeMessagingHosts}; do
|
||||||
echo ${browser} > $out/nix-support/propagated-user-env-packages
|
${lndir}/bin/lndir -silent $ext/lib/mozilla $out/lib/mozilla
|
||||||
'';
|
done
|
||||||
|
|
||||||
preferLocalBuild = true;
|
# For manpages, in case the program supplies them
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
echo ${browser} > $out/nix-support/propagated-user-env-packages
|
||||||
|
'';
|
||||||
|
|
||||||
# Let each plugin tell us (through its `mozillaPlugin') attribute
|
preferLocalBuild = true;
|
||||||
# where to find the plugin in its tree.
|
|
||||||
plugins = map (x: x + x.mozillaPlugin) plugins;
|
|
||||||
libs = lib.makeLibraryPath libs + ":" + lib.makeSearchPathOutput "lib" "lib64" libs;
|
|
||||||
gtk_modules = map (x: x + x.gtkModule) gtk_modules;
|
|
||||||
|
|
||||||
passthru = { unwrapped = browser; };
|
# Let each plugin tell us (through its `mozillaPlugin') attribute
|
||||||
|
# where to find the plugin in its tree.
|
||||||
|
plugins = map (x: x + x.mozillaPlugin) plugins;
|
||||||
|
libs = lib.makeLibraryPath libs + ":" + lib.makeSearchPathOutput "lib" "lib64" libs;
|
||||||
|
gtk_modules = map (x: x + x.gtkModule) gtk_modules;
|
||||||
|
|
||||||
disallowedRequisites = [ stdenv.cc ];
|
passthru = { unwrapped = browser; };
|
||||||
|
|
||||||
meta = browser.meta // {
|
disallowedRequisites = [ stdenv.cc ];
|
||||||
description =
|
|
||||||
browser.meta.description
|
meta = browser.meta // {
|
||||||
+ " (with plugins: "
|
description =
|
||||||
+ lib.concatStrings (lib.intersperse ", " (map (x: x.name) plugins))
|
browser.meta.description
|
||||||
+ ")";
|
+ " (with plugins: "
|
||||||
hydraPlatforms = [];
|
+ lib.concatStrings (lib.intersperse ", " (map (x: x.name) plugins))
|
||||||
priority = (browser.meta.priority or 0) - 1; # prefer wrapper over the package
|
+ ")";
|
||||||
};
|
hydraPlatforms = [];
|
||||||
}
|
priority = (browser.meta.priority or 0) - 1; # prefer wrapper over the package
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.makeOverridable wrapper
|
||||||
|
|
Loading…
Reference in a new issue