diff --git a/pkgs/applications/networking/browsers/chromium/cups_allow_deprecated.patch b/pkgs/applications/networking/browsers/chromium/cups_allow_deprecated.patch new file mode 100644 index 00000000000..4fd6a24cc14 --- /dev/null +++ b/pkgs/applications/networking/browsers/chromium/cups_allow_deprecated.patch @@ -0,0 +1,14 @@ +diff --git a/printing/printing.gyp b/printing/printing.gyp +index 19fa1b2..f11d76e 100644 +--- a/printing/printing.gyp ++++ b/printing/printing.gyp +@@ -26,6 +26,9 @@ + 'include_dirs': [ + '..', + ], ++ 'cflags': [ ++ '-Wno-deprecated-declarations', ++ ], + 'sources': [ + 'backend/print_backend.cc', + 'backend/print_backend.h', diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index 2ea5bac0600..a486c80e185 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -1,62 +1,187 @@ -{ GConf, alsaLib, bzip2, cairo, cups, dbus, dbus_glib, expat -, fetchurl, ffmpeg, fontconfig, freetype, libX11, libXfixes -, glib, gtk, gdk_pixbuf, pango -, libXScrnSaver, libXdamage, libXext, libXrender, libXt, libXtst, libXcomposite -, libgcrypt, libjpeg, libpng, makeWrapper, nspr, nss, patchelf -, stdenv, unzip, zlib, pam, pcre, udev }: +{ stdenv, getConfig, fetchurl, makeWrapper, which -assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" ; +# default dependencies +, bzip2, flac, speex +, libevent, expat, libjpeg +, libpng, libxml2, libxslt +, xdg_utils, yasm, zlib -stdenv.mkDerivation rec { - name = "chromium-19.0.1061.0-pre${version}"; +, python, perl, pkgconfig +, nspr, udev, krb5 +, utillinux, alsaLib +, gcc, bison, gperf +, glib, gtk, dbus_glib +, libXScrnSaver, libXcursor, mesa - # To determine the latest revision, get - # ‘http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/LAST_CHANGE’. - # For the version number, see ‘about:version’. - version = "124950"; - - src = - if stdenv.system == "x86_64-linux" then - fetchurl { - url = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux_x64/${version}/chrome-linux.zip"; - sha256 = "4472bf584a96e477e2c17f96d4452dd41f4f34ac3d6a9bb4c845cf15d8db0c73"; - } - else if stdenv.system == "i686-linux" then - fetchurl { - url = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/${version}/chrome-linux.zip"; - sha256 = "6e8a49d9917ee26b67d14cd10b85711c3b9382864197ba02b3cfe8e636d3d69c"; - } - else throw "Chromium is not supported on this platform."; +# optional dependencies +, libgnome_keyring # config.gnomeKeyring +, gconf # config.gnome +, libgcrypt # config.gnome || config.cups +, nss, openssl # config.openssl +, pulseaudio # config.pulseaudio +, libselinux # config.selinux +}: - phases = "unpackPhase installPhase"; +let + mkConfigurable = stdenv.lib.mapAttrs (flag: default: getConfig ["chromium" flag] default); - buildInputs = [ makeWrapper unzip ]; + config = mkConfigurable { + selinux = false; + nacl = false; + openssl = true; + gnome = false; + gnomeKeyring = false; + proprietaryCodecs = true; + cups = false; + pulseaudio = getConfig ["pulseaudio"] true; + }; - libPath = - stdenv.lib.makeLibraryPath - [ GConf alsaLib bzip2 cairo cups dbus dbus_glib expat - ffmpeg fontconfig freetype libX11 libXScrnSaver libXfixes libXcomposite - libXdamage libXext libXrender libXt libXtst libgcrypt libjpeg - libpng nspr stdenv.gcc.gcc zlib stdenv.gcc.libc - glib gtk gdk_pixbuf pango - pam udev - ]; + sourceInfo = import ./source.nix; + + mkGypFlags = with stdenv.lib; let + sanitize = value: + if value == true then "1" + else if value == false then "0" + else "${value}"; + toFlag = key: value: "-D${key}=${sanitize value}"; + in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs)); + + gypFlagsUseSystemLibs = { + use_system_bzip2 = true; + use_system_flac = true; + use_system_libevent = true; + use_system_libexpat = true; + use_system_libjpeg = true; + use_system_libpng = true; + use_system_libxml = true; + use_system_speex = true; + use_system_ssl = true; + use_system_stlport = true; + use_system_xdg_utils = true; + use_system_yasm = true; + use_system_zlib = true; + + use_system_harfbuzz = false; + use_system_icu = false; + use_system_libwebp = false; # See chromium issue #133161 + use_system_skia = false; + use_system_sqlite = false; # See chromium issue #22208 + use_system_v8 = false; + }; + + defaultDependencies = [ + bzip2 flac speex + libevent expat libjpeg + libpng libxml2 libxslt + xdg_utils yasm zlib + ]; + +in stdenv.mkDerivation rec { + name = "${packageName}-${version}"; + packageName = "chromium"; + + version = sourceInfo.version; + + src = fetchurl { + url = sourceInfo.url; + sha256 = sourceInfo.sha256; + }; + + buildInputs = defaultDependencies ++ [ + which makeWrapper + python perl pkgconfig + nspr udev + (if config.openssl then openssl else nss) + utillinux alsaLib + gcc bison gperf + krb5 + glib gtk dbus_glib + libXScrnSaver libXcursor mesa + ] ++ stdenv.lib.optional config.gnomeKeyring libgnome_keyring + ++ stdenv.lib.optionals config.gnome [ gconf libgcrypt ] + ++ stdenv.lib.optional config.selinux libselinux + ++ stdenv.lib.optional config.cups libgcrypt + ++ stdenv.lib.optional config.pulseaudio pulseaudio; + + opensslPatches = stdenv.lib.optional config.openssl openssl.patches; + + prePatch = "patchShebangs ."; + + patches = stdenv.lib.optional (!config.selinux) ./enable_seccomp.patch + ++ stdenv.lib.optional config.cups ./cups_allow_deprecated.patch + ++ stdenv.lib.optional config.pulseaudio ./pulseaudio_array_bounds.patch; + + postPatch = stdenv.lib.optionalString config.openssl '' + cat $opensslPatches | patch -p1 -d third_party/openssl/openssl + ''; + + gypFlags = mkGypFlags (gypFlagsUseSystemLibs // { + linux_use_gold_binary = false; + linux_use_gold_flags = false; + proprietary_codecs = false; + use_gnome_keyring = config.gnomeKeyring; + use_gconf = config.gnome; + use_gio = config.gnome; + use_pulseaudio = config.pulseaudio; + disable_nacl = !config.nacl; + use_openssl = config.openssl; + selinux = config.selinux; + use_cups = config.cups; + } // stdenv.lib.optionalAttrs config.proprietaryCodecs { + # enable support for the H.264 codec + proprietary_codecs = true; + ffmpeg_branding = "Chrome"; + } // stdenv.lib.optionalAttrs (stdenv.system == "x86_64-linux") { + target_arch = "x64"; + } // stdenv.lib.optionalAttrs (stdenv.system == "i686-linux") { + target_arch = "ia32"; + }); + + buildType = "Release"; + + enableParallelBuilding = true; + + configurePhase = '' + python build/gyp_chromium --depth "$(pwd)" ${gypFlags} + ''; + + makeFlags = let + CC = "${gcc}/bin/gcc"; + CXX = "${gcc}/bin/g++"; + in [ + "CC=${CC}" + "CXX=${CXX}" + "CC.host=${CC}" + "CXX.host=${CXX}" + "LINK.host=${CXX}" + ]; + + buildFlags = [ + "BUILDTYPE=${buildType}" + "library=shared_library" + "chrome" + ]; installPhase = '' - mkdir -p $out/bin - mkdir -p $out/libexec/chrome + mkdir -vp "$out/libexec/${packageName}" + cp -v "out/${buildType}/"*.pak "$out/libexec/${packageName}/" + cp -vR "out/${buildType}/locales" "out/${buildType}/resources" "$out/libexec/${packageName}/" - cp -R * $out/libexec/chrome + cp -v "out/${buildType}/chrome" "$out/libexec/${packageName}/${packageName}" - strip $out/libexec/chrome/chrome - - ${patchelf}/bin/patchelf \ - --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ - --set-rpath ${libPath}:$out/lib:${stdenv.gcc.gcc}/lib64:${stdenv.gcc.gcc}/lib \ - $out/libexec/chrome/chrome + mkdir -vp "$out/bin" + makeWrapper "$out/libexec/${packageName}/${packageName}" "$out/bin/${packageName}" - makeWrapper $out/libexec/chrome/chrome $out/bin/chrome \ - --prefix LD_LIBRARY_PATH : "${pcre}/lib:${nss}/lib" + mkdir -vp "$out/share/man/man1" + cp -v "out/${buildType}/chrome.1" "$out/share/man/man1/${packageName}.1" + + for icon_file in chrome/app/theme/chromium/product_logo_*[0-9].png; do + num_and_suffix="''${icon_file##*logo_}" + icon_size="''${num_and_suffix%.*}" + logo_output_path="$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps" + mkdir -vp "$logo_output_path" + cp -v "$icon_file" "$logo_output_path/${packageName}.png" + done ''; meta = with stdenv.lib; { diff --git a/pkgs/applications/networking/browsers/chromium/enable_seccomp.patch b/pkgs/applications/networking/browsers/chromium/enable_seccomp.patch new file mode 100644 index 00000000000..edeee37f19c --- /dev/null +++ b/pkgs/applications/networking/browsers/chromium/enable_seccomp.patch @@ -0,0 +1,20 @@ +diff --git a/content/common/seccomp_sandbox.h b/content/common/seccomp_sandbox.h +index a07d6f3..a622a35 100644 +--- a/content/common/seccomp_sandbox.h ++++ b/content/common/seccomp_sandbox.h +@@ -29,15 +29,9 @@ static bool SeccompSandboxEnabled() { + // TODO(evan): turn on for release too once we've flushed out all the bugs, + // allowing us to delete this file entirely and just rely on the "disabled" + // switch. +-#ifdef NDEBUG +- // Off by default; allow turning on with a switch. +- return CommandLine::ForCurrentProcess()->HasSwitch( +- switches::kEnableSeccompSandbox); +-#else + // On by default; allow turning off with a switch. + return !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableSeccompSandbox); +-#endif // NDEBUG + } + #endif // SECCOMP_SANDBOX + diff --git a/pkgs/applications/networking/browsers/chromium/pulseaudio_array_bounds.patch b/pkgs/applications/networking/browsers/chromium/pulseaudio_array_bounds.patch new file mode 100644 index 00000000000..ca78b6959c0 --- /dev/null +++ b/pkgs/applications/networking/browsers/chromium/pulseaudio_array_bounds.patch @@ -0,0 +1,12 @@ +diff --git a/media/media.gyp b/media/media.gyp +index 2a8c6c6..66ca767 100644 +--- a/media/media.gyp ++++ b/media/media.gyp +@@ -399,6 +399,7 @@ + ['use_pulseaudio == 1', { + 'cflags': [ + 'chromium-[^<]*chromium-\([^<.]\+\(\.[^<.]\+\)\+\)\.tar\.bz2<.*$/\1/p + }'; +} + +cd "$(dirname "$0")"; + +version="$(get_newest_version)"; + +if [ -e source.nix ]; then + oldver="$(sed -n 's/^ *version *= *"\([^"]\+\)".*$/\1/p' source.nix)"; + if [ "x$oldver" = "x$version" ]; then + echo "Already the newest version: $version" >&2; + exit 1; + fi; +fi; + +url="${bucket_url%/}/chromium-$version.tar.bz2"; + +sha256="$(nix-prefetch-url "$url")"; + +cat > source.nix <