From 95c1429e624f3ff85a301102511a2483cfdf61fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sun, 10 Jan 2016 10:35:45 +0100 Subject: [PATCH] wrapFirefox: move out of all-packages.nix, change defaults - I don't think that amount of code belonged into all-packages.nix. - Now the default name of the wrapped package is identical with the command that runs the browser. - Other defaults were changed according to how the wrapper is (almost always) used. - `meta` is improved: mostly inherited with priority above the unwrapped package. --- .../networking/browsers/firefox/wrapper.nix | 63 +++++++++++++++++-- pkgs/top-level/all-packages.nix | 38 +---------- 2 files changed, 58 insertions(+), 43 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index db51dc8b148..8c805b0bf5f 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -1,11 +1,58 @@ -{ stdenv, lib, browser, makeDesktopItem, makeWrapper, plugins, gst_plugins, libs, gtk_modules -, browserName, desktopName, nameSuffix, icon, libtrick ? true +{ stdenv, lib, makeDesktopItem, makeWrapper, config + +## various stuff that can be plugged in +, gnash, flashplayer, hal-flash +, MPlayerPlugin, gecko_mediaplayer, gst_all, xorg, libpulseaudio, libcanberra +, supportsJDK, jrePlugin, icedtea_web +, trezor-bridge, bluejeans, djview4 +, google_talk_plugin, fribid, gnome3/*.gnome_shell*/ }: -let p = builtins.parseDrvName browser.name; in +## configurability of the wrapper itself +browser : +{ browserName ? (lib.head (lib.splitString "-" browser.name)) # name of the executable +, 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, libtrick ? true +}: +let + cfg = stdenv.lib.attrByPath [ browserName ] {} config; + enableAdobeFlash = cfg.enableAdobeFlash or false; + enableGnash = cfg.enableGnash or false; + jre = cfg.jre or false; + icedtea = cfg.icedtea or false; + + plugins = + assert !(enableGnash && enableAdobeFlash); + assert !(jre && icedtea); + ([ ] + ++ lib.optional enableGnash gnash + ++ lib.optional enableAdobeFlash flashplayer + ++ lib.optional (cfg.enableDjvu or false) (djview4) + ++ lib.optional (cfg.enableMPlayer or false) (MPlayerPlugin browser) + ++ lib.optional (cfg.enableGeckoMediaPlayer or false) gecko_mediaplayer + ++ 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 + ); + libs = [ gst_all.gstreamer gst_all.gst-plugins-base ] + ++ lib.optionals (cfg.enableQuakeLive or false) + (with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib ]) + ++ 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 ]; + +in stdenv.mkDerivation { - name = "${p.name}-with-plugins-${p.version}"; + inherit name; desktopItem = makeDesktopItem { name = browserName; @@ -26,7 +73,7 @@ stdenv.mkDerivation { ]; }; - buildInputs = [makeWrapper] ++ gst_plugins; + buildInputs = [makeWrapper] ++ gst-plugins; buildCommand = '' if [ ! -x "${browser}/bin/${browserName}" ] @@ -82,11 +129,15 @@ stdenv.mkDerivation { libs = map (x: x + "/lib") libs ++ map (x: x + "/lib64") libs; gtk_modules = map (x: x + x.gtkModule) gtk_modules; - meta = { + passthru = { unwrapped = browser; }; + + 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 }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e214487a3e3..0b7771251bd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13621,43 +13621,7 @@ let inherit (python27Packages) cheetah; }; - wrapFirefox = - { browser, browserName ? "firefox", desktopName ? "Firefox", nameSuffix ? "" - , icon ? browserName }: - let - cfg = stdenv.lib.attrByPath [ browserName ] {} config; - enableAdobeFlash = cfg.enableAdobeFlash or false; - enableGnash = cfg.enableGnash or false; - jre = cfg.jre or false; - icedtea = cfg.icedtea or false; - in - callPackage ../applications/networking/browsers/firefox/wrapper.nix { - inherit browser browserName desktopName nameSuffix icon; - libtrick = true; - plugins = - assert !(enableGnash && enableAdobeFlash); - assert !(jre && icedtea); - ([ ] - ++ lib.optional enableGnash gnash - ++ lib.optional enableAdobeFlash flashplayer - ++ lib.optional (cfg.enableDjvu or false) (djview4) - ++ lib.optional (cfg.enableMPlayer or false) (MPlayerPlugin browser) - ++ lib.optional (cfg.enableGeckoMediaPlayer or false) gecko_mediaplayer - ++ 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 - ); - libs = [ gstreamer gst_plugins_base ] ++ lib.optionals (cfg.enableQuakeLive or false) - (with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib ]) - ++ lib.optional (enableAdobeFlash && (cfg.enableAdobeFlashDRM or false)) hal-flash - ++ lib.optional (config.pulseaudio or false) libpulseaudio; - gst_plugins = [ gst_plugins_base gst_plugins_good gst_plugins_bad gst_plugins_ugly gst_ffmpeg ]; - gtk_modules = [ libcanberra ]; - }; + wrapFirefox = callPackage ../applications/networking/browsers/firefox/wrapper.nix { }; retroArchCores = let