chromium: Move plugins into its own Nix file.

We now no longer pass enablePepperFlash and enablePepperPDF to the
browser package itself and only use plugins.flagsEnabled from there.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-03-19 12:57:49 +01:00
parent 1ae328ba86
commit 16af058ff9
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961
3 changed files with 87 additions and 73 deletions

View File

@ -25,12 +25,11 @@
, gnomeSupport ? false, gnome ? null
, gnomeKeyringSupport ? false, libgnome_keyring3 ? null
, proprietaryCodecs ? true
, enablePepperFlash ? false
, enablePepperPDF ? false
, cupsSupport ? false
, pulseSupport ? false, pulseaudio ? null
, source
, plugins
}:
with stdenv.lib;
@ -88,68 +87,6 @@ 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";
@ -249,12 +186,7 @@ in stdenv.mkDerivation rec {
chrome ${optionalString (!enableSELinux) "chrome_sandbox"}
'';
installPhase = let
enabledPlugins = optional enablePepperFlash binaryPlugins.flash
++ optional enablePepperPDF binaryPlugins.pdf;
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
pluginArgs = concatStringsSep " " (map getFlags enabledPlugins);
in ''
installPhase = ''
ensureDir "${libExecPath}"
cp -v "${buildPath}/"*.pak "${libExecPath}/"
${optionalString (!versionOlder source.version "34.0.0.0") ''
@ -267,7 +199,7 @@ in stdenv.mkDerivation rec {
mkdir -vp "$out/bin"
makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" \
--add-flags "${pluginArgs}"
--add-flags "${plugins.flagsEnabled}"
mkdir -vp "$out/share/man/man1"
cp -v "${buildPath}/chrome.1" "$out/share/man/man1/${packageName}.1"

View File

@ -26,8 +26,12 @@ let
browser = callPackage ./browser.nix {
inherit enableSELinux enableNaCl useOpenSSL gnomeSupport
gnomeKeyringSupport proprietaryCodecs enablePepperFlash
enablePepperPDF cupsSupport pulseSupport;
gnomeKeyringSupport proprietaryCodecs cupsSupport
pulseSupport;
};
plugins = callPackage ./plugins.nix {
inherit enablePepperFlash enablePepperPDF;
};
};

View File

@ -0,0 +1,78 @@
{ stdenv
, enablePepperFlash ? false
, enablePepperPDF ? false
, fetchurl # XXX
}:
with stdenv.lib;
let
plugins = 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 PepperFlash/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"
'';
passthru.flagsEnabled = let
enabledPlugins = optional enablePepperFlash plugins.flash
++ optional enablePepperPDF plugins.pdf;
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
in concatStringsSep " " (map getFlags enabledPlugins);
};
in plugins