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
|
2019-06-03 16:07:41 +01:00
|
|
|
, MPlayerPlugin, ffmpeg, xorg, libpulseaudio, libcanberra-gtk2, libglvnd
|
2017-12-15 12:39:29 +00:00
|
|
|
, jrePlugin, icedtea_web
|
2018-09-28 16:36:40 +01:00
|
|
|
, bluejeans, djview4, adobe-reader
|
2018-02-25 02:23:58 +00:00
|
|
|
, google_talk_plugin, fribid, gnome3/*.gnome-shell*/
|
2016-04-26 22:04:14 +01:00
|
|
|
, esteidfirefoxplugin
|
2018-07-30 22:02:32 +01:00
|
|
|
, browserpass, chrome-gnome-shell, uget-integrator, plasma-browser-integration, bukubrow
|
2019-05-28 12:14:06 +01:00
|
|
|
, tridactyl-native
|
2018-07-17 21:11:16 +01:00
|
|
|
, udev
|
2017-09-27 14:30:29 +01: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 12:51:24 +01:00
|
|
|
browser:
|
2004-10-17 14:28:28 +01: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 ? []
|
2019-02-03 11:06:11 +00:00
|
|
|
, gdkWayland ? false
|
2019-06-25 21:17:21 +01:00
|
|
|
, cfg ? config.${browserName} or {}
|
2017-11-16 15:39:16 +00:00
|
|
|
}:
|
|
|
|
|
2019-02-03 11:06:11 +00:00
|
|
|
assert gdkWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used
|
|
|
|
|
2017-11-16 15:39:16 +00:00
|
|
|
let
|
|
|
|
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 =
|
2018-08-20 20:11:29 +01:00
|
|
|
stdenv.hostPlatform.system == "i686-linux" ||
|
|
|
|
stdenv.hostPlatform.system == "x86_64-linux" ||
|
|
|
|
stdenv.hostPlatform.system == "armv7l-linux" ||
|
|
|
|
stdenv.hostPlatform.system == "aarch64-linux";
|
2017-11-16 15:39:16 +00:00
|
|
|
|
|
|
|
plugins =
|
|
|
|
assert !(jre && icedtea);
|
2018-08-12 12:32:38 +01:00
|
|
|
if builtins.hasAttr "enableVLC" cfg
|
|
|
|
then throw "The option \"${browserName}.enableVLC\" has been removed since Firefox no longer supports npapi plugins"
|
|
|
|
else
|
2017-11-16 15:39:16 +00:00
|
|
|
([ ]
|
|
|
|
++ 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.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 =
|
|
|
|
([ ]
|
2018-07-07 20:11:19 +01:00
|
|
|
++ lib.optional (cfg.enableBrowserpass or false) (lib.getBin browserpass)
|
2018-07-30 22:02:32 +01:00
|
|
|
++ lib.optional (cfg.enableBukubrow or false) bukubrow
|
2019-05-28 12:14:06 +01:00
|
|
|
++ lib.optional (cfg.enableTridactylNative or false) tridactyl-native
|
2018-01-13 14:20:01 +00:00
|
|
|
++ lib.optional (cfg.enableGnomeExtensions or false) chrome-gnome-shell
|
2018-04-30 03:41:36 +01:00
|
|
|
++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator
|
2018-06-13 13:35:15 +01:00
|
|
|
++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma-browser-integration
|
2017-11-16 15:39:36 +00:00
|
|
|
++ extraNativeMessagingHosts
|
2017-11-16 15:39:16 +00:00
|
|
|
);
|
2018-07-17 21:11:16 +01:00
|
|
|
libs = lib.optional stdenv.isLinux udev
|
2018-06-25 02:49:30 +01:00
|
|
|
++ lib.optional ffmpegSupport ffmpeg
|
2017-11-16 15:39:16 +00:00
|
|
|
++ lib.optional gssSupport kerberos
|
2019-06-03 16:07:41 +01:00
|
|
|
++ lib.optional gdkWayland libglvnd
|
2017-11-16 15:39:16 +00:00
|
|
|
++ lib.optionals (cfg.enableQuakeLive or false)
|
2018-06-25 02:49:30 +01:00
|
|
|
(with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib ])
|
2017-11-16 15:39:16 +00:00
|
|
|
++ 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 = "";
|
2019-02-03 11:06:11 +00:00
|
|
|
desktopName = "${desktopName}${nameSuffix}${lib.optionalString gdkWayland " (Wayland)"}";
|
2017-11-16 15:39:16 +00:00
|
|
|
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"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2018-07-29 05:15:14 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper lndir ];
|
|
|
|
buildInputs = lib.optional (browser ? gtk3) browser.gtk3;
|
2017-11-16 15:39:16 +00:00
|
|
|
|
2018-08-09 02:14:59 +01:00
|
|
|
buildCommand = lib.optionalString stdenv.isDarwin ''
|
|
|
|
mkdir -p $out/Applications
|
|
|
|
cp -R --no-preserve=mode,ownership ${browser}/Applications/${browserName}.app $out/Applications
|
2018-08-15 04:34:46 +01:00
|
|
|
rm -f $out${browser.execdir or "/bin"}/${browserName}
|
2018-08-09 02:14:59 +01:00
|
|
|
'' + ''
|
2018-08-15 04:34:46 +01:00
|
|
|
if [ ! -x "${browser}${browser.execdir or "/bin"}/${browserName}" ]
|
2017-11-16 15:39:16 +00:00
|
|
|
then
|
2018-08-17 19:59:53 +01:00
|
|
|
echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
|
2017-11-16 15:39:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-08-17 19:59:53 +01:00
|
|
|
makeWrapper "$(readlink -v --canonicalize-existing "${browser}${browser.execdir or "/bin"}/${browserName}")" \
|
2018-08-15 04:34:46 +01:00
|
|
|
"$out${browser.execdir or "/bin"}/${browserName}${nameSuffix}" \
|
2017-11-16 15:39:16 +00:00
|
|
|
--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))" \
|
2018-08-15 04:34:46 +01:00
|
|
|
--suffix PATH ':' "$out${browser.execdir or "/bin"}" \
|
2017-11-16 15:39:16 +00:00
|
|
|
--set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}" \
|
|
|
|
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
|
2019-05-23 23:17:40 +01:00
|
|
|
--set SNAP_NAME "firefox" \
|
2019-02-03 11:06:11 +00:00
|
|
|
${lib.optionalString gdkWayland ''
|
|
|
|
--set GDK_BACKEND "wayland" \
|
|
|
|
''}${lib.optionalString (browser ? gtk3)
|
2017-11-16 15:39:16 +00:00
|
|
|
''--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
|
2019-02-13 21:47:50 +00:00
|
|
|
--suffix XDG_DATA_DIRS : '${gnome3.adwaita-icon-theme}/share'
|
2017-11-16 15:39:16 +00:00
|
|
|
''
|
|
|
|
}
|
|
|
|
|
|
|
|
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 08:33:09 +01: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 08:33:09 +01: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
|
2018-07-29 05:15:14 +01:00
|
|
|
lndir -silent $ext/lib/mozilla $out/lib/mozilla
|
2017-11-16 15:39:16 +00:00
|
|
|
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
|