diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index dcd2f78a4f5e..b70825670156 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -26,6 +26,8 @@ , gnomeSupport ? false, gconf ? null , gnomeKeyringSupport ? false, libgnome_keyring3 ? null , proprietaryCodecs ? true +, enablePepperFlash ? false +, enablePepperPDF ? false , cupsSupport ? false , pulseSupport ? false, pulseaudio ? null }: @@ -151,6 +153,68 @@ let binary = "${packageName}_sandbox"; }; + binaryPlugins = stdenv.mkDerivation { + name = "chromium-binary-plugins"; + + # XXX: Only temporary and has to be version-specific + src = fetchurl { + url = "https://dl.google.com/linux/chrome/deb/pool/main/g/" + + "google-chrome-unstable/google-chrome-unstable_" + + "35.0.1897.2-1_amd64.deb"; + sha1 = "b68683fc5321d10536e4135c266b14894b7668ed"; + }; + + phases = [ "unpackPhase" "patchPhase" "checkPhase" "installPhase" ]; + outputs = [ "pdf" "flash" ]; + + unpackCmd = '' + ensureDir plugins + ar p "$src" data.tar.lzma | tar xJ -C plugins --strip-components=4 \ + ./opt/google/chrome-unstable/PepperFlash \ + ./opt/google/chrome-unstable/libpdf.so + ''; + + doCheck = true; + checkPhase = '' + ! find -iname '*.so' -exec ldd {} + | grep 'not found' + ''; + + patchPhase = let + rpaths = [ stdenv.gcc.gcc ]; + mkrpath = p: "${makeSearchPath "lib64" p}:${makeSearchPath "lib" p}"; + in '' + for sofile in PepperFlash/libpepflashplayer.so libpdf.so; do + chmod +x "$sofile" + patchelf --set-rpath "${mkrpath rpaths}" "$sofile" + done + ''; + + installPhase = let + pdfName = "Chrome PDF Viewer"; + pdfDescription = "Portable Document Format"; + pdfMimeTypes = concatStringsSep ";" [ + "application/pdf" + "application/x-google-chrome-print-preview-pdf" + ]; + pdfInfo = "#${pdfName}#${pdfDescription};${pdfMimeTypes}"; + in '' + install -vD libpdf.so "$pdf/lib/libpdf.so" + ensureDir "$pdf/nix-support" + echo "--register-pepper-plugins='$pdf/lib/libpdf.so${pdfInfo}'" \ + > "$pdf/nix-support/chromium-flags" + + flashVersion="$( + sed -n -r 's/.*"version": "([^"]+)",.*/\1/p' PepperFlash/manifest.json + )" + + install -vD libpepflashplayer.so "$flash/lib/libpepflashplayer.so" + ensureDir "$flash/nix-support" + echo "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'" \ + "--ppapi-flash-version=$flashVersion" \ + > "$flash/nix-support/chromium-flags" + ''; + }; + # build paths and release info packageName = "chromium"; buildType = "Release"; @@ -248,7 +312,12 @@ in stdenv.mkDerivation rec { chrome ${optionalString (!enableSELinux) "chrome_sandbox"} ''; - installPhase = '' + installPhase = let + enabledPlugins = optional enablePepperFlash binaryPlugins.flash + ++ optional enablePepperPDF binaryPlugins.pdf; + getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)"; + pluginArgs = concatStringsSep " " (map getFlags enabledPlugins); + in '' ensureDir "${libExecPath}" cp -v "${buildPath}/"*.pak "${libExecPath}/" ${optionalString (!versionOlder src.version "34.0.0.0") '' @@ -260,7 +329,8 @@ in stdenv.mkDerivation rec { cp -v "${buildPath}/chrome" "${libExecPath}/${packageName}" mkdir -vp "$out/bin" - makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" + makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" \ + --add-flags "${pluginArgs}" mkdir -vp "$out/share/man/man1" cp -v "${buildPath}/chrome.1" "$out/share/man/man1/${packageName}.1"