about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 16:24:38 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 16:24:41 +0000
commitc4b52f54d926974fdba1499c37713c8b8a01b8ae (patch)
treee508301d2a9cbd17a4540a74efe3515f5574dc1f
parent8c0790eb6095ef59a9623596f5794d250b95c699 (diff)
parent68bb2d2ae21ea73392f81f436e89577997fa8db4 (diff)
downloadnixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar.gz
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar.bz2
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar.lz
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar.xz
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.tar.zst
nixlib-c4b52f54d926974fdba1499c37713c8b8a01b8ae.zip
Add 'nixpkgs-overlays/nixpkgs-mozilla/' from commit '68bb2d2ae21ea73392f81f436e89577997fa8db4'
git-subtree-dir: nixpkgs-overlays/nixpkgs-mozilla
git-subtree-mainline: 8c0790eb6095ef59a9623596f5794d250b95c699
git-subtree-split: 68bb2d2ae21ea73392f81f436e89577997fa8db4
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/.gitignore1
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/.travis.yml32
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/LICENSE19
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/README.rst231
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/compilers-overlay.nix101
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/default.nix9
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/deploy_rsa.encbin0 -> 3248 bytes
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/firefox-overlay.nix180
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/firefox.key254
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/git-cinnabar-overlay.nix9
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/lib-overlay.nix5
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/lib/parseTOML.nix210
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/overlays.nix8
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/package-set.nix8
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/phlay-overlay.nix5
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pinned.nix36
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/builder.sh14
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/default.nix39
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/libidn.nix47
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/cbindgen/default.nix25
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/clang/bug-14435.patch35
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/firefox-nightly-bin/update.nix47
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/arm-eabi.patch230
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/builder.sh245
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/default.nix533
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gfortran-driving.patch20
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gnat-cflags.patch33
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/java-jvgenmain-link.patch17
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/libstdc++-target.patch32
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/no-sys-dirs.patch41
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/parallel-bconfig-4.7.patch30
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/default.nix203
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/source.json6
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/git-cinnabar/default.nix71
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/default.nix7
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/update.nix50
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/nixpkgs.json6
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/phlay/default.nix26
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/pkgs/servo/default.nix102
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/release.nix100
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/rr-overlay.nix14
-rwxr-xr-xnixpkgs-overlays/nixpkgs-mozilla/rust-overlay-install.sh12
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/rust-overlay.nix331
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/rust-src-overlay.nix18
-rwxr-xr-xnixpkgs-overlays/nixpkgs-mozilla/update.nix144
-rw-r--r--nixpkgs-overlays/nixpkgs-mozilla/vidyo-overlay.nix5
46 files changed, 3591 insertions, 0 deletions
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/.gitignore b/nixpkgs-overlays/nixpkgs-mozilla/.gitignore
new file mode 100644
index 000000000000..d6944e3ddc11
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/.gitignore
@@ -0,0 +1 @@
+/result*
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/.travis.yml b/nixpkgs-overlays/nixpkgs-mozilla/.travis.yml
new file mode 100644
index 000000000000..71953faad061
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/.travis.yml
@@ -0,0 +1,32 @@
+language: nix
+addons:
+  ssh_known_hosts: floki.garbas.si
+env:
+- STDENV=clang
+- STDENV=clang36
+- STDENV=clang37
+- STDENV=clang38
+- STDENV=gcc
+- STDENV=gcc49
+- STDENV=gcc48
+script:
+- if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then
+    nix-shell update.nix --pure;
+  fi
+- if [ "$TRAVIS_PULL_REQUEST" != "true" -a "$TRAVIS_BRANCH" = "master" ]; then
+    nix-build release.nix -A gecko."x86_64-linux"."$STDENV";
+    mkdir nars/;
+    nix-push --dest "$PWD/nars/" --force ./result;
+  fi
+before_install:
+- openssl aes-256-cbc -K $encrypted_be02022e0814_key -iv $encrypted_be02022e0814_iv -in deploy_rsa.enc -out deploy_rsa -d
+before_deploy:
+- eval "$(ssh-agent -s)"
+- chmod 600 $TRAVIS_BUILD_DIR/deploy_rsa
+- ssh-add $TRAVIS_BUILD_DIR/deploy_rsa
+deploy:
+  provider: script
+  skip_cleanup: true
+  script: rsync -avh --ignore-existing $TRAVIS_BUILD_DIR/nars/ travis@floki.garbas.si:/var/travis/nixpkgs-mozilla/
+  on:
+    branch: master
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/LICENSE b/nixpkgs-overlays/nixpkgs-mozilla/LICENSE
new file mode 100644
index 000000000000..5655fa311cd2
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/LICENSE
@@ -0,0 +1,19 @@
+Copyright 2017 Mozilla
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/README.rst b/nixpkgs-overlays/nixpkgs-mozilla/README.rst
new file mode 100644
index 000000000000..d55958172029
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/README.rst
@@ -0,0 +1,231 @@
+nixpkgs-mozilla
+===============
+
+Gathering nix efforts in one repository.
+
+
+Current packages
+----------------
+
+- gecko (https://github.com/mozilla/gecko-dev)
+- firefox-bin variants including Nightly
+- VidyoDesktop ()
+
+firefox-bin variants
+--------------------
+
+Nixpkgs already has definitions for `firefox
+<https://github.com/NixOS/nixpkgs/blob/246d2848ff657d56fcf2d8596709e8869ce8616a/pkgs/applications/networking/browsers/firefox/packages.nix>`_,
+which is built from source, as well as `firefox-bin
+<https://github.com/NixOS/nixpkgs/blob/ba2fe3c9a626a8fb845c786383b8b23ad8355951/pkgs/applications/networking/browsers/firefox-bin/default.nix>`_,
+which is the binary Firefox version built by Mozilla.
+
+The ``firefox-overlay.nix`` in this repository adds definitions for
+some other firefox-bin variants that Mozilla ships:
+``firefox-nightly-bin``, ``firefox-beta-bin``, and
+``firefox-esr-bin``. All are exposed under a ``latest`` attribute,
+e.g. ``latest.firefox-nightly-bin``.
+
+Unfortunately, these variants do not auto-update, and you may see some
+annoying pop-ups complaining about this.
+
+Note that all the ``-bin`` packages are "unfree" (because of the
+Firefox trademark, held by Mozilla), so you will need to set
+``nixpkgs.config.allowUnfree`` in order to use them. More info `here
+<https://nixos.wiki/wiki/FAQ#How_can_I_install_a_proprietary_or_unfree_package.3F>`_.
+
+Rust overlay
+------------
+
+**NOTE:** Nix overlays only works on up-to-date versions of NixOS/nixpkgs, starting from 17.03.
+
+A nixpkgs overlay is provided to contains all of the latest rust releases.
+
+To use the rust overlay run the ``./rust-overlay-install.sh`` command. It will
+link the current ``./rust-overlay.nix`` into your ``~/.config/nixpkgs/overlays`` folder.
+
+Once this is done, use ``nix-env -iA nixpkgs.latest.rustChannels.nightly.rust`` for
+example. Replace the ``nixpkgs.`` prefix with ``nixos.`` on NixOS.
+
+Using in nix expressions
+------------------------
+
+Example of using in ```shell.nix```:
+
+.. code:: nix
+
+ let
+   moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
+   nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
+ in
+   with nixpkgs;
+   stdenv.mkDerivation {
+     name = "moz_overlay_shell";
+     buildInputs = [
+       nixpkgs.latest.rustChannels.nightly.rust
+       ];
+   }
+
+Or to retrieve a specific nightly version:
+
+.. code:: nix
+
+ let
+   moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
+   nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
+ in
+   with nixpkgs;
+   stdenv.mkDerivation {
+     name = "moz_overlay_shell";
+     buildInputs = [
+       (nixpkgs.rustChannelOf { date = "2018-04-11"; channel = "nightly"; }).rust
+       ];
+   }
+
+Firefox Development Environment
+-------------------------------
+
+This repository provides several tools to facilitate development on
+Firefox. Firefox is built on an engine called Gecko, which lends its
+name to some of the files and derivations in this repo.
+
+Checking out Firefox
+~~~~~~~~~~~~~~~~~~~~
+
+To build Firefox from source, it is best to have a local checkout of
+``mozilla-central``. ``mozilla-central`` is hosted in Mercurial, but
+some people prefer to access it using ``git`` and
+``git-cinnabar``. The tools in this repo support either using
+mercurial or git.
+
+This repository provides a ``git-cinnabar-overlay.nix`` which defines
+a ``git-cinnabar`` derivation. This overlay can be used to install
+``git-cinnabar``, either using ``nix-env`` or as part of a system-wide
+``configuration.nix``.
+
+Building Firefox
+~~~~~~~~~~~~~~~~
+
+The ``firefox-overlay.nix`` provides an environment to build Firefox
+from its sources, once you have finished the checkout of
+``mozilla-central``. You can use ``nix-shell`` to enter this
+environment to launch ``mach`` commands to build Firefox and test your
+build.
+
+Some debugging tools are available in this environment as well, but
+other development tools (such as those used to submit changes for
+review) are outside the scope of this environment.
+
+The ``nix-shell`` environment is available in the
+``gecko.<arch>.<cc>`` attribute of the ``release.nix`` file provided
+in this repository.
+
+The ``<arch>`` attribute is either ``x86_64-linux`` or ``i686-linux``. The first
+one would create a native toolchain for compiling on x64, while the second one
+would give a native toolchain for compiling on x86. Note that due to the size of
+the compilation units on x86, the compilation might not be able to complete, but
+some sub part of Gecko, such as SpiderMonkey would compile fine.
+
+The ``<cc>`` attribute is either ``gcc`` or ``clang``, or any specific version
+of the compiler available in the ``compiler-overlay.nix`` file which is repeated
+in ``release.nix``. This compiler would only be used for compiling Gecko, and
+the rest of the toolchain is compiled against the default ``stdenv`` of the
+architecture.
+
+When first entering the ``nix-shell``, the toolchain will pull and build all
+the dependencies necessary to build Gecko, this includes might take some time.
+This work will not be necessary the second time, unless you use a different
+toolchain or architecture.
+
+.. code:: sh
+
+  ~/$ cd mozilla-central
+  ~/mozilla-central$ nix-shell ../nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc --pure
+    ... pull the rust compiler
+    ... compile the toolchain
+  [~/mozilla-central] python ./mach build
+    ... build firefox desktop
+  [~/mozilla-central] python ./mach run
+    ... run firefox
+
+When entering the ``nix-shell``, the ``MOZCONFIG`` environment variable is set
+to a local file, named ``.mozconfig.nix-shell``, created each time you enter the
+``nix-shell``. You can create your own ``.mozconfig`` file which extends the
+default one, with your own options.
+
+.. code:: sh
+
+  ~/mozilla-central$ nix-shell ../nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc --pure
+  [~/mozilla-central] cat .mozconfig
+  # Import current nix-shell config.
+  . .mozconfig.nix-shell
+
+  ac_add_options --enable-js-shell
+  ac_add_options --disable-tests
+  [~/mozilla-central] export MOZCONFIG=$(pwd)/.mozconfig
+  [~/mozilla-central] python ./mach build
+
+To avoid repeating yourself, you can also rely on the ``NIX_SHELL_HOOK``
+environment variable, to reset the ``MOZCONFIG`` environment variable for you.
+
+.. code:: sh
+
+  ~/mozilla-central$ export NIX_SHELL_HOOK="export MOZCONFIG=$(pwd)/.mozconfig;"
+  ~/mozilla-central$ nix-shell ../nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc --pure
+  [~/mozilla-central] python ./mach build
+
+Submitting Firefox patches
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Firefox development happens in `Mozilla Phabricator
+<https://phabricator.services.mozilla.com/>`_. Mozilla Phabricator
+docs are `here
+<https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html>`_.
+
+To get your commits into Phabricator, some options include:
+
+- Arcanist, the upstream tool for interacting with
+  Phabricator. Arcanist is packaged in nixpkgs already; you can find
+  it in `nixos.arcanist`. Unfortunately, as of this writing, upstream
+  Arcanist does not support ``git-cinnabar`` (according to `the
+  "Setting up Arcanist"
+  <https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html#setting-up-arcanist>`_
+  documentation). `Mozilla maintains a fork of Arcanist
+  <https://github.com/mozilla-conduit/arcanist>`_ but it isn't yet
+  packaged. (PRs welcome.)
+
+- `moz-phab <https://github.com/mozilla-conduit/review>`_, a small
+  Python script that wraps Arcanist to try to handle commit series
+  better than stock Arcanist. Because it wraps Arcanist, it suffers
+  from the same problems that Arcanist does if you use git-cinnabar,
+  and may work better if you use Mozilla's Arcanist fork.  ``moz-phab``
+  isn't packaged yet. (PRs welcome.)
+
+- `phlay <https://github.com/mystor/phlay>`_, a small Python script
+  that speaks to the Phabricator API directly. This repository ships a
+  ``phlay-overlay.nix`` that you can use to make ``phlay`` available
+  in a nix-shell or nix-env.
+
+Note: although the ``nix-shell`` from the previous section may have
+all the tools you would normally use to do Firefox development, it
+isn't recommended that you use that shell for anything besides tasks
+that involve running ``mach``. Other development tasks such as
+committing code and submitting patches to code review are best handled
+in a separate nix-shell.
+
+TODO
+----
+
+- setup hydra to have binary channels
+
+- make sure pinned revisions get updated automatically (if build passes we
+  should update revisions in default.nix)
+
+- pin to specific (working) nixpkgs revision (as we do for other sources)
+
+- can we make this work on darwin as well?
+
+- assign maintainers for our packages that will montior that it "always" builds
+
+- hook it with vulnix report to monitor CVEs (once vulnix is ready, it must be
+  ready soon :P)
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/compilers-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/compilers-overlay.nix
new file mode 100644
index 000000000000..30b2ba7aa4c3
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/compilers-overlay.nix
@@ -0,0 +1,101 @@
+# This overlays add a customStdenv attribute which provide an stdenv with
+# different versions of the compilers. This can be used to test Gecko builds
+# against different compiler settings, or different compiler versions.
+#
+# See release.nix "builder" function, to understand how these different stdenv
+# are used.
+self: super: 
+
+let
+  noSysDirs = (super.stdenv.system != "x86_64-darwin"
+             && super.stdenv.system != "x86_64-freebsd"
+             && super.stdenv.system != "i686-freebsd"
+             && super.stdenv.system != "x86_64-kfreebsd-gnu");
+  crossSystem = null;
+
+  gcc473 = super.wrapCC (super.callPackage ./pkgs/gcc-4.7 (with self; {
+    inherit noSysDirs;
+    texinfo = texinfo4;
+    # I'm not sure if profiling with enableParallelBuilding helps a lot.
+    # We can enable it back some day. This makes the *gcc* builds faster now.
+    profiledCompiler = false;
+
+    # When building `gcc.crossDrv' (a "Canadian cross", with host == target
+    # and host != build), `cross' must be null but the cross-libc must still
+    # be passed.
+    cross = null;
+    libcCross = if crossSystem != null then libcCross else null;
+    libpthreadCross =
+      if crossSystem != null && crossSystem.config == "i586-pc-gnu"
+      then gnu.libpthreadCross
+      else null;
+  }));
+
+  # By default wrapCC keep the same header files, but NixOS is using the
+  # latest header files from GCC, which are not supported by clang, because
+  # clang implement a different set of locking primitives than GCC.  This
+  # expression is used to wrap clang with a matching verion of the libc++.
+  maybeWrapClang = cc: cc;
+  /*
+    if cc ? clang
+    then clangWrapCC cc
+    else cc;
+    */
+
+  clangWrapCC = llvmPackages:
+    let libcxx =
+      super.lib.overrideDerivation llvmPackages.libcxx (drv: {
+        # https://bugzilla.mozilla.org/show_bug.cgi?id=1277619
+        # https://llvm.org/bugs/show_bug.cgi?id=14435
+        patches = drv.patches ++ [ ./pkgs/clang/bug-14435.patch ];
+      });
+    in
+    super.callPackage <nixpkgs/pkgs/build-support/cc-wrapper> {
+      cc = llvmPackages.clang-unwrapped or llvmPackages.clang;
+      isClang = true;
+      stdenv = self.clangStdenv;
+      libc = self.glibc;
+      # cc-wrapper pulls gcc headers, which are not compatible with features
+      # implemented in clang.  These packages are used to override that.
+      extraPackages = [ self.libcxx llvmPackages.libcxxabi ];
+      nativeTools = false;
+      nativeLibc = false;
+    };
+
+  buildWithCompiler = cc:
+    super.stdenvAdapters.overrideCC self.stdenv (maybeWrapClang cc);
+
+  chgCompilerSource = cc: name: src:
+    cc.override (conf:
+      if conf ? gcc then # Nixpkgs 14.12
+        { gcc = super.lib.overrideDerivation conf.gcc (old: { inherit name src; }); }
+      else # Nixpkgs 15.05
+        { cc = super.lib.overrideDerivation conf.cc (old: { inherit name src; }); }
+    );
+
+  compilersByName = with self; {
+    clang = llvmPackages.clang;
+    clang36 = llvmPackages_36.clang;
+    clang37 = llvmPackages_37.clang;
+    clang38 = llvmPackages_38.clang; # not working yet.
+    gcc = gcc;
+    gcc6 = gcc6;
+    gcc5 = gcc5;
+    gcc49 = gcc49;
+    gcc48 = gcc48;
+    gcc474 = chgCompilerSource gcc473 "gcc-4.7.4" (fetchurl {
+      url = "mirror://gnu/gcc/gcc-4.7.4/gcc-4.7.4.tar.bz2";
+      sha256 = "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj";
+    });
+    gcc473 = gcc473;
+    # Version used on Linux slaves, except Linux x64 ASAN.
+    gcc472 = chgCompilerSource gcc473 "gcc-4.7.2" (fetchurl {
+      url = "mirror://gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2";
+      sha256 = "115h03hil99ljig8lkrq4qk426awmzh0g99wrrggxf8g07bq74la";
+    });
+  };
+
+in {
+  customStdenvs =
+    super.lib.mapAttrs (name: value: buildWithCompiler value) compilersByName;
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/default.nix
new file mode 100644
index 000000000000..76cbe3966f45
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/default.nix
@@ -0,0 +1,9 @@
+# Nixpkgs overlay which aggregates overlays for tools and products, used and
+# published by Mozilla.
+self: super:
+
+with super.lib;
+
+(foldl' (flip extends) (_: super)
+  (map import (import ./overlays.nix)))
+  self
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/deploy_rsa.enc b/nixpkgs-overlays/nixpkgs-mozilla/deploy_rsa.enc
new file mode 100644
index 000000000000..131e0dee5350
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/deploy_rsa.enc
Binary files differdiff --git a/nixpkgs-overlays/nixpkgs-mozilla/firefox-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/firefox-overlay.nix
new file mode 100644
index 000000000000..083b9fbbe683
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/firefox-overlay.nix
@@ -0,0 +1,180 @@
+# This file provide the latest binary versions of Firefox published by Mozilla.
+self: super:
+
+# firefox.key file is downloaded from:
+# https://gpg.mozilla.org/pks/lookup?search=Mozilla+Software+Releases+%3Crelease%40mozilla.com%3E&op=get
+
+let
+  # This file is currently maintained manually, if this Nix expression attempt
+  # to download the wrong version, this is likely to be the problem.
+  #
+  # Open a pull request against https://github.com/mozilla-releng/ship-it/ to
+  # update the version, as done in
+  # https://github.com/mozilla-releng/ship-it/pull/182
+  firefox_versions = with builtins;
+    fromJSON (readFile (fetchurl https://product-details.mozilla.org/1.0/firefox_versions.json));
+
+  arch = if self.stdenv.system == "i686-linux"
+    then "linux-i686"
+    else "linux-x86_64";
+
+  yearOf = with super.lib; yyyymmddhhmmss:
+    head (splitString "-" yyyymmddhhmmss);
+  monthOf = with super.lib; yyyymmddhhmmss:
+    head (tail (splitString "-" yyyymmddhhmmss));
+
+  # Given SHA512SUMS file contents and file name, extract matching sha512sum.
+  extractSha512Sum = sha512sums: file:
+    with builtins;
+    # Nix 1.x do not have `builtins.split`.
+    # Nix 2.0 have an bug in `builtins.match` (see https://github.com/NixOS/nix/issues/2147).
+    # So I made separate logic for Nix 1.x and Nix 2.0.
+    if builtins ? split then
+      substring 0 128 (head
+        (super.lib.filter
+          (s: isString s && substring 128 (stringLength s) s == "  ${file}")
+          (split "\n" sha512sums)))
+    else
+      head (match ".*[\n]([0-9a-f]*)  ${file}.*" sha512sums);
+
+  # The timestamp argument is a yyyy-mm-dd-hh-mm-ss date, which corresponds to
+  # one specific version. This is used mostly for bisecting.
+  versionInfo = { name, version, release, system ? arch, timestamp ? null }: with builtins;
+    if release then
+      # For versions such as Beta & Release:
+      # https://download.cdn.mozilla.net/pub/firefox/releases/55.0b3/SHA256SUMS
+      let
+        dir = "https://download.cdn.mozilla.net/pub/firefox/releases/${version}";
+        file = "${system}/en-US/firefox-${version}.tar.bz2";
+      in rec {
+        chksum = "${dir}/SHA512SUMS";
+        chksumSig = "${chksum}.asc";
+        url = "${dir}/${file}";
+        sha512 = extractSha512Sum (readFile (fetchurl chksum)) file;
+      }
+    else
+      # For Nightly versions:
+      # https://download.cdn.mozilla.net/pub/firefox/nightly/latest-mozilla-central/firefox-56.0a1.en-US.linux-x86_64.checksums
+      let
+        dir =
+          if timestamp == null then "https://download.cdn.mozilla.net/pub/firefox/nightly/latest-mozilla-central"
+          else "https://download.cdn.mozilla.net/pub/firefox/nightly/${yearOf timestamp}/${monthOf timestamp}/${timestamp}-mozilla-central" ;
+        file = "firefox-${version}.en-US.${system}.tar.bz2";
+      in rec {
+        chksum = "${dir}/firefox-${version}.en-US.${system}.checksums";
+        chksumSig = "${chksum}.asc";
+        # file content:
+        # <hash> sha512 62733881 firefox-56.0a1.en-US.linux-x86_64.tar.bz2
+        # <hash> sha256 62733881 firefox-56.0a1.en-US.linux-x86_64.tar.bz2
+        url = "${dir}/${file}";
+        sha512 = head (match ".*[\n]([0-9a-f]*) sha512 [0-9]* ${file}[\n].*" (readFile (fetchurl chksum)));
+      };
+
+  # From the version info, check the authenticity of the check sum file, such
+  # that we guarantee that we have
+  verifyAuthenticity = info:
+    super.runCommandNoCC "check-firefox-signature" {
+      buildInputs = [ self.gnupg ];
+      CHKSUM_FILE = builtins.fetchurl info.chksum;
+      CHKSUM_ASC = builtins.fetchurl info.chksumSig;
+    } ''
+      HOME=`mktemp -d`
+      set -eu
+      cat ${./firefox.key} | gpg --import
+      gpgv --keyring=$HOME/.gnupg/pubring.kbx $CHKSUM_ASC $CHKSUM_FILE
+      mkdir $out
+    '';
+
+  # From the version info, create a fetchurl derivation which will get the
+  # sources from the remote.
+  fetchVersion = info:
+    super.fetchurl {
+      inherit (info) url sha512;
+
+      # This is a fixed derivation, but we still add as a dependency the
+      # verification of the checksum.  Thus, this fetch script can only be
+      # executed once the verifyAuthenticity script finished successfully.
+      postFetch = ''
+        : # Authenticity Check (${verifyAuthenticity info})
+      '';
+  };
+
+  firefoxVersion = version:
+    let info = versionInfo version; in
+    super.wrapFirefox ((self.firefox-bin-unwrapped.override {
+      generated = {
+        version = version.version;
+        sources = { inherit (info) url sha512; };
+      };
+    }).overrideAttrs (old: {
+      # Add a dependency on the signature check.
+      src = fetchVersion info;
+    })) {
+      browserName = "firefox";
+      name = "firefox-bin-${version.version}";
+      desktopName = "Firefox";
+    };
+in
+
+{
+  lib = super.lib // {
+    firefoxOverlay = {
+      inherit firefoxVersion;
+    };
+  };
+
+  # Set of packages which are automagically updated. Do not rely on these for
+  # reproducible builds.
+  latest = (super.latest or {}) // {
+    firefox-nightly-bin = firefoxVersion {
+      name = "Firefox Nightly";
+      version = firefox_versions.FIREFOX_NIGHTLY;
+      release = false;
+    };
+    firefox-beta-bin = firefoxVersion {
+      name = "Firefox Beta";
+      version = firefox_versions.LATEST_FIREFOX_DEVEL_VERSION;
+      release = true;
+    };
+    firefox-bin = firefoxVersion {
+      name = "Firefox";
+      version = firefox_versions.LATEST_FIREFOX_VERSION;
+      release = true;
+    };
+    firefox-esr-bin = firefoxVersion {
+      name = "Firefox Esr";
+      version = firefox_versions.FIREFOX_ESR;
+      release = true;
+    };
+  };
+
+  # Set of packages which used to build developer environment
+  devEnv = (super.shell or {}) // {
+    gecko = super.callPackage ./pkgs/gecko {
+      inherit (self.python35Packages) setuptools;
+      pythonFull = self.python35Full;
+      nodejs =
+        if builtins.compareVersions self.nodejs.name "nodejs-8.11.3" < 0
+        then self.nodejs-8_x else self.nodejs;
+
+      rust-cbindgen =
+        if !(self ? "rust-cbindgen") then self.rust-cbindgen-latest
+        else if builtins.compareVersions self.rust-cbindgen.version "0.6.7" < 0
+        then self.rust-cbindgen-latest else self.rust-cbindgen;
+
+      # Due to std::ascii::AsciiExt changes in 1.23, Gecko does not compile, so
+      # use the latest Rust version before 1.23.
+      # rust = (super.rustChannelOf { channel = "stable"; date = "2017-11-22"; }).rust;
+      inherit (self.latest.rustChannels.stable) rust;
+    };
+  };
+
+  # Use rust-cbindgen imported from Nixpkgs (September 2018) unless the current
+  # version of Nixpkgs already packages a version of rust-cbindgen.
+  rust-cbindgen-latest = super.callPackage ./pkgs/cbindgen {
+    rustPlatform = super.makeRustPlatform {
+      cargo = self.latest.rustChannels.stable.rust;
+      rustc = self.latest.rustChannels.stable.rust;
+    };
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/firefox.key b/nixpkgs-overlays/nixpkgs-mozilla/firefox.key
new file mode 100644
index 000000000000..bd27ce85c94f
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/firefox.key
@@ -0,0 +1,254 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----

+Version: SKS 1.1.5

+Comment: Hostname: keyserver.mozilla.org

+

+mQINBFWpQAQBEAC+9wVlwGLy8ILCybLesuB3KkHHK+Yt1F1PJaI30X448ttGzxCzPQpH6BoA

+73uzcTReVjfCFGvM4ij6qVV2SNaTxmNBrL1uVeEUsCuGduDUQMQYRGxRtWq5rCH48LnltKPa

+mPiEBzrgFL3i5bYEUHO7M0lATEknG7Iaz697K/ssHREZfuucB4GNxXMgswZ7GTZO3VBDVEw5

+GwU3sUvww93TwMC29lIPCux445AxZPKr5sOVEsEndUB2oDMsSAoS/dZcl8F4otqfR1pXg618

+cU06omvq5yguWLDRV327BLmezYK0prD3P+7qwEp8MTVmxlbkrClS5j5pR47FrJGdyupNKqLz

+K+7hok5kBxhsdMsdTZLd4tVRjXf04isVO3iFFf/GKuwscOi1+ZYeB3l3sAqgFUWnjbpbHxfs

+lTmo7BgvmjZvAH5ZasaewF3wA06biCDJdcSkC9GmFPmN5DS5/Dkjwfj8+dZAttuSKfmQQnyp

+UPaJ2sBublnJ6INpvYgsEZjV6CFG1EiDJDPu2Zxap8ep0iRMbBBZnpfZTn7SKAcurDJptxin

+CRclTcdOdi1iSZ35LZW0R2FKNnGL33u1IhxU9HRLw3XuljXCOZ84RLn6M+PBc1eZsuv1TA+M

+n111yD3uDv/u/edZ/xeJccF6bYcMvUgRRZh0sgZ0ZT4b0Q6YcQARAQABtC9Nb3ppbGxhIFNv

+ZnR3YXJlIFJlbGVhc2VzIDxyZWxlYXNlQG1vemlsbGEuY29tPohGBBARAgAGBQJVrP9LAAoJ

+EHYlQD1/DRWxU2QAoOOFRbkbIU1zKP2i3jy/6VKHkYEgAJ9N6f9Gmjm1/vtSrvjjlxWzzQQr

+kIhGBBARAgAGBQJVrTrjAAoJEMNOV0fiPdZ3BbkAoJUNHEqNv9dioaGMEIpiFtDjEm44AJ9U

+inMTfAYsL9yb15SdJWe/56VCcoheBBARCAAGB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D1A5e6/os

+O9V7kjhXKzM2zSO11zHQ/5PlUisoUBjJ/QIK4v9RBNGtbRKso5X9Fke692lVgrdggDJ3j2Qq

+MuTo71rAVDLtxerc+GNq0GI=

+=YjV6

+-----END PGP PUBLIC KEY BLOCK-----

diff --git a/nixpkgs-overlays/nixpkgs-mozilla/git-cinnabar-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/git-cinnabar-overlay.nix
new file mode 100644
index 000000000000..0b1bbd63bbba
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/git-cinnabar-overlay.nix
@@ -0,0 +1,9 @@
+self: super:
+
+{
+  git-cinnabar = super.callPackage ./pkgs/git-cinnabar {
+    # we need urllib to recognize ssh.
+    # python = self.pythonFull;
+    python = self.mercurial.python;
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/lib-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/lib-overlay.nix
new file mode 100644
index 000000000000..23d6b397db99
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/lib-overlay.nix
@@ -0,0 +1,5 @@
+self: super:
+
+{
+  lib = super.lib // (import ./pkgs/lib/default.nix { pkgs = self; });
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/lib/parseTOML.nix b/nixpkgs-overlays/nixpkgs-mozilla/lib/parseTOML.nix
new file mode 100644
index 000000000000..07a93696340c
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/lib/parseTOML.nix
@@ -0,0 +1,210 @@
+with builtins;
+
+# Tokenizer.
+let
+  layout_pat = "[ \n]+";
+  layout_pat_opt = "[ \n]*";
+  token_pat = ''=|[[][[][a-zA-Z0-9_."*-]+[]][]]|[[][a-zA-Z0-9_."*-]+[]]|[a-zA-Z0-9_-]+|"[^"]*"''; #"
+
+  tokenizer_1_11 = str:
+    let
+      tokenizer_rec = len: prevTokens: patterns: str:
+        let
+          pattern = head patterns;
+          layoutAndTokens = match pattern str;
+          matchLength = stringLength (head layoutAndTokens);
+          tokens = prevTokens ++ tail layoutAndTokens;
+        in
+          if layoutAndTokens == null then
+            # if we cannot reduce the pattern, return the list of token
+            if tail patterns == [] then prevTokens
+            # otherwise, take the next pattern, which only captures half the token.
+            else tokenizer_rec len prevTokens (tail patterns) str
+          else tokenizer_rec len tokens patterns (substring matchLength len str);
+
+      avgTokenSize = 100;
+      ceilLog2 = v:
+        let inner = n: i: if i < v then inner (n + 1) (i * 2) else n; in
+        inner 1 1;
+
+      # The builtins.match function match the entire string, and generate a list of all captured
+      # elements. This is the most efficient way to make a tokenizer, if we can make a pattern which
+      # capture all token of the file. Unfortunately C++ std::regex does not support captures in
+      # repeated patterns. As a work-around, we generate patterns which are matching tokens in multiple
+      # of 2, such that we can avoid iterating too many times over the content.
+      generatePatterns = str:
+        let
+          depth = ceilLog2 (stringLength str / avgTokenSize);
+          inner = depth:
+            if depth == 0 then [ "(${token_pat})" ]
+            else
+              let next = inner (depth - 1); in
+              [ "${head next}${layout_pat}${head next}" ] ++ next;
+        in
+          map (pat: "(${layout_pat_opt}${pat}).*" ) (inner depth);
+
+    in
+      tokenizer_rec (stringLength str) [] (generatePatterns str) str;
+
+  tokenizer_1_12 = str:
+    let
+      # Nix 1.12 has the builtins.split function which allow to tokenize the
+      # file quickly. by iterating with a simple regexp.
+      layoutTokenList = split "(${token_pat})" str;
+      isLayout = s: match layout_pat_opt s != null;
+      filterLayout = list:
+        filter (s:
+          if isString s then
+            if isLayout s then false
+            else throw "Error: Unexpected token: '${s}'"
+          else true) list;
+      removeTokenWrapper = list:
+        map (x: assert tail x == []; head x) list;
+    in
+      removeTokenWrapper (filterLayout layoutTokenList);
+
+  tokenizer =
+    if builtins ? split
+    then tokenizer_1_12
+    else tokenizer_1_11;
+in
+
+# Parse entry headers
+let
+  unescapeString = str:
+    # Let's ignore any escape character for the moment.
+    assert match ''"[^"]*"'' str != null; #"
+    substring 1 (stringLength str - 2) str;
+
+  # Match the content of TOML format section names.
+  ident_pat = ''[a-zA-Z0-9_-]+|"[^"]*"''; #"
+
+  removeBraces = token: wrapLen:
+    substring wrapLen (stringLength token - 2 * wrapLen) token;
+
+  # Note, this implementation is limited to 11 identifiers.
+  matchPathFun_1_11 = token:
+    let
+      # match header_pat "a.b.c" == [ "a" ".b" "b" ".c" "c" ]
+      header_pat =
+        foldl' (pat: n: "(${ident_pat})([.]${pat})?")
+           "(${ident_pat})" (genList (n: 0) 10);
+      matchPath = match header_pat token;
+      filterDot = filter (s: substring 0 1 s != ".") matchPath;
+    in
+      filterDot;
+
+  matchPathFun_1_12 = token:
+    map (e: head e)
+      (filter (s: isList s)
+        (split "(${ident_pat})" token));
+
+  matchPathFun =
+    if builtins ? split
+    then matchPathFun_1_12
+    else matchPathFun_1_11;
+
+  headerToPath = token: wrapLen:
+    let
+      token' = removeBraces token wrapLen;
+      matchPath = matchPathFun token';
+      path =
+        map (s:
+          if substring 0 1 s != ''"'' then s #"
+          else unescapeString s 
+        ) matchPath;
+    in 
+      assert matchPath != null;
+      # assert trace "Path: ${token'}; match as ${toString path}" true;
+      path;
+in
+
+# Reconstruct the equivalent attribute set.
+let
+  tokenToValue = token:
+    if token == "true" then true
+    else if token == "false" then false
+    else unescapeString token;
+
+  parserInitState = {
+    idx = 0;
+    path = [];
+    isList = false;
+    output = [];
+    elem = {};
+  };
+
+  # Imported from nixpkgs library.
+  setAttrByPath = attrPath: value:
+    if attrPath == [] then value
+    else listToAttrs
+      [ { name = head attrPath; value = setAttrByPath (tail attrPath) value; } ];
+
+  closeSection = state:
+    state // {
+      output = state.output ++ [ (setAttrByPath state.path (
+        if state.isList then [ state.elem ]
+        else state.elem
+      )) ];
+    };
+
+  readToken = state: token:
+    # assert trace "Read '${token}'" true;
+    if state.idx == 0 then
+      if substring 0 2 token == "[[" then
+        (closeSection state) // {
+          path = headerToPath token 2;
+          isList = true;
+          elem = {};
+        }
+      else if substring 0 1 token == "[" then
+        (closeSection state) // {
+          path = headerToPath token 1;
+          isList = false;
+          elem = {};
+        }
+      else
+        assert match "[a-zA-Z0-9_-]+" token != null;
+        state // { idx = 1; name = token; }
+    else if state.idx == 1 then
+      assert token == "=";
+      state // { idx = 2; }
+    else
+      assert state.idx == 2;
+      state // {
+        idx = 0;
+        elem = state.elem // {
+          "${state.name}" = tokenToValue token;
+        };
+      };
+
+  # aggregate each section as individual attribute sets.
+  parser = str:
+    closeSection (foldl' readToken parserInitState (tokenizer str));
+
+  fromTOML = toml:
+    let
+      sections = (parser toml).output;
+      # Inlined from nixpkgs library functions.
+      zipAttrs = sets:
+        listToAttrs (map (n: {
+          name = n;
+          value =
+            let v = catAttrs n sets; in
+            # assert trace "Visiting ${n}" true;
+            if tail v == [] then head v 
+            else if isList (head v) then concatLists v
+            else if isAttrs (head v) then zipAttrs v
+            else throw "cannot merge sections";
+        }) (concatLists (map attrNames sets)));
+    in
+      zipAttrs sections;
+in
+
+{
+  testing = fromTOML (builtins.readFile ./channel-rust-nightly.toml);
+  testing_url = fromTOML (builtins.readFile (builtins.fetchurl
+  https://static.rust-lang.org/dist/channel-rust-nightly.toml));
+  inherit fromTOML;
+}
+
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/overlays.nix b/nixpkgs-overlays/nixpkgs-mozilla/overlays.nix
new file mode 100644
index 000000000000..2eaf175417cc
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/overlays.nix
@@ -0,0 +1,8 @@
+[
+  ./lib-overlay.nix
+  ./rust-overlay.nix
+  ./rr-overlay.nix
+  ./firefox-overlay.nix
+  ./vidyo-overlay.nix
+  ./git-cinnabar-overlay.nix
+]
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/package-set.nix b/nixpkgs-overlays/nixpkgs-mozilla/package-set.nix
new file mode 100644
index 000000000000..0b58b67eadac
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/package-set.nix
@@ -0,0 +1,8 @@
+{ pkgs }:
+
+with pkgs.lib;
+let
+  self = foldl'
+    (prev: overlay: prev // (overlay (pkgs // self) (pkgs // prev)))
+    {} (map import (import ./overlays.nix));
+in self
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/phlay-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/phlay-overlay.nix
new file mode 100644
index 000000000000..7dcb133adada
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/phlay-overlay.nix
@@ -0,0 +1,5 @@
+self: super:
+
+{
+  phlay = super.callPackage ./pkgs/phlay {};
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pinned.nix b/nixpkgs-overlays/nixpkgs-mozilla/pinned.nix
new file mode 100644
index 000000000000..1499d40ea7c6
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pinned.nix
@@ -0,0 +1,36 @@
+# This script extends nixpkgs with mozilla packages.
+#
+# First it imports the <nixpkgs> in the environment and depends on it
+# providing fetchFromGitHub and lib.importJSON.
+#
+# After that it loads a pinned release of nixos-unstable and uses that as the
+# base for the rest of packaging. One can pass it's own pkgsPath attribute if
+# desired, probably in the context of hydra.
+
+{ pkgsPath ? null
+, overlays ? []
+, system ? null
+, geckoSrc ? null
+}:
+
+# Pin a specific version of Nixpkgs.
+let
+  _pkgs = import <nixpkgs> {};
+  _pkgsPath =
+    if pkgsPath != null then pkgsPath
+    else _pkgs.fetchFromGitHub (_pkgs.lib.importJSON ./pkgs/nixpkgs.json);
+  nixpkgs = import _pkgsPath ({
+    overlays = import ./default.nix ++ overlays;
+  } // (if system != null then { inherit system; } else {}));
+in
+  nixpkgs // {
+    # Do not add a name attribute attribute in an overlay !!! As this will cause
+    # tons of recompilations.
+    name = "nixpkgs";
+    updateScript = nixpkgs.lib.updateFromGitHub {
+      owner = "NixOS";
+      repo = "nixpkgs-channels";
+      branch = "nixos-unstable-small";
+      path = "pkgs/nixpkgs.json";
+    };
+  }
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/builder.sh b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/builder.sh
new file mode 100644
index 000000000000..e3bc78283a43
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/builder.sh
@@ -0,0 +1,14 @@
+source $stdenv/setup
+PATH=$dpkg/bin:$PATH
+
+dpkg -x $src unpacked
+
+mkdir -p $out/bin
+cp -r unpacked/* $out/
+
+ln -s $out/usr/bin/VidyoDesktop $out/bin/VidyoDesktop
+touch $out/etc/issue
+
+#wrapProgram $out/bin/VidyoDesktop \
+#    --set PULSE_LATENCY_MSEC "60" \
+#    --set VIDYO_AUDIO_FRAMEWORK "ALSA"
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/default.nix
new file mode 100644
index 000000000000..7dfdb6b59aed
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, buildFHSUserEnv, makeWrapper, dpkg, alsaLib
+, alsaUtils, alsaOss, alsaTools, alsaPlugins, libGL, utillinux, mesa_glu, qt4
+, zlib, patchelf, xorg, libpulseaudio
+, callPackage
+#, libidn
+}:
+
+let
+  libidn = callPackage ./libidn.nix {};
+  vidyoVersion = "3.6.3";
+  vidyoBuild = "017";
+  vidyoVersionUnderscore = builtins.replaceStrings ["."] ["_"] vidyoVersion;
+  VidyoDesktopDeb = stdenv.mkDerivation {
+    name = "VidyoDesktopDeb-${vidyoVersion}";
+    builder = ./builder.sh;
+    inherit dpkg;
+    src = fetchurl {
+      url = "https://client-downloads.vidyocloud.com/VidyoDesktopInstaller-ubuntu64-TAG_VD_${vidyoVersionUnderscore}_${vidyoBuild}.deb";
+      sha256 = "01spq6r49myv82fdimvq3ykwb1lc5bymylzcydfdp9xz57f5a94x";
+    };
+    buildInputs = [ makeWrapper ];
+  };
+
+in buildFHSUserEnv {
+  name = "VidyoDesktop";
+  targetPkgs = pkgs: [ VidyoDesktopDeb ];
+  multiPkgs = pkgs: [
+    patchelf dpkg alsaLib alsaUtils alsaOss alsaTools alsaPlugins
+    libidn libGL utillinux mesa_glu qt4 zlib xorg.libXext xorg.libXv xorg.libX11
+    xorg.libXfixes xorg.libXrandr xorg.libXScrnSaver
+    libpulseaudio
+  ];
+  extraBuildCommands = ''
+    ln -s ${VidyoDesktopDeb}/opt $out/opt
+  '';
+  runScript = "VidyoDesktop";
+  # for debugging
+  #runScript = "bash";
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/libidn.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/libidn.nix
new file mode 100644
index 000000000000..b6f08a9206ee
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/VidyoDesktop/libidn.nix
@@ -0,0 +1,47 @@
+{ fetchurl, stdenv, libiconv }:
+
+stdenv.mkDerivation rec {
+  name = "libidn-1.34";
+
+  src = fetchurl {
+    url = "mirror://gnu/libidn/${name}.tar.gz";
+    sha256 = "0g3fzypp0xjcgr90c5cyj57apx1cmy0c6y9lvw2qdcigbyby469p";
+  };
+
+  outputs = [ "bin" "dev" "out" "info" "devdoc" ];
+
+  # broken with gcc-7
+  #doCheck = !stdenv.isDarwin && !stdenv.hostPlatform.isMusl;
+
+  hardeningDisable = [ "format" ];
+
+  buildInputs = stdenv.lib.optional stdenv.isDarwin libiconv;
+
+  doCheck = false; # fails
+
+  meta = {
+    homepage = http://www.gnu.org/software/libidn/;
+    description = "Library for internationalized domain names";
+
+    longDescription = ''
+      GNU Libidn is a fully documented implementation of the
+      Stringprep, Punycode and IDNA specifications.  Libidn's purpose
+      is to encode and decode internationalized domain names.  The
+      native C, C\# and Java libraries are available under the GNU
+      Lesser General Public License version 2.1 or later.
+
+      The library contains a generic Stringprep implementation.
+      Profiles for Nameprep, iSCSI, SASL, XMPP and Kerberos V5 are
+      included.  Punycode and ASCII Compatible Encoding (ACE) via IDNA
+      are supported.  A mechanism to define Top-Level Domain (TLD)
+      specific validation tables, and to compare strings against those
+      tables, is included.  Default tables for some TLDs are also
+      included.
+    '';
+
+    repositories.git = git://git.savannah.gnu.org/libidn.git;
+    license = stdenv.lib.licenses.lgpl2Plus;
+    platforms = stdenv.lib.platforms.all;
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/cbindgen/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/cbindgen/default.nix
new file mode 100644
index 000000000000..fbaf74ed93ac
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/cbindgen/default.nix
@@ -0,0 +1,25 @@
+### NOTE: This file is a copy of the one from Nixpkgs repository
+### (taken 2018 October).  It is used when the version of cbindgen in
+### upstream nixpkgs is not up-to-date enough to compile Firefox.
+{ stdenv, fetchFromGitHub, rustPlatform }:
+
+rustPlatform.buildRustPackage rec {
+  name = "rust-cbindgen-${version}";
+  version = "0.6.7";
+
+  src = fetchFromGitHub {
+    owner = "eqrion";
+    repo = "cbindgen";
+    rev = "v${version}";
+    sha256 = "0sgkgvkqrc6l46fvk6d9hsy0xrjpl2ix47f3cv5bi74dv8i4y2b4";
+  };
+
+  cargoSha256 = "137dqj1sp02dh0dz9psf8i8q57gmz3rfgmwk073k7x5zzkgvj21c";
+
+  meta = with stdenv.lib; {
+    description = "A project for generating C bindings from Rust code";
+    homepage = https://github.com/eqrion/cbindgen;
+    license = licenses.mpl20;
+    maintainers = with maintainers; [ jtojnar ];
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/clang/bug-14435.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/clang/bug-14435.patch
new file mode 100644
index 000000000000..c16a8f82f182
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/clang/bug-14435.patch
@@ -0,0 +1,35 @@
+diff -x _inst -x _build -x .svn -ur libcxx.old/include/cstdio libcxx.new/include/cstdio
+--- libcxx.old/include/cstdio   2016-07-08 12:47:12.964181871 +0000
++++ libcxx.new/include/cstdio   2016-07-08 12:47:27.540149147 +0000
+@@ -109,15 +109,15 @@
+ #endif
+ 
+ #ifdef getc
+-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);}
++inline __attribute__ ((__always_inline__)) int __libcpp_getc(FILE* __stream) {return getc(__stream);}
+ #undef getc
+-inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);}
++inline __attribute__ ((__always_inline__)) int getc(FILE* __stream) {return __libcpp_getc(__stream);}
+ #endif  // getc
+ 
+ #ifdef putc
+-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
++inline __attribute__ ((__always_inline__)) int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
+ #undef putc
+-inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
++inline __attribute__ ((__always_inline__)) int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
+ #endif  // putc
+ 
+ #ifdef clearerr
+diff -x _inst -x _build -x .svn -ur libcxx.old/include/utility libcxx.new/include/utility
+--- libcxx.old/include/utility  2016-07-08 12:46:02.570334913 +0000
++++ libcxx.new/include/utility  2016-07-08 12:51:00.760636878 +0000
+@@ -217,7 +217,7 @@
+ }
+ 
+ template<class _Tp, size_t _Np>
+-inline _LIBCPP_INLINE_VISIBILITY
++inline __attribute__ ((__always_inline__))
+ void
+ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+ {
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/firefox-nightly-bin/update.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/firefox-nightly-bin/update.nix
new file mode 100644
index 000000000000..21fbac4c12e7
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/firefox-nightly-bin/update.nix
@@ -0,0 +1,47 @@
+{ name
+, writeScript
+, xidel
+, coreutils
+, gnused
+, gnugrep
+, curl
+, jq
+}:
+
+let
+  version = (builtins.parseDrvName name).version;
+in writeScript "update-firefox-nightly-bin" ''
+  PATH=${coreutils}/bin:${gnused}/bin:${gnugrep}/bin:${xidel}/bin:${curl}/bin:${jq}/bin
+
+  #set -eux
+  pushd pkgs/firefox-nightly-bin
+
+  tmpfile=`mktemp`
+  url=https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/
+
+  nightly_file=`curl $url | \
+                xidel - --extract //a | \
+                grep firefox | \
+                grep linux-x86_64.json | \
+                tail -1 | \
+                sed -e 's/.json//'`
+  nightly_json=`curl --silent $url$nightly_file.json`
+
+  cat > $tmpfile <<EOF
+  {
+    version = `echo $nightly_json | jq ."moz_app_version"` + "-" + `echo $nightly_json | jq ."buildid"`;
+    sources = [
+      { url = "$url$nightly_file.tar.bz2";
+        locale = "`echo $nightly_file | cut -d"." -f3`";
+        arch = "`echo $nightly_file | cut -d"." -f4`";
+        sha512 = "`curl --silent $url$nightly_file.checksums | grep $nightly_file.tar.bz2$ | grep sha512 | cut -d" " -f1`";
+      }
+    ];
+  }
+  EOF
+
+  mv $tmpfile sources.nix
+
+  popd
+
+''
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/arm-eabi.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/arm-eabi.patch
new file mode 100644
index 000000000000..63b017062b5b
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/arm-eabi.patch
@@ -0,0 +1,230 @@
+Index: gcc-4_7-branch/libstdc++-v3/configure.host
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194580)
+@@ -340,7 +340,7 @@
+         fi
+     esac
+     case "${host}" in
+-      arm*-*-linux-*eabi)
++      arm*-*-linux-*eabi*)
+ 	port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
+ 	;;
+     esac
+Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194580)
+@@ -1,5 +1,5 @@
+ // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
+-// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
+ //
+Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194580)
+@@ -1,5 +1,5 @@
+ // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
+-// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
+ //
+Index: gcc-4_7-branch/libjava/configure.ac
+===================================================================
+--- gcc-4_7-branch/libjava/configure.ac	(revision 194579)
++++ gcc-4_7-branch/libjava/configure.ac	(revision 194580)
+@@ -931,7 +931,7 @@
+     # on Darwin -single_module speeds up loading of the dynamic libraries.
+     extra_ldflags_libjava=-Wl,-single_module
+     ;;
+-arm*linux*eabi)
++arm*-*-linux*eabi*)
+     # Some of the ARM unwinder code is actually in libstdc++.  We
+     # could in principle replicate it in libgcj, but it's better to
+     # have a dependency on libstdc++.
+Index: gcc-4_7-branch/libjava/configure
+===================================================================
+--- gcc-4_7-branch/libjava/configure	(revision 194579)
++++ gcc-4_7-branch/libjava/configure	(revision 194580)
+@@ -20542,7 +20542,7 @@
+     # on Darwin -single_module speeds up loading of the dynamic libraries.
+     extra_ldflags_libjava=-Wl,-single_module
+     ;;
+-arm*linux*eabi)
++arm*-*-linux*eabi*)
+     # Some of the ARM unwinder code is actually in libstdc++.  We
+     # could in principle replicate it in libgcj, but it's better to
+     # have a dependency on libstdc++.
+Index: gcc-4_7-branch/libgcc/config.host
+===================================================================
+--- gcc-4_7-branch/libgcc/config.host	(revision 194579)
++++ gcc-4_7-branch/libgcc/config.host	(revision 194580)
+@@ -327,7 +327,7 @@
+ arm*-*-linux*)			# ARM GNU/Linux with ELF
+ 	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix"
+ 	case ${host} in
+-	arm*-*-linux-*eabi)
++	arm*-*-linux-*eabi*)
+ 	  tmake_file="${tmake_file} arm/t-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
+ 	  tm_file="$tm_file arm/bpabi-lib.h"
+ 	  unwind_header=config/arm/unwind-arm.h
+Index: gcc-4_7-branch/gcc/doc/install.texi
+===================================================================
+--- gcc-4_7-branch/gcc/doc/install.texi	(revision 194579)
++++ gcc-4_7-branch/gcc/doc/install.texi	(revision 194580)
+@@ -3222,7 +3222,7 @@
+ @heading @anchor{arm-x-eabi}arm-*-eabi
+ ARM-family processors.  Subtargets that use the ELF object format
+ require GNU binutils 2.13 or newer.  Such subtargets include:
+-@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi}
++@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi*}
+ and @code{arm-*-rtemseabi}.
+ 
+ @html
+Index: gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194580)
+@@ -1,4 +1,4 @@
+-/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi } } } */
++/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi* } } } */
+ 
+ void *foo (void)
+ {
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194580)
+@@ -7,10 +7,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ #include <limits.h>
+ 
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194580)
+@@ -9,10 +9,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ enum E { 
+   a = -312
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194580)
+@@ -7,10 +7,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // GROUPS passed enums
+   extern "C" int printf (const char *, ...);
+Index: gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194580)
+@@ -3818,7 +3818,7 @@
+ 		}
+ 	    } ""
+ 	}]
+-    } elseif { [istarget arm*-*-linux-gnueabi] } {
++    } elseif { [istarget arm*-*-linux-gnueabi*] } {
+ 	return [check_runtime sync_longlong_runtime {
+ 	    #include <stdlib.h>
+ 	    int main ()
+@@ -3860,7 +3860,7 @@
+ 	     || [istarget i?86-*-*]
+ 	     || [istarget x86_64-*-*]
+ 	     || [istarget alpha*-*-*] 
+-	     || [istarget arm*-*-linux-gnueabi] 
++	     || [istarget arm*-*-linux-gnueabi*] 
+ 	     || [istarget bfin*-*linux*]
+ 	     || [istarget hppa*-*linux*]
+ 	     || [istarget s390*-*-*] 
+@@ -3890,7 +3890,7 @@
+ 	     || [istarget i?86-*-*]
+ 	     || [istarget x86_64-*-*]
+ 	     || [istarget alpha*-*-*] 
+-	     || [istarget arm*-*-linux-gnueabi] 
++	     || [istarget arm*-*-linux-gnueabi*] 
+ 	     || [istarget hppa*-*linux*]
+ 	     || [istarget s390*-*-*] 
+ 	     || [istarget powerpc*-*-*]
+Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194580)
+@@ -1,6 +1,6 @@
+ ! { dg-do run }
+ ! { dg-options "-fshort-enums" }
+-! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ ! Program to test enumerations when option -fshort-enums is given
+ 
+ program main
+Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194580)
+@@ -1,7 +1,7 @@
+ ! { dg-do run }
+ ! { dg-additional-sources enum_10.c }
+ ! { dg-options "-fshort-enums -w" }
+-! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ ! Make sure short enums are indeed interoperable with the
+ ! corresponding C type.
+ 
+Index: gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in
+===================================================================
+--- gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194579)
++++ gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194580)
+@@ -1866,7 +1866,7 @@
+   LIBRARY_VERSION := $(LIB_VERSION)
+ endif
+ 
+-ifeq ($(strip $(filter-out arm% linux-gnueabi,$(arch) $(osys)-$(word 4,$(targ)))),)
++ifeq ($(strip $(filter-out arm%-linux,$(arch)-$(osys)) $(if $(findstring eabi,$(word 4,$(targ))),,$(word 4,$(targ)))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<a-intnam-linux.ads \
+   s-inmaop.adb<s-inmaop-posix.adb \
+Index: gcc-4_7-branch/gcc/config.gcc
+===================================================================
+--- gcc-4_7-branch/gcc/config.gcc	(revision 194579)
++++ gcc-4_7-branch/gcc/config.gcc	(revision 194580)
+@@ -855,7 +855,7 @@
+ 	esac
+ 	tmake_file="${tmake_file} arm/t-arm"
+ 	case ${target} in
+-	arm*-*-linux-*eabi)
++	arm*-*-linux-*eabi*)
+ 	    tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ 	    tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
+ 	    # Define multilib configuration for arm-linux-androideabi.
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/builder.sh b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/builder.sh
new file mode 100644
index 000000000000..dc6fdd935613
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/builder.sh
@@ -0,0 +1,245 @@
+source $stdenv/setup
+
+
+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+mkdir $NIX_FIXINC_DUMMY
+
+
+if test "$staticCompiler" = "1"; then
+    EXTRA_LDFLAGS="-static"
+else
+    EXTRA_LDFLAGS=""
+fi
+
+# GCC interprets empty paths as ".", which we don't want.
+if test -z "$CPATH"; then unset CPATH; fi
+if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
+echo "\$CPATH is \`$CPATH'"
+echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'"
+
+if test "$noSysDirs" = "1"; then
+
+    if test -e $NIX_GCC/nix-support/orig-libc; then
+
+        # Figure out what extra flags to pass to the gcc compilers
+        # being generated to make sure that they use our glibc.
+        extraFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+        # Use *real* header files, otherwise a limits.h is generated
+        # that does not include Glibc's limits.h (notably missing
+        # SSIZE_MAX, which breaks the build).
+        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+
+        # The path to the Glibc binaries such as `crti.o'.
+        glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib"
+        
+    else
+        # Hack: support impure environments.
+        extraFlags="-isystem /usr/include"
+        extraLDFlags="-L/usr/lib64 -L/usr/lib"
+        glibc_libdir="/usr/lib"
+        export NIX_FIXINC_DUMMY=/usr/include
+    fi
+
+    extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+    # BOOT_CFLAGS defaults to `-g -O2'; since we override it below,
+    # make sure to explictly add them so that files compiled with the
+    # bootstrap compiler are optimized and (optionally) contain
+    # debugging information (info "(gccinstall) Building").
+    if test -n "$dontStrip"; then
+	extraFlags="-O2 -g $extraFlags"
+    else
+	# Don't pass `-g' at all; this saves space while building.
+	extraFlags="-O2 $extraFlags"
+    fi
+
+    EXTRA_FLAGS="$extraFlags"
+    for i in $extraLDFlags; do
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
+    done
+
+    if test -n "$targetConfig"; then
+        # Cross-compiling, we need gcc not to read ./specs in order to build
+        # the g++ compiler (after the specs for the cross-gcc are created).
+        # Having LIBRARY_PATH= makes gcc read the specs from ., and the build
+        # breaks. Having this variable comes from the default.nix code to bring
+        # gcj in.
+        unset LIBRARY_PATH
+        unset CPATH
+        if test -z "$crossStageStatic"; then
+            EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include"
+            EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib -Wl,-rpath,${libcCross}/lib -Wl,-rpath-link,${libcCross}/lib"
+        fi
+    else
+        if test -z "$NIX_GCC_CROSS"; then
+            EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+        else
+            # This the case of cross-building the gcc.
+            # We need special flags for the target, different than those of the build
+            # Assertion:
+            test -e $NIX_GCC_CROSS/nix-support/orig-libc
+
+            # Figure out what extra flags to pass to the gcc compilers
+            # being generated to make sure that they use our glibc.
+            extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
+            extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
+
+            # Use *real* header files, otherwise a limits.h is generated
+            # that does not include Glibc's limits.h (notably missing
+            # SSIZE_MAX, which breaks the build).
+            NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
+
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)"
+            glibc_libdir="$glibc_dir/lib"
+            configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include"
+
+            extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+            EXTRA_TARGET_CFLAGS="$extraFlags"
+            for i in $extraLDFlags; do
+                EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i"
+            done
+        fi
+    fi
+
+
+    # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
+    # the startfiles.
+    # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
+    # for the startfiles.
+    makeFlagsArray=( \
+        "${makeFlagsArray[@]}" \
+        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        CXXFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \
+        )
+
+    if test -z "$targetConfig"; then
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+            BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+            )
+    fi
+
+    if test -n "$targetConfig" -a "$crossStageStatic" == 1; then
+        # We don't want the gcc build to assume there will be a libc providing
+        # limits.h in this stagae
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            LIMITS_H_TEST=false \
+            )
+    else
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            LIMITS_H_TEST=true \
+            )
+    fi
+fi
+
+if test -n "$targetConfig"; then
+    # The host strip will destroy some important details of the objects
+    dontStrip=1
+fi
+
+providedPreConfigure="$preConfigure";
+preConfigure() {
+    if test -n "$newlibSrc"; then
+        tar xvf "$newlibSrc" -C ..
+        ln -s ../newlib-*/newlib newlib
+        # Patch to get armvt5el working:
+        sed -i -e 's/ arm)/ arm*)/' newlib/configure.host
+    fi
+    # Bug - they packaged zlib
+    if test -d "zlib"; then
+        # This breaks the build without-headers, which should build only
+        # the target libgcc as target libraries.
+        # See 'configure:5370'
+        rm -Rf zlib
+    fi
+
+    if test -f "$NIX_GCC/nix-support/orig-libc"; then
+        # Patch the configure script so it finds glibc headers.  It's
+        # important for example in order not to get libssp built,
+        # because its functionality is in glibc already.
+        glibc_headers="$(cat $NIX_GCC/nix-support/orig-libc)/include"
+        sed -i \
+            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
+            gcc/configure
+    fi
+
+    if test -n "$crossMingw" -a -n "$crossStageStatic"; then
+        mkdir -p ../mingw
+        # --with-build-sysroot expects that:
+        cp -R $libcCross/include ../mingw
+        configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
+    fi
+
+    # Eval the preConfigure script from nix expression.
+    eval $providedPreConfigure;
+    env;
+    # Perform the build in a different directory.
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+}
+
+
+postConfigure() {
+    # Don't store the configure flags in the resulting executables.
+    sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
+}
+
+
+postInstall() {
+    # Remove precompiled headers for now.  They are very big and
+    # probably not very useful yet.
+    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
+
+    # Remove `fixincl' to prevent a retained dependency on the
+    # previous gcc.
+    rm -rf $out/libexec/gcc/*/*/install-tools
+    rm -rf $out/lib/gcc/*/*/install-tools
+    
+    # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
+    rm -rf $out/bin/gccbug
+    # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
+    for i in $out/libexec/gcc/*/*/*; do
+        if PREV_RPATH=`patchelf --print-rpath $i`; then
+            patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
+        fi
+    done
+
+    # Get rid of some "fixed" header files
+    rm -rf $out/lib/gcc/*/*/include/root
+
+    # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
+    for i in $out/bin/*-gcc*; do
+        if cmp -s $out/bin/gcc $i; then
+            ln -sfn gcc $i
+        fi
+    done
+
+    for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
+        if cmp -s $out/bin/g++ $i; then
+            ln -sfn g++ $i
+        fi
+    done
+
+    eval "$postInstallGhdl"
+}
+
+genericBuild
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/default.nix
new file mode 100644
index 000000000000..34ea93cf5f0e
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/default.nix
@@ -0,0 +1,533 @@
+{ stdenv, fetchurl, noSysDirs
+, langC ? true, langCC ? true, langFortran ? false
+, langJava ? false
+, langAda ? false
+, langVhdl ? false
+, langGo ? false
+, profiledCompiler ? false
+, staticCompiler ? false
+, enableShared ? true
+, texinfo ? null
+, perl ? null # optional, for texi2pod (then pod2man); required for Java
+, gmp, mpfr, mpc, gettext, which
+, libelf                      # optional, for link-time optimizations (LTO)
+, ppl ? null, cloog ? null # optional, for the Graphite optimization framework.
+, zlib ? null, boehmgc ? null
+, zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
+, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
+, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
+, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
+, gnatboot ? null
+, enableMultilib ? false
+, enablePlugin ? true             # whether to support user-supplied plug-ins
+, name ? "gcc"
+, cross ? null
+, binutilsCross ? null
+, libcCross ? null
+, crossStageStatic ? true
+, gnat ? null
+, libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
+, stripped ? true
+, gnused ? null
+}:
+
+assert langJava     -> zip != null && unzip != null
+                       && zlib != null && boehmgc != null
+                       && perl != null;  # for `--enable-java-home'
+assert langAda      -> gnatboot != null;
+assert langVhdl     -> gnat != null;
+
+# LTO needs libelf and zlib.
+assert libelf != null -> zlib != null;
+
+# Make sure we get GNU sed.
+assert stdenv.isDarwin -> gnused != null;
+
+# The go frontend is written in c++
+assert langGo -> langCC;
+
+with stdenv.lib;
+with builtins;
+
+let version = "4.7.3";
+
+    # Whether building a cross-compiler for GNU/Hurd.
+    crossGNU = cross != null && cross.config == "i586-pc-gnu";
+
+  /* gccinstall.info says that "parallel make is currently not supported since
+     collisions in profile collecting may occur".
+
+     Parallel make of gfortran is disabled because of an apparent race
+     condition concerning the generation of "bconfig.h". Please try and
+     re-enable parallel make for a later release of gfortran to check whether
+     the error has been fixed.
+  */
+    enableParallelBuilding = !profiledCompiler && !langFortran;
+
+    patches = []
+      ++ optional enableParallelBuilding ./parallel-bconfig-4.7.patch
+      ++ optional stdenv.isArm [ ./arm-eabi.patch ]
+      ++ optional (cross != null) ./libstdc++-target.patch
+      # ++ optional noSysDirs ./no-sys-dirs.patch
+      # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
+      # target libraries and tools.
+      ++ optional langAda ./gnat-cflags.patch
+      ++ optional langFortran ./gfortran-driving.patch;
+
+    javaEcj = fetchurl {
+      # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
+      # `configure' time.
+
+      # XXX: Eventually we might want to take it from upstream.
+      url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
+      sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
+    };
+
+    # Antlr (optional) allows the Java `gjdoc' tool to be built.  We want a
+    # binary distribution here to allow the whole chain to be bootstrapped.
+    javaAntlr = fetchurl {
+      url = http://www.antlr.org/download/antlr-3.1.3.jar;
+      sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09";
+    };
+
+    xlibs = [
+      libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
+      xproto renderproto xextproto inputproto randrproto
+    ];
+
+    javaAwtGtk = langJava && gtk != null;
+
+    /* Platform flags */
+    platformFlags = let
+        gccArch = stdenv.lib.attrByPath [ "platform" "gcc" "arch" ] null stdenv;
+        gccCpu = stdenv.lib.attrByPath [ "platform" "gcc" "cpu" ] null stdenv;
+        gccAbi = stdenv.lib.attrByPath [ "platform" "gcc" "abi" ] null stdenv;
+        gccFpu = stdenv.lib.attrByPath [ "platform" "gcc" "fpu" ] null stdenv;
+        gccFloat = stdenv.lib.attrByPath [ "platform" "gcc" "float" ] null stdenv;
+        gccMode = stdenv.lib.attrByPath [ "platform" "gcc" "mode" ] null stdenv;
+        withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
+        withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
+        withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in 
+        (withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode);
+
+    /* Cross-gcc settings */
+    crossMingw = (cross != null && cross.libc == "msvcrt");
+    crossConfigureFlags = let
+        gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross;
+        gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross;
+        gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross;
+        gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross;
+        gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross;
+        gccMode = stdenv.lib.attrByPath [ "gcc" "mode" ] null cross;
+        withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
+        withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
+        withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in
+        "--target=${cross.config}" +
+        withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode +
+        (if crossMingw && crossStageStatic then
+          " --with-headers=${libcCross}/include" +
+          " --with-gcc" +
+          " --with-gnu-as" +
+          " --with-gnu-ld" +
+          " --with-gnu-ld" +
+          " --disable-shared" +
+          " --disable-nls" +
+          " --disable-debug" +
+          " --enable-sjlj-exceptions" +
+          " --enable-threads=win32" +
+          " --disable-win32-registry"
+          else if crossStageStatic then
+          " --disable-libssp --disable-nls" +
+          " --without-headers" +
+          " --disable-threads " +
+          " --disable-libmudflap " +
+          " --disable-libgomp " +
+          " --disable-libquadmath" +
+          " --disable-shared" +
+          " --disable-decimal-float" # libdecnumber requires libc
+          else
+          " --with-headers=${libcCross}/include" +
+          " --enable-__cxa_atexit" +
+          " --enable-long-long" +
+          (if crossMingw then
+            " --enable-threads=win32" +
+            " --enable-sjlj-exceptions" +
+            " --enable-hash-synchronization" +
+            " --disable-libssp" +
+            " --disable-nls" +
+            " --with-dwarf2" +
+            # I think noone uses shared gcc libs in mingw, so we better do the same.
+            # In any case, mingw32 g++ linking is broken by default with shared libs,
+            # unless adding "-lsupc++" to any linking command. I don't know why.
+            " --disable-shared" +
+            (if cross.config == "x86_64-w64-mingw32" then
+              # To keep ABI compatibility with upstream mingw-w64
+              " --enable-fully-dynamic-string"
+              else "")
+            else (if cross.libc == "uclibc" then
+              # In uclibc cases, libgomp needs an additional '-ldl'
+              # and as I don't know how to pass it, I disable libgomp.
+              " --disable-libgomp" else "") +
+            " --enable-threads=posix" +
+            " --enable-nls" +
+            " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
+          );
+    stageNameAddon = if crossStageStatic then "-stage-static" else
+      "-stage-final";
+    crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
+
+  bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
+
+in
+
+# We need all these X libraries when building AWT with GTK+.
+assert gtk != null -> (filter (x: x == null) xlibs) == [];
+
+stdenv.mkDerivation ({
+  name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+    sha256 = "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g";
+  };
+
+  inherit patches;
+
+  postPatch =
+    if (stdenv.isGNU
+        || (libcCross != null                  # e.g., building `gcc.crossDrv'
+            && libcCross ? crossConfig
+            && libcCross.crossConfig == "i586-pc-gnu")
+        || (crossGNU && libcCross != null))
+    then
+      # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
+      # in glibc, so add the right `-I' flags to the default spec string.
+      assert libcCross != null -> libpthreadCross != null;
+      let
+        libc = if libcCross != null then libcCross else stdenv.glibc;
+        gnu_h = "gcc/config/gnu.h";
+        extraCPPDeps =
+             libc.propagatedBuildInputs
+          ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
+          ++ stdenv.lib.optional (libpthread != null) libpthread;
+        extraCPPSpec =
+          concatStrings (intersperse " "
+                          (map (x: "-I${x}/include") extraCPPDeps));
+        extraLibSpec =
+          if libpthreadCross != null
+          then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
+          else "-L${libpthread}/lib";
+      in
+        '' echo "augmenting \`CPP_SPEC' in \`${gnu_h}' with \`${extraCPPSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
+
+           echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
+
+           echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
+           sed -i "${gnu_h}" \
+               -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
+        ''
+    else if cross != null || stdenv.gcc.libc != null then
+      # On NixOS, use the right path to the dynamic linker instead of
+      # `/lib/ld*.so'.
+      let
+        libc = if libcCross != null then libcCross else stdenv.gcc.libc;
+      in
+        '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
+           for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
+           do
+             grep -q LIBC_DYNAMIC_LINKER "$header" || continue
+             echo "  fixing \`$header'..."
+             sed -i "$header" \
+                 -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
+           done
+        ''
+    else null;
+
+  inherit noSysDirs staticCompiler langJava crossStageStatic
+    libcCross crossMingw;
+
+  nativeBuildInputs = [ texinfo which gettext ]
+    ++ (optional (perl != null) perl)
+    ++ (optional javaAwtGtk pkgconfig);
+
+  buildInputs = [ gmp mpfr mpc libelf ]
+    ++ (optional (ppl != null) ppl)
+    ++ (optional (cloog != null) cloog)
+    ++ (optional (zlib != null) zlib)
+    ++ (optionals langJava [ boehmgc zip unzip ])
+    ++ (optionals javaAwtGtk ([ gtk libart_lgpl ] ++ xlibs))
+    ++ (optionals (cross != null) [binutilsCross])
+    ++ (optionals langAda [gnatboot])
+    ++ (optionals langVhdl [gnat])
+
+    # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
+    # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
+    ++ (optional stdenv.isDarwin gnused)
+    ;
+
+  NIX_LDFLAGS = stdenv.lib.optionalString  stdenv.isSunOS "-lm -ldl";
+
+  preConfigure = ''
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
+        "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"}
+      ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS)
+        "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
+         \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
+    );
+    ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit)
+      ''
+        export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+        export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+        export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+        export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+      ''}
+    '';
+
+  # 'iant' at #go-nuts@freenode, gccgo maintainer, said that
+  # they have a bug in 4.7.1 if adding "--disable-static"
+  dontDisableStatic = langGo || staticCompiler;
+
+  configureFlags = "
+    ${if stdenv.isSunOS then
+      " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
+      # On Illumos/Solaris GNU as is preferred
+      " --with-gnu-as --without-gnu-ld "
+      else ""}
+    --enable-lto
+    ${if enableMultilib then "" else "--disable-multilib"}
+    ${if enableShared then "" else "--disable-shared"}
+    ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
+    ${if ppl != null then "--with-ppl=${ppl} --disable-ppl-version-check" else ""}
+    ${if cloog != null then
+      "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"
+      else ""}
+    ${if langJava then
+      "--with-ecj-jar=${javaEcj} " +
+
+      # Follow Sun's layout for the convenience of IcedTea/OpenJDK.  See
+      # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
+      "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
+      else ""}
+    ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+    ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""}
+    --with-gmp=${gmp}
+    --with-mpfr=${mpfr}
+    --with-mpc=${mpc}
+    ${if libelf != null then "--with-libelf=${libelf}" else ""}
+    --disable-libstdcxx-pch
+    --without-included-gettext
+    --with-system-zlib
+    --enable-languages=${
+      concatStrings (intersperse ","
+        (  optional langC        "c"
+        ++ optional langCC       "c++"
+        ++ optional langFortran  "fortran"
+        ++ optional langJava     "java"
+        ++ optional langAda      "ada"
+        ++ optional langVhdl     "vhdl"
+        ++ optional langGo       "go"
+        )
+      )
+    }
+    ${if (stdenv ? glibc && cross == null)
+      then " --with-native-system-header-dir=${stdenv.glibc}/include"
+      else ""}
+    ${if langAda then " --enable-libada" else ""}
+    ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
+    ${if cross != null then crossConfigureFlags else ""}
+    ${if !bootstrap then "--disable-bootstrap" else ""}
+    ${if cross == null then platformFlags else ""}
+  ";
+
+  targetConfig = if cross != null then cross.config else null;
+
+  buildFlags = if bootstrap then
+    (if profiledCompiler then "profiledbootstrap" else "bootstrap")
+    else "";
+
+  installTargets =
+    if stripped
+    then "install-strip"
+    else "install";
+
+  crossAttrs = let
+    xgccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null stdenv.cross;
+    xgccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null stdenv.cross;
+    xgccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null stdenv.cross;
+    xgccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null stdenv.cross;
+    xgccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null stdenv.cross;
+    xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
+    xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
+    xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
+    xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
+    xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
+  in {
+    AR = "${stdenv.cross.config}-ar";
+    LD = "${stdenv.cross.config}-ld";
+    CC = "${stdenv.cross.config}-gcc";
+    CXX = "${stdenv.cross.config}-gcc";
+    AR_FOR_TARGET = "${stdenv.cross.config}-ar";
+    LD_FOR_TARGET = "${stdenv.cross.config}-ld";
+    CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
+    NM_FOR_TARGET = "${stdenv.cross.config}-nm";
+    CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    # If we are making a cross compiler, cross != null
+    NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
+    dontStrip = true;
+    configureFlags = ''
+      ${if enableMultilib then "" else "--disable-multilib"}
+      ${if enableShared then "" else "--disable-shared"}
+      ${if ppl != null then "--with-ppl=${ppl.crossDrv}" else ""}
+      ${if cloog != null then "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" else ""}
+      ${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""}
+      ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+      ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""}
+      --with-gmp=${gmp.crossDrv}
+      --with-mpfr=${mpfr.crossDrv}
+      --disable-libstdcxx-pch
+      --without-included-gettext
+      --with-system-zlib
+      --enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langJava     "java"
+          ++ optional langAda      "ada"
+          ++ optional langVhdl     "vhdl"
+          ++ optional langGo       "go"
+          )
+        )
+      }
+      ${if langAda then " --enable-libada" else ""}
+      --target=${stdenv.cross.config}
+      ${xwithArch}
+      ${xwithCpu}
+      ${xwithAbi}
+      ${xwithFpu}
+      ${xwithFloat}
+    '';
+    buildFlags = "";
+  };
+
+
+  # Needed for the cross compilation to work
+  AR = "ar";
+  LD = "ld";
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  CC = if stdenv.system == "x86_64-solaris" then "gcc -m64"
+       else "gcc";
+
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
+  # the library headers and binaries, regarless of the language being
+  # compiled.
+
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't
+  # honor `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
+  # add them to $CPATH and $LIBRARY_PATH in this case.
+  #
+  # Likewise, the LTO code doesn't find zlib.
+
+  CPATH = concatStrings
+            (intersperse ":" (map (x: x + "/include")
+                                  (optionals (zlib != null) [ zlib ]
+                                   ++ optionals langJava [ boehmgc ]
+                                   ++ optionals javaAwtGtk xlibs
+                                   ++ optionals javaAwtGtk [ gmp mpfr ]
+                                   ++ optional (libpthread != null) libpthread
+                                   ++ optional (libpthreadCross != null) libpthreadCross
+
+                                   # On GNU/Hurd glibc refers to Mach & Hurd
+                                   # headers.
+                                   ++ optionals (libcCross != null &&
+                                                 hasAttr "propagatedBuildInputs" libcCross)
+                                        libcCross.propagatedBuildInputs)));
+
+  LIBRARY_PATH = concatStrings
+                   (intersperse ":" (map (x: x + "/lib")
+                                         (optionals (zlib != null) [ zlib ]
+                                          ++ optionals langJava [ boehmgc ]
+                                          ++ optionals javaAwtGtk xlibs
+                                          ++ optionals javaAwtGtk [ gmp mpfr ]
+                                          ++ optional (libpthread != null) libpthread)));
+
+  EXTRA_TARGET_CFLAGS =
+    if cross != null && libcCross != null
+    then "-idirafter ${libcCross}/include"
+    else null;
+
+  EXTRA_TARGET_LDFLAGS =
+    if cross != null && libcCross != null
+    then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
+         (optionalString (libpthreadCross != null)
+           " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
+    else null;
+
+  passthru = { inherit langC langCC langAda langFortran langVhdl
+      langGo enableMultilib version; };
+
+  inherit enableParallelBuilding;
+
+  meta = {
+    homepage = http://gcc.gnu.org/;
+    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    description = "GNU Compiler Collection, version ${version}"
+      + (if stripped then "" else " (with debugging info)");
+
+    longDescription = ''
+      The GNU Compiler Collection includes compiler front ends for C, C++,
+      Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
+      as libraries for these languages (libstdc++, libgcj, libgomp,...).
+
+      GCC development is a part of the GNU Project, aiming to improve the
+      compiler used in the GNU system including the GNU/Linux variant.
+    '';
+
+    maintainers = [
+      stdenv.lib.maintainers.ludo
+      stdenv.lib.maintainers.viric
+      stdenv.lib.maintainers.shlevy
+    ];
+
+    # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
+    # gnatboot is not available out of linux platforms, so we disable the darwin build
+    # for the gnat (ada compiler).
+    platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false && libelf == null) [ "i686-darwin" ];
+  };
+}
+
+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
+  makeFlags = [ "all-gcc" "all-target-libgcc" ];
+  installTargets = "install-gcc install-target-libgcc";
+}
+
+
+# Strip kills static libs of other archs (hence cross != null)
+// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
+)
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gfortran-driving.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gfortran-driving.patch
new file mode 100644
index 000000000000..70708886b405
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gfortran-driving.patch
@@ -0,0 +1,20 @@
+This patch fixes interaction with Libtool.
+See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details.
+
+--- a/gcc/fortran/gfortranspec.c
++++ b/gcc/fortran/gfortranspec.c
+@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n"));
+     {
+       fprintf (stderr, _("Driving:"));
+       for (i = 0; i < g77_newargc; i++)
++	{
++	  if (g77_new_decoded_options[i].opt_index == OPT_l)
++	    /* Make sure no white space is inserted after `-l'.  */
++	    fprintf (stderr, " -l%s",
++		     g77_new_decoded_options[i].canonical_option[1]);
++	  else
+ 	fprintf (stderr, " %s",
+ 		 g77_new_decoded_options[i].orig_option_with_args_text);
++	}
+       fprintf (stderr, "\n");
+     }
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gnat-cflags.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gnat-cflags.patch
new file mode 100644
index 000000000000..bf2acf065e9b
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/gnat-cflags.patch
@@ -0,0 +1,33 @@
+diff --git a/libada/Makefile.in b/libada/Makefile.in
+index f5057a0..337e0c6 100644
+--- a/libada/Makefile.in
++++ b/libada/Makefile.in
+@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
+ WARN_CFLAGS = @warn_cflags@
+ 
+ TARGET_LIBGCC2_CFLAGS=
+-GNATLIBCFLAGS= -g -O2
++GNATLIBCFLAGS= -g -O2 $(CFLAGS)
+ GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
+ 	-DIN_RTS @have_getipinfo@
+ 
+--- a/gcc/ada/gcc-interface/Makefile.in
++++ b/gcc/ada/gcc-interface/Makefile.in
+@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
+ SOME_ADAFLAGS =-gnata
+ FORCE_DEBUG_ADAFLAGS = -g
+ GNATLIBFLAGS = -gnatpg -nostdinc
+-GNATLIBCFLAGS = -g -O2
++GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
+ # Pretend that _Unwind_GetIPInfo is available for the target by default.  This
+ # should be autodetected during the configuration of libada and passed down to
+ # here, but we need something for --disable-libada and hope for the best.
+@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
+ # Link flags used to build gnat tools.  By default we prefer to statically
+ # link with libgcc to avoid a dependency on shared libgcc (which is tricky
+ # to deal with as it may conflict with the libgcc provided by the system).
+-GCC_LINK_FLAGS=-static-libgcc
++GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
+ 
+ # End of variables for you to override.
+ 
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/java-jvgenmain-link.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/java-jvgenmain-link.patch
new file mode 100644
index 000000000000..2612e8bfbbbc
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/java-jvgenmain-link.patch
@@ -0,0 +1,17 @@
+The `jvgenmain' executable must be linked against `vec.o', among others,
+since it uses its vector API.
+
+--- gcc-4.3.3/gcc/java/Make-lang.in	2008-12-05 00:00:19.000000000 +0100
++++ gcc-4.3.3/gcc/java/Make-lang.in	2009-07-03 16:11:41.000000000 +0200
+@@ -109,9 +109,9 @@ jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIB
+ 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
+ 		$(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS)
+ 
+-jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS)
++jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) $(BUILD_RTL)
+ 	rm -f $@
+-	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(LIBS)
++	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(BUILD_RTL) $(LIBS)
+ 
+ #
+ # Build hooks:
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/libstdc++-target.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/libstdc++-target.patch
new file mode 100644
index 000000000000..fb622b395806
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/libstdc++-target.patch
@@ -0,0 +1,32 @@
+Patch to make the target libraries 'configure' scripts find the proper CPP.
+I noticed that building the mingw32 cross compiler.
+Looking at the build script for mingw in archlinux, I think that only nixos
+needs this patch. I don't know why.
+diff --git a/Makefile.in b/Makefile.in
+index 93f66b6..d691917 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
+ 	AR="$(AR_FOR_TARGET)"; export AR; \
+ 	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
+ 	CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
++	CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
+ 	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+ 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
+ 	CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
+@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
+ RAW_CXX_TARGET_EXPORTS = \
+ 	$(BASE_TARGET_EXPORTS) \
+ 	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
+-	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
++	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
++	CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
+ 
+ NORMAL_TARGET_EXPORTS = \
+ 	$(BASE_TARGET_EXPORTS) \
+-	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
++	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
++	CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
+ 
+ # Where to find GMP
+ HOST_GMPLIBS = @gmplibs@
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/no-sys-dirs.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/no-sys-dirs.patch
new file mode 100644
index 000000000000..79901703cb82
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/no-sys-dirs.patch
@@ -0,0 +1,41 @@
+diff -ru gcc-4.3.1-orig/gcc/cppdefault.c gcc-4.3.1/gcc/cppdefault.c
+--- gcc-4.3.1-orig/gcc/cppdefault.c	2007-07-26 10:37:01.000000000 +0200
++++ gcc-4.3.1/gcc/cppdefault.c	2008-06-25 17:48:23.000000000 +0200
+@@ -41,6 +41,10 @@
+ # undef CROSS_INCLUDE_DIR
+ #endif
+ 
++#undef LOCAL_INCLUDE_DIR
++#undef SYSTEM_INCLUDE_DIR
++#undef STANDARD_INCLUDE_DIR
++
+ const struct default_include cpp_include_defaults[]
+ #ifdef INCLUDE_DEFAULTS
+ = INCLUDE_DEFAULTS;
+diff -ru gcc-4.3.1-orig/gcc/gcc.c gcc-4.3.1/gcc/gcc.c
+--- gcc-4.3.1-orig/gcc/gcc.c	2008-03-02 23:55:19.000000000 +0100
++++ gcc-4.3.1/gcc/gcc.c	2008-06-25 17:52:53.000000000 +0200
+@@ -1478,10 +1478,10 @@
+ /* Default prefixes to attach to command names.  */
+ 
+ #ifndef STANDARD_STARTFILE_PREFIX_1
+-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
++#define STANDARD_STARTFILE_PREFIX_1 ""
+ #endif
+ #ifndef STANDARD_STARTFILE_PREFIX_2
+-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
++#define STANDARD_STARTFILE_PREFIX_2 ""
+ #endif
+ 
+ #ifdef CROSS_DIRECTORY_STRUCTURE  /* Don't use these prefixes for a cross compiler.  */
+--- gcc-4.3.1-orig/gcc/Makefile.in	2008-05-11 20:54:15.000000000 +0200
++++ gcc-4.3.1/gcc/Makefile.in	2008-06-25 17:48:23.000000000 +0200
+@@ -3277,7 +3281,7 @@
+   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
+   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+-  -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
++  -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
+   -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+   -DPREFIX=\"$(prefix)/\" \
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/parallel-bconfig-4.7.patch b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/parallel-bconfig-4.7.patch
new file mode 100644
index 000000000000..bdf0fa4931a5
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gcc-4.7/parallel-bconfig-4.7.patch
@@ -0,0 +1,30 @@
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 0f6735a..ba93e9b 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3904,21 +3904,21 @@ build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)	\
+   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
+ build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
+ gengtype-lex.o build/gengtype-lex.o : gengtype-lex.c gengtype.h $(SYSTEM_H)
+-gengtype-lex.o: $(CONFIG_H)
++gengtype-lex.o: $(CONFIG_H) $(BCONFIG_H)
+ build/gengtype-lex.o: $(BCONFIG_H)
+ gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
+   $(SYSTEM_H)
+-gengtype-parse.o: $(CONFIG_H)
++gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H)
+ build/gengtype-parse.o: $(BCONFIG_H)
+ gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
+   gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
+   $(XREGEX_H)
+-gengtype-state.o: $(CONFIG_H)
++gengtype-state.o: $(CONFIG_H) $(BCONFIG_H)
+ build/gengtype-state.o: $(BCONFIG_H)
+ gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h 	\
+   rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
+   $(OBSTACK_H) $(XREGEX_H)
+-gengtype.o: $(CONFIG_H)
++gengtype.o: $(CONFIG_H) $(BCONFIG_H)
+ build/gengtype.o: $(BCONFIG_H)
+ build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
+   errors.h $(READ_MD_H)
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/default.nix
new file mode 100644
index 000000000000..5007832c2697
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/default.nix
@@ -0,0 +1,203 @@
+{ geckoSrc ? null, lib
+, stdenv, fetchFromGitHub, pythonFull, which, autoconf213
+, perl, unzip, zip, gnumake, yasm, pkgconfig, xlibs, gnome2, pango, freetype, fontconfig, cairo
+, dbus, dbus_glib, alsaLib, libpulseaudio, gstreamer, gst_plugins_base
+, gtk3, glib, gobjectIntrospection, gdk_pixbuf, atk, gtk2
+, git, mercurial, openssl, cmake, procps
+, libnotify
+, valgrind, gdb, rr
+, setuptools
+, rust # rust & cargo bundled. (otheriwse use pkgs.rust.{rustc,cargo})
+, buildFHSUserEnv # Build a FHS environment with all Gecko dependencies.
+, llvmPackages, nasm
+, ccache
+
+, zlib, xorg
+, rust-cbindgen
+, nodejs
+}:
+
+let
+
+  inherit (lib) updateFromGitHub importJSON optionals inNixShell;
+
+  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
+
+  # Gecko sources are huge, we do not want to import them in the nix-store when
+  # we use this expression for making a build environment.
+  src =
+    if inNixShell then
+      null
+    else if geckoSrc == null then
+      fetchFromGitHub (importJSON ./source.json)
+    else
+      geckoSrc;
+
+  version = "HEAD"; # XXX: builtins.readFile "${src}/browser/config/version.txt";
+
+  buildInputs = [
+
+    # Expected by "mach"
+    pythonFull setuptools which autoconf213
+
+    # Expected by the configure script
+    perl unzip zip gnumake yasm pkgconfig
+
+    xlibs.libICE xlibs.libSM xlibs.libX11 xlibs.libXau xlibs.libxcb
+    xlibs.libXdmcp xlibs.libXext xlibs.libXt xlibs.printproto
+    xlibs.renderproto xlibs.xextproto xlibs.xproto xlibs.libXcomposite
+    xlibs.compositeproto xlibs.libXfixes xlibs.fixesproto
+    xlibs.damageproto xlibs.libXdamage xlibs.libXrender xlibs.kbproto
+
+    gnome2.libart_lgpl gnome2.libbonobo gnome2.libbonoboui
+    gnome2.libgnome gnome2.libgnomecanvas gnome2.libgnomeui
+    gnome2.libIDL
+
+    pango freetype fontconfig cairo
+
+    dbus dbus_glib
+
+    alsaLib libpulseaudio
+    gstreamer gst_plugins_base
+
+    gtk3 glib gobjectIntrospection gdk_pixbuf atk
+    gtk2 gnome2.GConf
+
+    rust
+
+    # For building bindgen
+    # Building bindgen is now done with the extra options added by genMozConfig
+    # shellHook, do not include clang directly in order to avoid messing up with
+    # the choices of the compilers.
+
+    # clang
+
+    # mach mochitest
+    procps
+
+    # "mach vendor rust" wants to list modified files by using the vcs.
+    git mercurial
+
+    # needed for compiling cargo-vendor and its dependencies
+    openssl cmake
+
+    # Useful for getting notification at the end of the build.
+    libnotify
+
+    # cbindgen is used to generate C bindings for WebRender.
+    rust-cbindgen
+
+    # nasm is used to build libdav1d.
+    nasm
+
+    # NodeJS is used for tooling around JS development.
+    nodejs
+
+  ] ++ optionals inNixShell [
+    valgrind gdb rr ccache
+  ];
+
+  genMozConfig = ''
+    cxxLib=$( echo -n ${gcc}/include/c++/* )
+    archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
+
+    cat - > $MOZCONFIG <<EOF
+    mk_add_options AUTOCONF=${autoconf213}/bin/autoconf
+    ac_add_options --with-libclang-path=${llvmPackages.clang.cc.lib}/lib
+    ac_add_options --with-clang-path=${llvmPackages.clang}/bin/clang
+    export BINDGEN_CFLAGS="-cxx-isystem $cxxLib -isystem $archLib"
+    export CC="${stdenv.cc}/bin/cc"
+    export CXX="${stdenv.cc}/bin/c++"
+    EOF
+  '';
+
+  shellHook = ''
+    export MOZCONFIG=$PWD/.mozconfig.nix-shell
+    export MOZBUILD_STATE_PATH=$PWD/.mozbuild
+    export CC="${stdenv.cc}/bin/cc";
+    export CXX="${stdenv.cc}/bin/c++";
+    # To be used when building the JS Shell.
+    export NIX_EXTRA_CONFIGURE_ARGS="--with-libclang-path=${llvmPackages.clang.cc.lib}/lib --with-clang-path=${llvmPackages.clang}/bin/clang"
+    cxxLib=$( echo -n ${gcc}/include/c++/* )
+    archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
+    export BINDGEN_CFLAGS="-cxx-isystem $cxxLib -isystem $archLib"
+    ${genMozConfig}
+    ${builtins.getEnv "NIX_SHELL_HOOK"}
+    unset AS
+  '';
+
+  # propagatedBuildInput should already have applied the "lib.chooseDevOutputs"
+  # on the propagated build inputs.
+  pullAllInputs = inputs:
+    inputs ++ lib.concatMap (i: pullAllInputs (i.propagatedNativeBuildInputs or [])) inputs;
+
+  fhs = buildFHSUserEnv rec {
+    name = "gecko-deps-fhs";
+    targetPkgs = _: pullAllInputs (lib.chooseDevOutputs (buildInputs ++ [ stdenv.cc zlib xorg.libXinerama xorg.libXxf86vm ]));
+    multiPkgs = null; #targetPkgs;
+    extraOutputsToInstall = [ "share" ];
+    profile = ''
+      # build-fhs-userenv/env.nix adds it, but causes 'ls' to SEGV.
+      unset LD_LIBRARY_PATH;
+      export LD_LIBRARY_PATH=/lib/;
+      export IN_NIX_SHELL=1
+      export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig
+      ${shellHook}
+    '';
+  };
+in
+
+stdenv.mkDerivation {
+  name = "gecko-dev-${version}";
+  inherit src buildInputs shellHook;
+
+  # Useful for debugging this Nix expression.
+  tracePhases = true;
+
+  configurePhase = ''
+    unset AS; # Set to CC when configured.
+    export MOZBUILD_STATE_PATH=$(pwd)/.mozbuild
+    export MOZCONFIG=$(pwd)/.mozconfig
+    export builddir=$(pwd)/builddir
+    ${genMozConfig}
+
+    mkdir -p $MOZBUILD_STATE_PATH $builddir
+
+    echo >> $MOZCONFIG "
+    # . $src/build/mozconfig.common
+
+    ac_add_options --enable-application=browser
+    mk_add_options MOZ_OBJDIR=$builddir
+    ac_add_options --prefix=$out
+    ac_add_options --enable-official-branding
+    "
+  '';
+
+  AUTOCONF = "${autoconf213}/bin/autoconf";
+
+  buildPhase = ''
+    cd $builddir
+    $src/mach build
+  '';
+
+  installPhase = ''
+    cd $builddir
+    $src/mach install
+  '';
+
+  # TODO: are there tests we would like to run? or should we package them separately?
+  doCheck = false;
+  doInstallCheck = false;
+
+  # This is for debugging purposes, go to hell damn wrapper which are removing
+  # all I need for debugging.
+  hardeningDisable = [ "all" ];
+
+  passthru.updateScript = updateFromGitHub {
+    owner = "mozilla";
+    repo = "gecko-dev";
+    branch = "master";
+    path = "pkgs/gecko/source.json";
+  };
+  passthru.fhs = fhs; # gecko.x86_64-linux.gcc.fhs.env
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/source.json b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/source.json
new file mode 100644
index 000000000000..f2b2da32ed46
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/source.json
@@ -0,0 +1,6 @@
+{
+  "owner": "mozilla",
+  "repo": "gecko-dev",
+  "rev": "fee636af734a0ce6dc7335691cc94664bafc385d",
+  "sha256": "0nnkqmglbi2znkz1avnyn064i5hngvsqrmhw8ccg6g4ga9bac8fv"
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/git-cinnabar/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/git-cinnabar/default.nix
new file mode 100644
index 000000000000..8d498be7c1d2
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/git-cinnabar/default.nix
@@ -0,0 +1,71 @@
+{ stdenv, fetchFromGitHub, autoconf
+, zlib
+, python
+, perl
+, gettext
+, git
+, mercurial
+}:
+
+# NOTE: git-cinnabar depends on a specific version of git-core, thus you should
+# ensure that you install a git-cinnabar version which matches your git version.
+#
+# NOTE: This package only provides git-cinnabar tools, as a git users might want
+# to have additional commands not provided by this forked version of git-core.
+stdenv.mkDerivation rec {
+  version = "0.5.0";
+  name = "git-cinnabar-${version}";
+  src = fetchFromGitHub {
+    owner = "glandium";
+    repo = "git-cinnabar";
+    inherit name;
+    rev = version; # tag name
+    fetchSubmodules = true;
+    sha256 = "1yki44qzh3ca41xv4ch3fkxalsj707q2az0yjb917q3mpavxsx9q";
+  };
+  buildInputs = [ autoconf python gettext git ];
+
+  ZLIB_PATH = zlib;
+  ZLIB_DEV_PATH = zlib.dev;
+
+  PERL_PATH = "${perl}/bin/perl";
+  NO_TCLTK = true;
+  V=1;
+
+  preBuild = ''
+    export ZLIB_PATH;
+    export ZLIB_DEV_PATH;
+    substituteInPlace git-core/Makefile --replace \
+      '$(ZLIB_PATH)/include' '$(ZLIB_DEV_PATH)/include'
+    # Comment out calls to git to try to verify that git-core is up to date
+    substituteInPlace Makefile \
+      --replace '$(eval $(call exec,git' '# $(eval $(call exec,git'
+
+
+    export PERL_PATH;
+    export NO_TCLTK
+    export V;
+  '';
+
+  makeFlags = "prefix=\${out}";
+
+  installTargets = "git-install";
+
+  postInstall =
+    let mercurial-py = mercurial + "/" + mercurial.python.sitePackages; in ''
+    # git-cinnabar rebuild git, we do not need that.
+    rm -rf $out/bin/* $out/share $out/lib
+    for f in $out/libexec/git-core/{git-remote-hg,git-cinnabar} ; do
+      substituteInPlace $f --replace \
+        "sys.path.append(os.path.join(os.path.dirname(__file__), 'pythonlib'))" \
+        "sys.path.extend(['$out/libexec/git-core/pythonlib', '${mercurial-py}'])"
+      mv $f $out/bin
+    done
+    mv $out/libexec/git-core/git-cinnabar-helper $out/bin/git-cinnabar-helper
+    mv $out/libexec/git-core/pythonlib $out/pythonlib
+    rm -rf $out/libexec/git-core/*
+    mv $out/pythonlib $out/libexec/git-core/pythonlib
+    substituteInPlace $out/libexec/git-core/pythonlib/cinnabar/helper.py \
+      --replace 'Git.config('cinnabar.helper')' "Git.config('cinnabar.helper') or '$out/bin/git-cinnabar-helper'"
+  '';
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/default.nix
new file mode 100644
index 000000000000..0557d1bdb4ae
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/default.nix
@@ -0,0 +1,7 @@
+{ pkgs }:
+
+let
+  update = import ./update.nix { inherit pkgs; };
+in
+  { inherit update; }
+  // update
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/update.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/update.nix
new file mode 100644
index 000000000000..2b97a2661aa0
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/lib/update.nix
@@ -0,0 +1,50 @@
+{ pkgs }:
+
+let
+  inherit (pkgs) cacert nix jq curl gnused gnugrep coreutils;
+in {
+
+  updateFromGitHub = { owner, repo, path, branch }: ''
+    export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
+
+    github_rev() {
+      ${curl.bin}/bin/curl -sSf "https://api.github.com/repos/$1/$2/branches/$3" | \
+        ${jq}/bin/jq '.commit.sha' | \
+        ${gnused}/bin/sed 's/"//g'
+    }
+
+    github_sha256() {
+      ${nix}/bin/nix-prefetch-url \
+         --unpack \
+         --type sha256 \
+         "https://github.com/$1/$2/archive/$3.tar.gz" 2>&1 | \
+         tail -1
+    }
+
+    echo "=== ${owner}/${repo}@${branch} ==="
+
+    echo -n "Looking up latest revision ... "
+    rev=$(github_rev "${owner}" "${repo}" "${branch}");
+    echo "revision is \`$rev\`."
+
+    sha256=$(github_sha256 "${owner}" "${repo}" "$rev");
+    echo "sha256 is \`$sha256\`."
+
+    if [ "$sha256" == "" ]; then
+      echo "sha256 is not valid!"
+      exit 2
+    fi
+    source_file=${path}
+    echo "Content of source file (``$source_file``) written."
+    cat <<REPO | ${coreutils}/bin/tee "$source_file"
+    {
+      "owner": "${owner}",
+      "repo": "${repo}",
+      "rev": "$rev",
+      "sha256": "$sha256"
+    }
+    REPO
+    echo
+  '';
+
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/nixpkgs.json b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/nixpkgs.json
new file mode 100644
index 000000000000..ac47434e17be
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/nixpkgs.json
@@ -0,0 +1,6 @@
+{
+  "owner": "NixOS",
+  "repo": "nixpkgs-channels",
+  "rev": "ed070354a9e307fdf20a94cb2af749738562385d",
+  "sha256": "05pqwg7s4w34v99yykb27031kc21x4n3f33szdi6wv11k4asjyfp"
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/phlay/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/phlay/default.nix
new file mode 100644
index 000000000000..e8b72c369de1
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/phlay/default.nix
@@ -0,0 +1,26 @@
+{ fetchFromGitHub
+, python36Packages
+}:
+python36Packages.buildPythonApplication {
+  name = "phlay";
+  version = "0.1.4";
+  src = fetchFromGitHub {
+    owner = "mystor";
+    repo = "phlay";
+    rev = "d3594b4c48b40f742bbd8b6293aeb29f33be45ef";
+    sha256 = "0b7xzrkafm6nb8rm19izyaymmc3mbr0ana1yspffxw819xwzl6vx";
+  };
+  meta = {
+    description = "A command-line interface for Phabricator";
+    longDescription = ''
+      Phlay is an alternative to Arcanist for submitting changes to Phabricator.
+
+      You might like Phlay if you do Mozilla development using git and
+      a "commit series" workflow.
+    '';
+  };
+  # phlay is designed as a single-file Python script with no
+  # dependencies outside the stdlib.
+  format = "other";
+  installPhase = "mkdir -p $out/bin; cp phlay $out/bin";
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/pkgs/servo/default.nix b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/servo/default.nix
new file mode 100644
index 000000000000..9ca931709278
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/pkgs/servo/default.nix
@@ -0,0 +1,102 @@
+{ servoSrc ? null
+, lib
+, rustPlatform
+, pkgs
+}:
+
+let
+
+  inherit (lib) updateFromGitHub;
+  inherit (pkgs) fetchFromGitHub curl dbus fontconfig freeglut freetype
+    gperf libxmi llvm mesa mesa_glu openssl pkgconfig makeWrapper writeText
+    xorg;
+  inherit (pkgs.stdenv) mkDerivation;
+  inherit (pkgs.lib) importJSON;
+  inherit (rustPlatform) buildRustPackage;
+  inherit (rustPlatform.rust) rustc cargo;
+
+  pythonPackages = pkgs.python3Packages;
+
+  src =
+    if servoSrc == null then
+      fetchFromGitHub (importJSON ./source.json)
+    else
+      servoSrc;
+
+  # TODO: figure out version from servoSrc
+  version = "latest";
+
+  # TODO: add possibility to test against wayland
+  xorgCompositorLibs = "${xorg.libXcursor.out}/lib:${xorg.libXi.out}/lib";
+
+  servobuild = writeText "servobuild" ''
+    [tools]
+    cache-dir = "./downloads"
+    cargo-home-dir = "./.downloads/clones
+    system-rust = true
+    rust-root = "${rustc}/bin/rustc"
+    system-cargo = true
+    cargo-root = "${cargo}/bin/cargo"
+    [build]
+  '';
+
+  servoRust = buildRustPackage rec {
+    inherit src;
+    name = "servo-rust-${version}";
+    postUnpack = ''
+      pwd
+      ls -la 
+      exit 100
+    '';
+    sourceRoot = "servo/components/servo";
+
+    depsSha256 = "0ca0lc8mm8kczll5m03n5fwsr0540c2xbfi4nn9ksn0s4sap50yn";
+
+    doCheck = false;
+  };
+
+in mkDerivation rec {
+  name = "servo-${version}";
+  src = servoSrc;
+
+  buildInputs = [
+    #cmake
+    curl
+    dbus
+    fontconfig
+    freeglut
+    freetype
+    gperf
+    libxmi
+    llvm
+    mesa
+    mesa_glu
+    openssl
+    pkgconfig
+    pythonPackages.pip
+    pythonPackages.virtualenv
+    xorg.libX11
+    xorg.libXmu
+
+    # nix stuff
+    makeWrapper
+    servoRust
+  ];
+  preConfigure = ''
+    ln -s ${servobuild} .servobuild
+  '';
+  postInstall = ''
+    wrapProgram "$out/bin/servo" --prefix LD_LIBRARY_PATH : "${xorgCompositorLibs}"
+  '';
+  shellHook = ''
+    # Servo tries to switch between libX11 and wayland at runtime so we have
+    # to provide a path
+    export LD_LIBRARY_PATH=${xorgCompositorLibs}:$LD_LIBRARY_PATH
+  '';
+  passthru.updateScript = updateFromGitHub {
+    owner = "servo";
+    repo = "servo";
+    branch = "master";
+    path = "pkgs/servo/source.json";
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/release.nix b/nixpkgs-overlays/nixpkgs-mozilla/release.nix
new file mode 100644
index 000000000000..7d7e44f491f7
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/release.nix
@@ -0,0 +1,100 @@
+# To pin a specific version of nixpkgs, change the nixpkgsSrc argument.
+{ nixpkgsSrc ? <nixpkgs>
+, supportedSystems ? [ "x86_64-linux" "i686-linux" /* "x86_64-darwin" */ ]
+}:
+
+let
+  lib = (import nixpkgsSrc {}).lib;
+
+  # Make an attribute set for each system, the builder is then specialized to
+  # use the selected system.
+  forEachSystem = systems: builder /* system -> stdenv -> pkgs */:
+    lib.genAttrs systems builder;
+
+  # Make an attribute set for each compiler, the builder is then be specialized
+  # to use the selected compiler.
+  forEachCompiler = compilers: builder: system:
+    builtins.listToAttrs (map (compiler: {
+      name = compiler;
+      value = builder compiler system;
+    }) compilers);
+
+
+  # Overide the previous derivation, with a different stdenv.
+  builder = path: compiler: system:
+    lib.getAttrFromPath path (import nixpkgsSrc {
+      inherit system;
+      overlays = [
+        # Add all packages from nixpkgs-mozilla.
+        (import ./default.nix)
+
+        # Define customStdenvs, which is a set of various compilers which can be
+        # used to compile the given package against.
+        (import ./compilers-overlay.nix)
+
+        # Use the following overlay to override the requested package from
+        # nixpkgs, with a custom stdenv taken from the compilers-overlay.
+        (self: super:
+          if compiler == null then {}
+          else lib.setAttrByPath path ((lib.getAttrFromPath path super).override {
+            stdenv = self.customStdenvs."${compiler}";
+          }))
+      ];
+    });
+
+  build = path: { systems ? supportedSystems, compilers ? null }:
+    forEachSystem systems (
+      if compilers == null
+      then builder path null
+      else forEachCompiler compilers (builder path)
+    );
+
+  geckoCompilers = [
+    "clang"
+    "clang36"
+    "clang37"
+    "clang38"
+    "gcc"
+    "gcc6"
+    "gcc5"
+    "gcc49"
+    "gcc48"
+    #"gcc474"
+    #"gcc473"
+    #"gcc472"
+  ];
+
+  jobs = {
+
+    # For each system, and each compiler, create an attribute with the name of
+    # the system and compiler. Use this attribute name to select which
+    # environment you are interested in for building firefox.  These can be
+    # build using the following command:
+    #
+    #   $ nix-build release.nix -A gecko.x86_64-linux.clang -o firefox-x64
+    #   $ nix-build release.nix -A gecko.i686-linux.gcc48 -o firefox-x86
+    #
+    # If you are only interested in getting a build environment, the use the
+    # nix-shell command instead, which will skip the copy of Firefox sources,
+    # and pull the the dependencies needed for building firefox with this
+    # environment.
+    #
+    #   $ nix-shell release.nix -A gecko.i686-linux.gcc --pure --command '$CC --version'
+    #   $ nix-shell release.nix -A gecko.x86_64-linux.clang --pure
+    #
+    # As some of the test script of Gecko are checking against absolute path, a
+    # fake-FHS is provided for Gecko.  It can be accessed by appending
+    # ".fhs.env" behind the previous commands:
+    #
+    #   $ nix-shell release.nix -A gecko.x86_64-linux.gcc.fhs.env
+    #
+    # Which will spawn a new shell where the closure of everything used to build
+    # Gecko would be part of the fake-root.
+    gecko = build [ "devEnv" "gecko" ] { compilers = geckoCompilers; };
+    VidyoDesktop = build [ "VidyoDesktop" ];
+    latest = {
+      "firefox-nightly-bin" = build [ "latest" "firefox-nightly-bin" ];
+    };
+  };
+
+in jobs
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/rr-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/rr-overlay.nix
new file mode 100644
index 000000000000..30405a828345
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/rr-overlay.nix
@@ -0,0 +1,14 @@
+self: super:
+
+{
+  # Add i686-linux platform as a valid target.
+  rr = super.rr.override {
+    stdenv = self.stdenv // {
+      mkDerivation = args: self.stdenv.mkDerivation (args // {
+        meta = args.meta // {
+          platforms = self.stdenv.lib.platforms.linux;
+        };
+      });
+    };
+  };
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay-install.sh b/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay-install.sh
new file mode 100755
index 000000000000..fac41ae43316
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay-install.sh
@@ -0,0 +1,12 @@
+#!/bin/sh -e
+
+cd "$(dirname "$0")" || exit
+
+overlay_dir=$HOME/.config/nixpkgs/overlays
+name=rust-overlay.nix
+
+echo Installing $name as an overlay
+
+set -x
+mkdir -p "$overlay_dir"
+ln -s "$PWD/$name" "$overlay_dir/$name"
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay.nix
new file mode 100644
index 000000000000..306819e7625d
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/rust-overlay.nix
@@ -0,0 +1,331 @@
+# This file provide a Rust overlay, which provides pre-packaged bleeding edge versions of rustc
+# and cargo.
+self: super:
+
+let
+  fromTOML = (import ./lib/parseTOML.nix).fromTOML;
+
+  parseRustToolchain = file: with builtins;
+    if file == null then
+      {}
+    else
+      let res = match "([a-z]*)-([0-9-]*).*" (readFile file); in
+      { channel = head res; date = head (tail res); };
+
+  # See https://github.com/rust-lang-nursery/rustup.rs/blob/master/src/rustup-dist/src/dist.rs
+  defaultDistRoot = "https://static.rust-lang.org";
+  manifest_v1_url = {
+    dist_root ? defaultDistRoot + "/dist",
+    date ? null,
+    staging ? false,
+    # A channel can be "nightly", "beta", "stable", "\d{1}.\d{1}.\d{1}", or "\d{1}.\d{2\d{1}".
+    channel ? "nightly",
+    rustToolchain ? null
+  }:
+    let args = { inherit channel date; } // parseRustToolchain rustToolchain; in
+    let inherit (args) date channel; in
+    if date == null && staging == false
+    then "${dist_root}/channel-rust-${channel}"
+    else if date != null && staging == false
+    then "${dist_root}/${date}/channel-rust-${channel}"
+    else if date == null && staging == true
+    then "${dist_root}/staging/channel-rust-${channel}"
+    else throw "not a real-world case";
+
+  manifest_v2_url = args: (manifest_v1_url args) + ".toml";
+
+  # Intersection of rustup-dist/src/dist.rs listed platforms and stdenv/default.nix.
+  hostTripleOf = system: { # switch
+    "i686-linux"      = "i686-unknown-linux-gnu";
+    "x86_64-linux"    = "x86_64-unknown-linux-gnu";
+    "armv5tel-linux"  = "arm-unknown-linux-gnueabi";
+    "armv6l-linux"    = "arm-unknown-linux-gnueabi";
+    "armv7a-android"  = "armv7-linux-androideabi";
+    "armv7l-linux"    = "armv7-unknown-linux-gnueabihf";
+    "aarch64-linux"   = "aarch64-unknown-linux-gnu";
+    "mips64el-linux"  = "mips64el-unknown-linux-gnuabi64";
+    "x86_64-darwin"   = "x86_64-apple-darwin";
+    "i686-cygwin"     = "i686-pc-windows-gnu"; # or msvc?
+    "x86_64-cygwin"   = "x86_64-pc-windows-gnu"; # or msvc?
+    "x86_64-freebsd"  = "x86_64-unknown-freebsd";
+  }.${system} or (throw "Rust overlay does not support ${system} yet.");
+
+  getComponentsWithFixedPlatform = pkgs: pkgname: stdenv:
+    let
+      pkg = pkgs.${pkgname};
+      srcInfo = pkg.target.${hostTripleOf stdenv.system} or pkg.target."*";
+      components = srcInfo.components or [];
+      componentNamesList =
+        builtins.map (pkg: pkg.pkg) (builtins.filter (pkg: (pkg.target != "*")) components);
+    in
+      componentNamesList;
+
+  getExtensions = pkgs: pkgname: stdenv:
+    let
+      inherit (super.lib) unique;
+      pkg = pkgs.${pkgname};
+      srcInfo = pkg.target.${hostTripleOf stdenv.system} or pkg.target."*";
+      extensions = srcInfo.extensions or [];
+      extensionNamesList = unique (builtins.map (pkg: pkg.pkg) extensions);
+    in
+      extensionNamesList;
+
+  hasTarget = pkgs: pkgname: target:
+    pkgs ? ${pkgname}.target.${target};
+
+  getTuples = pkgs: name: targets:
+    builtins.map (target: { inherit name target; }) (builtins.filter (target: hasTarget pkgs name target) targets);
+
+  # In the manifest, a package might have different components which are bundled with it, as opposed as the extensions which can be added.
+  # By default, a package will include the components for the same architecture, and offers them as extensions for other architectures.
+  #
+  # This functions returns a list of { name, target } attribute sets, which includes the current system package, and all its components for the selected targets.
+  # The list contains the package for the pkgTargets as well as the packages for components for all compTargets
+  getTargetPkgTuples = pkgs: pkgname: pkgTargets: compTargets: stdenv:
+    let
+      inherit (builtins) elem;
+      inherit (super.lib) intersectLists;
+      components = getComponentsWithFixedPlatform pkgs pkgname stdenv;
+      extensions = getExtensions pkgs pkgname stdenv;
+      compExtIntersect = intersectLists components extensions;
+      tuples = (getTuples pkgs pkgname pkgTargets) ++ (builtins.map (name: getTuples pkgs name compTargets) compExtIntersect);
+    in
+      tuples;
+
+  getFetchUrl = pkgs: pkgname: target: stdenv: fetchurl:
+    let
+      pkg = pkgs.${pkgname};
+      srcInfo = pkg.target.${target};
+    in
+      (super.fetchurl { url = srcInfo.xz_url; sha256 = srcInfo.xz_hash; });
+
+  checkMissingExtensions = pkgs: pkgname: stdenv: extensions:
+    let
+      inherit (builtins) head;
+      inherit (super.lib) concatStringsSep subtractLists;
+      availableExtensions = getExtensions pkgs pkgname stdenv;
+      missingExtensions = subtractLists availableExtensions extensions;
+      extensionsToInstall =
+        if missingExtensions == [] then extensions else throw ''
+          While compiling ${pkgname}: the extension ${head missingExtensions} is not available.
+          Select extensions from the following list:
+          ${concatStringsSep "\n" availableExtensions}'';
+    in
+      extensionsToInstall;
+
+  getComponents = pkgs: pkgname: targets: extensions: targetExtensions: stdenv: fetchurl:
+    let
+      inherit (builtins) head map;
+      inherit (super.lib) flatten remove subtractLists unique;
+      targetExtensionsToInstall = checkMissingExtensions pkgs pkgname stdenv targetExtensions;
+      extensionsToInstall = checkMissingExtensions pkgs pkgname stdenv extensions;
+      hostTargets = [ "*" (hostTripleOf stdenv.system)];
+      pkgTuples = flatten (getTargetPkgTuples pkgs pkgname hostTargets targets stdenv);
+      extensionTuples = flatten (map (name: getTargetPkgTuples pkgs name hostTargets targets stdenv) extensionsToInstall);
+      targetExtensionTuples = flatten (map (name: getTargetPkgTuples pkgs name targets targets stdenv) targetExtensionsToInstall);
+      pkgsTuples = pkgTuples ++ extensionTuples ++ targetExtensionTuples;
+      missingTargets = subtractLists (map (tuple: tuple.target) pkgsTuples) (remove "*" targets);
+      pkgsTuplesToInstall =
+        if missingTargets == [] then pkgsTuples else throw ''
+          While compiling ${pkgname}: the target ${head missingTargets} is not available for any package.'';
+    in
+      map (tuple: { name = tuple.name; src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl); }) pkgsTuplesToInstall;
+
+  installComponents = stdenv: namesAndSrcs:
+    let
+      inherit (builtins) map;
+      installComponent = name: src:
+        stdenv.mkDerivation {
+          inherit name;
+          inherit src;
+          # (@nbp) TODO: Check on Windows and Mac.
+          # This code is inspired by patchelf/setup-hook.sh to iterate over all binaries.
+          installPhase = ''
+            patchShebangs install.sh
+            sed -i "s/llvm-tools-preview//" components
+            CFG_DISABLE_LDCONFIG=1 ./install.sh --prefix=$out --verbose
+
+            setInterpreter() {
+              local dir="$1"
+              [ -e "$dir" ] || return 0
+
+              header "Patching interpreter of ELF executables and libraries in $dir"
+              local i
+              while IFS= read -r -d ''$'\0' i; do
+                if [[ "$i" =~ .build-id ]]; then continue; fi
+                if ! isELF "$i"; then continue; fi
+                echo "setting interpreter of $i"
+                patchelf \
+                  --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+                  --add-needed ${stdenv.cc.cc.lib}/lib/libstdc++.so.6 \
+                  "$i" || true
+              done < <(find "$dir" -type f -print0)
+            }
+
+            setInterpreter $out
+          '';
+
+          postFixup = ''
+            # Function moves well-known files from etc/
+            handleEtc() {
+              local oldIFS="$IFS"
+
+              # Directories we are aware of, given as substitution lists
+              for paths in \
+                "etc/bash_completion.d","share/bash_completion/completions","etc/bash_completions.d","share/bash_completions/completions";
+                do
+                # Some directoties may be missing in some versions. If so we just skip them.
+                # See https://github.com/mozilla/nixpkgs-mozilla/issues/48 for more infomation.
+                if [ ! -e $paths ]; then continue; fi
+
+                IFS=","
+                set -- $paths
+                IFS="$oldIFS"
+
+                local orig_path="$1"
+                local wanted_path="$2"
+
+                # Rename the files
+                if [ -d ./"$orig_path" ]; then
+                  mkdir -p "$(dirname ./"$wanted_path")"
+                fi
+                mv -v ./"$orig_path" ./"$wanted_path"
+
+                # Fail explicitly if etc is not empty so we can add it to the list and/or report it upstream
+                rmdir ./etc || {
+                  echo Installer tries to install to /etc:
+                  find ./etc
+                  exit 1
+                }
+              done
+            }
+
+            if [ -d "$out"/etc ]; then
+              pushd "$out"
+              handleEtc
+              popd
+            fi
+          '';
+
+          dontStrip = true;
+        };
+    in
+      map (nameAndSrc: (installComponent nameAndSrc.name nameAndSrc.src)) namesAndSrcs;
+
+  # Manifest files are organized as follow:
+  # { date = "2017-03-03";
+  #   pkg.cargo.version= "0.18.0-nightly (5db6d64 2017-03-03)";
+  #   pkg.cargo.target.x86_64-unknown-linux-gnu = {
+  #     available = true;
+  #     hash = "abce..."; # sha256
+  #     url = "https://static.rust-lang.org/dist/....tar.gz";
+  #     xz_hash = "abce..."; # sha256
+  #     xz_url = "https://static.rust-lang.org/dist/....tar.xz";
+  #   };
+  # }
+  #
+  # The packages available usually are:
+  #   cargo, rust-analysis, rust-docs, rust-src, rust-std, rustc, and
+  #   rust, which aggregates them in one package.
+  #
+  # For each package the following options are available:
+  #   extensions        - The extensions that should be installed for the package.
+  #                       For example, install the package rust and add the extension rust-src.
+  #   targets           - The package will always be installed for the host system, but with this option
+  #                       extra targets can be specified, e.g. "mips-unknown-linux-musl". The target
+  #                       will only apply to components of the package that support being installed for
+  #                       a different architecture. For example, the rust package will install rust-std
+  #                       for the host system and the targets.
+  #   targetExtensions  - If you want to force extensions to be installed for the given targets, this is your option.
+  #                       All extensions in this list will be installed for the target architectures.
+  #                       *Attention* If you want to install an extension like rust-src, that has no fixed architecture (arch *),
+  #                       you will need to specify this extension in the extensions options or it will not be installed!
+  fromManifestFile = manifest: { stdenv, fetchurl, patchelf }:
+    let
+      inherit (builtins) elemAt;
+      inherit (super) makeOverridable;
+      inherit (super.lib) flip mapAttrs;
+      pkgs = fromTOML (builtins.readFile manifest);
+    in
+    flip mapAttrs pkgs.pkg (name: pkg:
+      makeOverridable ({extensions, targets, targetExtensions}:
+        let
+          version' = builtins.match "([^ ]*) [(]([^ ]*) ([^ ]*)[)]" pkg.version;
+          version = "${elemAt version' 0}-${elemAt version' 2}-${elemAt version' 1}";
+          namesAndSrcs = getComponents pkgs.pkg name targets extensions targetExtensions stdenv fetchurl;
+          components = installComponents stdenv namesAndSrcs;
+          componentsOuts = builtins.map (comp: (super.lib.strings.escapeNixString (super.lib.getOutput "out" comp))) components;
+        in
+          super.pkgs.symlinkJoin {
+            name = name + "-" + version;
+            paths = components;
+            postBuild = ''
+	      # If rustc is in the derivation, we need to copy the rustc
+	      # executable into the final derivation. This is required
+	      # for making rustc find the correct SYSROOT.
+              if [ -e "$out/bin/rustc" ]; then
+                RUSTC_PATH=$(realpath -e $out/bin/rustc)
+                rm $out/bin/rustc
+                cp $RUSTC_PATH $out/bin/rustc
+              fi
+            '';
+
+            # Add the compiler as part of the propagated build inputs in order
+            # to run:
+            #
+            #    $ nix-shell -p rustChannels.stable.rust
+            #
+            # And get a fully working Rust compiler, with the stdenv linker.
+            propagatedBuildInputs = [ stdenv.cc ];
+          }
+      ) { extensions = []; targets = []; targetExtensions = []; }
+    );
+
+  fromManifest = manifest: { stdenv, fetchurl, patchelf }:
+    fromManifestFile (builtins.fetchurl manifest) { inherit stdenv fetchurl patchelf; };
+
+in
+
+rec {
+  lib = super.lib // {
+    inherit fromTOML;
+    rustLib = {
+      inherit fromManifest fromManifestFile manifest_v2_url;
+    };
+  };
+
+  rustChannelOf = manifest_args: fromManifest
+    (manifest_v2_url manifest_args)
+    { inherit (self) stdenv fetchurl patchelf; }
+    ;
+
+  # Set of packages which are automagically updated. Do not rely on these for
+  # reproducible builds.
+  latest = (super.latest or {}) // {
+    rustChannels = {
+      nightly = rustChannelOf { channel = "nightly"; };
+      beta    = rustChannelOf { channel = "beta"; };
+      stable  = rustChannelOf { channel = "stable"; };
+    };
+  };
+
+  # Helper builder
+  rustChannelOfTargets = channel: date: targets:
+    (rustChannelOf { inherit channel date; })
+      .rust.override { inherit targets; };
+
+  # For backward compatibility
+  rustChannels = latest.rustChannels;
+
+  # For each channel:
+  #   latest.rustChannels.nightly.cargo
+  #   latest.rustChannels.nightly.rust   # Aggregate all others. (recommended)
+  #   latest.rustChannels.nightly.rustc
+  #   latest.rustChannels.nightly.rust-analysis
+  #   latest.rustChannels.nightly.rust-docs
+  #   latest.rustChannels.nightly.rust-src
+  #   latest.rustChannels.nightly.rust-std
+
+  # For a specific date:
+  #   rustChannelOf { date = "2017-06-06"; channel = "beta"; }.rust
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/rust-src-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/rust-src-overlay.nix
new file mode 100644
index 000000000000..05cb6130ec84
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/rust-src-overlay.nix
@@ -0,0 +1,18 @@
+# Overlay that builds on top of rust-overlay.nix.
+# Adds rust-src component to all channels which is helpful for racer, intellij, ...
+
+self: super:
+
+let mapAttrs = super.stdenv.lib.mapAttrs;
+    flip = super.stdenv.lib.flip;
+in {
+  # install stable rust with rust-src:
+  # "nix-env -i -A nixos.latest.rustChannels.stable.rust"
+
+  latest.rustChannels =
+    flip mapAttrs super.latest.rustChannels (name: value: value // {
+      rust = value.rust.override {
+        extensions = ["rust-src"];
+      };
+    });
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/update.nix b/nixpkgs-overlays/nixpkgs-mozilla/update.nix
new file mode 100755
index 000000000000..6ea2c03e691e
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/update.nix
@@ -0,0 +1,144 @@
+let
+  _pkgs = import <nixpkgs> {};
+  _nixpkgs = _pkgs.fetchFromGitHub (_pkgs.lib.importJSON ./pkgs/nixpkgs.json);
+in
+
+{ pkgs ? import _nixpkgs {}
+, package ? null
+, maintainer ? null
+, dont_prompt ? false
+}:
+
+# TODO: add assert statements
+
+let
+
+  pkgs-mozilla = import ./default.nix { inherit pkgs; };
+
+  dont_prompt_str = if dont_prompt then "yes" else "no";
+
+  packagesWith = cond: return: set:
+    pkgs.lib.flatten
+      (pkgs.lib.mapAttrsToList
+        (name: pkg:
+          let
+            result = builtins.tryEval (
+              if pkgs.lib.isDerivation pkg && cond name pkg
+                then [(return name pkg)]
+              else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
+                then packagesWith cond return pkg
+              else []
+            );
+          in
+            if result.success then result.value
+            else []
+        )
+        set
+      );
+
+  packagesWithUpdateScriptAndMaintainer = maintainer':
+    let
+      maintainer =
+        if ! builtins.hasAttr maintainer' pkgs.lib.maintainers then
+          builtins.throw "Maintainer with name `${maintainer'} does not exist in `lib/maintainers.nix`."
+        else
+          builtins.getAttr maintainer' pkgs.lib.maintainers;
+    in
+      packagesWith (name: pkg: builtins.hasAttr "updateScript" pkg &&
+                                 (if builtins.hasAttr "maintainers" pkg.meta
+                                   then (if builtins.isList pkg.meta.maintainers
+                                           then builtins.elem maintainer pkg.meta.maintainers
+                                           else maintainer == pkg.meta.maintainers
+                                        )
+                                   else false
+                                 )
+                   )
+                   (name: pkg: pkg)
+                   pkgs-mozilla;
+
+  packageByName = name:
+    let
+        package = pkgs.lib.attrByPath (pkgs.lib.splitString "." name) null pkgs-mozilla;
+    in
+      if package == null then
+        builtins.throw "Package with an attribute name `${name}` does not exists."
+      else if ! builtins.hasAttr "updateScript" package then
+        builtins.throw "Package with an attribute name `${name}` does have an `passthru.updateScript` defined."
+      else
+        package;
+
+  packages =
+    if package != null then
+      [ (packageByName package) ]
+    else if maintainer != null then
+      packagesWithUpdateScriptAndMaintainer maintainer
+    else
+      builtins.throw "No arguments provided.\n\n${helpText}";
+
+  helpText = ''
+    Please run:
+
+        % nix-shell maintainers/scripts/update.nix --argstr maintainer garbas
+
+    to run all update scripts for all packages that lists \`garbas\` as a maintainer
+    and have \`updateScript\` defined, or:
+
+        % nix-shell maintainers/scripts/update.nix --argstr package garbas
+
+    to run update script for specific package.
+  '';
+
+  runUpdateScript = package: ''
+    echo -ne " - ${package.name}: UPDATING ..."\\r
+    ${package.updateScript} &> ${(builtins.parseDrvName package.name).name}.log
+    CODE=$?
+    if [ "$CODE" != "0" ]; then
+      echo " - ${package.name}: ERROR       "
+      echo ""
+      echo "--- SHOWING ERROR LOG FOR ${package.name} ----------------------"
+      echo ""
+      cat ${(builtins.parseDrvName package.name).name}.log
+      echo ""
+      echo "--- SHOWING ERROR LOG FOR ${package.name} ----------------------"
+      exit $CODE
+    else
+      rm ${(builtins.parseDrvName package.name).name}.log
+    fi
+    echo " - ${package.name}: DONE.       "
+  '';
+
+in pkgs.stdenv.mkDerivation {
+  name = "nixpkgs-mozilla-update-script";
+  buildCommand = ''
+    echo ""
+    echo "----------------------------------------------------------------"
+    echo ""
+    echo "Not possible to update packages using \`nix-build\`"
+    echo ""
+    echo "${helpText}"
+    echo "----------------------------------------------------------------"
+    exit 1
+  '';
+  shellHook = ''
+    echo ""
+    echo "Going to be running update for following packages:"
+    echo "${builtins.concatStringsSep "\n" (map (x: " - ${x.name}") packages)}"
+    echo ""
+    if [ "${dont_prompt_str}" = "no" ]; then
+      read -n1 -r -p "Press space to continue..." confirm
+    else
+      confirm=""
+    fi
+    if [ "$confirm" = "" ]; then
+      echo ""
+      echo "Running update for:"
+      ${builtins.concatStringsSep "\n" (map runUpdateScript packages)}
+      echo ""
+      echo "Packages updated!"
+      exit 0
+    else
+      echo "Aborting!"
+      exit 1
+    fi
+  '';
+}
diff --git a/nixpkgs-overlays/nixpkgs-mozilla/vidyo-overlay.nix b/nixpkgs-overlays/nixpkgs-mozilla/vidyo-overlay.nix
new file mode 100644
index 000000000000..691db5c0e767
--- /dev/null
+++ b/nixpkgs-overlays/nixpkgs-mozilla/vidyo-overlay.nix
@@ -0,0 +1,5 @@
+self: super:
+
+{
+  VidyoDesktop = super.callPackage ./pkgs/VidyoDesktop { };
+}