2017-11-12 20:18:31 +00:00
|
|
|
{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config
|
2016-01-10 09:35:45 +00:00
|
|
|
|
|
|
|
## various stuff that can be plugged in
|
2017-02-07 02:40:19 +00:00
|
|
|
, flashplayer, hal-flash
|
2018-05-04 01:19:25 +00:00
|
|
|
, MPlayerPlugin, ffmpeg, xorg, libpulseaudio, libcanberra-gtk2
|
2017-12-15 12:39:29 +00:00
|
|
|
, jrePlugin, icedtea_web
|
2016-02-09 17:19:56 +00:00
|
|
|
, trezor-bridge, bluejeans, djview4, adobe-reader
|
2018-02-25 02:23:58 +00:00
|
|
|
, google_talk_plugin, fribid, gnome3/*.gnome-shell*/
|
2016-04-26 21:04:14 +00:00
|
|
|
, esteidfirefoxplugin
|
2018-04-30 02:41:36 +00:00
|
|
|
, browserpass, chrome-gnome-shell, uget-integrator
|
2017-07-02 15:22:40 +00:00
|
|
|
, libudev
|
2017-09-27 13:30:29 +00:00
|
|
|
, kerberos
|
2016-01-10 09:35:45 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
## configurability of the wrapper itself
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2016-04-01 11:51:24 +00:00
|
|
|
browser:
|
2004-10-17 13:28:28 +00:00
|
|
|
|
2016-01-10 09:35:45 +00:00
|
|
|
let
|
2017-11-16 15:39:16 +00:00
|
|
|
wrapper =
|
|
|
|
{ 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
|
2017-11-16 15:39:36 +00:00
|
|
|
, extraPlugins ? []
|
|
|
|
, extraNativeMessagingHosts ? []
|
2017-11-16 15:39:16 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-03-15 00:00:00 +00:00
|
|
|
cfg = config.${browserName} or {};
|
2017-11-16 15:39:16 +00:00
|
|
|
enableAdobeFlash = cfg.enableAdobeFlash or false;
|
|
|
|
ffmpegSupport = browser.ffmpegSupport or false;
|
|
|
|
gssSupport = browser.gssSupport or false;
|
|
|
|
jre = cfg.jre or false;
|
|
|
|
icedtea = cfg.icedtea or false;
|
2017-12-15 09:14:48 +00:00
|
|
|
supportsJDK =
|
|
|
|
stdenv.system == "i686-linux" ||
|
|
|
|
stdenv.system == "x86_64-linux" ||
|
|
|
|
stdenv.system == "armv7l-linux" ||
|
|
|
|
stdenv.system == "aarch64-linux";
|
2017-11-16 15:39:16 +00:00
|
|
|
|
|
|
|
plugins =
|
|
|
|
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
|
2018-02-25 02:23:58 +00:00
|
|
|
++ lib.optional (cfg.enableGnomeExtensions or false) gnome3.gnome-shell
|
2017-11-16 15:39:16 +00:00
|
|
|
++ 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
|
2017-11-16 15:39:36 +00:00
|
|
|
++ extraPlugins
|
2017-11-16 15:39:16 +00:00
|
|
|
);
|
|
|
|
nativeMessagingHosts =
|
|
|
|
([ ]
|
2017-11-16 15:57:36 +00:00
|
|
|
++ lib.optional (cfg.enableBrowserpass or false) browserpass
|
2018-01-13 14:20:01 +00:00
|
|
|
++ lib.optional (cfg.enableGnomeExtensions or false) chrome-gnome-shell
|
2018-04-30 02:41:36 +00:00
|
|
|
++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator
|
2017-11-16 15:39:36 +00:00
|
|
|
++ extraNativeMessagingHosts
|
2017-11-16 15:39:16 +00:00
|
|
|
);
|
2018-05-04 01:19:25 +00:00
|
|
|
libs = lib.optional ffmpegSupport ffmpeg
|
2017-11-16 15:39:16 +00:00
|
|
|
++ 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
|
2018-02-15 14:03:38 +00:00
|
|
|
++ lib.optional (config.pulseaudio or true) libpulseaudio;
|
2018-02-25 02:23:58 +00:00
|
|
|
gtk_modules = [ libcanberra-gtk2 ];
|
2017-11-16 15:39:16 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = browserName;
|
|
|
|
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]
|
|
|
|
++ lib.optional (browser ? gtk3) browser.gtk3;
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
if [ ! -x "${browser}/bin/${browserName}" ]
|
|
|
|
then
|
|
|
|
echo "cannot find executable file \`${browser}/bin/${browserName}'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")" \
|
|
|
|
"$out/bin/${browserName}${nameSuffix}" \
|
|
|
|
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
|
|
|
|
--suffix LD_LIBRARY_PATH ':' "$libs" \
|
|
|
|
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
|
|
|
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
|
|
|
|
--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" \
|
2018-05-04 01:19:25 +00:00
|
|
|
${lib.optionalString (browser ? gtk3)
|
2017-11-16 15:39:16 +00:00
|
|
|
''--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
|
|
|
|
--suffix XDG_DATA_DIRS : '${gnome3.defaultIconTheme}/share'
|
|
|
|
''
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -e "${browser}/share/icons" ]; then
|
|
|
|
mkdir -p "$out/share"
|
|
|
|
ln -s "${browser}/share/icons" "$out/share/icons"
|
|
|
|
else
|
2018-03-22 16:42:25 +00:00
|
|
|
for res in 16 32 48 64 128; do
|
|
|
|
mkdir -p "$out/share/icons/hicolor/''${res}x''${res}/apps"
|
2018-04-23 07:33:09 +00:00
|
|
|
icon=( "${browser}/lib/"*"/browser/chrome/icons/default/default''${res}.png" )
|
|
|
|
if [ -e "$icon" ]; then ln -s "$icon" \
|
2018-03-22 16:42:25 +00:00
|
|
|
"$out/share/icons/hicolor/''${res}x''${res}/apps/${browserName}.png"
|
2018-04-23 07:33:09 +00:00
|
|
|
fi
|
2018-03-22 16:42:25 +00:00
|
|
|
done
|
2017-11-16 15:39:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
|
|
|
passthru = { unwrapped = browser; };
|
|
|
|
|
|
|
|
disallowedRequisites = [ stdenv.cc ];
|
|
|
|
|
|
|
|
meta = browser.meta // {
|
|
|
|
description =
|
|
|
|
browser.meta.description
|
|
|
|
+ " (with plugins: "
|
|
|
|
+ lib.concatStrings (lib.intersperse ", " (map (x: x.name) plugins))
|
|
|
|
+ ")";
|
|
|
|
hydraPlatforms = [];
|
|
|
|
priority = (browser.meta.priority or 0) - 1; # prefer wrapper over the package
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
lib.makeOverridable wrapper
|