diff options
Diffstat (limited to 'pkgs/applications/networking/browsers/chromium/default.nix')
-rw-r--r-- | pkgs/applications/networking/browsers/chromium/default.nix | 134 |
1 files changed, 93 insertions, 41 deletions
diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index 087bde000eda..fa91a877fdc0 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -7,8 +7,8 @@ , xdg_utils, yasm, zlib , libusb1, libexif, pciutils -, python, perl, pkgconfig -, nspr, udev, krb5 +, python, pythonPackages, perl, pkgconfig +, nspr, udev, krb5, file , utillinux, alsaLib , gcc, bison, gperf , glib, gtk, dbus_glib @@ -18,9 +18,6 @@ # optional dependencies , libgcrypt ? null # gnomeSupport || cupsSupport -# dependency for version 30 -, file - # package customization , channel ? "stable" , enableSELinux ? false, libselinux ? null @@ -36,7 +33,65 @@ with stdenv.lib; let - sourceInfo = builtins.getAttr channel (import ./sources.nix); + src = with getAttr channel (import ./sources.nix); stdenv.mkDerivation { + name = "chromium-source-${version}"; + + src = fetchurl { + inherit url sha256; + }; + + phases = [ "unpackPhase" "patchPhase" "installPhase" ]; + + opensslPatches = optional useOpenSSL openssl.patches; + + prePatch = "patchShebangs ."; + + patches = singleton ( + if versionOlder version "31.0.0.0" + then ./sandbox_userns_30.patch + else ./sandbox_userns_31.patch + ); + + postPatch = '' + sed -i -r -e 's/-f(stack-protector)(-all)?/-fno-\1/' build/common.gypi + sed -i -e 's|/usr/bin/gcc|gcc|' third_party/WebKit/Source/core/core.gypi + '' + optionalString useOpenSSL '' + cat $opensslPatches | patch -p1 -d third_party/openssl/openssl + ''; + + outputs = [ "out" "sandbox" "bundled" "main" ]; + installPhase = '' + ensureDir "$out" "$sandbox" "$bundled" "$main" + + header "copying browser main sources to $main" + find . -mindepth 1 -maxdepth 1 \ + \! -path ./sandbox \ + \! -path ./third_party \ + \! -path ./build \ + \! -path ./tools \ + \! -name '.*' \ + -print | xargs cp -rt "$main" + stopNest + + header "copying sandbox components to $sandbox" + cp -rt "$sandbox" sandbox/* + stopNest + + header "copying third party sources to $bundled" + cp -rt "$bundled" third_party/* + stopNest + + header "copying build requisites to $out" + cp -rt "$out" build tools + stopNest + + rm -rf "$out/tools/gyp" # XXX: Don't even copy it in the first place. + ''; + + passthru = { + inherit version; + }; + }; mkGypFlags = let @@ -81,27 +136,22 @@ let libusb1 libexif ]; + sandbox = import ./sandbox.nix { + inherit stdenv; + src = src.sandbox; + binary = "${packageName}_sandbox"; + }; + # build paths and release info packageName = "chromium"; buildType = "Release"; buildPath = "out/${buildType}"; libExecPath = "$out/libexec/${packageName}"; - - # user namespace sandbox patch - userns_patch = if versionOlder sourceInfo.version "30.0.0.0" - then ./sandbox_userns_29.patch - else ./sandbox_userns_30.patch; + sandboxPath = "${sandbox}/bin/${packageName}_sandbox"; in stdenv.mkDerivation rec { - name = "${packageName}-${version}"; - inherit packageName; - - version = sourceInfo.version; - - src = fetchurl { - url = sourceInfo.url; - sha256 = sourceInfo.sha256; - }; + name = "${packageName}-${src.version}"; + inherit packageName src; buildInputs = defaultDependencies ++ [ which makeWrapper @@ -110,32 +160,31 @@ in stdenv.mkDerivation rec { (if useOpenSSL then openssl else nss) utillinux alsaLib gcc bison gperf - krb5 + krb5 file glib gtk dbus_glib libXScrnSaver libXcursor libXtst mesa pciutils protobuf speechd libXdamage + pythonPackages.gyp ] ++ optional gnomeKeyringSupport libgnome_keyring ++ optionals gnomeSupport [ gconf libgcrypt ] ++ optional enableSELinux libselinux ++ optional cupsSupport libgcrypt - ++ optional pulseSupport pulseaudio - ++ optional (!versionOlder sourceInfo.version "30.0.0.0") file; - - opensslPatches = optional useOpenSSL openssl.patches; - - prePatch = "patchShebangs ."; - - patches = [ userns_patch ]; + ++ optional pulseSupport pulseaudio; + + prePatch = '' + # XXX: Figure out a way how to split these properly. + #cpflags="-dsr --no-preserve=mode" + cpflags="-dr" + cp $cpflags "${src.main}"/* . + cp $cpflags "${src.bundled}" third_party + cp $cpflags "${src.sandbox}" sandbox + chmod -R u+w . # XXX! + ''; postPatch = '' - sed -i -r -e 's/-f(stack-protector)(-all)?/-fno-\1/' build/common.gypi - sed -i -e 's|/usr/bin/gcc|gcc|' third_party/WebKit/Source/core/core.gypi - '' + optionalString useOpenSSL '' - cat $opensslPatches | patch -p1 -d third_party/openssl/openssl - '' + optionalString (!versionOlder sourceInfo.version "30.0.0.0") '' sed -i -e '/base::FilePath exe_dir/,/^ *} *$/c \ sandbox_binary = \ - base::FilePath("'"${libExecPath}/${packageName}_sandbox"'"); + base::FilePath("'"${sandboxPath}"'"); ' content/browser/browser_main_loop.cc ''; @@ -151,7 +200,7 @@ in stdenv.mkDerivation rec { use_openssl = useOpenSSL; selinux = enableSELinux; use_cups = cupsSupport; - linux_sandbox_path="${libExecPath}/${packageName}_sandbox"; + linux_sandbox_path="${sandboxPath}"; linux_sandbox_chrome_path="${libExecPath}/${packageName}"; werror = ""; @@ -173,7 +222,7 @@ in stdenv.mkDerivation rec { }); configurePhase = '' - GYP_GENERATORS=ninja python build/gyp_chromium --depth "$(pwd)" ${gypFlags} + python build/gyp_chromium -f ninja --depth "$(pwd)" ${gypFlags} ''; buildPhase = let @@ -183,13 +232,13 @@ in stdenv.mkDerivation rec { CC="${CC}" CC_host="${CC}" \ CXX="${CXX}" CXX_host="${CXX}" \ LINK_host="${CXX}" \ - "${ninja}/bin/ninja" -C "out/${buildType}" \ - -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES \ + "${ninja}/bin/ninja" -C "${buildPath}" \ + -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES \ chrome ${optionalString (!enableSELinux) "chrome_sandbox"} ''; installPhase = '' - mkdir -vp "${libExecPath}" + ensureDir "${libExecPath}" cp -v "${buildPath}/"*.pak "${libExecPath}/" cp -vR "${buildPath}/locales" "${buildPath}/resources" "${libExecPath}/" cp -v ${buildPath}/libffmpegsumo.so "${libExecPath}/" @@ -198,7 +247,6 @@ in stdenv.mkDerivation rec { mkdir -vp "$out/bin" makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" - cp -v "${buildPath}/chrome_sandbox" "${libExecPath}/${packageName}_sandbox" mkdir -vp "$out/share/man/man1" cp -v "${buildPath}/chrome.1" "$out/share/man/man1/${packageName}.1" @@ -214,6 +262,10 @@ in stdenv.mkDerivation rec { done ''; + passthru = { + inherit sandbox; + }; + meta = { description = "An open source web browser from Google"; homepage = http://www.chromium.org/; |