summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2015-11-13 15:53:10 -0800
committerWilliam A. Kennington III <william@wkennington.com>2015-11-13 15:53:10 -0800
commit9579c9ec7f53be31efba3803bd86661b59b0bb81 (patch)
treee9e9ec19c0989f18d96ec0b8c6faf3780eb3dfb1
parent83aeb00a78ebca04bd6a42721284cad87da9fabe (diff)
parentcb21b77ff1b9ed006d1180ad7c94b2ee7ed3c096 (diff)
downloadnixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar.gz
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar.bz2
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar.lz
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar.xz
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.tar.zst
nixpkgs-9579c9ec7f53be31efba3803bd86661b59b0bb81.zip
Merge commit 'cb21b77' into master.upstream
This is a partial merge of staging for builds which are working
-rw-r--r--doc/haskell-users-guide.md21
-rw-r--r--lib/maintainers.nix2
-rwxr-xr-xmaintainers/scripts/gnome.sh238
-rw-r--r--nixos/modules/services/mail/opensmtpd.nix20
-rw-r--r--nixos/modules/services/networking/networkmanager.nix5
-rw-r--r--nixos/modules/system/boot/systemd.nix6
-rw-r--r--nixos/modules/tasks/network-interfaces.nix45
-rw-r--r--nixos/tests/gnome3_18.nix36
-rw-r--r--pkgs/applications/audio/audacity/default.nix8
-rw-r--r--pkgs/applications/audio/jackmix/default.nix35
-rw-r--r--pkgs/applications/graphics/gimp/plugins/default.nix2
-rw-r--r--pkgs/applications/graphics/hugin/default.nix4
-rw-r--r--pkgs/applications/misc/eaglemode/default.nix1
-rw-r--r--pkgs/applications/networking/ids/daq/default.nix6
-rw-r--r--pkgs/applications/networking/ids/snort/default.nix2
-rw-r--r--pkgs/applications/networking/iptraf-ng/default.nix44
-rw-r--r--pkgs/applications/networking/p2p/transmission/default.nix4
-rw-r--r--pkgs/applications/version-management/git-and-tools/git-hub/default.nix30
-rw-r--r--pkgs/applications/version-management/subversion/default.nix16
-rw-r--r--pkgs/applications/video/smplayer/default.nix8
-rw-r--r--pkgs/applications/window-managers/weston/default.nix7
-rwxr-xr-xpkgs/build-support/buildenv/builder.pl12
-rw-r--r--pkgs/build-support/buildenv/default.nix4
-rw-r--r--pkgs/build-support/builder-defs/builder-defs.nix2
-rw-r--r--pkgs/build-support/grsecurity/default.nix2
-rw-r--r--pkgs/build-support/setup-hooks/wrap-gapps-hook.sh5
-rw-r--r--pkgs/data/misc/shared-mime-info/default.nix9
-rw-r--r--pkgs/desktops/gnome-3/3.16/core/gnome-control-center/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/3.16/core/gnome-settings-daemon/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/accerciser/default.nix28
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/bijiben/default.nix36
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/bijiben/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/cheese/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/cheese/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/evolution/default.nix49
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/evolution/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/file-roller/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/file-roller/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gedit/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gedit/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/glade/default.nix30
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/glade/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/default.nix42
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-characters/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-characters/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/default.nix27
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-documents/default.nix39
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-documents/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/default.nix15
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-logs/default.nix21
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-logs/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-maps/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-maps/soup.patch10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-maps/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-music/default.nix30
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-music/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-nettool/default.nix26
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-photos/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-photos/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-weather/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/gnome-weather/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/nautilus-sendto/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/polari/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/polari/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/seahorse/default.nix35
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/seahorse/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/vinagre/default.nix21
-rw-r--r--pkgs/desktops/gnome-3/3.18/apps/vinagre/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/default.nix21
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/baobab/default.nix32
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/baobab/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/caribou/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/dconf-editor/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/dconf-editor/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/dconf/default.nix23
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/empathy/default.nix57
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/eog/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/eog/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/epiphany/default.nix42
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/epiphany/libxml_depend.patch10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/epiphany/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/evince/default.nix64
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/evince/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/evolution-data-server/default.nix30
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/evolution-data-server/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/folks/default.nix43
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gconf/default.nix32
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gcr/default.nix28
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gcr/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/default.nix41
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/disable_x_access_control.patch15
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/sessions_dir.patch17
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/xserver_path.patch83
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/default.nix41
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/disable_x_access_control.patch13
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/no-dbus-launch.patch20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/sessions_dir.patch17
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gdm/xserver_path.patch15
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/geocode-glib/default.nix14
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/geocode-glib/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gjs/default.nix28
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/default.nix12
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/default.nix23
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-calculator/default.nix30
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-calculator/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-common/default.nix17
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-common/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-contacts/default.nix47
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-contacts/gio_unix.patch10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-contacts/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-control-center/default.nix59
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-control-center/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-control-center/vpn_plugins_path.patch19
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-desktop/default.nix24
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-desktop/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/default.nix32
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/default.nix35
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-keyring/default.nix34
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-keyring/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-menus/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-online-miners/default.nix37
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-session/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-session/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-shell/default.nix57
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-shell/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-system-log/default.nix36
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/default.nix32
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-terminal/default.nix28
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-terminal/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/default.nix14
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/default.nix15
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-user-share/default.nix45
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gnome-user-share/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/grilo-plugins/default.nix27
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/grilo/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/grilo/setup-hook.sh7
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gsound/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gtksourceview/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gtksourceview/nix_share_path.patch11
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gtksourceview/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gucharmap/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/gucharmap/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libcroco/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgdata/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgee/default.nix26
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgee/fix_introspection_paths.patch13
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgnome-keyring/default.nix26
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgnomekbd/default.nix24
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgweather/default.nix17
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgweather/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libgxps/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libpeas/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libpeas/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/libzapojit/default.nix16
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/mutter/default.nix31
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/mutter/math.patch10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/mutter/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/mutter/x86.patch20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/nautilus/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/nautilus/extension_dir.patch24
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/nautilus/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/rest/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/sushi/default.nix33
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/sushi/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/totem-pl-parser/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/totem/default.nix42
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/totem/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/tracker/default.nix55
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vino/default.nix25
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vino/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vte/2.90.nix40
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vte/default.nix39
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vte/expose_select_text.0.40.0.patch226
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/vte/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp-tools/default.nix17
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp-tools/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp-xsl/default.nix18
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp-xsl/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp/default.nix26
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/yelp/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/zenity/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/core/zenity/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/default.nix394
-rw-r--r--pkgs/desktops/gnome-3/3.18/desktop/rarian/default.nix16
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/anjuta/default.nix24
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/anjuta/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/devhelp/default.nix18
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/devhelp/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/gdl/default.nix15
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/gdl/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/default.nix15
-rw-r--r--pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/aisleriot/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/aisleriot/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/five-or-more/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/five-or-more/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/four-in-a-row/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/four-in-a-row/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-chess/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-chess/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-klotski/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-klotski/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-mines/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-mines/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-robots/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-robots/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/default.nix17
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-taquin/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-taquin/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/default.nix18
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/hitori/default.nix24
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/iagno/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/iagno/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/lightsoff/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/lightsoff/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/quadrapassel/default.nix21
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/quadrapassel/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/swell-foop/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/swell-foop/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/tali/default.nix19
-rw-r--r--pkgs/desktops/gnome-3/3.18/games/tali/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/california/0002-Build-with-evolution-data-server-3.13.90.patch39
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/california/default.nix39
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/geary/default.nix52
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/geary/disable_valadoc.patch24
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gexiv2/default.nix28
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gfbgraph/default.nix23
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gitg/default.nix39
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gitg/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0001-Search-for-themes-and-icons-in-system-data-dirs.patch123
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0002-Don-t-show-multiple-entries-for-a-single-theme.patch103
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0003-Create-config-dir-if-it-doesn-t-exist.patch29
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/default.nix44
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/find_gsettings.patch22
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gnome-video-effects/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gpaste/default.nix44
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gtkhtml/default.nix16
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/gtkhtml/src.nix10
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/libgda/default.nix30
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/libgit2-glib/default.nix21
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/libmediaart/default.nix22
-rw-r--r--pkgs/desktops/gnome-3/3.18/misc/pomodoro/default.nix50
-rw-r--r--pkgs/desktops/xfce/core/thunar-volman.nix4
-rw-r--r--pkgs/development/compilers/llvm/3.7/libc++/default.nix9
-rw-r--r--pkgs/development/compilers/llvm/3.7/libc++abi.nix2
-rw-r--r--pkgs/development/compilers/llvm/3.7/llvm.nix4
-rw-r--r--pkgs/development/compilers/sbcl/bootstrap.nix3
-rw-r--r--pkgs/development/interpreters/perl/5.22/default.nix7
-rw-r--r--pkgs/development/interpreters/perl/5.22/no-libutil.patch16
-rw-r--r--pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix7
-rw-r--r--pkgs/development/libraries/at-spi2-atk/default.nix4
-rw-r--r--pkgs/development/libraries/at-spi2-core/default.nix4
-rw-r--r--pkgs/development/libraries/atk/default.nix4
-rw-r--r--pkgs/development/libraries/audiofile/CVE-2015-7747.patch161
-rw-r--r--pkgs/development/libraries/audiofile/default.nix2
-rw-r--r--pkgs/development/libraries/boost/1.55.nix2
-rw-r--r--pkgs/development/libraries/boost/gcc-5.patch64
-rw-r--r--pkgs/development/libraries/cairo/default.nix4
-rw-r--r--pkgs/development/libraries/clutter/1.24.nix52
-rw-r--r--pkgs/development/libraries/cogl/1.22.nix56
-rw-r--r--pkgs/development/libraries/ffmpeg-full/default.nix4
-rw-r--r--pkgs/development/libraries/ffmpeg/2.6.nix7
-rw-r--r--pkgs/development/libraries/ffmpeg/2.7.nix7
-rw-r--r--pkgs/development/libraries/ffmpeg/2.8.nix7
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix6
-rw-r--r--pkgs/development/libraries/glew/default.nix4
-rw-r--r--pkgs/development/libraries/glib/default.nix6
-rw-r--r--pkgs/development/libraries/glpk/default.nix4
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix8
-rw-r--r--pkgs/development/libraries/gtk+/3.x.nix24
-rw-r--r--pkgs/development/libraries/gvfs/default.nix8
-rw-r--r--pkgs/development/libraries/harfbuzz/default.nix4
-rw-r--r--pkgs/development/libraries/icu/default.nix4
-rw-r--r--pkgs/development/libraries/jemalloc/default.nix4
-rw-r--r--pkgs/development/libraries/libaccounts-glib/default.nix2
-rw-r--r--pkgs/development/libraries/libarchive/default.nix8
-rw-r--r--pkgs/development/libraries/libdnet/default.nix4
-rw-r--r--pkgs/development/libraries/libgudev/default.nix21
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix4
-rw-r--r--pkgs/development/libraries/libmbim/default.nix6
-rw-r--r--pkgs/development/libraries/libpsl/default.nix4
-rw-r--r--pkgs/development/libraries/libseccomp/default.nix17
-rw-r--r--pkgs/development/libraries/libunwind/native.nix17
-rw-r--r--pkgs/development/libraries/libwacom/default.nix4
-rw-r--r--pkgs/development/libraries/mesa/default.nix4
-rw-r--r--pkgs/development/libraries/neon/default.nix5
-rw-r--r--pkgs/development/libraries/nghttp2/default.nix5
-rw-r--r--pkgs/development/libraries/pango/default.nix18
-rw-r--r--pkgs/development/libraries/pcre/cve-2015-3210.patch87
-rw-r--r--pkgs/development/libraries/pcre/cve-2015-5073.patch68
-rw-r--r--pkgs/development/libraries/pcre/default.nix12
-rw-r--r--pkgs/development/libraries/pcre/fixes.patch3538
-rw-r--r--pkgs/development/libraries/pixman/default.nix24
-rw-r--r--pkgs/development/libraries/poppler/default.nix4
-rw-r--r--pkgs/development/libraries/sqlite/default.nix7
-rw-r--r--pkgs/development/libraries/wayland/default.nix4
-rw-r--r--pkgs/development/libraries/webkitgtk/default.nix12
-rw-r--r--pkgs/development/python-modules/generic/default.nix1
-rw-r--r--pkgs/development/tools/misc/pkgconfig/default.nix4
-rw-r--r--pkgs/development/tools/misc/texinfo/6.0.nix2
-rw-r--r--pkgs/development/web/nodejs/default-arch.patch24
-rw-r--r--pkgs/development/web/nodejs/default.nix7
-rw-r--r--pkgs/development/web/nodejs/no-xcode-4.1.0.patch95
-rw-r--r--pkgs/development/web/nodejs/no-xcode.patch21
-rw-r--r--pkgs/development/web/nodejs/pkg-libpath.patch13
-rw-r--r--pkgs/development/web/nodejs/v0_10.nix2
-rw-r--r--pkgs/development/web/nodejs/v4_1_0.nix53
-rw-r--r--pkgs/misc/jackaudio/jack1.nix3
-rw-r--r--pkgs/misc/urbit/default.nix42
-rw-r--r--pkgs/os-specific/linux/kernel-headers/3.14.nix71
-rw-r--r--pkgs/os-specific/linux/kernel-headers/3.18.nix (renamed from pkgs/os-specific/linux/kernel-headers/3.12.nix)4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.10.nix17
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.12.nix17
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.14.nix18
-rw-r--r--pkgs/os-specific/linux/libcap-ng/default.nix34
-rw-r--r--pkgs/os-specific/linux/miraclecast/default.nix26
-rw-r--r--pkgs/os-specific/linux/nvidiabl/default.nix2
-rw-r--r--pkgs/os-specific/linux/nvidiabl/linux4compat.patch22
-rw-r--r--pkgs/os-specific/linux/systemd/default.nix55
-rw-r--r--pkgs/os-specific/linux/systemd/fixes.patch2569
-rw-r--r--pkgs/os-specific/linux/udisks/2-default.nix6
-rw-r--r--pkgs/os-specific/linux/upower/default.nix4
-rw-r--r--pkgs/os-specific/linux/util-linux/default.nix8
-rw-r--r--pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch22
-rw-r--r--pkgs/servers/mail/opensmtpd/default.nix7
-rw-r--r--pkgs/servers/mail/opensmtpd/extras.nix79
-rw-r--r--pkgs/servers/mail/opensmtpd/proc_path.diff76
-rw-r--r--pkgs/servers/search/elasticsearch/default.nix4
-rw-r--r--pkgs/servers/search/elasticsearch/es-home.patch13
-rw-r--r--pkgs/servers/sql/mariadb/default.nix22
-rw-r--r--pkgs/servers/x11/quartz-wm/default.nix3
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix3
-rw-r--r--pkgs/servers/x11/xquartz/default.nix3
-rw-r--r--pkgs/stdenv/darwin/default.nix2
-rw-r--r--pkgs/stdenv/generic/setup.sh2
-rw-r--r--pkgs/stdenv/pure-darwin/default.nix8
-rw-r--r--pkgs/tools/archivers/unzip/CVE-2015-7696.diff66
-rw-r--r--pkgs/tools/archivers/unzip/CVE-2015-7697.diff36
-rw-r--r--pkgs/tools/archivers/unzip/default.nix2
-rw-r--r--pkgs/tools/backup/httrack/default.nix2
-rw-r--r--pkgs/tools/compression/xz/default.nix4
-rw-r--r--pkgs/tools/filesystems/duff/default.nix19
-rw-r--r--pkgs/tools/graphics/enblend-enfuse/default.nix10
-rw-r--r--pkgs/tools/misc/cloc/default.nix8
-rw-r--r--pkgs/tools/misc/colord/default.nix7
-rw-r--r--pkgs/tools/misc/file/default.nix4
-rw-r--r--pkgs/tools/misc/heatseeker/default.nix28
-rw-r--r--pkgs/tools/networking/curl/default.nix4
-rw-r--r--pkgs/tools/networking/modemmanager/default.nix4
-rw-r--r--pkgs/tools/networking/network-manager-applet/default.nix4
-rw-r--r--pkgs/tools/networking/network-manager/default.nix4
-rw-r--r--pkgs/tools/text/gnugrep/cve-2015-1345.patch60
-rw-r--r--pkgs/tools/text/gnugrep/default.nix10
-rw-r--r--pkgs/tools/typesetting/tex/texlive-new/combine.nix14
-rw-r--r--pkgs/tools/typesetting/tex/texlive-new/default.nix5
-rw-r--r--pkgs/top-level/all-packages.nix95
-rw-r--r--pkgs/top-level/go-packages.nix20
-rw-r--r--pkgs/top-level/perl-packages.nix10
-rw-r--r--pkgs/top-level/python-packages.nix7
392 files changed, 7281 insertions, 7265 deletions
diff --git a/doc/haskell-users-guide.md b/doc/haskell-users-guide.md
index 446f08eb697..b06a81e5b36 100644
--- a/doc/haskell-users-guide.md
+++ b/doc/haskell-users-guide.md
@@ -666,27 +666,6 @@ to find out the store path of the system's zlib library. Now, you can
    The same thing applies to `cabal configure`, of course, if you're
    building with `cabal-install` instead of Stack.
 
-## Creating statically linked binaries
-
-There are two levels of static linking. The first option is to configure the
-build with the Cabal flag `--disable-executable-dynamic`. In Nix expressions,
-this can be achieved by setting the attribute:
-
-    enableSharedExecutables = false;
-
-That gives you a binary with statically linked Haskell libraries and
-dynamically linked system libraries.
-
-To link both Haskell libraries and system libraries statically, the additional
-flags `--ghc-option=-optl=-static --ghc-option=-optl=-pthread` need to be used.
-In Nix, this is accomplished with:
-
-    configureFlags = [ "--ghc-option=-optl=-static" "--ghc-option=-optl=-pthread" ];
-
-It's important to realize, however, that most system libraries in Nix are built
-as shared libraries only, i.e. there is just no static library available that
-Cabal could link!
-
 
 # Other resources
 
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index 14a7de594aa..0ec329e6afb 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -150,7 +150,6 @@
   jwilberding = "Jordan Wilberding <jwilberding@afiniate.com>";
   jzellner = "Jeff Zellner <jeffz@eml.cc>";
   kamilchm = "Kamil Chmielewski <kamil.chm@gmail.com>";
-  kampfschlaefer = "Arnold Krille <arnold@arnoldarts.de>";
   khumba = "Bryan Gardiner <bog@khumba.net>";
   kkallio = "Karn Kallio <tierpluspluslists@gmail.com>";
   koral = "Koral <koral@mailoo.org>";
@@ -189,7 +188,6 @@
   meditans = "Carlo Nucera <meditans@gmail.com>";
   meisternu = "Matt Miemiec <meister@krutt.org>";
   michelk = "Michel Kuhlmann <michel@kuhlmanns.info>";
-  michaelpj = "Michael Peyton Jones <michaelpj@gmail.com>";
   mirdhyn = "Merlin Gaillard <mirdhyn@gmail.com>";
   mschristiansen = "Mikkel Christiansen <mikkel@rheosystems.com>";
   modulistic = "Pablo Costa <modulistic@gmail.com>";
diff --git a/maintainers/scripts/gnome.sh b/maintainers/scripts/gnome.sh
index cd2c5777403..9398331d0d6 100755
--- a/maintainers/scripts/gnome.sh
+++ b/maintainers/scripts/gnome.sh
@@ -4,28 +4,24 @@ set -o pipefail
 
 GNOME_FTP="ftp.gnome.org/pub/GNOME/sources"
 
+# projects that don't follow the GNOME major versioning, or that we don't want to
+# programmatically update
+NO_GNOME_MAJOR="gtkhtml gdm"
+
 usage() {
-  echo "Usage: $0 show|update project [major.minor]" >&2
+  echo "Usage: $0 gnome_dir <show project>|<update project>|<update-all> [major.minor]" >&2
+  echo "gnome_dir is for example pkgs/desktops/gnome-3/3.18" >&2
   exit 0
 }
 
-if [ "$#" -lt 1 ]; then
+if [ "$#" -lt 2 ]; then
   usage
 fi
 
-action="$1"
-project="$2"
-majorVersion="$3"
-
-if [ "$action" != "show" ] && [ "$action" != "update" ]; then
-  echo "Unknown action $action" >&2
-  usage
-fi
+GNOME_TOP="$1"
+shift
 
-if [ -z "$project" ]; then
-  echo "No project specified, exiting"
-  exit 1
-fi
+action="$1"
 
 # curl -l ftp://... doesn't work from my office in HSE, and I don't want to have
 # any conversations with sysadmin. Somehow lftp works.
@@ -39,79 +35,93 @@ else
   }
 fi
 
-if [ -z "$majorVersion" ]; then
-  echo "Looking for available versions..." >&2
-  available_baseversions=( `ls_ftp ftp://${GNOME_FTP}/${project} | grep '[0-9]\.[0-9]' | sort -t. -k1,1n -k 2,2n` )
-  if [ "$?" -ne "0" ]; then
-    echo "Project $project not found" >&2
-    exit 1
+find_project() {
+  exec find "$GNOME_TOP" -mindepth 2 -maxdepth 2 -type d $@
+}
+
+show_project() {
+  local project="$1"
+  local majorVersion="$2"
+  local version=""
+
+  if [ -z "$majorVersion" ]; then
+    echo "Looking for available versions..." >&2
+    local available_baseversions=( `ls_ftp ftp://${GNOME_FTP}/${project} | grep '[0-9]\.[0-9]' | sort -t. -k1,1n -k 2,2n` )
+    if [ "$?" -ne "0" ]; then
+      echo "Project $project not found" >&2
+      return 1
+    fi
+    
+    echo -e "The following versions are available:\n ${available_baseversions[@]}" >&2
+    echo -en "Choose one of them: " >&2
+    read majorVersion
   fi
   
-  echo -e "The following versions are available:\n ${available_baseversions[@]}" >&2
-  echo -en "Choose one of them: " >&2
-  read majorVersion
-fi
-
-if echo "$majorVersion" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then
-	# not a major version
-	version="$majorVersion"
-	majorVersion=$(echo "$majorVersion" | cut -d '.' -f 1,2)
-fi
-
-FTPDIR="${GNOME_FTP}/${project}/${majorVersion}"
-
-#version=`curl -l ${FTPDIR}/ 2>/dev/null | grep LATEST-IS | sed -e s/LATEST-IS-//`
-# gnome's LATEST-IS is broken. Do not trust it.
-
-if [ -z "$version" ]; then
-	files=$(ls_ftp "${FTPDIR}")
-	declare -A versions
-	
-	for f in $files; do
-		case $f in
-    (LATEST-IS-*|*.news|*.changes|*.sha256sum|*.diff*):
-		;;
-    ($project-*.*.9*.tar.*):
-		tmp=${f#$project-}
-		tmp=${tmp%.tar*}
-		echo "Ignored unstable version ${tmp}" >&2
-		;;
-    ($project-*.tar.*):
-		tmp=${f#$project-}
-		tmp=${tmp%.tar*}
-		versions[${tmp}]=1
-		;;
-    (*):
-		echo "UNKNOWN FILE $f"
-		;;
-		esac
-	done
-	echo "Found versions ${!versions[@]}" >&2
-	version=`echo ${!versions[@]} | sed -e 's/ /\n/g' | sort -t. -k1,1n -k 2,2n -k 3,3n | tail -n1`
-	echo "Latest version is: ${version}" >&2
-fi
-
-name=${project}-${version}
-echo "Fetching .sha256 file" >&2
-sha256out=$(curl -s -f http://${FTPDIR}/${name}.sha256sum)
-
-if [ "$?" -ne "0" ]; then
-	echo "Version not found" >&2
-	exit 1
-fi
-
-extensions=( "xz" "bz2" "gz" )
-echo "Choosing archive extension (known are ${extensions[@]})..." >&2
-for ext in ${extensions[@]}; do
-  if echo -e "$sha256out" | grep -q "\\.tar\\.${ext}$"; then
-    ext_pref=$ext
-    sha256=$(echo -e "$sha256out" | grep "\\.tar\\.${ext}$" | cut -f1 -d\ )
-    break
+  if echo "$majorVersion" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then
+    # not a major version
+    version="$majorVersion"
+    majorVersion=$(echo "$majorVersion" | cut -d '.' -f 1,2)
   fi
-done
-echo "Chosen ${ext_pref}, hash is ${sha256}" >&2
-
-src="# Autogenerated by maintainers/scripts/gnome.sh update
+  
+  local FTPDIR="${GNOME_FTP}/${project}/${majorVersion}"
+  
+  #version=`curl -l ${FTPDIR}/ 2>/dev/null | grep LATEST-IS | sed -e s/LATEST-IS-//`
+  # gnome's LATEST-IS is broken. Do not trust it.
+  
+  if [ -z "$version" ]; then
+  	local files=$(ls_ftp "${FTPDIR}")
+  	declare -A versions
+  	
+  	for f in $files; do
+  		case $f in
+      (LATEST-IS-*|*.news|*.changes|*.sha256sum|*.diff*):
+  		;;
+      ($project-*.*.9*.tar.*):
+  		tmp=${f#$project-}
+  		tmp=${tmp%.tar*}
+  		echo "Ignored unstable version ${tmp}" >&2
+  		;;
+      ($project-*.tar.*):
+  		tmp=${f#$project-}
+  		tmp=${tmp%.tar*}
+  		versions[${tmp}]=1
+  		;;
+      (*):
+  		echo "UNKNOWN FILE $f" >&2
+  		;;
+  		esac
+  	done
+  	echo "Found versions ${!versions[@]}" >&2
+  	version=`echo ${!versions[@]} | sed -e 's/ /\n/g' | sort -t. -k1,1n -k 2,2n -k 3,3n | tail -n1`
+        if [ -z "$version" ]; then
+          echo "No version available for major $majorVersion" >&2
+          return 1
+        fi
+
+  	echo "Latest version is: ${version}" >&2
+  fi
+  
+  local name=${project}-${version}
+  echo "Fetching .sha256 file" >&2
+  local sha256out=$(curl -s -f http://${FTPDIR}/${name}.sha256sum)
+  
+  if [ "$?" -ne "0" ]; then
+  	echo "Version not found" >&2
+  	return 1
+  fi
+  
+  extensions=( "xz" "bz2" "gz" )
+  echo "Choosing archive extension (known are ${extensions[@]})..." >&2
+  for ext in ${extensions[@]}; do
+    if echo -e "$sha256out" | grep -q "\\.tar\\.${ext}$"; then
+      ext_pref=$ext
+      sha256=$(echo -e "$sha256out" | grep "\\.tar\\.${ext}$" | cut -f1 -d\ )
+      break
+    fi
+  done
+  echo "Chosen ${ext_pref}, hash is ${sha256}" >&2
+  
+  echo "# Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
   name = \"${project}-${version}\";
@@ -122,17 +132,63 @@ fetchurl: {
   };
 }"
 
-if [ "$action" == "update" ]; then
+  return 0
+}
+
+update_project() {
+  local project="$1"
+  local majorVersion="$2"
+
   # find project in nixpkgs tree
-  GNOME_TOP=$(readlink -e $(dirname "${BASH_SOURCE[0]}")"/../../pkgs/desktops/gnome-3/")
-  projectPath=$(find "$GNOME_TOP" -name "$project" -print)
+  projectPath=$(find_project -name "$project" -print)
   if [ -z "$projectPath" ]; then
     echo "Project $project not found under $GNOME_TOP"
     exit 1
   fi
 
-  echo "Updating $projectPath/src.nix"
-  echo -e "$src" > "$projectPath/src.nix"
+  src=$(show_project "$project" "$majorVersion")
+  
+  if [ "$?" -eq "0" ]; then
+    echo "Updating $projectPath/src.nix" >&2
+    echo -e "$src" > "$projectPath/src.nix"
+  fi
+
+  return 0
+}
+
+if [ "$action" == "update-all" ]; then
+  majorVersion="$2"
+  if [ -z "$majorVersion" ]; then
+    echo "No major version specified" >&2
+    usage
+  fi
+
+  # find projects
+  projects=$(find_project -exec basename '{}' \;)
+  for project in $projects; do
+    if echo "$NO_GNOME_MAJOR"|grep -q $project; then
+      echo "Skipping $project"
+    else
+      echo "= Updating $project to $majorVersion" >&2
+      update_project $project $majorVersion
+      echo >&2
+    fi
+  done
 else
-  echo -e "\n$src"
-fi
\ No newline at end of file
+  project="$2"
+  majorVersion="$3"
+
+  if [ -z "$project" ]; then
+    echo "No project specified, exiting" >&2
+    usage
+  fi
+
+  if [ "$action" == "show" ]; then
+    show_project $project $majorVersion
+  elif [ "$action" == "update" ]; then
+    update_project $project $majorVersion
+  else
+    echo "Unknown action $action" >&2
+    usage
+  fi
+fi
diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix
index a1cfd84365a..a3e50b42292 100644
--- a/nixos/modules/services/mail/opensmtpd.nix
+++ b/nixos/modules/services/mail/opensmtpd.nix
@@ -46,17 +46,6 @@ in {
           is left empty, the OpenSMTPD server will not start.
         '';
       };
-
-      procPackages = mkOption {
-        type = types.listOf types.path;
-        default = [];
-        description = ''
-          Packages to search for filters, tables, queues, and schedulers.
-
-          Add OpenSMTPD-extras here if you want to use the filters, etc. from
-          that package.
-        '';
-      };
     };
 
   };
@@ -83,19 +72,12 @@ in {
       };
     };
 
-    systemd.services.opensmtpd = let
-      procEnv = pkgs.buildEnv {
-        name = "opensmtpd-procs";
-        paths = [ opensmtpd ] ++ cfg.procPackages;
-        pathsToLink = [ "/libexec/opensmtpd" ];
-      };
-    in {
+    systemd.services.opensmtpd = {
       wantedBy = [ "multi-user.target" ];
       wants = [ "network.target" ];
       after = [ "network.target" ];
       preStart = "mkdir -p /var/spool";
       serviceConfig.ExecStart = "${opensmtpd}/sbin/smtpd -d -f ${conf} ${args}";
-      environment.OPENSMTPD_PROC_PATH = "${procEnv}/libexec/opensmtpd";
     };
 
     environment.systemPackages = [ (pkgs.runCommand "opensmtpd-sendmail" {} ''
diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix
index 7df194fa419..19ff73ad1b8 100644
--- a/nixos/modules/services/networking/networkmanager.nix
+++ b/nixos/modules/services/networking/networkmanager.nix
@@ -72,10 +72,11 @@ let
     ${coreutils}/bin/rm -f $tmp $tmp.ns
   '';
 
+  # pre-up and pre-down hooks were added in NM 0.9.10, but we still use 0.9.0
   dispatcherTypesSubdirMap = {
     "basic" = "";
-    "pre-up" = "pre-up.d/";
-    "pre-down" = "pre-down.d/";
+    /*"pre-up" = "pre-up.d/";
+    "pre-down" = "pre-down.d/";*/
   };
 
 in {
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 4704b3981e4..0b7647093e0 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -69,6 +69,7 @@ let
       "systemd-journal-flush.service"
       "systemd-journal-gatewayd.socket"
       "systemd-journal-gatewayd.service"
+      "systemd-journald-audit.socket"
       "systemd-journald-dev-log.socket"
       "syslog.socket"
 
@@ -99,7 +100,7 @@ let
       # Maintaining state across reboots.
       "systemd-random-seed.service"
       "systemd-backlight@.service"
-      "systemd-rfkill@.service"
+      "systemd-rfkill.service"
 
       # Hibernate / suspend.
       "hibernate.target"
@@ -109,8 +110,6 @@ let
       "systemd-hibernate.service"
       "systemd-suspend.service"
       "systemd-hybrid-sleep.service"
-      "systemd-shutdownd.socket"
-      "systemd-shutdownd.service"
 
       # Reboot stuff.
       "reboot.target"
@@ -758,7 +757,6 @@ in
     systemd.services."systemd-rfkill@".restartIfChanged = false;
     systemd.services."user@".restartIfChanged = false;
     systemd.services.systemd-journal-flush.restartIfChanged = false;
-    systemd.services.systemd-journald.restartIfChanged = false; # FIXME: shouldn't be necessary with systemd 219
     systemd.services.systemd-random-seed.restartIfChanged = false;
     systemd.services.systemd-remount-fs.restartIfChanged = false;
     systemd.services.systemd-update-utmp.restartIfChanged = false;
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 2d6522a1bf9..d042ee094cf 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -46,6 +46,51 @@ let
     '';
   });
 
+  # Collect all interfaces that are defined for a device
+  # as device:interface key:value pairs.
+  wlanDeviceInterfaces =
+    let
+      allDevices = unique (mapAttrsToList (_: v: v.device) cfg.wlanInterfaces);
+      interfacesOfDevice = d: filterAttrs (_: v: v.device == d) cfg.wlanInterfaces;
+    in
+      genAttrs allDevices (d: interfacesOfDevice d);
+
+  # Convert device:interface key:value pairs into a list, and if it exists,
+  # place the interface which is named after the device at the beginning.
+  wlanListDeviceFirst = device: interfaces:
+    if hasAttr device interfaces
+    then [{"${device}"=interfaces.device; _iName=device;}] ++ mapAttrsToList (n: v: v//{_iName=n;}) (filterAttrs (n: _: n!=device) interfaces)
+    else mapAttrsToList (n: v: v // {_iName = n;}) interfaces;
+
+  # udev script that configures a physical wlan device and adds virtual interfaces
+  wlanDeviceUdevScript = device: interfaceList: pkgs.writeScript "wlan-${device}-udev-script" ''
+    #!${pkgs.stdenv.shell}
+
+    # Change the wireless phy device to a predictable name.
+    if [ -e "/sys/class/net/${device}/phy80211/name" ]; then
+      ${pkgs.iw}/bin/iw phy `${pkgs.coreutils}/bin/cat /sys/class/net/${device}/phy80211/name` set name ${device} || true
+    fi
+
+    # Crate new, virtual interfaces and configure them at the same time
+    ${flip concatMapStrings (drop 1 interfaceList) (i: ''
+    ${pkgs.iw}/bin/iw dev ${device} interface add ${i._iName} type ${i.type} \
+      ${optionalString (i.type == "mesh" && i.meshID != null) "mesh_id ${i.meshID}"} \
+      ${optionalString (i.type == "monitor" && i.flags != null) "flags ${i.flags}"} \
+      ${optionalString (i.type == "managed" && i.fourAddr != null) "4addr ${if i.fourAddr then "on" else "off"}"} \
+      ${optionalString (i.mac != null) "addr ${i.mac}"}
+    '')}
+
+    # Reconfigure and rename the default interface that already exists
+    ${flip concatMapStrings (take 1 interfaceList) (i: ''
+      ${pkgs.iw}/bin/iw dev ${device} set type ${i.type}
+      ${optionalString (i.type == "mesh" && i.meshID != null) "${pkgs.iw}/bin/iw dev ${device} set meshid ${i.meshID}"}
+      ${optionalString (i.type == "monitor" && i.flags != null) "${pkgs.iw}/bin/iw dev ${device} set monitor ${i.flags}"}
+      ${optionalString (i.type == "managed" && i.fourAddr != null) "${pkgs.iw}/bin/iw dev ${device} set 4addr ${if i.fourAddr then "on" else "off"}"}
+      ${optionalString (i.mac != null) "${pkgs.iproute}/bin/ip link set dev ${device} address ${i.mac}"}
+      ${optionalString (device != i._iName) "${pkgs.iproute}/bin/ip link set dev ${device} name ${i._iName}"}
+    '')}
+  '';
+
   # We must escape interfaces due to the systemd interpretation
   subsystemDevice = interface:
     "sys-subsystem-net-devices-${escapeSystemdPath interface}.device";
diff --git a/nixos/tests/gnome3_18.nix b/nixos/tests/gnome3_18.nix
new file mode 100644
index 00000000000..971fd48b186
--- /dev/null
+++ b/nixos/tests/gnome3_18.nix
@@ -0,0 +1,36 @@
+import ./make-test.nix ({ pkgs, ...} : {
+  name = "gnome3";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ iElectric eelco chaoflow lethalman ];
+  };
+
+  machine =
+    { config, pkgs, ... }:
+
+    { imports = [ ./common/user-account.nix ];
+
+      services.xserver.enable = true;
+
+      services.xserver.displayManager.auto.enable = true;
+      services.xserver.displayManager.auto.user = "alice";
+      services.xserver.desktopManager.gnome3.enable = true;
+
+      environment.gnome3.packageSet = pkgs.gnome3_18;
+
+      virtualisation.memorySize = 512;
+    };
+
+  testScript =
+    ''
+      $machine->waitForX;
+      $machine->sleep(15);
+
+      # Check that logging in has given the user ownership of devices.
+      $machine->succeed("getfacl /dev/snd/timer | grep -q alice");
+
+      $machine->succeed("su - alice -c 'DISPLAY=:0.0 gnome-terminal &'");
+      $machine->waitForWindow(qr/Terminal/);
+      $machine->sleep(20);
+      $machine->screenshot("screen");
+    '';
+})
diff --git a/pkgs/applications/audio/audacity/default.nix b/pkgs/applications/audio/audacity/default.nix
index 67ec6b5a419..6f25693f734 100644
--- a/pkgs/applications/audio/audacity/default.nix
+++ b/pkgs/applications/audio/audacity/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, wxGTK, pkgconfig, gettext, gtk, glib, zlib, perl, intltool,
   libogg, libvorbis, libmad, alsaLib, libsndfile, soxr, flac, lame,
-  expat, libid3tag, ffmpeg, soundtouch /*, portaudio - given up fighting their portaudio.patch */
+  expat, libid3tag, ffmpeg /*, portaudio - given up fighting their portaudio.patch */
   }:
 
 stdenv.mkDerivation rec {
@@ -19,13 +19,11 @@ stdenv.mkDerivation rec {
     rm -r lib-src-rm/
   '';
 
-  configureFlags = "--with-libsamplerate";
-
   buildInputs = [
     pkgconfig gettext wxGTK gtk expat alsaLib
     libsndfile soxr libid3tag
-    ffmpeg libmad lame libvorbis flac soundtouch
-  ]; #ToDo: detach sbsms
+    ffmpeg libmad lame libvorbis flac
+  ]; #ToDo: soundtouch, detach sbsms
 
   dontDisableStatic = true;
   doCheck = true;
diff --git a/pkgs/applications/audio/jackmix/default.nix b/pkgs/applications/audio/jackmix/default.nix
deleted file mode 100644
index 8176a340470..00000000000
--- a/pkgs/applications/audio/jackmix/default.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{ stdenv, fetchurl, pkgs, jack ? pkgs.libjack2 }:
-
-stdenv.mkDerivation rec {
-  name = "jackmix-0.5.2";
-  src = fetchurl {
-    url = https://github.com/kampfschlaefer/jackmix/archive/v0.5.2.tar.gz;
-    sha256 = "18f5v7g66mgarhs476frvayhch7fy4nyjf2xivixc061ipn0m82j";
-  };
-
-  buildInputs = [
-    pkgs.pkgconfig
-    pkgs.scons
-    pkgs.kde4.qt4
-    pkgs.lash
-    jack
-  ];
-
-  buildPhase = ''
-    scons
-  '';
-  installPhase = ''
-    mkdir -p $out/bin
-    cp jackmix/jackmix $out/bin
-  '';
-
-  meta = {
-    description = "Matrix-Mixer for the Jack-Audio-connection-Kit";
-    homepage = http://www.arnoldarts.de/jackmix/;
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.kampfschlaefer ];
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
-
-
diff --git a/pkgs/applications/graphics/gimp/plugins/default.nix b/pkgs/applications/graphics/gimp/plugins/default.nix
index 702911fee74..ea638de7925 100644
--- a/pkgs/applications/graphics/gimp/plugins/default.nix
+++ b/pkgs/applications/graphics/gimp/plugins/default.nix
@@ -245,7 +245,7 @@ rec {
 
   /* =============== simple script files ==================== */
 
-  # also have a look at enblend-enfuse in all-packages.nix
+  # also have a look at enblendenfuse in all-packages.nix
   exposureBlend = scriptDerivation {
     name = "exposure-blend";
     src = fetchurl {
diff --git a/pkgs/applications/graphics/hugin/default.nix b/pkgs/applications/graphics/hugin/default.nix
index b11ed1a99df..88912cbda55 100644
--- a/pkgs/applications/graphics/hugin/default.nix
+++ b/pkgs/applications/graphics/hugin/default.nix
@@ -1,7 +1,7 @@
 { stdenv, cmake, fetchurl, gnumake, pkgconfig
 , boost, gettext, tclap, wxGTK
 , freeglut, glew, libXi, libXmu, mesa
-, autopanosiftc, enblend-enfuse, exiv2, ilmbase, lensfun, libpng, libtiff
+, autopanosiftc, enblendenfuse, exiv2, ilmbase, lensfun, libpng, libtiff
 , openexr, panotools, perlPackages
 }:
 
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
 
   # commandline tools needed by the hugin batch processor
   # you may have to tell hugin (in the preferences) where these binaries reside
-  propagatedUserEnvPackages = [ autopanosiftc enblend-enfuse gnumake
+  propagatedUserEnvPackages = [ autopanosiftc enblendenfuse gnumake
                                 perlPackages.ImageExifTool
                               ];
 
diff --git a/pkgs/applications/misc/eaglemode/default.nix b/pkgs/applications/misc/eaglemode/default.nix
index 4324a33d238..d81061f3207 100644
--- a/pkgs/applications/misc/eaglemode/default.nix
+++ b/pkgs/applications/misc/eaglemode/default.nix
@@ -37,5 +37,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl3;
     maintainers = with maintainers; [ viric ];
     platforms = with platforms; linux;
+    hydraPlatforms = [];
   };
 }
diff --git a/pkgs/applications/networking/ids/daq/default.nix b/pkgs/applications/networking/ids/daq/default.nix
index 9339bfef6e0..c4a82966238 100644
--- a/pkgs/applications/networking/ids/daq/default.nix
+++ b/pkgs/applications/networking/ids/daq/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, flex, bison, libpcap, libdnet, libnfnetlink, libnetfilter_queue}:
+{stdenv, fetchurl, flex, bison, libpcap}:
 
 stdenv.mkDerivation rec {
   name = "daq-2.0.5";
@@ -9,9 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "0vdwb0r9kdlgj4g0i0swafbc7qik0zmks17mhqji8cl7hpdva13p";
   };
 
-  buildInputs = [ flex bison libpcap libdnet libnfnetlink libnetfilter_queue];
-
-  configureFlags = "--enable-nfq-module=yes --with-dnet-includes=${libdnet}/includes --with-dnet-libraries=${libdnet}/lib"; 
+  buildInputs = [ flex bison libpcap ];
 
   meta = {
     description = "Data AcQuisition library (DAQ), for packet I/O";
diff --git a/pkgs/applications/networking/ids/snort/default.nix b/pkgs/applications/networking/ids/snort/default.nix
index 580ecf4b6ab..a55b80df2b2 100644
--- a/pkgs/applications/networking/ids/snort/default.nix
+++ b/pkgs/applications/networking/ids/snort/default.nix
@@ -1,4 +1,4 @@
-{stdenv, makeWrapper, fetchurl, libpcap, pcre, libdnet, daq, zlib, flex, bison}:
+{stdenv, fetchurl, libpcap, pcre, libdnet, daq, zlib, flex, bison, makeWrapper}:
 
 stdenv.mkDerivation rec {
   version = "2.9.7.2";
diff --git a/pkgs/applications/networking/iptraf-ng/default.nix b/pkgs/applications/networking/iptraf-ng/default.nix
deleted file mode 100644
index 368d78a36f9..00000000000
--- a/pkgs/applications/networking/iptraf-ng/default.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ stdenv, fetchurl, ncurses }:
-
-stdenv.mkDerivation rec {
-  version = "1.1.4";
-  name = "iptraf-ng-${version}";
-
-  src = fetchurl {
-    url = "https://fedorahosted.org/releases/i/p/iptraf-ng/${name}.tar.gz";
-    sha256 = "02gb8z9h2s6s1ybyikywz7jgb1mafdx88hijfasv3khcgkq0q53r";
-  };
-
-  buildInputs = [ ncurses ];
-
-  configurePhase = ''
-    ./configure --prefix=$out/usr --sysconfdir=$out/etc \
-                --localstatedir=$out/var --sbindir=$out/bin
-  '';
-
-  meta = {
-    description = "A console-based network monitoring utility (fork of iptraf)";
-    longDescription = ''
-      IPTraf-ng is a console-based network monitoring utility. IPTraf-ng
-      gathers data like TCP connection packet and byte counts, interface
-      statistics and activity indicators, TCP/UDP traffic breakdowns, and LAN
-      station packet and byte counts. IPTraf-ng features include an IP traffic
-      monitor which shows TCP flag information, packet and byte counts, ICMP
-      details, OSPF packet types, and oversized IP packet warnings; interface
-      statistics showing IP, TCP, UDP, ICMP, non-IP and other IP packet counts,
-      IP checksum errors, interface activity and packet size counts; a TCP and
-      UDP service monitor showing counts of incoming and outgoing packets for
-      common TCP and UDP application ports, a LAN statistics module that
-      discovers active hosts and displays statistics about their activity; TCP,
-      UDP and other protocol display filters so you can view just the traffic
-      you want; logging; support for Ethernet, FDDI, ISDN, SLIP, PPP, and
-      loopback interfaces; and utilization of the built-in raw socket interface
-      of the Linux kernel, so it can be used on a wide variety of supported
-      network cards.
-    '';
-    homepage = https://fedorahosted.org/iptraf-ng/;
-    license = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.devhell ];
-  };
-}
diff --git a/pkgs/applications/networking/p2p/transmission/default.nix b/pkgs/applications/networking/p2p/transmission/default.nix
index b836e75132c..e81ef7a4f9f 100644
--- a/pkgs/applications/networking/p2p/transmission/default.nix
+++ b/pkgs/applications/networking/p2p/transmission/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, intltool, file, makeWrapper
-, openssl, curl, libevent, inotify-tools, systemd
+, openssl, curl, libevent, inotify-tools, systemd, zlib
 , enableGTK3 ? false, gtk3
 }:
 
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     sha256 = "1sxr1magqb5s26yvr5yhs1f7bmir8gl09niafg64lhgfnhv1kz59";
   };
 
-  buildInputs = [ pkgconfig intltool file openssl curl libevent inotify-tools ]
+  buildInputs = [ pkgconfig intltool file openssl curl libevent inotify-tools zlib ]
     ++ optionals enableGTK3 [ gtk3 makeWrapper ]
     ++ optional stdenv.isLinux systemd;
 
diff --git a/pkgs/applications/version-management/git-and-tools/git-hub/default.nix b/pkgs/applications/version-management/git-and-tools/git-hub/default.nix
index e657215f2cd..e47d2569b10 100644
--- a/pkgs/applications/version-management/git-and-tools/git-hub/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git-hub/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, docutils, python }:
 
 let version = "0.9.0"; in
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   name = "git-hub-${version}";
 
   src = fetchFromGitHub {
@@ -11,6 +11,20 @@ stdenv.mkDerivation rec {
     owner = "sociomantic";
   };
 
+  meta = with stdenv.lib; {
+    inherit version;
+    description = "Git command line interface to GitHub";
+    longDescription = ''
+      A simple command line interface to GitHub, enabling most useful GitHub
+      tasks (like creating and listing pull request or issues) to be accessed
+      directly through the Git command line.
+    '';
+    homepage = https://github.com/sociomantic/git-hub;
+    license = licenses.gpl3Plus;
+    platforms = with platforms; linux;
+    maintainers = with maintainers; [ nckx ];
+  };
+
   buildInputs = [ python ];
   nativeBuildInputs = [ docutils ];
 
@@ -27,18 +41,4 @@ stdenv.mkDerivation rec {
     # Remove inert ftdetect vim plugin and a README that's a man page subset:
     rm -r $out/share/{doc,vim}
   '';
-
-  meta = with stdenv.lib; {
-    inherit version;
-    inherit (src.meta) homepage;
-    description = "Git command line interface to GitHub";
-    longDescription = ''
-      A simple command line interface to GitHub, enabling most useful GitHub
-      tasks (like creating and listing pull request or issues) to be accessed
-      directly through the Git command line.
-    '';
-    license = licenses.gpl3Plus;
-    platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
-  };
 }
diff --git a/pkgs/applications/version-management/subversion/default.nix b/pkgs/applications/version-management/subversion/default.nix
index f563bebd9db..db29360c9ec 100644
--- a/pkgs/applications/version-management/subversion/default.nix
+++ b/pkgs/applications/version-management/subversion/default.nix
@@ -8,7 +8,6 @@
 , stdenv, fetchurl, apr, aprutil, zlib, sqlite
 , apacheHttpd ? null, expat, swig ? null, jdk ? null, python ? null, perl ? null
 , sasl ? null, serf ? null
-, branch ? "1.9"
 }:
 
 assert bdbSupport -> aprutil.bdbSupport;
@@ -16,26 +15,15 @@ assert httpServer -> apacheHttpd != null;
 assert pythonBindings -> swig != null && python != null;
 assert javahlBindings -> jdk != null && perl != null;
 
-let
-  config = {
-    "1.9".ver_min = "2";
-    "1.9".sha1 = "fb9db3b7ddf48ae37aa8785872301b59bfcc7017";
-
-    "1.8".ver_min = "14";
-    "1.8".sha1 = "0698efc58373e7657f6dd3ce13cab7b002ffb497";
-  };
-in
-assert builtins.hasAttr branch config;
-
 stdenv.mkDerivation (rec {
 
-  version = "${branch}." + config.${branch}.ver_min;
+  version = "1.9.2";
 
   name = "subversion-${version}";
 
   src = fetchurl {
     url = "mirror://apache/subversion/${name}.tar.bz2";
-    inherit (config.${branch}) sha1;
+    sha1 = "fb9db3b7ddf48ae37aa8785872301b59bfcc7017";
   };
 
   buildInputs = [ zlib apr aprutil sqlite ]
diff --git a/pkgs/applications/video/smplayer/default.nix b/pkgs/applications/video/smplayer/default.nix
index d56ef964967..22935064c4b 100644
--- a/pkgs/applications/video/smplayer/default.nix
+++ b/pkgs/applications/video/smplayer/default.nix
@@ -1,16 +1,16 @@
-{ stdenv, fetchurl, qt5 }:
+{ stdenv, fetchurl, qt4 }:
 
 stdenv.mkDerivation rec {
-  name = "smplayer-15.9.0";
+  name = "smplayer-14.9.0.6690";
 
   src = fetchurl {
     url = "mirror://sourceforge/smplayer/${name}.tar.bz2";
-    sha256 = "1yx6kikaj9v5aj8aavvrcklx283wl6wrnpl905hjc7v03kgp1ac5";
+    sha256 = "0nmw69kg8rqvl9icyx1r1v1pyxg6560363l0kyqyja18j79a3j2y";
   };
 
   patches = [ ./basegui.cpp.patch ];
 
-  buildInputs = [ qt5.script ];
+  buildInputs = [ qt4 ];
 
   preConfigure = ''
     makeFlags="PREFIX=$out"
diff --git a/pkgs/applications/window-managers/weston/default.nix b/pkgs/applications/window-managers/weston/default.nix
index 7a662aaf09e..862e8b0ea01 100644
--- a/pkgs/applications/window-managers/weston/default.nix
+++ b/pkgs/applications/window-managers/weston/default.nix
@@ -7,15 +7,16 @@
 
 stdenv.mkDerivation rec {
   name = "weston-${version}";
-  version = "1.8.0";
+  version = "1.9.0";
 
   src = fetchurl {
     url = "http://wayland.freedesktop.org/releases/${name}.tar.xz";
-    sha256 = "04nkbbdglh0pqznxkdqvak3pc53jmz24d0658bn5r0cf6agycqw9";
+    sha256 = "1ks8mja6glzy2dkayi535hd6w5c5h021bqk7vzgv182g33rh66ww";
   };
 
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
-    pkgconfig wayland mesa libxkbcommon cairo libxcb libXcursor xlibsWrapper udev libdrm
+    wayland mesa libxkbcommon cairo libxcb libXcursor xlibsWrapper udev libdrm
     mtdev libjpeg pam dbus.libs libinput pango libunwind freerdp vaapi libva
     libwebp
   ];
diff --git a/pkgs/build-support/buildenv/builder.pl b/pkgs/build-support/buildenv/builder.pl
index fd8098caf13..155af314397 100755
--- a/pkgs/build-support/buildenv/builder.pl
+++ b/pkgs/build-support/buildenv/builder.pl
@@ -117,10 +117,20 @@ sub addPkg {
     }
 }
 
+# Read packages list.
+my $pkgs;
+
+if (exists $ENV{"pkgsPath"}) {
+    open FILE, $ENV{"pkgsPath"};
+    $pkgs = <FILE>;
+    close FILE;
+} else {
+    $pkgs = $ENV{"pkgs"}
+}
 
 # Symlink to the packages that have been installed explicitly by the
 # user.
-for my $pkg (@{decode_json $ENV{"pkgs"}}) {
+for my $pkg (@{decode_json $pkgs}) {
     for my $path (@{$pkg->{paths}}) {
         addPkg($path, $ENV{"ignoreCollisions"} eq "1", $pkg->{priority}) if -e $path;
     }
diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix
index bbfc572f55f..5bcc1708e7f 100644
--- a/pkgs/build-support/buildenv/default.nix
+++ b/pkgs/build-support/buildenv/default.nix
@@ -38,7 +38,7 @@
 }:
 
 runCommand name
-  { inherit manifest ignoreCollisions passthru pathsToLink extraPrefix postBuild buildInputs;
+  rec { inherit manifest ignoreCollisions passthru pathsToLink extraPrefix postBuild buildInputs;
     pkgs = builtins.toJSON (map (drv: {
       paths =
         [ drv ]
@@ -46,6 +46,8 @@ runCommand name
       priority = drv.meta.priority or 5;
     }) paths);
     preferLocalBuild = true;
+    # XXX: The size is somewhat arbitrary
+    passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null;
   }
   ''
     ${perl}/bin/perl -w ${./builder.pl}
diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix
index 551ed9ea57e..e21b032aacb 100644
--- a/pkgs/build-support/builder-defs/builder-defs.nix
+++ b/pkgs/build-support/builder-defs/builder-defs.nix
@@ -336,7 +336,7 @@ let inherit (builtins) head tail trace; in
 
         doDump = n: noDepEntry "echo Dump number ${n}; set";
 
-	saveEnv = noDepEntry ''export > $TMP/env-vars'';
+	saveEnv = noDepEntry ''export > "$TMP/env-vars" || true'';
 
 	doDumpBuildInputs = noDepEntry (''
 	  echo "${toString realBuildInputs}"
diff --git a/pkgs/build-support/grsecurity/default.nix b/pkgs/build-support/grsecurity/default.nix
index 3bf40a2e8d6..6a964c535b8 100644
--- a/pkgs/build-support/grsecurity/default.nix
+++ b/pkgs/build-support/grsecurity/default.nix
@@ -32,7 +32,7 @@ let
     stable-patch = with pkgs.kernelPatches; grsecurity_stable;
 
     grKernel = if cfg.stable
-               then mkKernel pkgs.linux_3_14 stable-patch
+               then throw "Grsecurity stable no longer supported due to https://grsecurity.net/announce.php"
                else mkKernel pkgs.linux_4_2 test-patch;
 
     ## -- grsecurity configuration ---------------------------------------------
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
index 3445c4b9cc1..9e0cd22c119 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
@@ -8,7 +8,12 @@ find_gio_modules() {
 
 envHooks+=(find_gio_modules)
 
+# Note: $gappsWrapperArgs still gets defined even if $dontWrapGApps is set.
 wrapGAppsHook() {
+  # guard against running multiple times (e.g. due to propagation)
+  [ -z "$wrapGAppsHookHasRun" ] || return
+  wrapGAppsHookHasRun=1
+
   if [ -n "$GDK_PIXBUF_MODULE_FILE" ]; then
     gappsWrapperArgs+=(--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE")
   fi
diff --git a/pkgs/data/misc/shared-mime-info/default.nix b/pkgs/data/misc/shared-mime-info/default.nix
index 57f5b24a6f8..46be9a6060b 100644
--- a/pkgs/data/misc/shared-mime-info/default.nix
+++ b/pkgs/data/misc/shared-mime-info/default.nix
@@ -1,20 +1,23 @@
 {stdenv, fetchurl, pkgconfig, gettext, perl, perlXMLParser, intltool
 , libxml2, glib}:
 
+let version = "1.5"; in
 stdenv.mkDerivation rec {
-  name = "shared-mime-info-1.3";
+  name = "shared-mime-info-${version}";
 
   src = fetchurl {
     url = "http://freedesktop.org/~hadess/${name}.tar.xz";
-    sha256 = "0fijrc8j2kw6bvdx7fmlfafbcwxvinhr8l44b46b3v59gj69rm2g";
+    sha256 = "1021x95xbkfc5ipx3gi2rdc0y6x2pv36yyzxc5pg6nr6xd02hhfn";
   };
 
-  buildInputs = [
+  nativeBuildInputs = [
     pkgconfig gettext intltool perl perlXMLParser libxml2 glib
   ];
 
   meta = {
+    inherit version;
     description = "A database of common MIME types";
     homepage = http://freedesktop.org/wiki/Software/shared-mime-info;
+    license = stdenv.lib.licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/desktops/gnome-3/3.16/core/gnome-control-center/default.nix b/pkgs/desktops/gnome-3/3.16/core/gnome-control-center/default.nix
index 1dfc76a2dd5..0ca81f54299 100644
--- a/pkgs/desktops/gnome-3/3.16/core/gnome-control-center/default.nix
+++ b/pkgs/desktops/gnome-3/3.16/core/gnome-control-center/default.nix
@@ -3,7 +3,7 @@
 , gdk_pixbuf, librsvg, libxkbfile, libnotify
 , libxml2, polkit, libxslt, libgtop, libsoup, colord, colord-gtk
 , cracklib, python, libkrb5, networkmanagerapplet, networkmanager
-, libwacom, samba, shared_mime_info, tzdata, icu, libtool, udev
+, libwacom, samba, shared_mime_info, tzdata, icu, libtool, udev, libgudev
 , docbook_xsl, docbook_xsl_ns, modemmanager, clutter, clutter_gtk
 , fontconfig, sound-theme-freedesktop }:
 
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
       accountsservice libkrb5 networkmanagerapplet libwacom samba libnotify libxkbfile
       shared_mime_info icu libtool docbook_xsl docbook_xsl_ns gnome3.grilo
       gdk_pixbuf gnome3.defaultIconTheme librsvg clutter clutter_gtk
-      gnome3.vino udev libcanberra_gtk3
+      gnome3.vino udev libgudev libcanberra_gtk3
       networkmanager modemmanager makeWrapper gnome3.gnome-bluetooth ];
 
   preBuild = ''
diff --git a/pkgs/desktops/gnome-3/3.16/core/gnome-settings-daemon/default.nix b/pkgs/desktops/gnome-3/3.16/core/gnome-settings-daemon/default.nix
index 2477bb7bc1f..c80d1101ac9 100644
--- a/pkgs/desktops/gnome-3/3.16/core/gnome-settings-daemon/default.nix
+++ b/pkgs/desktops/gnome-3/3.16/core/gnome-settings-daemon/default.nix
@@ -1,6 +1,6 @@
 { fetchurl, stdenv, pkgconfig, gnome3, intltool, glib, libnotify, lcms2, libXtst
 , libxkbfile, libpulseaudio, libcanberra_gtk3, upower, colord, libgweather, polkit
-, geoclue2, librsvg, xf86_input_wacom, udev, libwacom, libxslt, libtool, networkmanager
+, geoclue2, librsvg, xf86_input_wacom, udev, libgudev, libwacom, libxslt, libtool, networkmanager
 , docbook_xsl, docbook_xsl_ns, makeWrapper, ibus, xkeyboard_config }:
 
 stdenv.mkDerivation rec {
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     [ intltool pkgconfig ibus gtk glib gsettings_desktop_schemas networkmanager
       libnotify gnome_desktop lcms2 libXtst libxkbfile libpulseaudio
       libcanberra_gtk3 upower colord libgweather xkeyboard_config
-      polkit geocode_glib geoclue2 librsvg xf86_input_wacom udev libwacom libxslt
+      polkit geocode_glib geoclue2 librsvg xf86_input_wacom udev libgudev libwacom libxslt
       libtool docbook_xsl docbook_xsl_ns makeWrapper gnome_themes_standard ];
 
   preFixup = ''
diff --git a/pkgs/desktops/gnome-3/3.18/apps/accerciser/default.nix b/pkgs/desktops/gnome-3/3.18/apps/accerciser/default.nix
new file mode 100644
index 00000000000..a2813e0581b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/accerciser/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, itstool, libxml2, python3, python3Packages, pyatspi, at_spi2_core
+, dbus, intltool, libwnck3 }:
+
+stdenv.mkDerivation rec {
+  name = "accerciser-3.14.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/accerciser/3.14/${name}.tar.xz";
+    sha256 = "0x05gpajpcs01g7m34g6fxz8122cf9kx3k0lchwl34jy8xfr39gm";
+  };
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook itstool libxml2 python3 pyatspi
+    python3Packages.pygobject3 python3Packages.ipython
+    at_spi2_core dbus intltool libwnck3 gnome3.defaultIconTheme
+  ];
+
+  wrapPrefixVariables = [ "PYTHONPATH" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Accerciser;
+    description = "Interactive Python accessibility explorer";
+    maintainers = gnome3.maintainers;
+    license = licenses.bsd3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/bijiben/default.nix b/pkgs/desktops/gnome-3/3.18/apps/bijiben/default.nix
new file mode 100644
index 00000000000..00895f9a2bb
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/bijiben/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, intltool, fetchurl, pkgconfig, glib
+, evolution_data_server, evolution, sqlite
+, makeWrapper, itstool, desktop_file_utils
+, clutter_gtk, libuuid, webkitgtk, zeitgeist
+, gnome3, librsvg, gdk_pixbuf, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig glib intltool itstool libxml2
+                  clutter_gtk libuuid webkitgtk gnome3.tracker
+                  gnome3.gnome_online_accounts zeitgeist desktop_file_utils
+                  gnome3.gsettings_desktop_schemas makeWrapper
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  evolution_data_server evolution sqlite ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    wrapProgram "$out/bin/bijiben" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Bijiben;
+    description = "Note editor designed to remain simple to use";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/bijiben/src.nix b/pkgs/desktops/gnome-3/3.18/apps/bijiben/src.nix
new file mode 100644
index 00000000000..9eb11c0e379
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/bijiben/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "bijiben-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/bijiben/3.18/bijiben-3.18.0.tar.xz;
+    sha256 = "3e933eae3776ae50a639f0866b5c11279961b5ebdaa83a621509dfe31c218fea";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/cheese/default.nix b/pkgs/desktops/gnome-3/3.18/apps/cheese/default.nix
new file mode 100644
index 00000000000..ed5bbf6ca22
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/cheese/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, intltool, fetchurl, wrapGAppsHook, gnome-video-effects, libcanberra_gtk3
+, pkgconfig, gtk3, glib, clutter_gtk, clutter-gst_2, udev, gst_all_1, itstool
+, adwaita-icon-theme, librsvg, gdk_pixbuf, gnome3, gnome_desktop, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 glib intltool wrapGAppsHook gnome-video-effects itstool
+                  gdk_pixbuf adwaita-icon-theme librsvg udev gst_all_1.gstreamer libxml2
+                  gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gnome_desktop
+                  gst_all_1.gst-plugins-bad clutter_gtk clutter-gst_2
+                  libcanberra_gtk3 ];
+
+  enableParallelBuilding = true;
+
+  NIX_CFLAGS_COMPILE = "-I${glib}/include/gio-unix-2.0";
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Cheese;
+    description = "Take photos and videos with your webcam, with fun graphical effects";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/cheese/src.nix b/pkgs/desktops/gnome-3/3.18/apps/cheese/src.nix
new file mode 100644
index 00000000000..7e47c2c4950
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/cheese/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "cheese-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/cheese/3.18/cheese-3.18.0.tar.xz;
+    sha256 = "65ba4a60be51b9fc5537e5c1cdb6605b3098145982fae75a08ace94b965aeb0b";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/evolution/default.nix b/pkgs/desktops/gnome-3/3.18/apps/evolution/default.nix
new file mode 100644
index 00000000000..a9bb87d4ddd
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/evolution/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, intltool, fetchurl, libxml2, webkitgtk, highlight
+, pkgconfig, gtk3, glib, libnotify, gtkspell3
+, makeWrapper, itstool, shared_mime_info, libical, db, gcr, sqlite
+, gnome3, librsvg, gdk_pixbuf, libsecret, nss, nspr, icu, libtool
+, libcanberra_gtk3, bogofilter, gst_all_1, procps, p11_kit }:
+
+let
+  majVer = gnome3.version;
+in stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  propagatedBuildInputs = [ gnome3.gtkhtml ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2 libtool
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg db icu
+                  gnome3.evolution_data_server libsecret libical gcr
+                  webkitgtk shared_mime_info gnome3.gnome_desktop gtkspell3
+                  libcanberra_gtk3 bogofilter gnome3.libgdata sqlite
+                  gst_all_1.gstreamer gst_all_1.gst-plugins-base p11_kit
+                  nss nspr libnotify procps highlight gnome3.libgweather
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  configureFlags = [ "--disable-spamassassin" "--disable-pst-import" "--disable-autoar"
+                     "--disable-libcryptui" ];
+
+  NIX_CFLAGS_COMPILE = "-I${nspr}/include/nspr -I${nss}/include/nss -I${glib}/include/gio-unix-2.0";
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    for f in $out/bin/* $out/libexec/*; do
+      wrapProgram "$f" \
+        --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+        --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Evolution;
+    description = "Personal information management application that provides integrated mail, calendaring and address book functionality";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/evolution/src.nix b/pkgs/desktops/gnome-3/3.18/apps/evolution/src.nix
new file mode 100644
index 00000000000..46af1c8b8bb
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/evolution/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "evolution-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/evolution/3.18/evolution-3.18.0.tar.xz;
+    sha256 = "a3efe42a861200c0463476e0a02e566fde74a0d4a699d8cc6514c031d5cad410";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/file-roller/default.nix b/pkgs/desktops/gnome-3/3.18/apps/file-roller/default.nix
new file mode 100644
index 00000000000..4e35676f3cb
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/file-roller/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, glib, pkgconfig, gnome3, intltool, itstool, libxml2, libarchive
+, attr, bzip2, acl, makeWrapper, librsvg, gdk_pixbuf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # TODO: support nautilus
+  # it tries to create {nautilus}/lib/nautilus/extensions-3.0/libnautilus-fileroller.so
+
+  buildInputs = [ glib pkgconfig gnome3.gtk intltool itstool libxml2 libarchive
+                  gnome3.defaultIconTheme attr bzip2 acl gdk_pixbuf librsvg
+                  makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/file-roller" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:$out/share"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/FileRoller;
+    description = "Archive manager for the GNOME desktop environment";
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/file-roller/src.nix b/pkgs/desktops/gnome-3/3.18/apps/file-roller/src.nix
new file mode 100644
index 00000000000..3e166f996e9
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/file-roller/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "file-roller-3.16.4";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/file-roller/3.16/file-roller-3.16.4.tar.xz;
+    sha256 = "5455980b2c9c7eb063d2d65560ae7ab2e7f01b208ea3947e151680231c7a4185";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gedit/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gedit/default.nix
new file mode 100644
index 00000000000..6cff4bdee48
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gedit/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, intltool, fetchurl, enchant, isocodes
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, libsoup, libxml2
+, gnome3, librsvg, gdk_pixbuf, file }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool enchant isocodes
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg libsoup
+                  gnome3.libpeas gnome3.gtksourceview libxml2
+                  gnome3.gsettings_desktop_schemas makeWrapper file ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    wrapProgram "$out/bin/gedit" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --prefix LD_LIBRARY_PATH : "${gnome3.libpeas}/lib:${gnome3.gtksourceview}/lib" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Gedit;
+    description = "Official text editor of the GNOME desktop environment";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gedit/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gedit/src.nix
new file mode 100644
index 00000000000..ff427fdfb90
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gedit/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gedit-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gedit/3.18/gedit-3.18.0.tar.xz;
+    sha256 = "9abd4f1478385f8b6c983298206f4ab1a25c682b9c87fb00d759b7db5b949533";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/glade/default.nix b/pkgs/desktops/gnome-3/3.18/apps/glade/default.nix
new file mode 100644
index 00000000000..a0f8d966955
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/glade/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, intltool, fetchurl, python
+, pkgconfig, gtk3, glib
+, makeWrapper, itstool, libxml2, docbook_xsl
+, gnome3, librsvg, gdk_pixbuf, libxslt }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2 python
+                  gnome3.gsettings_desktop_schemas makeWrapper docbook_xsl
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg libxslt ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    wrapProgram "$out/bin/glade" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Glade;
+    description = "User interface designer for GTK+ applications";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/glade/src.nix b/pkgs/desktops/gnome-3/3.18/apps/glade/src.nix
new file mode 100644
index 00000000000..aaa913babea
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/glade/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "glade-3.18.3";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/glade/3.18/glade-3.18.3.tar.xz;
+    sha256 = "ecdbce46e7fbfecd463be840b94fbf54d83723b3ebe075414cfd225ddab66452";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/default.nix
new file mode 100644
index 00000000000..90955bd3ccf
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, makeWrapper, pkgconfig, intltool, itstool, libvirt-glib
+, glib, gobjectIntrospection, libxml2, gtk3, gtkvnc, libvirt, spice_gtk
+, spice_protocol, libuuid, libsoup, libosinfo, systemd, tracker, vala
+, libcap_ng, libcap, yajl, gmp, gdbm, cyrus_sasl, gnome3, librsvg
+, desktop_file_utils, mtools, cdrkit, libcdio
+, libusb, libarchive, acl
+}:
+
+# TODO: ovirt (optional)
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  buildInputs = [
+    makeWrapper pkgconfig intltool itstool libvirt-glib glib
+    gobjectIntrospection libxml2 gtk3 gtkvnc libvirt spice_gtk spice_protocol
+    libuuid libsoup libosinfo systemd tracker vala libcap_ng libcap yajl gmp
+    gdbm cyrus_sasl gnome3.defaultIconTheme libusb libarchive
+    librsvg desktop_file_utils acl
+  ];
+
+  preFixup = ''
+    for prog in "$out/bin/"*; do
+        wrapProgram "$prog" \
+            --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+            --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
+            --prefix PATH : "${mtools}/bin:${cdrkit}/bin:${libcdio}/bin"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Simple GNOME 3 application to access remote or virtual systems";
+    homepage = https://wiki.gnome.org/action/show/Apps/Boxes;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ bjornfor ];
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/src.nix
new file mode 100644
index 00000000000..06543540e76
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-boxes/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-boxes-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-boxes/3.18/gnome-boxes-3.18.0.tar.xz;
+    sha256 = "ed2b442fc676bdfa47d6b6326836238c2c98af9725a91eb023784a3e692ae749";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/default.nix
new file mode 100644
index 00000000000..cbd5a84bdb5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, intltool, evolution_data_server, sqlite, libxml2, libsoup
+, glib, gnome_online_accounts }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool evolution_data_server
+    sqlite libxml2 libsoup glib gnome3.defaultIconTheme gnome_online_accounts
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Calendar;
+    description = "Simple and beautiful calendar application for GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/src.nix
new file mode 100644
index 00000000000..6b941b592e5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-calendar/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-calendar-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-calendar/3.18/gnome-calendar-3.18.0.tar.xz;
+    sha256 = "f7d50fe8d5d3dcc574f0034dba6a64cbb9b3f842faab5978c9d02b38548f355b";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/default.nix
new file mode 100644
index 00000000000..4571a5d50e8
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, intltool, gjs, gdk_pixbuf, librsvg }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool gjs gdk_pixbuf
+    librsvg gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Design/Apps/CharacterMap;
+    description = "Simple utility application to find and insert unusual characters";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/src.nix
new file mode 100644
index 00000000000..a957aa91d75
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-characters/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-characters-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-characters/3.18/gnome-characters-3.18.0.tar.xz;
+    sha256 = "e068b2275a08639565a88b096d378a4ac2abf90301ff43056bb5157dff54ce08";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/default.nix
new file mode 100644
index 00000000000..e39614e765d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, intltool, fetchurl, libgweather, libnotify
+, pkgconfig, gtk3, glib, gsound
+, makeWrapper, itstool, libcanberra_gtk3, libtool
+, gnome3, librsvg, gdk_pixbuf, geoclue2, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libcanberra_gtk3
+                  gnome3.gsettings_desktop_schemas makeWrapper
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  gnome3.gnome_desktop gnome3.geocode_glib geoclue2
+                  libgweather libnotify libtool gsound
+                  wrapGAppsHook ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Clocks;
+    description = "Clock application designed for GNOME 3";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/src.nix
new file mode 100644
index 00000000000..9f0be0ede98
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-clocks/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-clocks-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-clocks/3.18/gnome-clocks-3.18.0.tar.xz;
+    sha256 = "ca0818ec89e3539201da6b5388365e3d66df815198beccc90e2be44c7822baa0";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/default.nix
new file mode 100644
index 00000000000..7f1f70114b7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, intltool, fetchurl, evince, gjs
+, pkgconfig, gtk3, glib
+, makeWrapper, itstool, libxslt, webkitgtk
+, gnome3, librsvg, gdk_pixbuf, libsoup, docbook_xsl
+, gobjectIntrospection, json_glib, inkscape, poppler_utils
+, gmp, desktop_file_utils, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  configureFlags = [ "--enable-getting-started" ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxslt
+                  docbook_xsl desktop_file_utils inkscape poppler_utils
+                  gnome3.gsettings_desktop_schemas makeWrapper gmp
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg evince
+                  libsoup webkitgtk gjs gobjectIntrospection gnome3.rest
+                  gnome3.tracker gnome3.libgdata gnome3.gnome_online_accounts
+                  gnome3.gnome_desktop gnome3.libzapojit json_glib
+                  wrapGAppsHook ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    substituteInPlace $out/bin/gnome-documents --replace gapplication "${glib}/bin/gapplication"
+
+    gappsWrapperArgs+=(--run 'if [ -z "$XDG_CACHE_DIR" ]; then XDG_CACHE_DIR=$HOME/.cache; fi; if [ -w "$XDG_CACHE_DIR/.." ]; then mkdir -p "$XDG_CACHE_DIR/gnome-documents"; fi')
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Documents;
+    description = "Document manager application designed to work with GNOME 3";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/src.nix
new file mode 100644
index 00000000000..5906bade1ef
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-documents/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-documents-3.18.0.1";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-documents/3.18/gnome-documents-3.18.0.1.tar.xz;
+    sha256 = "0b19593e949276de71cb7292bb77520eb3cd915ac8c71d27a8d05f79b9e86816";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/default.nix
new file mode 100644
index 00000000000..0c75ebd7c78
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, fetchurl, gnome3, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ intltool itstool libxml2 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://live.gnome.org/DocumentationProject;
+    description = "Help a new user get started in GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.cc-by-sa-30;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/src.nix
new file mode 100644
index 00000000000..a4ed1d6b909
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-getting-started-docs/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-getting-started-docs-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-getting-started-docs/3.18/gnome-getting-started-docs-3.18.0.tar.xz;
+    sha256 = "5ef0373c5a864fefdecb17bffdfc2cca00fb2abf93756b1df9062e12208925d6";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/default.nix
new file mode 100644
index 00000000000..d4135fdb1ba
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, intltool, itstool, libxml2, systemd }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  configureFlags = [ "--disable-tests" ];
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool libxml2
+    systemd gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Logs;
+    description = "A log viewer for the systemd journal";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/src.nix
new file mode 100644
index 00000000000..b077f8cee4d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-logs/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-logs-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-logs/3.18/gnome-logs-3.18.0.tar.xz;
+    sha256 = "7602b55d47b5d889be7547869a0a48f03f6b22a1c872b86ed70049695d06d699";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/default.nix
new file mode 100644
index 00000000000..b9aac0539ae
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gnome3, gtk3
+, gobjectIntrospection, gdk_pixbuf, librsvg, autoreconfHook
+, geoclue2, wrapGAppsHook, folks, libchamplain, gfbgraph, file, libsoup }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  buildInputs = [ pkgconfig intltool gobjectIntrospection wrapGAppsHook
+                  gtk3 geoclue2 gnome3.gjs gnome3.libgee folks gfbgraph
+                  gnome3.geocode_glib libchamplain file libsoup
+                  gdk_pixbuf librsvg autoreconfHook
+                  gnome3.gnome_online_accounts gnome3.defaultIconTheme ];
+
+  patches = [ ./soup.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Maps;
+    description = "A map application for GNOME 3";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/soup.patch b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/soup.patch
new file mode 100644
index 00000000000..e7e86ba76c7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/soup.patch
@@ -0,0 +1,10 @@
+--- gnome-maps-3.18.0/configure.ac.orig	2015-09-24 18:38:31.912498368 +0200
++++ gnome-maps-3.18.0/configure.ac	2015-09-24 18:38:40.783320413 +0200
+@@ -50,6 +50,7 @@
+     folks                        >= $FOLKS_MIN_VERSION
+     geocode-glib-1.0             >= $GEOCODE_MIN_VERSION
+     champlain-0.12               >= $CHAMPLAIN_MIN_VERSION
++    libsoup-2.4
+ ])
+ AC_SUBST(GNOME_MAPS_LIB_CFLAGS)
+ AC_SUBST(GNOME_MAPS_LIB_LIBS)
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/src.nix
new file mode 100644
index 00000000000..9d33216480d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-maps/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-maps-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-maps/3.18/gnome-maps-3.18.0.tar.xz;
+    sha256 = "242f70346a1527ba0d9a664bd863b02e2227f9f0f0f577b9b0c00dc3075eb85e";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-music/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-music/default.nix
new file mode 100644
index 00000000000..bb89ef84202
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-music/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, intltool, fetchurl, gdk_pixbuf, tracker
+, python3, libxml2, python3Packages, libnotify, wrapGAppsHook
+, pkgconfig, gtk3, glib, cairo
+, makeWrapper, itstool, gnome3, librsvg, gst_all_1 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool gnome3.libmediaart
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg python3
+                  gnome3.grilo gnome3.grilo-plugins libxml2 python3Packages.pygobject3 libnotify
+                  python3Packages.pycairo python3Packages.dbus gnome3.totem-pl-parser
+                  gst_all_1.gstreamer gst_all_1.gst-plugins-base wrapGAppsHook
+                  gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad
+                  gnome3.gsettings_desktop_schemas makeWrapper tracker ];
+
+  wrapPrefixVariables = [ "PYTHONPATH" ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Music;
+    description = "Music player and management application for the GNOME desktop environment";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-music/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-music/src.nix
new file mode 100644
index 00000000000..de2cf605486
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-music/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-music-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-music/3.18/gnome-music-3.18.0.tar.xz;
+    sha256 = "e2e4b99a57c7b5c83ce3deccd38880cbafb875b423ab276204af523bc648d69c";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-nettool/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-nettool/default.nix
new file mode 100644
index 00000000000..4c152777f2c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-nettool/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, libgtop, intltool, itstool, libxml2, nmap, inetutils }:
+
+stdenv.mkDerivation rec {
+  name = "gnome-nettool-3.8.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gnome-nettool/3.8/${name}.tar.xz";
+    sha256 = "1c9cvzvyqgfwa5zzyvp7118pkclji62fkbb33g4y9sp5kw6m397h";
+  };
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook libgtop intltool itstool libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  propagatedUserEnvPkgs = [ nmap inetutils ];
+
+  meta = with stdenv.lib; {
+    homepage = http://projects.gnome.org/gnome-network;
+    description = "A collection of networking tools";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/default.nix
new file mode 100644
index 00000000000..eaace044af0
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, intltool, fetchurl, exempi, libxml2
+, pkgconfig, gtk3, glib
+, makeWrapper, itstool, gegl, babl, lcms2
+, desktop_file_utils, gmp, libmediaart, wrapGAppsHook
+, gnome3, librsvg, gdk_pixbuf, libexif }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool gegl babl gnome3.libgdata
+                  gnome3.gsettings_desktop_schemas makeWrapper gmp libmediaart
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg exempi
+                  gnome3.gfbgraph gnome3.grilo-plugins gnome3.grilo
+                  gnome3.gnome_online_accounts gnome3.gnome_desktop
+                  lcms2 libexif gnome3.tracker libxml2 desktop_file_utils
+                  wrapGAppsHook ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Photos;
+    description = "Photos is an application to access, organize and share your photos with GNOME 3";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/src.nix
new file mode 100644
index 00000000000..1af6b71cdb9
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-photos/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-photos-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-photos/3.18/gnome-photos-3.18.0.tar.xz;
+    sha256 = "5ca74b33de33da125059918e2d7c665ff78ac1adfbc04c98b3378e705cc73a54";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/default.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/default.nix
new file mode 100644
index 00000000000..f4d2c8ad0c1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook, gjs
+, libgweather, intltool, itstool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook gjs intltool itstool
+    libgweather gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Weather;
+    description = "Access current weather conditions and forecasts";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/src.nix b/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/src.nix
new file mode 100644
index 00000000000..b1dc538815d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/gnome-weather/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-weather-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-weather/3.18/gnome-weather-3.18.0.tar.xz;
+    sha256 = "fa0c098bef351af7457abf0ef6bd0afb62d727f041a15107e02693c9c7bd48aa";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/nautilus-sendto/default.nix b/pkgs/desktops/gnome-3/3.18/apps/nautilus-sendto/default.nix
new file mode 100644
index 00000000000..093900dcb7a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/nautilus-sendto/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, glib, pkgconfig, gnome3, intltool
+, gobjectIntrospection, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "nautilus-sendto-${version}";
+
+  version = "3.8.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/nautilus-sendto/3.8/${name}.tar.xz";
+    sha256 = "03fa46bff271acdbdedab6243b2a84e5ed3daa19c81b69d087b3e852c8fe5dab";
+  };
+
+  buildInputs = [ glib pkgconfig gobjectIntrospection intltool makeWrapper ];
+
+  meta = with stdenv.lib; {
+    description = "Integrates Evolution and Pidgin into the Nautilus file manager";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/polari/default.nix b/pkgs/desktops/gnome-3/3.18/apps/polari/default.nix
new file mode 100644
index 00000000000..8efaa4e4aac
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/polari/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, intltool, fetchurl, gdk_pixbuf, adwaita-icon-theme
+, telepathy_glib, gjs, itstool, telepathy_idle
+, pkgconfig, gtk3, glib, librsvg, gnome3, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ telepathy_idle ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool adwaita-icon-theme wrapGAppsHook
+                  telepathy_glib gjs gdk_pixbuf librsvg ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Polari;
+    description = "IRC chat client designed to integrate with the GNOME desktop";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/polari/src.nix b/pkgs/desktops/gnome-3/3.18/apps/polari/src.nix
new file mode 100644
index 00000000000..9d7497b61c7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/polari/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "polari-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/polari/3.18/polari-3.18.0.tar.xz;
+    sha256 = "7b98c820a1e9a25a0f3a927e8d4ba8400296041f783301a764e37840c7ef6018";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/seahorse/default.nix b/pkgs/desktops/gnome-3/3.18/apps/seahorse/default.nix
new file mode 100644
index 00000000000..3b78babadd9
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/seahorse/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, intltool, fetchurl, vala
+, pkgconfig, gtk3, glib
+, makeWrapper, itstool, gnupg, libsoup
+, gnome3, librsvg, gdk_pixbuf, gpgme
+, libsecret, avahi, p11_kit, openssh }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool gnome3.gcr
+                  gnome3.gsettings_desktop_schemas makeWrapper gnupg
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg gpgme
+                  libsecret avahi libsoup p11_kit vala gnome3.gcr
+                  openssh ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/seahorse" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Seahorse;
+    description = "Application for managing encryption keys and passwords in the GnomeKeyring";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/seahorse/src.nix b/pkgs/desktops/gnome-3/3.18/apps/seahorse/src.nix
new file mode 100644
index 00000000000..1d790c81e4f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/seahorse/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "seahorse-3.16.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/seahorse/3.16/seahorse-3.16.0.tar.xz;
+    sha256 = "770a5f03b8745054ef04cef9923dd713b1fbf309169150bc8dd32d7e5f7ee131";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/vinagre/default.nix b/pkgs/desktops/gnome-3/3.18/apps/vinagre/default.nix
new file mode 100644
index 00000000000..8b8b6248642
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/vinagre/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, vte, libxml2, gtkvnc, intltool
+, libsecret, itstool, makeWrapper, librsvg }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 vte libxml2 gtkvnc intltool libsecret
+                  itstool makeWrapper gnome3.defaultIconTheme librsvg ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/vinagre" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:$out/share"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Vinagre;
+    description = "Remote desktop viewer for GNOME";
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/apps/vinagre/src.nix b/pkgs/desktops/gnome-3/3.18/apps/vinagre/src.nix
new file mode 100644
index 00000000000..94b6d8a83e1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/apps/vinagre/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "vinagre-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/vinagre/3.18/vinagre-3.18.0.tar.xz;
+    sha256 = "77214384c03df985551a5094ea16fd3f42b74c708123128b29baff6458b2fef9";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/default.nix b/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/default.nix
new file mode 100644
index 00000000000..3c3a05dc3af
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, intltool, gnome3
+, iconnamingutils, gtk, gdk_pixbuf, librsvg, hicolor_icon_theme }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # For convenience, we can specify adwaita-icon-theme only in packages
+  propagatedBuildInputs = [ hicolor_icon_theme ];
+
+  buildInputs = [ gdk_pixbuf librsvg ];
+
+  nativeBuildInputs = [ pkgconfig intltool iconnamingutils gtk ];
+
+  # remove a tree of dirs with no files within
+  postInstall = '' rm -rf "$out/locale" '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/src.nix b/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/src.nix
new file mode 100644
index 00000000000..59fc291eb4e
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/adwaita-icon-theme/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "adwaita-icon-theme-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/adwaita-icon-theme/3.18/adwaita-icon-theme-3.18.0.tar.xz;
+    sha256 = "5e9ce726001fdd8ee93c394fdc3cdb9e1603bbed5b7c62df453ccf521ec50e58";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/baobab/default.nix b/pkgs/desktops/gnome-3/3.18/core/baobab/default.nix
new file mode 100644
index 00000000000..2ff85662bbb
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/baobab/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, intltool, fetchurl, vala, libgtop
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, libxml2
+, gnome3, librsvg, gdk_pixbuf, file }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ vala pkgconfig gtk3 glib libgtop intltool itstool libxml2
+                  gnome3.gsettings_desktop_schemas makeWrapper file
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/baobab" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Baobab;
+    description = "Graphical application to analyse disk usage in any Gnome environment";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/baobab/src.nix b/pkgs/desktops/gnome-3/3.18/core/baobab/src.nix
new file mode 100644
index 00000000000..5032262f278
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/baobab/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "baobab-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/baobab/3.18/baobab-3.18.0.tar.xz;
+    sha256 = "75924c53dd0e94d97c2f0ec30270fa3ffc59adfab7e21aac3ed9c6c088760b5a";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/caribou/default.nix b/pkgs/desktops/gnome-3/3.18/core/caribou/default.nix
new file mode 100644
index 00000000000..c2cb6a661ab
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/caribou/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, clutter, dbus, pythonPackages, libxml2, autoconf
+, libxklavier, libXtst, gtk2, intltool, libxslt, at_spi2_core, automake114x }:
+
+let
+  majorVersion = "0.4";
+in
+stdenv.mkDerivation rec {
+  name = "caribou-${majorVersion}.18.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/caribou/${majorVersion}/${name}.tar.xz";
+    sha256 = "0l1ikx56ddgayvny3s2xv8hs3p23xsclw4zljs3cczv4b89dzymf";
+  };
+
+  buildInputs = with gnome3;
+    [ glib pkgconfig gtk clutter at_spi2_core dbus pythonPackages.python automake114x
+      pythonPackages.pygobject3 libxml2 libXtst gtk2 intltool libxslt autoconf ];
+
+  propagatedBuildInputs = [ gnome3.libgee libxklavier ];
+
+  preBuild = ''
+    patchShebangs .
+    substituteInPlace libcaribou/Makefile.am --replace "--shared-library=libcaribou.so.0" "--shared-library=$out/lib/libcaribou.so.0"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/dconf-editor/default.nix b/pkgs/desktops/gnome-3/3.18/core/dconf-editor/default.nix
new file mode 100644
index 00000000000..5b2b055fe66
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/dconf-editor/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, vala, libxslt, pkgconfig, glib, dbus_glib, gnome3
+, libxml2, intltool, docbook_xsl_ns, docbook_xsl, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ vala libxslt pkgconfig glib dbus_glib gnome3.gtk libxml2 gnome3.defaultIconTheme
+                  intltool docbook_xsl docbook_xsl_ns makeWrapper gnome3.dconf ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/dconf-editor" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/dconf-editor/src.nix b/pkgs/desktops/gnome-3/3.18/core/dconf-editor/src.nix
new file mode 100644
index 00000000000..eb15838bb48
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/dconf-editor/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "dconf-editor-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/dconf-editor/3.18/dconf-editor-3.18.0.tar.xz;
+    sha256 = "6579b8b216b068acae7d8301b5e2d57054c85a3f147c92355ffa46a62c052534";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/dconf/default.nix b/pkgs/desktops/gnome-3/3.18/core/dconf/default.nix
new file mode 100644
index 00000000000..990e2007a23
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/dconf/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, vala, libxslt, pkgconfig, glib, dbus_glib, gnome3
+, libxml2, intltool, docbook_xsl_ns, docbook_xsl, makeWrapper }:
+
+let
+  majorVersion = "0.24";
+in
+stdenv.mkDerivation rec {
+  name = "dconf-${version}";
+  version = "${majorVersion}.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/dconf/${majorVersion}/${name}.tar.xz";
+    sha256 = "4373e0ced1f4d7d68d518038796c073696280e22957babb29feb0267c630fec2";
+  };
+
+  buildInputs = [ vala libxslt pkgconfig glib dbus_glib gnome3.gtk libxml2
+                  intltool docbook_xsl docbook_xsl_ns makeWrapper ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/empathy/default.nix b/pkgs/desktops/gnome-3/3.18/core/empathy/default.nix
new file mode 100644
index 00000000000..4c42c6c026d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/empathy/default.nix
@@ -0,0 +1,57 @@
+{ stdenv, intltool, fetchurl, webkitgtk, pkgconfig, gtk3, glib
+, file, librsvg, gnome3, gdk_pixbuf
+, dbus_glib, dbus_libs, telepathy_glib, telepathy_farstream
+, clutter_gtk, clutter-gst, gst_all_1, cogl, gnome_online_accounts
+, gcr, libsecret, folks, libpulseaudio, telepathy_mission_control
+, telepathy_logger, libnotify, clutter, libsoup, gnutls
+, evolution_data_server
+, libcanberra_gtk3, p11_kit, farstream, libtool, shared_mime_info
+, bash, makeWrapper, itstool, libxml2, libxslt, icu, libgee  }:
+
+# TODO: enable more features
+
+let
+  majorVersion = "3.12";
+in
+stdenv.mkDerivation rec {
+  name = "empathy-${majorVersion}.8";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/empathy/${majorVersion}/${name}.tar.xz";
+    sha256 = "10z6ksia6yx7vg0wsdbk4w6vjgfg3cg3n04jf9bj2vr7kr5zvs7w";
+  };
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard
+                            gnome_online_accounts shared_mime_info ];
+  propagatedBuildInputs = [ folks telepathy_logger evolution_data_server
+                            telepathy_mission_control ];
+  buildInputs = [ pkgconfig gtk3 glib webkitgtk intltool itstool
+                  libxml2 libxslt icu file makeWrapper
+                  telepathy_glib clutter_gtk clutter-gst cogl
+                  gst_all_1.gstreamer gst_all_1.gst-plugins-base
+                  gcr libsecret libpulseaudio gnome3.yelp_xsl gdk_pixbuf
+                  libnotify clutter libsoup gnutls libgee p11_kit
+                  libcanberra_gtk3 telepathy_farstream farstream
+                  gnome3.defaultIconTheme gnome3.gsettings_desktop_schemas
+                  file libtool librsvg ];
+
+  NIX_CFLAGS_COMPILE = [ "-I${dbus_glib}/include/dbus-1.0"
+                         "-I${dbus_libs}/include/dbus-1.0"
+                         "-I${dbus_libs}/lib/dbus-1.0/include" ];
+
+  preFixup = ''
+    for f in $out/bin/* $out/libexec/*; do
+      wrapProgram $f \
+        --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+        --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gnome3.gnome_themes_standard}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Empathy;
+    description = "Messaging program which supports text, voice, video chat, and file transfers over many different protocols";
+    maintainers = gnome3.maintainers;
+    # TODO: license = [ licenses.gpl2 licenses.lgpl2 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/eog/default.nix b/pkgs/desktops/gnome-3/3.18/core/eog/default.nix
new file mode 100644
index 00000000000..fff901142dc
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/eog/default.nix
@@ -0,0 +1,25 @@
+{ fetchurl, stdenv, intltool, pkgconfig, itstool, libxml2, libjpeg, gnome3
+, shared_mime_info, makeWrapper, librsvg, libexif }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = with gnome3;
+    [ intltool pkgconfig itstool libxml2 libjpeg gtk glib libpeas makeWrapper librsvg
+      gsettings_desktop_schemas shared_mime_info adwaita-icon-theme gnome_desktop libexif ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/eog" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${shared_mime_info}/share:${gnome3.adwaita-icon-theme}/share:${gnome3.gtk}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/EyeOfGnome; 
+    platforms = platforms.linux;
+    description = "GNOME image viewer";
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/eog/src.nix b/pkgs/desktops/gnome-3/3.18/core/eog/src.nix
new file mode 100644
index 00000000000..154a02d7b43
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/eog/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "eog-3.16.3";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/eog/3.16/eog-3.16.3.tar.xz;
+    sha256 = "ee6d101f8e73aacc8d48256f06a780c6d0d5f3975990f375f58cd0e70816b766";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/epiphany/default.nix b/pkgs/desktops/gnome-3/3.18/core/epiphany/default.nix
new file mode 100644
index 00000000000..5a98770b663
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/epiphany/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, intltool, fetchurl, pkgconfig, gtk3, glib, nspr, icu
+, bash, makeWrapper, gnome3, libwnck3, libxml2, libxslt, libtool
+, webkitgtk, libsoup, libsecret, gnome_desktop, libnotify, p11_kit
+, sqlite, gcr, avahi, nss, isocodes, itstool, file, which
+, gdk_pixbuf, librsvg, gnome_common }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # Tests need an X display
+  configureFlags = [ "--disable-static --disable-tests" ];
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  nativeBuildInputs = [ pkgconfig file ];
+
+  buildInputs = [ gtk3 glib intltool libwnck3 libxml2 libxslt pkgconfig file 
+                  webkitgtk libsoup libsecret gnome_desktop libnotify libtool
+                  sqlite isocodes nss itstool p11_kit nspr icu gnome3.yelp_tools
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg which gnome_common
+                  gcr avahi gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  NIX_CFLAGS_COMPILE = "-I${nspr}/include/nspr -I${nss}/include/nss -I${glib}/include/gio-unix-2.0";
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    for f in $out/bin/* $out/libexec/*; do
+      wrapProgram "$f" \
+        --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+        --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Epiphany;
+    description = "WebKit based web browser for GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/epiphany/libxml_depend.patch b/pkgs/desktops/gnome-3/3.18/core/epiphany/libxml_depend.patch
new file mode 100644
index 00000000000..89e3694a02d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/epiphany/libxml_depend.patch
@@ -0,0 +1,10 @@
+--- configure.ac.orig	2015-04-08 18:53:52.284580835 +0200
++++ configure.ac	2015-04-08 18:55:55.697225280 +0200
+@@ -113,6 +113,7 @@
+ PKG_CHECK_MODULES(WEB_EXTENSION, [
+                   webkit2gtk-web-extension-4.0 >= $WEBKIT_GTK_REQUIRED
+                   libsecret-1 >= $LIBSECRET_REQUIRED
++                  libxml-2.0 >= $LIBXML_REQUIRED
+                   ])
+ AC_SUBST(WEB_EXTENSION_CFLAGS)
+ AC_SUBST(WEB_EXTENSION_LIBS)
diff --git a/pkgs/desktops/gnome-3/3.18/core/epiphany/src.nix b/pkgs/desktops/gnome-3/3.18/core/epiphany/src.nix
new file mode 100644
index 00000000000..2ecf2c98d19
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/epiphany/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "epiphany-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/epiphany/3.18/epiphany-3.18.0.tar.xz;
+    sha256 = "d5ba67a8cd85c80b81e076862bcab3fc376ba51b0a1536ca7430608d1f50491d";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/evince/default.nix b/pkgs/desktops/gnome-3/3.18/core/evince/default.nix
new file mode 100644
index 00000000000..154182eef88
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/evince/default.nix
@@ -0,0 +1,64 @@
+{ fetchurl, stdenv, pkgconfig, intltool, perl, perlXMLParser, libxml2
+, glib, gtk3, pango, atk, gdk_pixbuf, shared_mime_info, itstool, gnome3
+, poppler, ghostscriptX, djvulibre, libspectre, libsecret , makeWrapper
+, librsvg, recentListSize ? null # 5 is not enough, allow passing a different number
+, gobjectIntrospection
+}:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig intltool perl perlXMLParser libxml2
+    glib gtk3 pango atk gdk_pixbuf gobjectIntrospection
+    itstool gnome3.adwaita-icon-theme
+    gnome3.libgnome_keyring gnome3.gsettings_desktop_schemas
+    poppler ghostscriptX djvulibre libspectre
+    makeWrapper libsecret librsvg gnome3.adwaita-icon-theme
+  ];
+
+  configureFlags = [
+    "--disable-nautilus" # Do not use nautilus
+    "--enable-introspection"
+  ];
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  preConfigure = with stdenv.lib;
+    optionalString doCheck ''
+      for file in test/*.py; do
+        echo "patching $file"
+        sed '1s,/usr,${python},' -i "$file"
+      done
+    '' + optionalString (recentListSize != null) ''
+      sed -i 's/\(gtk_recent_chooser_set_limit .*\)5)/\1${builtins.toString recentListSize})/' shell/ev-open-recent-action.c
+      sed -i 's/\(if (++n_items == \)5\(.*\)/\1${builtins.toString recentListSize}\2/' shell/ev-window.c
+    '';
+
+  preFixup = ''
+    # Tell Glib/GIO about the MIME info directory, which is used
+    # by `g_file_info_get_content_type ()'.
+    wrapProgram "$out/bin/evince" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3}/share:${shared_mime_info}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+
+  '';
+
+  doCheck = false; # would need pythonPackages.dogTail, which is missing
+
+  meta = with stdenv.lib; {
+    homepage = http://www.gnome.org/projects/evince/;
+    description = "GNOME's document viewer";
+
+    longDescription = ''
+      Evince is a document viewer for multiple document formats.  It
+      currently supports PDF, PostScript, DjVu, TIFF and DVI.  The goal
+      of Evince is to replace the multiple document viewers that exist
+      on the GNOME Desktop with a single simple application.
+    '';
+
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.vcunat ];
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/evince/src.nix b/pkgs/desktops/gnome-3/3.18/core/evince/src.nix
new file mode 100644
index 00000000000..392aeefb4e9
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/evince/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "evince-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/evince/3.18/evince-3.18.0.tar.xz;
+    sha256 = "96e8351f6a6fc5823bb8f51178cde1182bd66481af6fb09bf58a18b673cafa70";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/default.nix b/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/default.nix
new file mode 100644
index 00000000000..fb3c8bdceab
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/default.nix
@@ -0,0 +1,30 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, python
+, intltool, libsoup, libxml2, libsecret, icu, sqlite
+, p11_kit, db, nspr, nss, libical, gperf, makeWrapper, valaSupport ? true, vala }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = with gnome3;
+    [ pkgconfig glib python intltool libsoup libxml2 gtk gnome_online_accounts
+      gcr p11_kit libgweather libgdata gperf makeWrapper icu sqlite gsettings_desktop_schemas ]
+    ++ stdenv.lib.optional valaSupport vala;
+
+  propagatedBuildInputs = [ libsecret nss nspr libical db ];
+
+  # uoa irrelevant for now
+  configureFlags = [ "--disable-uoa" ]
+                   ++ stdenv.lib.optional valaSupport "--enable-vala-bindings";
+
+  preFixup = ''
+    for f in "$out/libexec/"*; do
+      wrapProgram "$f" --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/src.nix b/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/src.nix
new file mode 100644
index 00000000000..876b2236ef5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/evolution-data-server/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "evolution-data-server-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/evolution-data-server/3.18/evolution-data-server-3.18.0.tar.xz;
+    sha256 = "ca4273b888912cadc474c1c2aebd2f02639381a9ddfa516a46cf9abd3dbc11f7";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/folks/default.nix b/pkgs/desktops/gnome-3/3.18/core/folks/default.nix
new file mode 100644
index 00000000000..6e200bdb318
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/folks/default.nix
@@ -0,0 +1,43 @@
+{ fetchurl, stdenv, pkgconfig, glib, gnome3, nspr, intltool
+, vala, sqlite, libxml2, dbus_glib, libsoup, nss, dbus_libs
+, telepathy_glib, evolution_data_server, libsecret, db }:
+
+# TODO: enable more folks backends
+
+let
+  majorVersion = "0.11";
+in
+stdenv.mkDerivation rec {
+  name = "folks-${majorVersion}.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/folks/${majorVersion}/${name}.tar.xz";
+    sha256 = "0q9hny6a38zn0gamv0ji0pn3jw6bpn2i0fr6vbzkhm9h9ws0cqvz";
+  };
+
+  propagatedBuildInputs = [ glib gnome3.libgee sqlite ];
+  # dbus_daemon needed for tests
+  buildInputs = [ dbus_glib telepathy_glib evolution_data_server dbus_libs
+                  vala libsecret libxml2 libsoup nspr nss intltool db ];
+  nativeBuildInputs = [ pkgconfig ];
+
+  configureFlags = "--disable-fatal-warnings";
+
+  NIX_CFLAGS_COMPILE = ["-I${nspr}/include/nspr" "-I${nss}/include/nss"
+                        "-I${dbus_glib}/include/dbus-1.0" "-I${dbus_libs}/include/dbus-1.0"];
+
+  enableParallelBuilding = true;
+
+  postBuild = "rm -rf $out/share/gtk-doc";
+
+  meta = {
+    description = "Folks";
+
+    homepage = https://wiki.gnome.org/Projects/Folks;
+
+    license = stdenv.lib.licenses.lgpl2Plus;
+
+    maintainers = gnome3.maintainers;
+    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gconf/default.nix b/pkgs/desktops/gnome-3/3.18/core/gconf/default.nix
new file mode 100644
index 00000000000..a4cb3e8c146
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gconf/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, pkgconfig, dbus_glib, gnome3 ? null, glib, libxml2
+, intltool, polkit, orbit, withGtk ? false }:
+
+assert withGtk -> (gnome3 != null);
+
+stdenv.mkDerivation rec {
+
+  versionMajor = "3.2";
+  versionMinor = "6";
+  moduleName   = "GConf";
+
+  origName = "${moduleName}-${versionMajor}.${versionMinor}";
+
+  name = "gconf-${versionMajor}.${versionMinor}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${origName}.tar.xz";
+    sha256 = "0k3q9nh53yhc9qxf1zaicz4sk8p3kzq4ndjdsgpaa2db0ccbj4hr";
+  };
+
+  buildInputs = [ libxml2 polkit orbit ] ++ stdenv.lib.optional withGtk gnome3.gtk;
+  propagatedBuildInputs = [ glib dbus_glib  ];
+  nativeBuildInputs = [ pkgconfig intltool ];
+
+  # ToDo: ldap reported as not found but afterwards reported as supported
+
+  meta = with stdenv.lib; {
+    homepage = http://projects.gnome.org/gconf/;
+    description = "A system for storing application preferences";
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gcr/default.nix b/pkgs/desktops/gnome-3/3.18/core/gcr/default.nix
new file mode 100644
index 00000000000..e0e8d1e7338
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gcr/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, intltool, gnupg, p11_kit, glib
+, libgcrypt, libtasn1, dbus_glib, gtk, pango, gdk_pixbuf, atk
+, gobjectIntrospection, makeWrapper, libxslt, vala, gnome3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig intltool gnupg glib gobjectIntrospection libxslt
+    libgcrypt libtasn1 dbus_glib gtk pango gdk_pixbuf atk makeWrapper vala
+  ];
+
+  propagatedBuildInputs = [ p11_kit ];
+
+  #doCheck = true;
+
+  #enableParallelBuilding = true; issues on hydra
+
+  preFixup = ''
+    wrapProgram "$out/bin/gcr-viewer" \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gcr/src.nix b/pkgs/desktops/gnome-3/3.18/core/gcr/src.nix
new file mode 100644
index 00000000000..e2b4ad195ff
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gcr/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gcr-3.16.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gcr/3.16/gcr-3.16.0.tar.xz;
+    sha256 = "ecfe8df41cc88158364bb15addc670b11e539fe844742983629ba2323888d075";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/default.nix b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/default.nix
new file mode 100644
index 00000000000..51b67afb01f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus
+, intltool, accountsservice, libX11, gnome3, systemd, gnome_session
+, gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  name = "gdm-${gnome3.version}.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gdm/${gnome3.version}/${name}.tar.xz";
+    sha256 = "0mhv3q8z208qvhz00zrxlqn7w9gi5vy6w8dpjh5s2ka28l3yhbn3";
+  };
+
+  preConfigure = ''
+    substituteInPlace ./configure --replace "/usr/bin/X" "${xorg.xorgserver}/bin/X"
+    substituteInPlace daemon/gdm-simple-slave.c --replace 'BINDIR "/gnome-session' '"${gnome_session}/bin/gnome-session'
+    substituteInPlace daemon/gdm-launch-environment.c --replace 'BINDIR "/dbus-launch' '"${dbus.tools}/bin/dbus-launch'
+    substituteInPlace data/gdm.conf-custom.in --replace '#WaylandEnable=false' 'WaylandEnable=false'
+    sed 's/#Enable=true/Enable=true/' -i data/gdm.conf-custom.in
+ '';
+
+  configureFlags = [ "--localstatedir=/var" "--with-systemd=yes" "--without-plymouth"
+                     "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
+                     "--with-initial-vt=10" ];
+
+  buildInputs = [ pkgconfig glib itstool libxml2 intltool
+                  accountsservice gnome3.dconf systemd
+                  gobjectIntrospection libX11 gtk
+                  libcanberra_gtk3 pam libtool ];
+
+  #enableParallelBuilding = true; # problems compiling
+
+  # Disable Access Control because our X does not support FamilyServerInterpreted yet
+  patches = [ ./xserver_path.patch ./sessions_dir.patch ./disable_x_access_control.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GDM;
+    description = "A program that manages graphical display servers and handles graphical user logins";
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/disable_x_access_control.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/disable_x_access_control.patch
new file mode 100644
index 00000000000..7691a9e86f0
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/disable_x_access_control.patch
@@ -0,0 +1,15 @@
+--- gdm-3.16.0/daemon/gdm-display.c.orig	2015-04-08 13:53:14.370274369 +0200
++++ gdm-3.16.0/daemon/gdm-display.c	2015-04-08 13:53:36.287520435 +0200
+@@ -1706,9 +1706,10 @@
+ 
+                 gdm_error_trap_push ();
+ 
+-                for (i = 0; i < G_N_ELEMENTS (host_entries); i++) {
++                /*for (i = 0; i < G_N_ELEMENTS (host_entries); i++) {
+                         XAddHost (self->priv->x11_display, &host_entries[i]);
+-                }
++                }*/
++                XDisableAccessControl(self->priv->x11_display);
+ 
+                 XSync (self->priv->x11_display, False);
+                 if (gdm_error_trap_pop ()) {
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/sessions_dir.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/sessions_dir.patch
new file mode 100644
index 00000000000..b8fbad4d731
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/sessions_dir.patch
@@ -0,0 +1,17 @@
+diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
+index f759d2d..d154716 100644
+--- a/daemon/gdm-session.c
++++ b/daemon/gdm-session.c
+@@ -373,9 +373,12 @@ get_system_session_dirs (void)
+ #ifdef ENABLE_WAYLAND_SUPPORT
+                 DATADIR "/wayland-sessions/",
+ #endif
++                NULL,
+                 NULL
+         };
+ 
++        search_dirs[4] = getenv("GDM_SESSIONS_DIR") != NULL ? getenv("GDM_SESSIONS_DIR") : NULL;
++
+         return search_dirs;
+ }
+ 
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/xserver_path.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/xserver_path.patch
new file mode 100644
index 00000000000..b451d129391
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/3.16-wip/xserver_path.patch
@@ -0,0 +1,83 @@
+--- a/daemon/gdm-server.c	2014-07-30 23:00:17.786841724 +0200
++++ b/daemon/gdm-server.c	2014-07-30 23:02:10.491239180 +0200
+@@ -322,7 +322,11 @@
+ fallback:
+ #endif
+ 
+-        server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
++        if (g_getenv("GDM_X_SERVER") != NULL) {
++            server->priv->command = g_strdup (g_getenv("GDM_X_SERVER"));
++        } else {
++            server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
++        }
+ }
+ 
+ static gboolean
+--- gdm-3.16.0/daemon/gdm-x-session.c.orig	2015-04-15 18:44:16.875743928 +0200
++++ gdm-3.16.0/daemon/gdm-x-session.c	2015-04-16 13:34:02.335708638 +0200
+@@ -207,6 +207,8 @@
+         char     *display_fd_string = NULL;
+         char     *vt_string = NULL;
+         char     *display_number;
++        int nixos_argc = 0;
++        char **nixos_argv = NULL;
+         gsize     display_number_size;
+ 
+         auth_file = prepare_auth_file ();
+@@ -236,7 +238,15 @@
+ 
+         display_fd_string = g_strdup_printf ("%d", DISPLAY_FILENO);
+ 
+-        g_ptr_array_add (arguments, X_SERVER);
++        if (g_getenv("GDM_X_SERVER") != NULL) {
++                int i = 0;
++                g_shell_parse_argv(g_getenv("GDM_X_SERVER"), &nixos_argc, &nixos_argv, NULL);
++                for (i = 0; i < nixos_argc; i++) {
++                        g_ptr_array_add (arguments, nixos_argv[i]);
++                }
++        } else {
++                g_ptr_array_add (arguments, X_SERVER);
++        }
+ 
+         if (vt_string != NULL) {
+                 g_ptr_array_add (arguments, vt_string);
+@@ -259,12 +269,12 @@
+         g_ptr_array_add (arguments, "-noreset");
+         g_ptr_array_add (arguments, "-keeptty");
+ 
+-        g_ptr_array_add (arguments, "-verbose");
++        /*g_ptr_array_add (arguments, "-verbose");
+         if (state->debug_enabled) {
+                 g_ptr_array_add (arguments, "7");
+         } else {
+                 g_ptr_array_add (arguments, "3");
+-        }
++        }*/
+ 
+         if (state->debug_enabled) {
+                 g_ptr_array_add (arguments, "-core");
+@@ -275,6 +285,9 @@
+                                                    (const char * const *) arguments->pdata,
+                                                    &error);
+         g_free (display_fd_string);
++        if (nixos_argv) {
++                 g_strfreev (nixos_argv);
++        }
+         g_clear_object (&launcher);
+         g_ptr_array_free (arguments, TRUE);
+ 
+--- gdm-3.16.0/daemon/gdm-session.c.orig	2015-04-16 14:19:01.392802683 +0200
++++ gdm-3.16.0/daemon/gdm-session.c	2015-04-16 14:20:36.012296764 +0200
+@@ -2359,6 +2359,12 @@
+         gchar *desktop_names;
+         const char *locale;
+ 
++        if (g_getenv ("GDM_X_SERVER") != NULL) {
++                gdm_session_set_environment_variable (self,
++                                                      "GDM_X_SERVER",
++                                                      g_getenv ("GDM_X_SERVER"));
++        }
++
+         gdm_session_set_environment_variable (self,
+                                               "GDMSESSION",
+                                               get_session_name (self));
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/default.nix b/pkgs/desktops/gnome-3/3.18/core/gdm/default.nix
new file mode 100644
index 00000000000..1db96965131
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus
+, intltool, accountsservice, libX11, gnome3, systemd, gnome_session
+, gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # Only needed to make it build
+  preConfigure = ''
+    substituteInPlace ./configure --replace "/usr/bin/X" "${xorg.xorgserver}/bin/X"
+  '';
+
+  configureFlags = [ "--sysconfdir=/etc"
+                     "--localstatedir=/var"
+                     "--with-systemd=yes"
+                     "--with-systemdsystemunitdir=$(out)/etc/systemd/system" ];
+
+  buildInputs = [ pkgconfig glib itstool libxml2 intltool
+                  accountsservice gnome3.dconf systemd
+                  gobjectIntrospection libX11 gtk
+                  libcanberra_gtk3 pam libtool ];
+
+  #enableParallelBuilding = true; # problems compiling
+
+  preBuild = ''
+    substituteInPlace daemon/gdm-simple-slave.c --replace 'BINDIR "/gnome-session' '"${gnome_session}/bin/gnome-session'
+  '';
+
+  # Disable Access Control because our X does not support FamilyServerInterpreted yet
+  patches = [ ./xserver_path.patch ./sessions_dir.patch
+              ./disable_x_access_control.patch ./no-dbus-launch.patch ];
+
+  installFlags = [ "sysconfdir=$(out)/etc" "dbusconfdir=$(out)/etc/dbus-1/system.d" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GDM;
+    description = "A program that manages graphical display servers and handles graphical user logins";
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/disable_x_access_control.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/disable_x_access_control.patch
new file mode 100644
index 00000000000..e100e013b78
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/disable_x_access_control.patch
@@ -0,0 +1,13 @@
+--- gdm-3.14.2/daemon/gdm-slave.c.orig	2015-04-16 15:05:27.844353079 +0200
++++ gdm-3.14.2/daemon/gdm-slave.c	2015-04-16 15:05:40.240417915 +0200
+@@ -369,8 +369,9 @@
+                 gdm_error_trap_push ();
+ 
+                 for (i = 0; i < G_N_ELEMENTS (host_entries); i++) {
+-                        XAddHost (slave->priv->server_display, &host_entries[i]);
++                        //XAddHost (slave->priv->server_display, &host_entries[i]);
+                 }
++                XDisableAccessControl(slave->priv->server_display);
+ 
+                 XSync (slave->priv->server_display, False);
+                 if (gdm_error_trap_pop ()) {
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/no-dbus-launch.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/no-dbus-launch.patch
new file mode 100644
index 00000000000..c87554078c7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/no-dbus-launch.patch
@@ -0,0 +1,20 @@
+--- a/daemon/gdm-launch-environment.c	2015-06-22 15:11:07.277474398 +0000
++++ b/daemon/gdm-launch-environment.c	2015-06-22 15:12:31.301157665 +0000
+@@ -48,8 +48,6 @@
+ #include "gdm-session-enum-types.h"
+ #include "gdm-launch-environment.h"
+ 
+-#define DBUS_LAUNCH_COMMAND BINDIR "/dbus-launch --exit-with-session"
+-
+ extern char **environ;
+ 
+ #define GDM_LAUNCH_ENVIRONMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LAUNCH_ENVIRONMENT, GdmLaunchEnvironmentPrivate))
+@@ -512,7 +510,7 @@
+                 gdm_session_select_program (launch_environment->priv->session, launch_environment->priv->command);
+         } else {
+                 /* wrap it in dbus-launch */
+-                char *command = g_strdup_printf ("%s %s", DBUS_LAUNCH_COMMAND, launch_environment->priv->command);
++                char *command = g_strdup (launch_environment->priv->command);
+ 
+                 gdm_session_select_program (launch_environment->priv->session, command);
+                 g_free (command);
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/sessions_dir.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/sessions_dir.patch
new file mode 100644
index 00000000000..b8fbad4d731
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/sessions_dir.patch
@@ -0,0 +1,17 @@
+diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
+index f759d2d..d154716 100644
+--- a/daemon/gdm-session.c
++++ b/daemon/gdm-session.c
+@@ -373,9 +373,12 @@ get_system_session_dirs (void)
+ #ifdef ENABLE_WAYLAND_SUPPORT
+                 DATADIR "/wayland-sessions/",
+ #endif
++                NULL,
+                 NULL
+         };
+ 
++        search_dirs[4] = getenv("GDM_SESSIONS_DIR") != NULL ? getenv("GDM_SESSIONS_DIR") : NULL;
++
+         return search_dirs;
+ }
+ 
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/src.nix b/pkgs/desktops/gnome-3/3.18/core/gdm/src.nix
new file mode 100644
index 00000000000..acd46534e14
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gdm-3.14.2";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gdm/3.14/gdm-3.14.2.tar.xz;
+    sha256 = "e20eb61496161ad95b1058dbf8aea9b7b004df4d0ea6b0fab4401397d9db5930";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gdm/xserver_path.patch b/pkgs/desktops/gnome-3/3.18/core/gdm/xserver_path.patch
new file mode 100644
index 00000000000..412daee9f27
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gdm/xserver_path.patch
@@ -0,0 +1,15 @@
+--- a/daemon/gdm-server.c	2014-07-30 23:00:17.786841724 +0200
++++ b/daemon/gdm-server.c	2014-07-30 23:02:10.491239180 +0200
+@@ -322,7 +322,11 @@
+ fallback:
+ #endif
+ 
+-        server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
++        if (g_getenv("GDM_X_SERVER") != NULL) {
++            server->priv->command = g_strdup (g_getenv("GDM_X_SERVER"));
++        } else {
++            server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
++        }
+ }
+ 
+ static gboolean
diff --git a/pkgs/desktops/gnome-3/3.18/core/geocode-glib/default.nix b/pkgs/desktops/gnome-3/3.18/core/geocode-glib/default.nix
new file mode 100644
index 00000000000..4d75bdc4996
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/geocode-glib/default.nix
@@ -0,0 +1,14 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, intltool, libsoup, json_glib }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = with gnome3;
+    [ intltool pkgconfig glib libsoup json_glib ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/geocode-glib/src.nix b/pkgs/desktops/gnome-3/3.18/core/geocode-glib/src.nix
new file mode 100644
index 00000000000..faaadf5bb91
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/geocode-glib/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "geocode-glib-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/geocode-glib/3.18/geocode-glib-3.18.0.tar.xz;
+    sha256 = "8fb7f0d569e3e6696aaa1fdf275cb3094527ec5e9fa36fd88dd633dfec63495d";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gjs/default.nix b/pkgs/desktops/gnome-3/3.18/core/gjs/default.nix
new file mode 100644
index 00000000000..792e34c7b14
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gjs/default.nix
@@ -0,0 +1,28 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, gtk3, gobjectIntrospection
+, spidermonkey_24, pango, readline, glib, libxml2 }:
+
+let
+  majorVersion = "1.43";
+in
+stdenv.mkDerivation rec {
+  name = "gjs-${majorVersion}.3";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gjs/${majorVersion}/${name}.tar.xz";
+    sha256 = "0khwm8l6m6x71rwf3q92d6scbhmrpiw7kqmj34nn588fb7a4vdc2";
+  };
+
+  buildInputs = [ libxml2 gobjectIntrospection pkgconfig gtk3 glib pango readline ];
+
+  propagatedBuildInputs = [ spidermonkey_24 ];
+
+  postInstall = ''
+    sed 's|-lreadline|-L${readline}/lib -lreadline|g' -i $out/lib/libgjs.la
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = gnome3.maintainers;
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/default.nix
new file mode 100644
index 00000000000..32d6d6e7535
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/default.nix
@@ -0,0 +1,12 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, intltool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  nativeBuildInputs = [ pkgconfig intltool ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/src.nix
new file mode 100644
index 00000000000..b191826a2d0
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-backgrounds/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-backgrounds-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-backgrounds/3.18/gnome-backgrounds-3.18.0.tar.xz;
+    sha256 = "aa560f0e5f12a308dd36aaac2fff32916abd61d42f47b4bc42c8c7011bf2a7b9";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/default.nix
new file mode 100644
index 00000000000..7fae0b5c67f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, gnome3, pkgconfig, gtk3, intltool, glib
+, udev, itstool, libxml2, makeWrapper, libnotify, libcanberra_gtk3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig intltool glib gtk3 udev libxml2 gnome3.defaultIconTheme
+                  makeWrapper gnome3.gsettings_desktop_schemas itstool
+                  libnotify libcanberra_gtk3 ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/bluetooth-sendto" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://help.gnome.org/users/gnome-bluetooth/stable/index.html.en;
+    description = "Application that let you manage Bluetooth in the GNOME destkop";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/src.nix
new file mode 100644
index 00000000000..eb5f6149976
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-bluetooth/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-bluetooth-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-bluetooth/3.18/gnome-bluetooth-3.18.0.tar.xz;
+    sha256 = "f5c0d43226c4ec6a545dddb86181adadbc2b5cf720b640026003b9660fba0b8f";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/default.nix
new file mode 100644
index 00000000000..7ca66863d86
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, intltool, fetchurl, pkgconfig, libxml2
+, bash, gtk3, glib, makeWrapper
+, itstool, gnome3, librsvg, gdk_pixbuf, mpfr, gmp }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ bash pkgconfig gtk3 glib intltool itstool
+                  libxml2 gnome3.gtksourceview mpfr gmp
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-calculator" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Apps/Calculator;
+    description = "Application that solves mathematical equations and is suitable as a default application in a Desktop environment";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/src.nix
new file mode 100644
index 00000000000..42fc4667087
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-calculator-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-calculator/3.18/gnome-calculator-3.18.0.tar.xz;
+    sha256 = "54dc40de68b118c06b443f9d8a56397425434a45dddbb2daba7b720b77b35672";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-common/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-common/default.nix
new file mode 100644
index 00000000000..f9261e183ef
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-common/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl, which, gnome3, autoconf, automake }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  patches = [(fetchurl {
+    name = "gnome-common-patch";
+    url = "https://bug697543.bugzilla-attachments.gnome.org/attachment.cgi?id=240935";
+    sha256 = "17abp7czfzirjm7qsn2czd03hdv9kbyhk3lkjxg2xsf5fky7z7jl";
+  })];
+
+  propagatedBuildInputs = [ which autoconf automake ]; # autogen.sh which is using gnome_common tends to require which
+
+  meta = with stdenv.lib; {
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-common/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-common/src.nix
new file mode 100644
index 00000000000..8ffe7e20e1a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-common/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-common-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-common/3.18/gnome-common-3.18.0.tar.xz;
+    sha256 = "22569e370ae755e04527b76328befc4c73b62bfd4a572499fde116b8318af8cf";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/default.nix
new file mode 100644
index 00000000000..6ec3c7871bb
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, intltool, fetchurl, evolution_data_server, db
+, pkgconfig, gtk3, glib, libsecret
+, libchamplain, clutter_gtk, geocode_glib
+, bash, makeWrapper, itstool, folks, libnotify, libxml2
+, gnome3, librsvg, gdk_pixbuf, file, telepathy_glib, nspr, nss
+, libsoup, vala, dbus_glib, automake115x, autoconf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard evolution_data_server ];
+
+  # force build from vala
+  preBuild = ''
+   touch src/*.vala
+  '';
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool evolution_data_server
+                  gnome3.gsettings_desktop_schemas makeWrapper file libnotify
+                  folks gnome3.gnome_desktop telepathy_glib libsecret dbus_glib
+                  libxml2 libsoup gnome3.gnome_online_accounts nspr nss
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  libchamplain clutter_gtk geocode_glib
+                  vala automake115x autoconf db ];
+
+  preFixup = ''
+    for f in "$out/bin/gnome-contacts" "$out/libexec/gnome-contacts-search-provider"; do
+      wrapProgram $f \
+        --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+        --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  patches = [ ./gio_unix.patch ];
+
+  patchFlags = "-p0";
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Contacts;
+    description = "Contacts is GNOME's integrated address book";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/gio_unix.patch b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/gio_unix.patch
new file mode 100644
index 00000000000..f1b3d3c94ac
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/gio_unix.patch
@@ -0,0 +1,10 @@
+--- configure.ac.orig	2015-04-09 18:45:50.581232289 +0200
++++ configure.ac	2015-04-09 18:45:59.744280137 +0200
+@@ -54,6 +54,7 @@
+ 	     champlain-0.12
+ 	     clutter-gtk-1.0
+ 	     geocode-glib-1.0 >= 3.15.3
++	     gio-unix-2.0
+ 	     "
+ PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
+ 
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/src.nix
new file mode 100644
index 00000000000..94fcfb85fdf
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-contacts/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-contacts-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-contacts/3.18/gnome-contacts-3.18.0.tar.xz;
+    sha256 = "c81ad739a1f554e4c89979564565e32ceaf1d2cc6c93a6a75d929d7d1fe8e287";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/default.nix
new file mode 100644
index 00000000000..eab991f90a2
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/default.nix
@@ -0,0 +1,59 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, ibus, intltool, upower, makeWrapper
+, libcanberra, libcanberra_gtk3, accountsservice, libpwquality, libpulseaudio
+, gdk_pixbuf, librsvg, libxkbfile, libnotify, libgudev
+, libxml2, polkit, libxslt, libgtop, libsoup, colord, colord-gtk
+, cracklib, python, libkrb5, networkmanagerapplet, networkmanager
+, libwacom, samba, shared_mime_info, tzdata, icu, libtool, udev
+, docbook_xsl, docbook_xsl_ns, modemmanager, clutter, clutter_gtk
+, fontconfig, sound-theme-freedesktop }:
+
+# http://ftp.gnome.org/pub/GNOME/teams/releng/3.10.2/gnome-suites-core-3.10.2.modules
+# TODO: bluetooth, wacom, printers
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs =
+    [ gnome3.gnome_themes_standard gnome3.libgnomekbd ];
+
+  # https://bugzilla.gnome.org/show_bug.cgi?id=752596
+  enableParallelBuilding = false;
+
+  buildInputs = with gnome3;
+    [ pkgconfig intltool ibus gtk glib upower libcanberra gsettings_desktop_schemas
+      libxml2 gnome_desktop gnome_settings_daemon polkit libxslt libgtop gnome-menus
+      gnome_online_accounts libsoup colord libpulseaudio fontconfig colord-gtk libpwquality
+      accountsservice libkrb5 networkmanagerapplet libwacom samba libnotify libxkbfile
+      shared_mime_info icu libtool docbook_xsl docbook_xsl_ns gnome3.grilo
+      gdk_pixbuf gnome3.defaultIconTheme librsvg clutter clutter_gtk
+      gnome3.vino udev libcanberra_gtk3 libgudev
+      networkmanager modemmanager makeWrapper gnome3.gnome-bluetooth ];
+
+  preBuild = ''
+    substituteInPlace tz.h --replace "/usr/share/zoneinfo/zone.tab" "${tzdata}/share/zoneinfo/zone.tab"
+    substituteInPlace panels/datetime/tz.h --replace "/usr/share/zoneinfo/zone.tab" "${tzdata}/share/zoneinfo/zone.tab"
+
+    # hack to make test-endianess happy
+    mkdir -p $out/share/locale
+    substituteInPlace panels/datetime/test-endianess.c --replace "/usr/share/locale/" "$out/share/locale/"
+  '';
+
+  patches = [ ./vpn_plugins_path.patch ];
+
+  preFixup = with gnome3; ''
+    wrapProgram $out/bin/gnome-control-center \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:${sound-theme-freedesktop}/share:$out/share:$out/share/gnome-control-center:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    for i in $out/share/applications/*; do
+      substituteInPlace $i --replace "gnome-control-center" "$out/bin/gnome-control-center"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Utilities to configure the GNOME desktop";
+    license = licenses.gpl2Plus;
+    maintainers = gnome3.maintainers;
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/src.nix
new file mode 100644
index 00000000000..f87859fe51f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-control-center-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-control-center/3.18/gnome-control-center-3.18.0.tar.xz;
+    sha256 = "42648eda11fc1df0f717d7d3b385cb7c519fdd084ed4e3fad2e55fd11712fb52";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/vpn_plugins_path.patch b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/vpn_plugins_path.patch
new file mode 100644
index 00000000000..e25105a303f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-control-center/vpn_plugins_path.patch
@@ -0,0 +1,19 @@
+diff --git a/panels/network/connection-editor/vpn-helpers.c b/panels/network/connection-editor/vpn-helpers.c
+index 7dc23c2..fcb1384 100644
+--- a/panels/network/connection-editor/vpn-helpers.c
++++ b/panels/network/connection-editor/vpn-helpers.c
+@@ -95,14 +95,6 @@ vpn_get_plugins (GError **error)
+ 		if (!so_path)
+ 			goto next;
+ 
+-		/* Remove any path and extension components, then reconstruct path
+-		 * to the SO in LIBDIR
+-		 */
+-		so_name = g_path_get_basename (so_path);
+-		g_free (so_path);
+-		so_path = g_build_filename (NM_VPN_MODULE_DIR, so_name, NULL);
+-		g_free (so_name);
+-
+ 		module = g_module_open (so_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ 		if (!module) {
+ 			g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Cannot load the VPN plugin which provides the "
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/default.nix
new file mode 100644
index 00000000000..bf0ccd0224e
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, python, libxml2Python, libxslt, which, libX11, gnome3, gtk3, glib
+, intltool, gnome_doc_utils, libxkbfile, xkeyboard_config, isocodes, itstool, wayland
+, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # this should probably be setuphook for glib
+  NIX_CFLAGS_COMPILE = "-I${glib}/include/gio-unix-2.0";
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ pkgconfig python libxml2Python libxslt which libX11
+                  xkeyboard_config isocodes itstool wayland
+                  gtk3 glib intltool gnome_doc_utils libxkbfile
+                  gobjectIntrospection ];
+
+  propagatedBuildInputs = [ gnome3.gsettings_desktop_schemas ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/src.nix
new file mode 100644
index 00000000000..84fbb8ebdff
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-desktop/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-desktop-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-desktop/3.18/gnome-desktop-3.18.0.tar.xz;
+    sha256 = "44c806b16ea7d38bdc0e6343f2cb6be97afd7f64490f30c0cb5c3373e89a9d44";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/default.nix
new file mode 100644
index 00000000000..1d1f9d18c56
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, intltool, fetchurl
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, libxml2
+, gnome3, librsvg, gdk_pixbuf, file }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+  propagatedBuildInputs = [ gdk_pixbuf gnome3.defaultIconTheme librsvg ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2 file
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-dictionary" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gtk3}/share:${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Dictionary;
+    description = "Dictionary is the GNOME application to look up definitions";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/src.nix
new file mode 100644
index 00000000000..9e3660f207b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-dictionary/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-dictionary-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-dictionary/3.18/gnome-dictionary-3.18.0.tar.xz;
+    sha256 = "5338962124f6d784920ed4968d98734a7589513b36e4f4a6ff00d1ed5afb4ead";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/default.nix
new file mode 100644
index 00000000000..3f9f653bdba
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, intltool, fetchurl, pkgconfig, udisks2, libsecret, libdvdread
+, bash, gtk3, glib, makeWrapper, cracklib, libnotify
+, itstool, gnome3, librsvg, gdk_pixbuf, libxml2, python
+, libcanberra_gtk3, libxslt, libtool, docbook_xsl, libpwquality }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ bash pkgconfig gtk3 glib intltool itstool
+                  libxslt libtool libsecret libpwquality cracklib
+                  libnotify libdvdread libcanberra_gtk3 docbook_xsl
+                  gdk_pixbuf gnome3.defaultIconTheme
+                  librsvg udisks2 gnome3.gnome_settings_daemon
+                  gnome3.gsettings_desktop_schemas makeWrapper libxml2 ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-disks" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://en.wikipedia.org/wiki/GNOME_Disks;
+    description = "A udisks graphical front-end";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/src.nix
new file mode 100644
index 00000000000..29589586625
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-disk-utility/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-disk-utility-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-disk-utility/3.18/gnome-disk-utility-3.18.0.tar.xz;
+    sha256 = "e7363107e40fb1e7fb9f65e37194c0e8da3928f9ec35a4b27a5c439c64e51686";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/default.nix
new file mode 100644
index 00000000000..54767dbc4c5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, intltool, fetchurl
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool
+, gnome3, librsvg, gdk_pixbuf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool gnome3.gnome_desktop
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-font-viewer" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Program that can preview fonts and create thumbnails for fonts";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/src.nix
new file mode 100644
index 00000000000..256890e8079
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-font-viewer/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-font-viewer-3.16.2";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-font-viewer/3.16/gnome-font-viewer-3.16.2.tar.xz;
+    sha256 = "f5367417d926d1dbe175aceb8eb4d2733d723a237428f130edd4b4023c0dc1cf";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/default.nix
new file mode 100644
index 00000000000..8e755383dd6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, pkgconfig, dbus, libgcrypt, libtasn1, pam, python, glib, libxslt
+, intltool, pango, gcr, gdk_pixbuf, atk, p11_kit, makeWrapper
+, docbook_xsl_ns, docbook_xsl, gnome3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = with gnome3; [
+    dbus libgcrypt pam python gtk3 gconf libgnome_keyring
+    pango gcr gdk_pixbuf atk p11_kit makeWrapper
+  ];
+
+  propagatedBuildInputs = [ glib libtasn1 libxslt ];
+
+  nativeBuildInputs = [ pkgconfig intltool docbook_xsl_ns docbook_xsl ];
+
+  configureFlags = [
+    "--with-ca-certificates=/etc/ssl/certs/ca-certificates.crt" # NixOS hardcoded path
+    "--with-pkcs11-config=$$out/etc/pkcs11/" # installation directories
+    "--with-pkcs11-modules=$$out/lib/pkcs11/"
+  ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-keyring" \
+      --prefix XDG_DATA_DIRS : "${glib}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+    wrapProgram "$out/bin/gnome-keyring-daemon" \
+      --prefix XDG_DATA_DIRS : "${glib}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/src.nix
new file mode 100644
index 00000000000..ccd1488fd30
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-keyring/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-keyring-3.16.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-keyring/3.16/gnome-keyring-3.16.0.tar.xz;
+    sha256 = "15a3bb8c53855a4ff0dbbdfbe4ec3df206c32048f50bdc76a51f8e3e14ece1f5";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-menus/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-menus/default.nix
new file mode 100644
index 00000000000..90209634fbf
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-menus/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, intltool, pkgconfig, glib, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  name = "gnome-menus-${version}";
+  version = "3.10.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gnome-menus/3.10/${name}.tar.xz";
+    sha256 = "0wcacs1vk3pld8wvrwq7fdrm11i56nrajkrp6j1da6jc4yx0m5a6";
+  };
+
+  makeFlags = "INTROSPECTION_GIRDIR=$(out)/share/gir-1.0/ INTROSPECTION_TYPELIBDIR=$(out)/lib/girepository-1.0";
+
+  buildInputs = [ intltool pkgconfig glib gobjectIntrospection ];
+
+  meta = {
+    homepage = "http://www.gnome.org";
+    description = "Gnome menu specification";
+
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/default.nix
new file mode 100644
index 00000000000..d810fbb862b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, pkgconfig, glib, libxslt, gtk, makeWrapper
+, webkitgtk, json_glib, rest, libsecret, dbus_glib, gnome_common
+, telepathy_glib, intltool, dbus_libs, icu, autoreconfHook
+, libsoup, docbook_xsl_ns, docbook_xsl, gnome3
+}:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  NIX_CFLAGS_COMPILE = "-I${dbus_glib}/include/dbus-1.0 -I${dbus_libs}/include/dbus-1.0";
+
+  enableParallelBuilding = true;
+
+  preAutoreconf = ''
+    sed '/disable-settings/d' -i configure.ac
+    sed "/if HAVE_INTROSPECTION/a INTROSPECTION_COMPILER_ARGS = --shared-library=$out/lib/libgoa-1.0.so" -i src/goa/Makefile.am
+  '';
+
+  buildInputs = [ pkgconfig glib libxslt gtk webkitgtk json_glib rest gnome_common makeWrapper
+                  libsecret dbus_glib telepathy_glib intltool icu libsoup autoreconfHook
+                  docbook_xsl_ns docbook_xsl gnome3.defaultIconTheme ];
+
+  preFixup = ''
+    for f in "$out/libexec/"*; do
+      wrapProgram "$f" --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/src.nix
new file mode 100644
index 00000000000..3038209042e
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-online-accounts/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-online-accounts-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-online-accounts/3.18/gnome-online-accounts-3.18.0.tar.xz;
+    sha256 = "fc2dac96551746576759bd14f9b322bae1dd0aeedc0e755065ddf5eaaefacd34";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-online-miners/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-online-miners/default.nix
new file mode 100644
index 00000000000..4c879b75098
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-online-miners/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, pkgconfig, glib, gnome3, libxml2
+, libsoup, json_glib, gmp, openssl, makeWrapper }:
+
+let
+  majVer = "3.14";
+in stdenv.mkDerivation rec {
+  name = "gnome-online-miners-${majVer}.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gnome-online-miners/${majVer}/${name}.tar.xz";
+    sha256 = "0bbak8srcrvnw18s4ls5mqaamx9nqdi93lij6yjs0a3q320k22xl";
+  };
+
+  doCheck = true;
+
+  buildInputs = [ pkgconfig glib gnome3.libgdata libxml2 libsoup gmp openssl
+                  gnome3.grilo gnome3.libzapojit gnome3.grilo-plugins
+                  gnome3.gnome_online_accounts makeWrapper gnome3.libmediaart
+                  gnome3.tracker gnome3.gfbgraph json_glib gnome3.rest ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    for f in $out/libexec/*; do
+      wrapProgram "$f" \
+        --prefix GRL_PLUGIN_PATH : "${gnome3.grilo-plugins}/lib/grilo-0.2"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GnomeOnlineMiners;
+    description = "A set of crawlers that go through your online content and index them locally in Tracker";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/default.nix
new file mode 100644
index 00000000000..763fc990bda
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, intltool, fetchurl, pkgconfig, libcanberra_gtk3
+, bash, gtk3, glib, makeWrapper
+, itstool, gnome3, librsvg, gdk_pixbuf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+  propagatedBuildInputs = [ gdk_pixbuf gnome3.defaultIconTheme librsvg ];
+
+  buildInputs = [ bash pkgconfig gtk3 glib intltool itstool libcanberra_gtk3
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-screenshot" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gtk3}/share:${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://en.wikipedia.org/wiki/GNOME_Screenshot;
+    description = "Utility used in the GNOME desktop environment for taking screenshots";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/src.nix
new file mode 100644
index 00000000000..af6007fa233
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-screenshot/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-screenshot-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-screenshot/3.18/gnome-screenshot-3.18.0.tar.xz;
+    sha256 = "eba64dbf4acf0ab8222fec549d0a4f2dd7dbd51c255e7978dedf1f5c06a98841";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-session/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-session/default.nix
new file mode 100644
index 00000000000..dedad0729d1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-session/default.nix
@@ -0,0 +1,25 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, glib, dbus_glib, json_glib, upower
+, libxslt, intltool, makeWrapper, systemd, xorg }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  configureFlags = "--enable-systemd";
+
+  buildInputs = with gnome3;
+    [ pkgconfig glib gnome_desktop gtk dbus_glib json_glib libxslt 
+      gnome3.gnome_settings_daemon xorg.xtrans gnome3.defaultIconTheme
+      gsettings_desktop_schemas upower intltool gconf makeWrapper systemd ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-session" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --suffix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-session/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-session/src.nix
new file mode 100644
index 00000000000..211cc140a88
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-session/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-session-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-session/3.18/gnome-session-3.18.0.tar.xz;
+    sha256 = "ba23d0e41e90f238103835603eded0f30a7cc56506b68168899377785aec706f";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/default.nix
new file mode 100644
index 00000000000..99e1f596f18
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, intltool, glib, libnotify, lcms2, libXtst
+, libxkbfile, libpulseaudio, libcanberra_gtk3, upower, colord, libgweather, polkit
+, geoclue2, librsvg, xf86_input_wacom, udev, libgudev, libwacom, libxslt, libtool, networkmanager
+, docbook_xsl, docbook_xsl_ns, makeWrapper, ibus, xkeyboard_config }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # fatal error: gio/gunixfdlist.h: No such file or directory
+  NIX_CFLAGS_COMPILE = "-I${glib}/include/gio-unix-2.0";
+
+  buildInputs = with gnome3;
+    [ intltool pkgconfig ibus gtk glib gsettings_desktop_schemas networkmanager
+      libnotify gnome_desktop lcms2 libXtst libxkbfile libpulseaudio
+      libcanberra_gtk3 upower colord libgweather xkeyboard_config
+      polkit geocode_glib geoclue2 librsvg xf86_input_wacom udev libgudev libwacom libxslt
+      libtool docbook_xsl docbook_xsl_ns makeWrapper gnome_themes_standard ];
+
+  preFixup = ''
+    wrapProgram "$out/libexec/gnome-settings-daemon-localeexec" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --prefix PATH : "${glib}/bin" \
+      --prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/src.nix
new file mode 100644
index 00000000000..d7b459ae0ea
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-settings-daemon/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-settings-daemon-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-settings-daemon/3.18/gnome-settings-daemon-3.18.0.tar.xz;
+    sha256 = "8d3ef9c18538831ed89122fee0bdaca68b0e482a18b3c4388c4e672aba1b3cd5";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/default.nix
new file mode 100644
index 00000000000..e9eae87f14e
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, intltool, fetchurl, libgtop, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, gnome3, file }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  buildInputs = [ pkgconfig gtk3 glib libgtop intltool itstool
+                  makeWrapper file ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GnomeShell/Extensions;
+    description = "Modify and extend GNOME Shell functionality and behavior";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/src.nix
new file mode 100644
index 00000000000..ed51bc4b200
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-shell-extensions/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-shell-extensions-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-shell-extensions/3.18/gnome-shell-extensions-3.18.0.tar.xz;
+    sha256 = "a5fb88004b021e4a16f4fa5eb3d7d6f0903db1288023c18c0f9825152fa0f5f7";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-shell/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-shell/default.nix
new file mode 100644
index 00000000000..899efc5443b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-shell/default.nix
@@ -0,0 +1,57 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, json_glib, libcroco, intltool, libsecret
+, python3, libsoup, polkit, clutter, networkmanager, docbook_xsl, docbook_xsl_ns, at_spi2_core
+, libstartup_notification, telepathy_glib, telepathy_logger, libXtst, p11_kit, unzip
+, sqlite, libgweather, libcanberra_gtk3
+, libpulseaudio, libical, libtool, nss, gobjectIntrospection, gstreamer, makeWrapper
+, accountsservice, gdk_pixbuf, gdm, upower, ibus, networkmanagerapplet, librsvg }:
+
+# http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/gnome-base/gnome-shell/gnome-shell-3.10.2.1.ebuild?revision=1.3&view=markup
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # Needed to find /etc/NetworkManager/VPN
+  configureFlags = [ "--sysconfdir=/etc" ];
+
+  buildInputs = with gnome3;
+    [ gsettings_desktop_schemas gnome_keyring gnome-menus glib gcr json_glib accountsservice
+      libcroco intltool libsecret pkgconfig python3 libsoup polkit libcanberra gdk_pixbuf librsvg
+      clutter networkmanager libstartup_notification telepathy_glib docbook_xsl docbook_xsl_ns
+      libXtst p11_kit networkmanagerapplet gjs mutter libpulseaudio caribou evolution_data_server
+      libical libtool nss gobjectIntrospection gtk gstreamer makeWrapper gdm
+      libcanberra_gtk3 gnome_control_center
+      defaultIconTheme sqlite gnome3.gnome-bluetooth
+      libgweather # not declared at build time, but typelib is needed at runtime
+      gnome3.gnome-clocks # schemas needed
+      at_spi2_core upower ibus gnome_session gnome_desktop telepathy_logger gnome3.gnome_settings_daemon ];
+
+  installFlags = [ "keysdir=$(out)/share/gnome-control-center/keybindings" ];
+
+  preBuild = ''
+    patchShebangs src/data-to-c.pl
+    substituteInPlace data/Makefile --replace " install-keysDATA" ""
+  '';
+
+  preFixup = with gnome3; ''
+    wrapProgram "$out/bin/gnome-shell" \
+      --prefix PATH : "${unzip}/bin" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --suffix XDG_DATA_DIRS : "${gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+
+    wrapProgram "$out/libexec/gnome-shell-calendar-server" \
+      --prefix XDG_DATA_DIRS : "${evolution_data_server}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+
+    echo "${unzip}/bin" > $out/${passthru.mozillaPlugin}/extra-bin-path
+  '';
+
+  passthru = {
+    mozillaPlugin = "/lib/mozilla/plugins";
+  };
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-shell/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-shell/src.nix
new file mode 100644
index 00000000000..340a2e67252
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-shell/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-shell-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-shell/3.18/gnome-shell-3.18.0.tar.xz;
+    sha256 = "1f0f276c45c0979c72700121cb0f711aea343c4393eb3d5ddd6b311d8dc83c99";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-system-log/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-system-log/default.nix
new file mode 100644
index 00000000000..716f92a072d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-system-log/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, intltool, fetchurl, pkgconfig
+, bash, gtk3, glib, makeWrapper
+, itstool, gnome3, librsvg, gdk_pixbuf, libxml2 }:
+
+stdenv.mkDerivation rec {
+  name = "gnome-system-log-3.9.90";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gnome-system-log/3.9/${name}.tar.xz";
+    sha256 = "9eeb51982d347aa7b33703031e2c1d8084201374665425cd62199649b29a5411";
+  };
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+  propagatedBuildInputs = [ gdk_pixbuf gnome3.defaultIconTheme librsvg ];
+
+  buildInputs = [ bash pkgconfig gtk3 glib intltool itstool
+                  gnome3.gsettings_desktop_schemas makeWrapper libxml2 ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-system-log" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gtk3}/share:${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://help.gnome.org/users/gnome-system-log/3.9/;
+    description = "Graphical, menu-driven viewer that you can use to view and monitor your system logs";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/default.nix
new file mode 100644
index 00000000000..bdbdefecf22
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, intltool, fetchurl, pkgconfig, gtkmm3, libxml2
+, bash, gtk3, glib, makeWrapper
+, itstool, gnome3, librsvg, gdk_pixbuf, libgtop }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ bash pkgconfig gtk3 glib intltool itstool libxml2
+                  gtkmm3 libgtop makeWrapper
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  gnome3.gsettings_desktop_schemas ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-system-monitor" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://help.gnome.org/users/gnome-system-monitor/3.12/;
+    description = "System Monitor shows you what programs are running and how much processor time, memory, and disk space are being used";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/src.nix
new file mode 100644
index 00000000000..a4c87752e78
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-system-monitor/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-system-monitor-3.18.0.1";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-system-monitor/3.18/gnome-system-monitor-3.18.0.1.tar.xz;
+    sha256 = "71ff8db2fa3eb53d8f54ffd612c6679b231a9d69c13adb91cf63421425953b10";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/default.nix
new file mode 100644
index 00000000000..3bbb25ca5c1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, cairo, libxml2, gnome3, pango
+, gnome_doc_utils, intltool, libX11, which, libuuid, vala
+, desktop_file_utils, itstool, makeWrapper, appdata-tools }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ gnome3.gtk gnome3.gsettings_desktop_schemas gnome3.vte appdata-tools
+                  gnome3.dconf itstool makeWrapper gnome3.nautilus vala ];
+
+  nativeBuildInputs = [ pkgconfig intltool gnome_doc_utils which libuuid libxml2 desktop_file_utils ];
+
+  # FIXME: enable for gnome3
+  configureFlags = [ "--disable-search-provider" "--disable-migration" ];
+
+  preFixup = ''
+    for f in "$out/libexec/gnome-terminal-server"; do
+      wrapProgram "$f" \
+        --prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH" \
+        --prefix GIO_EXTRA_MODULES : "${gnome3.dconf}/lib/gio/modules"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/src.nix
new file mode 100644
index 00000000000..dff213cc389
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-terminal/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-terminal-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-terminal/3.18/gnome-terminal-3.18.0.tar.xz;
+    sha256 = "776642502b57b7a6b5f099291b660c0b4a4ff2b3024d15a2f5b33c4286c9dce6";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/default.nix
new file mode 100644
index 00000000000..a33252a934c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/default.nix
@@ -0,0 +1,14 @@
+{ stdenv, fetchurl, intltool, gtk3, gnome3, librsvg, pkgconfig, pango, atk, gtk2
+, gdk_pixbuf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+  
+  buildInputs = [ intltool gtk3 librsvg pkgconfig pango atk gtk2 gdk_pixbuf
+                  gnome3.defaultIconTheme ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/src.nix
new file mode 100644
index 00000000000..c352242537a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-themes-standard/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-themes-standard-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-themes-standard/3.18/gnome-themes-standard-3.18.0.tar.xz;
+    sha256 = "e646eb04c225282b7df7fff65741adaad4cf9ed2c12616b7310e7edd27d2bacb";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/default.nix
new file mode 100644
index 00000000000..4f02673e036
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, fetchurl, pkgconfig, file, gnome3, itstool, libxml2, intltool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gnome3.yelp itstool libxml2 intltool ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://help.gnome.org/users/gnome-help/${gnome3.version}";
+    description = "User and system administration help for the GNOME desktop";
+    maintainers = gnome3.maintainers;
+    license = licenses.cc-by-30;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/src.nix
new file mode 100644
index 00000000000..0187516061b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-user-docs/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-user-docs-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-user-docs/3.18/gnome-user-docs-3.18.0.tar.xz;
+    sha256 = "c515d2c8b051ffb05ec497e4231d1ceecec824dc4fca45425d21295bb592e952";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/default.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/default.nix
new file mode 100644
index 00000000000..49ad40912c6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/default.nix
@@ -0,0 +1,45 @@
+{ stdenv, intltool, fetchurl, apacheHttpd_2_2, nautilus
+, pkgconfig, gtk3, glib, libxml2, gnused
+, bash, makeWrapper, itstool, libnotify, libtool, mod_dnssd
+, gnome3, librsvg, gdk_pixbuf, file, libcanberra_gtk3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  preConfigure = ''
+    sed -e 's,^LoadModule dnssd_module.\+,LoadModule dnssd_module ${mod_dnssd}/modules/mod_dnssd.so,' -i data/dav_user_2.2.conf 
+  '';
+
+  configureFlags = [ "--with-httpd=${apacheHttpd_2_2}/bin/httpd"
+                     "--with-modules-path=${apacheHttpd_2_2}/modules"
+                     "--disable-bluetooth"
+                     "--with-nautilusdir=$(out)/lib/nautilus/extensions-3.0" ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2 libtool
+                  makeWrapper file gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  nautilus libnotify libcanberra_gtk3 ];
+
+  postInstall = ''
+    mkdir -p $out/share/gsettings-schemas/$name
+    mv $out/share/glib-2.0 $out/share/gsettings-schemas/$name
+    ${glib}/bin/glib-compile-schemas $out/share/gsettings-schemas/$name/glib-2.0/schemas
+  '';
+
+  preFixup = ''
+    wrapProgram "$out/libexec/gnome-user-share-webdav" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://help.gnome.org/users/gnome-user-share/3.8;
+    description = "Service that exports the contents of the Public folder in your home directory on the local network";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/src.nix b/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/src.nix
new file mode 100644
index 00000000000..e0a283d896d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gnome-user-share/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-user-share-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-user-share/3.18/gnome-user-share-3.18.0.tar.xz;
+    sha256 = "feb3bed59193eafea31f563ed7eab5f066aa5f86d4a89f067b162653d168d3fc";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/grilo-plugins/default.nix b/pkgs/desktops/gnome-3/3.18/core/grilo-plugins/default.nix
new file mode 100644
index 00000000000..a236238c257
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/grilo-plugins/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, pkgconfig, file, intltool, glib, sqlite
+, gnome3, libxml2, gupnp, gssdp, lua5, liboauth, gupnp_av
+, gmime, json_glib, avahi, tracker, itstool }:
+
+stdenv.mkDerivation rec {
+  name = "grilo-plugins-0.2.13";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/grilo-plugins/0.2/${name}.tar.xz";
+    sha256 = "008jwm5ydl0k25p3d2fkcail40fj9y3qknihxb5fg941p8qlhm55";
+  };
+
+  installFlags = [ "GRL_PLUGINS_DIR=$(out)/lib/grilo-0.2" ];
+
+  buildInputs = [ pkgconfig gnome3.grilo libxml2 gupnp gssdp gnome3.libgdata
+                  lua5 liboauth gupnp_av sqlite gnome3.gnome_online_accounts
+                  gnome3.totem-pl-parser gnome3.rest gmime json_glib
+                  avahi gnome3.libmediaart tracker intltool itstool ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Projects/Grilo;
+    description = "A collection of plugins for the Grilo framework";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/grilo/default.nix b/pkgs/desktops/gnome-3/3.18/core/grilo/default.nix
new file mode 100644
index 00000000000..16dfb638a24
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/grilo/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, pkgconfig, file, intltool, glib
+, libxml2, gnome3, gobjectIntrospection, libsoup }:
+
+stdenv.mkDerivation rec {
+  name = "grilo-0.2.12";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/grilo/0.2/${name}.tar.xz";
+    sha256 = "11bvc7rsrjjwz8hp67p3fn8zmywrpawrcbi3vgw8b0dwa0sndd2m";
+  };
+
+  setupHook = ./setup-hook.sh;
+
+  configureFlags = [ "--enable-grl-pls" "--enable-grl-net" ];
+
+  preConfigure = ''
+    for f in src/Makefile.in libs/pls/Makefile.in libs/net/Makefile.in; do
+       substituteInPlace $f --replace @INTROSPECTION_GIRDIR@ "$out/share/gir-1.0/"
+       substituteInPlace $f --replace @INTROSPECTION_TYPELIBDIR@ "$out/lib/girepository-1.0"
+    done
+  '';
+
+  buildInputs = [ pkgconfig file intltool glib libxml2 libsoup
+                  gnome3.totem-pl-parser gobjectIntrospection ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Projects/Grilo;
+    description = "Framework that provides access to various sources of multimedia content, using a pluggable system";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/grilo/setup-hook.sh b/pkgs/desktops/gnome-3/3.18/core/grilo/setup-hook.sh
new file mode 100644
index 00000000000..bc93dddec38
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/grilo/setup-hook.sh
@@ -0,0 +1,7 @@
+make_grilo_find_plugins() {
+    if [ -d "$1"/lib/grilo-0.2 ]; then
+        addToSearchPath GRL_PLUGIN_PATH "$1/lib/grilo-0.2"
+    fi
+}
+
+envHooks+=(make_grilo_find_plugins)
diff --git a/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/default.nix b/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/default.nix
new file mode 100644
index 00000000000..5123cadbdaf
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, intltool, glib, gobjectIntrospection
+  # just for passthru
+, gnome3, gtk3, gsettings_desktop_schemas }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  postPatch = ''
+    for file in "background" "screensaver"; do
+      substituteInPlace "schemas/org.gnome.desktop.$file.gschema.xml.in" \
+        --replace "@datadir@" "${gnome3.gnome-backgrounds}/share/"
+    done
+  '';
+
+  buildInputs = [ glib gobjectIntrospection ];
+
+  nativeBuildInputs = [ pkgconfig intltool ];
+
+  meta = with stdenv.lib; {
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/src.nix b/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/src.nix
new file mode 100644
index 00000000000..047f014d2af
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gsettings-desktop-schemas/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gsettings-desktop-schemas-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gsettings-desktop-schemas/3.18/gsettings-desktop-schemas-3.18.0.tar.xz;
+    sha256 = "ba27337226a96d83f385c0ad192fdfe561c7e7882c61bb326c571be24e41eceb";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gsound/default.nix b/pkgs/desktops/gnome-3/3.18/core/gsound/default.nix
new file mode 100644
index 00000000000..5f255743313
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gsound/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, glib, libcanberra, gobjectIntrospection, libtool, gnome3 }:
+
+let
+  majVer = "1.0";
+in stdenv.mkDerivation rec {
+  name = "gsound-${majVer}.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gsound/${majVer}/${name}.tar.xz";
+    sha256 = "ea0dd94429c0645f2f98824274ef04543fe459dd83a5449a68910acc3ba67f29";
+  };
+
+  buildInputs = [ pkgconfig glib libcanberra gobjectIntrospection libtool ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GSound;
+    description = "Small library for playing system sounds";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gtksourceview/default.nix b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/default.nix
new file mode 100644
index 00000000000..ea95e39e5b2
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, atk, cairo, glib, gtk3, pango
+, libxml2Python, perl, intltool, gettext, gnome3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedBuildInputs = [ gtk3 ];
+
+  buildInputs = [ pkgconfig atk cairo glib pango
+                  libxml2Python perl intltool gettext ];
+
+  preBuild = ''
+    substituteInPlace gtksourceview/gtksourceview-utils.c --replace "@NIX_SHARE_PATH@" "$out/share"
+  ''; 
+
+  patches = [ ./nix_share_path.patch ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gtksourceview/nix_share_path.patch b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/nix_share_path.patch
new file mode 100644
index 00000000000..c87350167c2
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/nix_share_path.patch
@@ -0,0 +1,11 @@
+--- a/gtksourceview/gtksourceview-utils.c	2014-07-13 16:13:57.418687726 +0200
++++ b/gtksourceview/gtksourceview-utils.c	2014-07-13 16:14:20.550847767 +0200
+@@ -68,6 +68,8 @@
+ 							 basename,
+ 							 NULL));
+ 
++        g_ptr_array_add (dirs, g_build_filename ("@NIX_SHARE_PATH@", SOURCEVIEW_DIR, basename, NULL));
++
+ 	g_ptr_array_add (dirs, NULL);
+ 
+ 	return (gchar**) g_ptr_array_free (dirs, FALSE);
diff --git a/pkgs/desktops/gnome-3/3.18/core/gtksourceview/src.nix b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/src.nix
new file mode 100644
index 00000000000..5bbd2c42474
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gtksourceview/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gtksourceview-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gtksourceview/3.18/gtksourceview-3.18.0.tar.xz;
+    sha256 = "54b111264e6985e26a878dec88ff94fd0a9ae0dc4cfcdf08f4a6b5f655d4b693";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gucharmap/default.nix b/pkgs/desktops/gnome-3/3.18/core/gucharmap/default.nix
new file mode 100644
index 00000000000..a43d3c570ce
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gucharmap/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, intltool, fetchurl, pkgconfig, gtk3
+, glib, desktop_file_utils, bash, appdata-tools
+, makeWrapper, gnome3, file, itstool, libxml2 }:
+
+# TODO: icons and theme still does not work
+# use packaged gnome3.adwaita-icon-theme 
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  preConfigure = "substituteInPlace ./configure --replace /usr/bin/file ${file}/bin/file";
+
+  buildInputs = [ pkgconfig gtk3 intltool itstool glib appdata-tools
+                  gnome3.yelp_tools libxml2 file desktop_file_utils
+                  gnome3.gsettings_desktop_schemas makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gucharmap" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Gucharmap;
+    description = "GNOME Character Map, based on the Unicode Character Database";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/gucharmap/src.nix b/pkgs/desktops/gnome-3/3.18/core/gucharmap/src.nix
new file mode 100644
index 00000000000..01eca1e367b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/gucharmap/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gucharmap-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gucharmap/3.18/gucharmap-3.18.0.tar.xz;
+    sha256 = "121d2652f59a26c9426c96e7c6ca73295c45b675dd4ef0ccdb1b50bc0b4f3830";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libcroco/default.nix b/pkgs/desktops/gnome-3/3.18/core/libcroco/default.nix
new file mode 100644
index 00000000000..e8ddf7096e6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libcroco/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, libxml2, glib }:
+
+stdenv.mkDerivation rec {
+  name = "libcroco-0.6.8";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libcroco/0.6/${name}.tar.xz";
+    sha256 = "0w453f3nnkbkrly7spx5lx5pf6mwynzmd5qhszprq8amij2invpa";
+  };
+
+  outputs = [ "out" "doc" ];
+
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-Bsymbolic";
+
+  buildInputs = [ pkgconfig libxml2 glib ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgdata/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgdata/default.nix
new file mode 100644
index 00000000000..bedbbee2dfe
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgdata/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, pkgconfig, intltool, libxml2, glib, json_glib
+, gobjectIntrospection, liboauth, gnome3, p11_kit, openssl }:
+
+let
+  majorVersion = "0.16";
+in
+stdenv.mkDerivation rec {
+  name = "libgdata-${majorVersion}.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgdata/${majorVersion}/${name}.tar.xz";
+    sha256 = "8740e071ecb2ae0d2a4b9f180d2ae5fdf9dc4c41e7ff9dc7e057f62442800827";
+  };
+
+  # TODO: need libuhttpmock
+  configureFlags = "--disable-tests";
+  
+  NIX_CFLAGS_COMPILE = "-I${gnome3.libsoup}/include/libsoup-gnome-2.4/ -I${gnome3.gcr}/include/gcr-3 -I${gnome3.gcr}/include/gck-1";
+
+  buildInputs = with gnome3;
+    [ pkgconfig libsoup intltool libxml2 glib gobjectIntrospection 
+      liboauth gcr gnome_online_accounts p11_kit openssl ];
+
+  propagatedBuildInputs = [ json_glib ];
+      
+  meta = with stdenv.lib; {
+    description = "GData API library";
+    maintainers = with maintainers; [ raskin lethalman ];
+    platforms = platforms.linux;
+    license = licenses.lgpl21Plus;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgee/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgee/default.nix
new file mode 100644
index 00000000000..4ff13295031
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgee/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, autoconf, vala, pkgconfig, glib, gobjectIntrospection, gnome3 }:
+let
+  ver_maj = "0.16";
+  ver_min = "1";
+in
+stdenv.mkDerivation rec {
+  name = "libgee-${ver_maj}.${ver_min}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgee/${ver_maj}/${name}.tar.xz";
+    sha256 = "d95f8ea8e78f843c71b1958fa2fb445e4a325e4821ec23d0d5108d8170e564a5";
+  };
+
+  doCheck = true;
+
+  patches = [ ./fix_introspection_paths.patch ];
+
+  buildInputs = [ autoconf vala pkgconfig glib gobjectIntrospection ];
+
+  meta = with stdenv.lib; {
+    description = "Utility library providing GObject-based interfaces and classes for commonly used data structures";
+    license = licenses.lgpl21Plus;
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgee/fix_introspection_paths.patch b/pkgs/desktops/gnome-3/3.18/core/libgee/fix_introspection_paths.patch
new file mode 100644
index 00000000000..67003f45164
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgee/fix_introspection_paths.patch
@@ -0,0 +1,13 @@
+--- fix_introspection_paths.patch/configure	2014-01-07 17:43:53.521339338 +0000
++++ fix_introspection_paths.patch/configure-fix	2014-01-07 17:45:11.068635069 +0000
+@@ -12085,8 +12085,8 @@
+        INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+        INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+        INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+-       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+-       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
++       INTROSPECTION_GIRDIR="${datadir}/gir-1.0"
++       INTROSPECTION_TYPELIBDIR="${libdir}/girepository-1.0"
+        INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+        INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+        INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgnome-keyring/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgnome-keyring/default.nix
new file mode 100644
index 00000000000..c6c9323c010
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgnome-keyring/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, glib, dbus_libs, libgcrypt, pkgconfig, intltool, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  name = "libgnome-keyring-3.12.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgnome-keyring/3.12/${name}.tar.xz";
+    sha256 = "c4c178fbb05f72acc484d22ddb0568f7532c409b0a13e06513ff54b91e947783";
+  };
+
+  propagatedBuildInputs = [ glib gobjectIntrospection dbus_libs libgcrypt ];
+  nativeBuildInputs = [ pkgconfig intltool ];
+
+  meta = {
+    description = "Framework for managing passwords and other secrets";
+    homepage = http://live.gnome.org/GnomeKeyring;
+    license = with stdenv.lib.licenses; [ gpl2Plus lgpl2Plus ];
+    inherit (glib.meta) platforms maintainers;
+
+    longDescription = ''
+      gnome-keyring is a program that keeps password and other secrets for
+      users. The library libgnome-keyring is used by applications to integrate
+      with the gnome-keyring system.
+    '';
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgnomekbd/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgnomekbd/default.nix
new file mode 100644
index 00000000000..4939a4ff728
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgnomekbd/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, file, intltool, glib, gtk3, libxklavier, makeWrapper, gnome3 }:
+
+stdenv.mkDerivation rec {
+  name = "libgnomekbd-3.6.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgnomekbd/3.6/${name}.tar.xz";
+    sha256 = "c41ea5b0f64da470925ba09f9f1b46b26b82d4e433e594b2c71eab3da8856a09";
+  };
+
+  buildInputs = [ pkgconfig file intltool glib gtk3 libxklavier makeWrapper ];
+
+  preFixup = ''
+    wrapProgram $out/bin/gkbd-keyboard-display \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Keyboard management library";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgweather/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgweather/default.nix
new file mode 100644
index 00000000000..79ede15df8f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgweather/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl, pkgconfig, libxml2, gtk, intltool, libsoup, gconf
+, pango, gdk_pixbuf, atk, tzdata, gnome3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  makeFlags = "INTROSPECTION_GIRDIR=$(out)/share/gir-1.0/ INTROSPECTION_TYPELIBDIR=$(out)/lib/girepository-1.0";
+
+  configureFlags = [ "--with-zoneinfo-dir=${tzdata}/share/zoneinfo" ];
+  propagatedBuildInputs = [ libxml2 gtk libsoup gconf pango gdk_pixbuf atk gnome3.geocode_glib ];
+  nativeBuildInputs = [ pkgconfig intltool ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgweather/src.nix b/pkgs/desktops/gnome-3/3.18/core/libgweather/src.nix
new file mode 100644
index 00000000000..da56dc3361a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgweather/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "libgweather-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/libgweather/3.18/libgweather-3.18.0.tar.xz;
+    sha256 = "8f4fda67f48c776f2bf955d384de4cc842aacb8d9b2ad87b42d83d0dc5a1cb1f";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libgxps/default.nix b/pkgs/desktops/gnome-3/3.18/core/libgxps/default.nix
new file mode 100644
index 00000000000..72d307f4f1a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libgxps/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, glib, cairo, libarchive, freetype, libjpeg, libtiff
+, openssl, bzip2, acl, attr
+}:
+
+stdenv.mkDerivation rec {
+  name = "libgxps-0.2.2";
+
+  src = fetchurl {
+    url = "http://ftp.acc.umu.se/pub/GNOME/core/3.10/3.10.2/sources/${name}.tar.xz";
+    sha256 = "1gi0b0x0354jyqc48vspk2hg2q1403cf2p9ibj847nzhkdrh9l9r";
+  };
+
+  buildInputs = [ pkgconfig glib cairo libarchive freetype libjpeg libtiff acl openssl bzip2 attr];
+
+  configureFlags = "--without-liblcms2";
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libpeas/default.nix b/pkgs/desktops/gnome-3/3.18/core/libpeas/default.nix
new file mode 100644
index 00000000000..8d40d977a80
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libpeas/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, intltool, gnome3
+, glib, gtk3, gobjectIntrospection, python, pygobject3
+}:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs =  [
+   intltool pkgconfig glib gtk3 gobjectIntrospection python pygobject3
+   gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A GObject-based plugins engine";
+    homepage = "http://ftp.acc.umu.se/pub/GNOME/sources/libpeas/";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libpeas/src.nix b/pkgs/desktops/gnome-3/3.18/core/libpeas/src.nix
new file mode 100644
index 00000000000..8a24097bbd6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libpeas/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "libpeas-1.16.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/libpeas/1.16/libpeas-1.16.0.tar.xz;
+    sha256 = "b093008ecd65f7d55c80517589509698ff15ad41f664b11a3eb88ff461b1454e";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/libzapojit/default.nix b/pkgs/desktops/gnome-3/3.18/core/libzapojit/default.nix
new file mode 100644
index 00000000000..5a8117528b6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/libzapojit/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, fetchurl, pkgconfig, glib, intltool, json_glib, rest, libsoup, gtk, gnome_online_accounts }:
+
+stdenv.mkDerivation rec {
+  name = "libzapojit-0.0.3";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libzapojit/0.0/${name}.tar.xz";
+    sha256 = "0zn3s7ryjc3k1abj4k55dr2na844l451nrg9s6cvnnhh569zj99x";
+  };
+
+  buildInputs = [ pkgconfig glib intltool json_glib rest libsoup gtk gnome_online_accounts ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/mutter/default.nix b/pkgs/desktops/gnome-3/3.18/core/mutter/default.nix
new file mode 100644
index 00000000000..dd08a96cc23
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/mutter/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv, pkgconfig, gnome3, intltool, gobjectIntrospection, upower, cairo
+, pango, cogl, clutter, libstartup_notification, libcanberra, zenity, libcanberra_gtk3
+, libtool, makeWrapper, xkeyboard_config, libxkbfile, libxkbcommon }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  # fatal error: gio/gunixfdlist.h: No such file or directory
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  configureFlags = "--with-x --disable-static --enable-shape --enable-sm --enable-startup-notification --enable-xsync --enable-verbose-mode --with-libcanberra"; 
+
+  buildInputs = with gnome3;
+    [ pkgconfig intltool glib gobjectIntrospection gtk gsettings_desktop_schemas upower
+      gnome_desktop cairo pango cogl clutter zenity libstartup_notification libcanberra
+      gnome3.geocode_glib
+      libcanberra_gtk3 zenity libtool makeWrapper xkeyboard_config libxkbfile libxkbcommon ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/mutter" \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  patches = [ ./x86.patch ./math.patch ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/mutter/math.patch b/pkgs/desktops/gnome-3/3.18/core/mutter/math.patch
new file mode 100644
index 00000000000..dbdfd93f5e1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/mutter/math.patch
@@ -0,0 +1,10 @@
+--- mutter-3.18.0/src/backends/meta-cursor-renderer.c.orig	2015-09-23 13:54:31.297523343 +0200
++++ mutter-3.18.0/src/backends/meta-cursor-renderer.c	2015-09-23 13:54:43.728271766 +0200
+@@ -31,6 +31,7 @@
+ 
+ #include <cogl/cogl.h>
+ #include <clutter/clutter.h>
++#include <math.h>
+ 
+ #include "meta-stage.h"
+ 
diff --git a/pkgs/desktops/gnome-3/3.18/core/mutter/src.nix b/pkgs/desktops/gnome-3/3.18/core/mutter/src.nix
new file mode 100644
index 00000000000..2f183d1a919
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/mutter/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "mutter-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/mutter/3.18/mutter-3.18.0.tar.xz;
+    sha256 = "9fb287976b9c65f0a2aca09d0e2c4c2748d3d2cfa5f38921dbeafe4cd1d541b1";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/mutter/x86.patch b/pkgs/desktops/gnome-3/3.18/core/mutter/x86.patch
new file mode 100644
index 00000000000..bc8829de42f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/mutter/x86.patch
@@ -0,0 +1,20 @@
+--- mutter-3.16.2/src/core/window.c.orig	2015-05-26 10:52:41.382834963 +0200
++++ mutter-3.16.2/src/core/window.c	2015-05-26 10:53:03.039948034 +0200
+@@ -3499,7 +3499,7 @@
+ 
+ static MetaMonitorInfo *
+ find_monitor_by_winsys_id (MetaWindow *window,
+-                           guint       winsys_id)
++                           gint       winsys_id)
+ {
+   int i;
+ 
+@@ -3618,7 +3618,7 @@
+    */
+ 
+   gboolean did_placement;
+-  guint old_output_winsys_id;
++  gint old_output_winsys_id;
+   MetaRectangle unconstrained_rect;
+   MetaRectangle constrained_rect;
+   MetaMoveResizeResultFlags result = 0;
diff --git a/pkgs/desktops/gnome-3/3.18/core/nautilus/default.nix b/pkgs/desktops/gnome-3/3.18/core/nautilus/default.nix
new file mode 100644
index 00000000000..f28e86d7bad
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/nautilus/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, pkgconfig, libxml2, dbus_glib, shared_mime_info, libexif
+, gtk, gnome3, libunique, intltool, gobjectIntrospection
+, libnotify, makeWrapper, exempi, librsvg, tracker }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig libxml2 dbus_glib shared_mime_info libexif gtk libunique intltool exempi librsvg
+                  gnome3.gnome_desktop gnome3.adwaita-icon-theme
+                  gnome3.gsettings_desktop_schemas libnotify makeWrapper tracker ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/nautilus" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  patches = [ ./extension_dir.patch ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/nautilus/extension_dir.patch b/pkgs/desktops/gnome-3/3.18/core/nautilus/extension_dir.patch
new file mode 100644
index 00000000000..317b8257992
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/nautilus/extension_dir.patch
@@ -0,0 +1,24 @@
+diff --git a/libnautilus-private/nautilus-module.c b/libnautilus-private/nautilus-module.c
+index 6273a76..4adcc8a 100644
+--- a/libnautilus-private/nautilus-module.c
++++ b/libnautilus-private/nautilus-module.c
+@@ -242,11 +242,17 @@ void
+ nautilus_module_setup (void)
+ {
+ 	static gboolean initialized = FALSE;
++	const gchar* extensiondir = NULL;
+ 
+ 	if (!initialized) {
+ 		initialized = TRUE;
+-		
+-		load_module_dir (NAUTILUS_EXTENSIONDIR);
++	
++		extensiondir = g_getenv ("NAUTILUS_EXTENSION_DIR");
++		if (extensiondir == NULL) {
++			extensiondir = NAUTILUS_EXTENSIONDIR;
++		}
++	
++		load_module_dir (extensiondir);
+ 
+ 		eel_debug_call_at_shutdown (free_module_objects);
+ 	}
diff --git a/pkgs/desktops/gnome-3/3.18/core/nautilus/src.nix b/pkgs/desktops/gnome-3/3.18/core/nautilus/src.nix
new file mode 100644
index 00000000000..4e8c692bce4
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/nautilus/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "nautilus-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/nautilus/3.18/nautilus-3.18.0.tar.xz;
+    sha256 = "6914e5698c5ce865870086e4db9395d56a78eddf8002020458ce05db16a95a33";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/rest/default.nix b/pkgs/desktops/gnome-3/3.18/core/rest/default.nix
new file mode 100644
index 00000000000..eada9ab1993
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/rest/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, glib, libsoup, gobjectIntrospection, gnome3 }:
+
+stdenv.mkDerivation rec {
+  name = "rest-0.7.92";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/rest/0.7/${name}.tar.xz";
+    sha256 = "07548c8785a3e743daf54a82b952ff5f32af94fee68997df4c83b00d52f9c0ec";
+  };
+
+  buildInputs = [ pkgconfig glib libsoup gobjectIntrospection];
+
+  configureFlags = "--with-ca-certificates=/etc/ssl/certs/ca-certificates.crt";
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/sushi/default.nix b/pkgs/desktops/gnome-3/3.18/core/sushi/default.nix
new file mode 100644
index 00000000000..17c37e89dec
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/sushi/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, pkgconfig, file, intltool, gobjectIntrospection, glib
+, clutter_gtk, clutter-gst, gnome3, gtksourceview, libmusicbrainz
+, webkitgtk, libmusicbrainz5, icu, makeWrapper, gst_all_1
+, gdk_pixbuf, librsvg, gtk3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good ];
+
+  buildInputs = [ pkgconfig file intltool gobjectIntrospection glib gtk3
+                  clutter_gtk clutter-gst gnome3.gjs gtksourceview gdk_pixbuf
+                  librsvg gnome3.defaultIconTheme libmusicbrainz5 webkitgtk
+                  gnome3.evince icu makeWrapper ];
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    wrapProgram $out/libexec/sushi-start \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "http://en.wikipedia.org/wiki/Sushi_(software)";
+    description = "A quick previewer for Nautilus";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/sushi/src.nix b/pkgs/desktops/gnome-3/3.18/core/sushi/src.nix
new file mode 100644
index 00000000000..5c852a0dc47
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/sushi/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "sushi-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/sushi/3.18/sushi-3.18.0.tar.xz;
+    sha256 = "7f4df92be950bf23aff28da49ce108766dd21a88efc14a9d0807e10225608e9c";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/totem-pl-parser/default.nix b/pkgs/desktops/gnome-3/3.18/core/totem-pl-parser/default.nix
new file mode 100644
index 00000000000..63f36004bcd
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/totem-pl-parser/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, file, intltool, gmime, libxml2, libsoup, gnome3 }:
+
+stdenv.mkDerivation rec {
+  name = "totem-pl-parser-3.10.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/totem-pl-parser/3.10/${name}.tar.xz";
+    sha256 = "38be09bddc46ddecd2b5ed7c82144ef52aafe879a5ec3d8b192b4b64ba995469";
+  };
+
+  buildInputs = [ pkgconfig file intltool gmime libxml2 libsoup ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Videos;
+    description = "Simple GObject-based library to parse and save a host of playlist formats";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/totem/default.nix b/pkgs/desktops/gnome-3/3.18/core/totem/default.nix
new file mode 100644
index 00000000000..13665c72274
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/totem/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, intltool, fetchurl, gst_all_1
+, clutter_gtk, clutter-gst, pygobject3, shared_mime_info
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, libxml2, dbus_glib
+, gnome3, librsvg, gdk_pixbuf, file }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0";
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2 gnome3.grilo
+                  clutter_gtk clutter-gst gnome3.totem-pl-parser gnome3.grilo-plugins
+                  gst_all_1.gstreamer gst_all_1.gst-plugins-base
+                  gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad
+                  gnome3.libpeas pygobject3 shared_mime_info dbus_glib
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg gnome3.gnome_desktop
+                  gnome3.gsettings_desktop_schemas makeWrapper file ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/totem" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
+      --prefix GRL_PLUGIN_PATH : "${gnome3.grilo-plugins}/lib/grilo-0.2" \
+      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Videos;
+    description = "Movie player for the GNOME desktop based on GStreamer";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/totem/src.nix b/pkgs/desktops/gnome-3/3.18/core/totem/src.nix
new file mode 100644
index 00000000000..92bf2c1f8a6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/totem/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "totem-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/totem/3.18/totem-3.18.0.tar.xz;
+    sha256 = "1b6a7e66414df4b2e2427a9c5f1fee5a5f286beb098fdbe0902e37e3663e3e89";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/tracker/default.nix b/pkgs/desktops/gnome-3/3.18/core/tracker/default.nix
new file mode 100644
index 00000000000..88e6da2ad2d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/tracker/default.nix
@@ -0,0 +1,55 @@
+{ stdenv, intltool, fetchurl, libxml2, upower
+, pkgconfig, gtk3, glib
+, bash, makeWrapper, itstool, vala, sqlite, libxslt
+, gnome3, librsvg, gdk_pixbuf, file, libnotify
+, evolution_data_server, gst_all_1, poppler
+, icu, taglib, libjpeg, libtiff, giflib, libcue
+, libvorbis, flac, exempi, networkmanager
+, libpng, libexif, libgsf, libuuid, bzip2 }:
+
+let
+  majorVersion = "1.4";
+in
+stdenv.mkDerivation rec {
+  name = "tracker-${majorVersion}.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/tracker/${majorVersion}/${name}.tar.xz";
+    sha256 = "1ssisbix7ib3d6bgx9s675gx6ayy68jq2srhpzv038mkbaskaz68";
+  };
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  NIX_CFLAGS_COMPILE = "-I${gnome3.glib}/include/gio-unix-2.0 -I${poppler}/include/poppler";
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ vala pkgconfig gtk3 glib intltool itstool libxml2
+                  bzip2 gnome3.totem-pl-parser libxslt
+                  gnome3.gsettings_desktop_schemas makeWrapper file
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg sqlite
+                  upower libnotify evolution_data_server gnome3.libgee
+                  gst_all_1.gstreamer gst_all_1.gst-plugins-base flac
+                  poppler icu taglib libjpeg libtiff giflib libvorbis
+                  exempi networkmanager libpng libexif libgsf libuuid ];
+
+  preConfigure = ''
+    substituteInPlace src/libtracker-sparql/Makefile.in --replace "--shared-library=libtracker-sparql" "--shared-library=$out/lib/libtracker-sparql"
+  '';
+
+  preFixup = ''
+    for f in $out/bin/* $out/libexec/*; do
+      wrapProgram $f \
+        --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+        --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/Tracker;
+    description = "Desktop-neutral user information store, search tool and indexer";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/vino/default.nix b/pkgs/desktops/gnome-3/3.18/core/vino/default.nix
new file mode 100644
index 00000000000..7a015b4a010
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vino/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, intltool, fetchurl, gtk3, glib, libsoup, pkgconfig, makeWrapper
+, gnome3, libnotify, file, telepathy_glib, dbus_glib }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  buildInputs = [ gtk3 intltool glib libsoup pkgconfig libnotify
+                  gnome3.defaultIconTheme dbus_glib telepathy_glib file
+                  makeWrapper ];
+
+  preFixup = ''
+    wrapProgram "$out/libexec/vino-server" \
+      --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Projects/Vino;
+    description = "GNOME desktop sharing server";
+    maintainers = with maintainers; [ lethalman iElectric ];
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/vino/src.nix b/pkgs/desktops/gnome-3/3.18/core/vino/src.nix
new file mode 100644
index 00000000000..b2202c48733
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vino/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "vino-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/vino/3.18/vino-3.18.0.tar.xz;
+    sha256 = "52be0b036389713eab224abf27f2ca2a067ba5bd1f6b526592703576005e0919";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/vte/2.90.nix b/pkgs/desktops/gnome-3/3.18/core/vte/2.90.nix
new file mode 100644
index 00000000000..5ccca36bcaa
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vte/2.90.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gnome3, ncurses, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  versionMajor = "0.36";
+  versionMinor = "3";
+  moduleName   = "vte";
+
+  name = "${moduleName}-${versionMajor}.${versionMinor}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
+    sha256 = "54e5b07be3c0f7b158302f54ee79d4de1cb002f4259b6642b79b1e0e314a959c";
+  };
+
+  buildInputs = [ gobjectIntrospection intltool pkgconfig gnome3.glib gnome3.gtk3 ncurses ];
+
+  configureFlags = [ "--enable-introspection" ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    substituteInPlace $out/lib/libvte2_90.la --replace "-lncurses" "-L${ncurses}/lib -lncurses"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.gnome.org/;
+    description = "A library implementing a terminal emulator widget for GTK+";
+    longDescription = ''
+      VTE is a library (libvte) implementing a terminal emulator widget for
+      GTK+, and a minimal sample application (vte) using that.  Vte is
+      mainly used in gnome-terminal, but can also be used to embed a
+      console/terminal in games, editors, IDEs, etc. VTE supports Unicode and
+      character set conversion, as well as emulating any terminal known to
+      the system's terminfo database.
+    '';
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [ astsmtl antono lethalman ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/vte/default.nix b/pkgs/desktops/gnome-3/3.18/core/vte/default.nix
new file mode 100644
index 00000000000..b47381cf61b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vte/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gnome3, ncurses, gobjectIntrospection, vala, libxml2
+, gnutls, selectTextPatch ? false }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  patches = with stdenv.lib; optional selectTextPatch ./expose_select_text.0.40.0.patch;
+
+  buildInputs = [ gobjectIntrospection intltool pkgconfig gnome3.glib 
+                  gnome3.gtk3 ncurses vala libxml2 ];
+
+  propagatedBuildInputs = [ gnutls ];
+
+  preConfigure = "patchShebangs .";
+
+  configureFlags = [ "--enable-introspection" ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    substituteInPlace $out/lib/libvte2_90.la --replace "-lncurses" "-L${ncurses}/lib -lncurses"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.gnome.org/;
+    description = "A library implementing a terminal emulator widget for GTK+";
+    longDescription = ''
+      VTE is a library (libvte) implementing a terminal emulator widget for
+      GTK+, and a minimal sample application (vte) using that.  Vte is
+      mainly used in gnome-terminal, but can also be used to embed a
+      console/terminal in games, editors, IDEs, etc. VTE supports Unicode and
+      character set conversion, as well as emulating any terminal known to
+      the system's terminfo database.
+    '';
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [ astsmtl antono lethalman ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/vte/expose_select_text.0.40.0.patch b/pkgs/desktops/gnome-3/3.18/core/vte/expose_select_text.0.40.0.patch
new file mode 100644
index 00000000000..c18f1b76b41
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vte/expose_select_text.0.40.0.patch
@@ -0,0 +1,226 @@
+Only in vte-0.40.0.new: .git
+diff --unified -aur vte-0.40.0/src/vteaccess.c vte-0.40.0.new/src/vteaccess.c
+--- vte-0.40.0/src/vteaccess.c	2015-03-16 06:34:37.000000000 -0400
++++ vte-0.40.0.new/src/vteaccess.c	2015-04-10 00:08:53.146853382 -0400
+@@ -1444,7 +1444,7 @@
+ 	*start_offset = offset_from_xy (priv, start_x, start_y);
+ 	_vte_terminal_get_end_selection (terminal, &end_x, &end_y);
+ 	*end_offset = offset_from_xy (priv, end_x, end_y);
+-	return _vte_terminal_get_selection (terminal);
++	return vte_terminal_get_selection (terminal);
+ }
+ 
+ static gboolean
+diff --unified -aur vte-0.40.0/src/vte.c vte-0.40.0.new/src/vte.c
+--- vte-0.40.0/src/vte.c	2015-03-18 12:38:09.000000000 -0400
++++ vte-0.40.0.new/src/vte.c	2015-04-10 00:08:53.150186722 -0400
+@@ -123,7 +123,6 @@
+ 						 gpointer data,
+ 						 GArray *attributes,
+ 						 gboolean include_trailing_spaces);
+-static void _vte_terminal_disconnect_pty_read(VteTerminal *terminal);
+ static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal);
+ static void vte_terminal_stop_processing (VteTerminal *terminal);
+ 
+@@ -3344,9 +3343,10 @@
+ 	_vte_debug_print (VTE_DEBUG_IO, "removed poll of vte_terminal_io_read\n");
+ 	terminal->pvt->pty_input_source = 0;
+ }
+-static void
+-_vte_terminal_connect_pty_read(VteTerminal *terminal)
++void
++vte_terminal_connect_pty_read(VteTerminal *terminal)
+ {
++	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ 	if (terminal->pvt->pty_channel == NULL) {
+ 		return;
+ 	}
+@@ -3398,9 +3398,10 @@
+ 	}
+ }
+ 
+-static void
+-_vte_terminal_disconnect_pty_read(VteTerminal *terminal)
++void
++vte_terminal_disconnect_pty_read(VteTerminal *terminal)
+ {
++	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ 	if (terminal->pvt->pty_input_source != 0) {
+ 		_vte_debug_print (VTE_DEBUG_IO, "disconnecting poll of vte_terminal_io_read\n");
+ 		g_source_remove(terminal->pvt->pty_input_source);
+@@ -6302,6 +6303,28 @@
+ 	}
+ }
+ 
++/**
++ * vte_terminal_set_cursor_position:
++ * @terminal: a #VteTerminal
++ * @column: the new cursor column
++ * @row: the new cursor row
++ *
++ * Set the location of the cursor.
++ */
++void
++vte_terminal_set_cursor_position(VteTerminal *terminal,
++				 long column, long row)
++{
++	g_return_if_fail(VTE_IS_TERMINAL(terminal));
++
++	_vte_invalidate_cursor_once(terminal, FALSE);
++	terminal->pvt->cursor.col = column;
++	terminal->pvt->cursor.row = row;
++	_vte_invalidate_cursor_once(terminal, FALSE);
++	_vte_check_cursor_blink(terminal);
++	vte_terminal_queue_cursor_moved(terminal);
++}
++
+ static GtkClipboard *
+ vte_terminal_clipboard_get(VteTerminal *terminal, GdkAtom board)
+ {
+@@ -6465,7 +6488,7 @@
+         vte_terminal_extend_selection(terminal, x, y, FALSE, TRUE);
+ 
+ 	/* Temporarily stop caring about input from the child. */
+-	_vte_terminal_disconnect_pty_read(terminal);
++	vte_terminal_disconnect_pty_read(terminal);
+ }
+ 
+ static gboolean
+@@ -6482,7 +6505,7 @@
+ 		terminal->pvt->selecting = FALSE;
+ 
+ 		/* Reconnect to input from the child if we paused it. */
+-		_vte_terminal_connect_pty_read(terminal);
++		vte_terminal_connect_pty_read(terminal);
+ 
+ 		return TRUE;
+ 	}
+@@ -6982,6 +7005,50 @@
+ 	vte_terminal_deselect_all (terminal);
+ }
+ 
++/**
++ * vte_terminal_get_selection_block_mode:
++ * @terminal: a #VteTerminal
++ *
++ * Checks whether or not block selection is enabled.
++ *
++ * Returns: %TRUE if block selection is enabled, %FALSE if not
++ */
++gboolean
++vte_terminal_get_selection_block_mode(VteTerminal *terminal) {
++	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
++	return terminal->pvt->selection_block_mode;
++}
++
++/**
++ * vte_terminal_set_selection_block_mode:
++ * @terminal: a #VteTerminal
++ * @block_mode: whether block selection is enabled
++ *
++ * Sets whether or not block selection is enabled.
++ */
++void
++vte_terminal_set_selection_block_mode(VteTerminal *terminal, gboolean block_mode) {
++	g_return_if_fail(VTE_IS_TERMINAL(terminal));
++	terminal->pvt->selection_block_mode = block_mode;
++}
++
++/**
++ * vte_terminal_select_text:
++ * @terminal: a #VteTerminal
++ * @start_col: the starting column for the selection
++ * @start_row: the starting row for the selection
++ * @end_col: the end column for the selection
++ * @end_row: the end row for the selection
++ *
++ * Sets the current selection region.
++ */
++void
++vte_terminal_select_text(VteTerminal *terminal,
++			 long start_col, long start_row,
++			 long end_col, long end_row) {
++	_vte_terminal_select_text(terminal, start_col, start_row, end_col, end_row, 0, 0);
++}
++
+ /* Autoscroll a bit. */
+ static gboolean
+ vte_terminal_autoscroll(VteTerminal *terminal)
+@@ -8631,7 +8698,7 @@
+ #endif
+ 		kill(terminal->pvt->pty_pid, SIGHUP);
+ 	}
+-	_vte_terminal_disconnect_pty_read(terminal);
++	vte_terminal_disconnect_pty_read(terminal);
+ 	_vte_terminal_disconnect_pty_write(terminal);
+ 	if (terminal->pvt->pty_channel != NULL) {
+ 		g_io_channel_unref (terminal->pvt->pty_channel);
+@@ -12188,7 +12255,7 @@
+         g_object_freeze_notify(object);
+ 
+         if (pvt->pty != NULL) {
+-                _vte_terminal_disconnect_pty_read(terminal);
++                vte_terminal_disconnect_pty_read(terminal);
+                 _vte_terminal_disconnect_pty_write(terminal);
+ 
+                 if (terminal->pvt->pty_channel != NULL) {
+@@ -12243,7 +12310,7 @@
+         _vte_terminal_setup_utf8 (terminal);
+ 
+         /* Open channels to listen for input on. */
+-        _vte_terminal_connect_pty_read (terminal);
++        vte_terminal_connect_pty_read (terminal);
+ 
+         g_object_notify(object, "pty");
+ 
+@@ -12276,7 +12343,7 @@
+ }
+ 
+ char *
+-_vte_terminal_get_selection(VteTerminal *terminal)
++vte_terminal_get_selection(VteTerminal *terminal)
+ {
+ 	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+ 
+diff --unified -aur vte-0.40.0/src/vteint.h vte-0.40.0.new/src/vteint.h
+--- vte-0.40.0/src/vteint.h	2014-05-28 08:22:48.000000000 -0400
++++ vte-0.40.0.new/src/vteint.h	2015-04-10 00:08:53.153520062 -0400
+@@ -25,7 +25,6 @@
+ G_BEGIN_DECLS
+ 
+ void _vte_terminal_accessible_ref(VteTerminal *terminal);
+-char* _vte_terminal_get_selection(VteTerminal *terminal);
+ void _vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y);
+ void _vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y);
+ void _vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset);
+diff --unified -aur vte-0.40.0/src/vteterminal.h vte-0.40.0.new/src/vteterminal.h
+--- vte-0.40.0/src/vteterminal.h	2015-03-18 12:38:09.000000000 -0400
++++ vte-0.40.0.new/src/vteterminal.h	2015-04-10 00:08:53.150186722 -0400
+@@ -169,6 +169,18 @@
+ 
+ void vte_terminal_select_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+ void vte_terminal_unselect_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
++gboolean vte_terminal_get_selection_block_mode(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
++void vte_terminal_set_selection_block_mode(VteTerminal *terminal,
++                                           gboolean block_mode) _VTE_GNUC_NONNULL(1);
++void vte_terminal_select_text(VteTerminal *terminal,
++                              long start_col, long start_row,
++                              long end_col, long end_row) _VTE_GNUC_NONNULL(1);
++char *
++vte_terminal_get_selection(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
++
++/* pause and unpause output */
++void vte_terminal_disconnect_pty_read(VteTerminal *vte);
++void vte_terminal_connect_pty_read(VteTerminal *vte);
+ 
+ /* By-word selection */
+ void vte_terminal_set_word_char_exceptions(VteTerminal *terminal,
+@@ -280,6 +292,8 @@
+ void vte_terminal_get_cursor_position(VteTerminal *terminal,
+ 				      glong *column,
+                                       glong *row) _VTE_GNUC_NONNULL(1);
++void vte_terminal_set_cursor_position(VteTerminal *terminal,
++				      long column, long row) _VTE_GNUC_NONNULL(1);
+ 
+ /* Add a matching expression, returning the tag the widget assigns to that
+  * expression. */
diff --git a/pkgs/desktops/gnome-3/3.18/core/vte/src.nix b/pkgs/desktops/gnome-3/3.18/core/vte/src.nix
new file mode 100644
index 00000000000..ea6e39182fc
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/vte/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "vte-0.42.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/vte/0.42/vte-0.42.0.tar.xz;
+    sha256 = "2168f79d2043cbbe6d4375d01e54cebda71bb6f5d9dc8ad658b9a1dc1052de04";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp-tools/default.nix b/pkgs/desktops/gnome-3/3.18/core/yelp-tools/default.nix
new file mode 100644
index 00000000000..de708d48c5e
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp-tools/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl, libxml2, libxslt, itstool, gnome3, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ libxml2 libxslt itstool gnome3.yelp_xsl pkgconfig ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Yelp/Tools;
+    description = "Small programs that help you create, edit, manage, and publish your Mallard or DocBook documentation";
+    maintainers = with maintainers; [ iElectric ];
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp-tools/src.nix b/pkgs/desktops/gnome-3/3.18/core/yelp-tools/src.nix
new file mode 100644
index 00000000000..f03c6d1bc31
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp-tools/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "yelp-tools-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/yelp-tools/3.18/yelp-tools-3.18.0.tar.xz;
+    sha256 = "c6c1d65f802397267cdc47aafd5398c4b60766e0a7ad2190426af6c0d0716932";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/default.nix b/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/default.nix
new file mode 100644
index 00000000000..0a3976f35a1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, intltool, fetchurl, pkgconfig, bash
+, itstool, libxml2, libxslt, gnome3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  buildInputs = [ pkgconfig intltool itstool libxml2 libxslt ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Yelp;
+    description = "Yelp's universal stylesheets for Mallard and DocBook";
+    maintainers = gnome3.maintainers;
+    license = [licenses.gpl2 licenses.lgpl2];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/src.nix b/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/src.nix
new file mode 100644
index 00000000000..a3343d2dfd1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp-xsl/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "yelp-xsl-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/yelp-xsl/3.18/yelp-xsl-3.18.0.tar.xz;
+    sha256 = "893620857b72b3b43ee3b462281240b7ca4d80292f469552827f0597bf60d2b2";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp/default.nix b/pkgs/desktops/gnome-3/3.18/core/yelp/default.nix
new file mode 100644
index 00000000000..13464137bd8
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, intltool, fetchurl, webkitgtk, pkgconfig, gtk3, glib
+, file, librsvg, gnome3, gdk_pixbuf, sqlite
+, bash, makeWrapper, itstool, libxml2, libxslt, icu, gst_all_1
+, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  preConfigure = "substituteInPlace ./configure --replace /usr/bin/file ${file}/bin/file";
+
+  buildInputs = [ pkgconfig gtk3 glib webkitgtk intltool itstool sqlite
+                  libxml2 libxslt icu file makeWrapper gnome3.yelp_xsl
+                  librsvg gdk_pixbuf gnome3.defaultIconTheme
+                  gnome3.gsettings_desktop_schemas wrapGAppsHook
+                  gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Yelp;
+    description = "The help viewer in Gnome";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/yelp/src.nix b/pkgs/desktops/gnome-3/3.18/core/yelp/src.nix
new file mode 100644
index 00000000000..cb25d3d30c6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/yelp/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "yelp-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/yelp/3.18/yelp-3.18.0.tar.xz;
+    sha256 = "a8c201e520c87832d017439492e4343e957a90da5c6d85060e8dd3b28ffee72e";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/zenity/default.nix b/pkgs/desktops/gnome-3/3.18/core/zenity/default.nix
new file mode 100644
index 00000000000..8f525945a6a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/zenity/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, cairo, libxml2, libxslt, gnome3, pango
+, gnome_doc_utils, intltool, libX11, which, itstool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  preBuild = ''
+    mkdir -p $out/include
+  '';
+
+  buildInputs = [ gnome3.gtk libxml2 libxslt libX11 itstool ];
+
+  nativeBuildInputs = [ pkgconfig intltool gnome_doc_utils which ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/core/zenity/src.nix b/pkgs/desktops/gnome-3/3.18/core/zenity/src.nix
new file mode 100644
index 00000000000..87f16156515
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/core/zenity/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "zenity-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/zenity/3.18/zenity-3.18.0.tar.xz;
+    sha256 = "0efafea95a830f3bf6eca805ff4a8008df760a6ad3e81181b9473dcf721c3a69";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/default.nix b/pkgs/desktops/gnome-3/3.18/default.nix
new file mode 100644
index 00000000000..a3ae8933e64
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/default.nix
@@ -0,0 +1,394 @@
+{ pkgs }:
+
+let
+
+  pkgsFun = overrides:
+    let 
+      self = self_ // overrides;
+      self_ = with self; {
+
+  overridePackages = f:
+    let newself = pkgsFun (f newself self);
+    in newself;
+
+  callPackage = pkgs.newScope self;
+
+  version = "3.18";
+  maintainers = with pkgs.lib.maintainers; [ lethalman jgeerds ];
+
+  corePackages = with gnome3; [
+    pkgs.desktop_file_utils pkgs.ibus
+    pkgs.shared_mime_info # for update-mime-database
+    glib # for gsettings
+    gtk3 # for gtk-update-icon-cache
+    glib_networking gvfs dconf gnome-backgrounds gnome_control_center
+    gnome-menus gnome_settings_daemon gnome_shell
+    gnome_themes_standard defaultIconTheme gnome-shell-extensions
+    pkgs.hicolor_icon_theme
+  ];
+
+  optionalPackages = with gnome3; [ baobab empathy eog epiphany evince
+    gucharmap nautilus totem vino yelp gnome-bluetooth
+    gnome-calculator gnome-contacts gnome-font-viewer gnome-screenshot
+    gnome-system-log gnome-system-monitor
+    gnome_terminal gnome-user-docs bijiben evolution file-roller gedit
+    gnome-clocks gnome-music gnome-tweak-tool gnome-photos
+    nautilus-sendto dconf-editor vinagre gnome-weather gnome-logs
+    gnome-maps gnome-characters gnome-calendar accerciser gnome-nettool
+    gnome-getting-started-docs
+  ];
+
+  gamesPackages = with gnome3; [ swell-foop lightsoff iagno
+    tali quadrapassel gnome-sudoku aisleriot five-or-more
+    four-in-a-row gnome-chess gnome-klotski gnome-mahjongg
+    gnome-mines gnome-nibbles gnome-robots gnome-tetravex
+    hitori gnome-taquin
+  ];
+
+  inherit (pkgs) glib gtk2 webkitgtk24x gtk3 gtkmm3 libcanberra;
+  inherit (pkgs.gnome2) ORBit2;
+  libsoup = pkgs.libsoup.override { gnomeSupport = true; };
+  libchamplain = pkgs.libchamplain.override { libsoup = libsoup; };
+  orbit = ORBit2;
+  gnome3 = self // { recurseForDerivations = false; };
+  clutter = pkgs.clutter_1_24;
+  clutter_gtk = pkgs.clutter_gtk_1_6.override { inherit clutter gtk3; };
+  clutter-gst_2 = pkgs.clutter-gst;
+  clutter-gst = pkgs.clutter-gst_3_0.override { inherit clutter cogl; };
+  cogl = pkgs.cogl_1_22;
+  gtk = gtk3;
+  gtkmm = gtkmm3;
+  gtkvnc = pkgs.gtkvnc.override { enableGTK3 = true; };
+  vala = pkgs.vala_0_26;
+  gegl_0_3 = pkgs.gegl_0_3.override { inherit gtk; };
+
+# Simplify the nixos module and gnome packages
+  defaultIconTheme = adwaita-icon-theme;
+
+#### Core (http://ftp.acc.umu.se/pub/GNOME/core/)
+
+  adwaita-icon-theme = callPackage ./core/adwaita-icon-theme { };
+
+  baobab = callPackage ./core/baobab { };
+
+  caribou = callPackage ./core/caribou { };
+
+  dconf = callPackage ./core/dconf { };
+  dconf-editor = callPackage ./core/dconf-editor { };
+
+  empathy = callPackage ./core/empathy { 
+    webkitgtk = webkitgtk24x;
+    clutter-gst = pkgs.clutter-gst;
+  };
+
+  epiphany = callPackage ./core/epiphany { };
+
+  evince = callPackage ./core/evince { }; # ToDo: dbus would prevent compilation, enable tests
+
+  evolution_data_server = callPackage ./core/evolution-data-server { };
+
+  gconf = callPackage ./core/gconf { };
+
+  geocode_glib = callPackage ./core/geocode-glib { };
+
+  gcr = callPackage ./core/gcr { }; # ToDo: tests fail
+
+  gdm = callPackage ./core/gdm { };
+
+  gjs = callPackage ./core/gjs { };
+
+  glib_networking = pkgs.glib_networking.override {
+    inherit gsettings_desktop_schemas;
+  };
+
+  gnome-backgrounds = callPackage ./core/gnome-backgrounds { };
+
+  gnome-bluetooth = callPackage ./core/gnome-bluetooth { };
+
+  gnome-contacts = callPackage ./core/gnome-contacts { };
+
+  gnome_control_center = callPackage ./core/gnome-control-center { };
+
+  gnome-calculator = callPackage ./core/gnome-calculator { };
+
+  gnome_common = callPackage ./core/gnome-common { };
+
+  gnome_desktop = callPackage ./core/gnome-desktop { };
+
+  gnome-dictionary = callPackage ./core/gnome-dictionary { };
+
+  gnome-disk-utility = callPackage ./core/gnome-disk-utility { };
+
+  gnome-font-viewer = callPackage ./core/gnome-font-viewer { };
+
+  gnome-menus = callPackage ./core/gnome-menus { };
+
+  gnome_keyring = callPackage ./core/gnome-keyring { };
+
+  libgnome_keyring = callPackage ./core/libgnome-keyring { };
+
+  libgnomekbd = callPackage ./core/libgnomekbd { };
+
+  folks = callPackage ./core/folks { };
+
+  gnome_online_accounts = callPackage ./core/gnome-online-accounts { };
+
+  gnome-online-miners = callPackage ./core/gnome-online-miners { };
+
+  gnome_session = callPackage ./core/gnome-session { };
+
+  gnome_shell = callPackage ./core/gnome-shell { };
+
+  gnome-shell-extensions = callPackage ./core/gnome-shell-extensions { };
+
+  gnome-screenshot = callPackage ./core/gnome-screenshot { };
+
+  gnome_settings_daemon = callPackage ./core/gnome-settings-daemon { };
+
+  gnome-system-log = callPackage ./core/gnome-system-log { };
+
+  gnome-system-monitor = callPackage ./core/gnome-system-monitor { };
+
+  gnome_terminal = callPackage ./core/gnome-terminal { };
+
+  gnome_themes_standard = callPackage ./core/gnome-themes-standard { };
+
+  gnome-user-docs = callPackage ./core/gnome-user-docs { };
+
+  gnome-user-share = callPackage ./core/gnome-user-share { };
+
+  grilo = callPackage ./core/grilo { };
+
+  grilo-plugins = callPackage ./core/grilo-plugins { };
+
+  gsettings_desktop_schemas = callPackage ./core/gsettings-desktop-schemas { };
+
+  gsound = callPackage ./core/gsound { };
+
+  gtksourceview = callPackage ./core/gtksourceview { };
+
+  gucharmap = callPackage ./core/gucharmap { };
+
+  gvfs = pkgs.gvfs.override { gnome = gnome3; gnomeSupport = true; };
+
+  eog = callPackage ./core/eog { };
+
+  libcroco = callPackage ./core/libcroco {};
+
+  libgee = callPackage ./core/libgee { };
+
+  libgdata = callPackage ./core/libgdata { };
+
+  libgxps = callPackage ./core/libgxps { };
+
+  libpeas = callPackage ./core/libpeas {};
+
+  libgweather = callPackage ./core/libgweather { };
+
+  libzapojit = callPackage ./core/libzapojit { };
+
+  mutter = callPackage ./core/mutter { };
+
+  nautilus = callPackage ./core/nautilus { };
+
+  networkmanager_openvpn = pkgs.networkmanager_openvpn.override {
+    inherit gnome3;
+  };
+
+  networkmanager_pptp = pkgs.networkmanager_pptp.override {
+    inherit gnome3;
+  };
+
+  networkmanager_vpnc = pkgs.networkmanager_vpnc.override {
+    inherit gnome3;
+  };
+
+  networkmanager_openconnect = pkgs.networkmanager_openconnect.override {
+    inherit gnome3;
+  };
+
+  networkmanager_l2tp = pkgs.networkmanager_l2tp.override {
+    inherit gnome3;
+  };
+
+  networkmanagerapplet = pkgs.networkmanagerapplet.override {
+    inherit gnome3 gsettings_desktop_schemas glib_networking;
+  };
+
+  rest = callPackage ./core/rest { };
+
+  sushi = callPackage ./core/sushi {
+    clutter-gst = pkgs.clutter-gst;
+  };
+
+  totem = callPackage ./core/totem { };
+
+  totem-pl-parser = callPackage ./core/totem-pl-parser { };
+
+  tracker = callPackage ./core/tracker { giflib = pkgs.giflib_5_0; };
+
+  vte = callPackage ./core/vte { };
+
+  vte_290 = callPackage ./core/vte/2.90.nix { };
+
+  vte-select-text = vte.override { selectTextPatch = true; };
+
+  vino = callPackage ./core/vino { };
+
+  yelp = callPackage ./core/yelp { };
+
+  yelp_xsl = callPackage ./core/yelp-xsl { };
+
+  yelp_tools = callPackage ./core/yelp-tools { };
+
+  zenity = callPackage ./core/zenity { };
+
+
+#### Apps (http://ftp.acc.umu.se/pub/GNOME/apps/)
+
+  accerciser = callPackage ./apps/accerciser { };
+
+  bijiben = callPackage ./apps/bijiben {
+    webkitgtk = webkitgtk24x;
+  };
+
+  cheese = callPackage ./apps/cheese { };
+
+  evolution = callPackage ./apps/evolution {
+    webkitgtk = webkitgtk24x;
+  };
+
+  file-roller = callPackage ./apps/file-roller { };
+
+  gedit = callPackage ./apps/gedit { };
+
+  glade = callPackage ./apps/glade { };
+
+  gnome-boxes = callPackage ./apps/gnome-boxes {
+    gtkvnc = pkgs.gtkvnc.override { enableGTK3 = true; };
+    spice_gtk = pkgs.spice_gtk.override { enableGTK3 = true; };
+  };
+
+  gnome-calendar = callPackage ./apps/gnome-calendar { };
+
+  gnome-characters = callPackage ./apps/gnome-characters { };
+
+  gnome-clocks = callPackage ./apps/gnome-clocks { };
+
+  gnome-documents = callPackage ./apps/gnome-documents { };
+
+  gnome-getting-started-docs = callPackage ./apps/gnome-getting-started-docs { };
+
+  gnome-logs = callPackage ./apps/gnome-logs { };
+
+  gnome-maps = callPackage ./apps/gnome-maps { };
+
+  gnome-music = callPackage ./apps/gnome-music { };
+
+  gnome-nettool = callPackage ./apps/gnome-nettool { };
+
+  gnome-photos = callPackage ./apps/gnome-photos {
+    gegl = gegl_0_3;
+  };
+
+  gnome-weather = callPackage ./apps/gnome-weather { };
+
+  nautilus-sendto = callPackage ./apps/nautilus-sendto { };
+
+  polari = callPackage ./apps/polari { };
+
+  # scrollkeeper replacement
+  rarian = callPackage ./desktop/rarian { };
+
+  seahorse = callPackage ./apps/seahorse { };
+
+  vinagre = callPackage ./apps/vinagre { };
+
+#### Dev http://ftp.gnome.org/pub/GNOME/devtools/
+
+  anjuta = callPackage ./devtools/anjuta { };
+
+  devhelp = callPackage ./devtools/devhelp {
+    webkitgtk = webkitgtk24x;
+  };
+
+  gdl = callPackage ./devtools/gdl { };
+
+  gnome-devel-docs = callPackage ./devtools/gnome-devel-docs { };
+
+#### Games
+
+  aisleriot = callPackage ./games/aisleriot { };
+
+  five-or-more = callPackage ./games/five-or-more { };
+
+  four-in-a-row = callPackage ./games/four-in-a-row { };
+
+  gnome-chess = callPackage ./games/gnome-chess { };
+
+  gnome-klotski = callPackage ./games/gnome-klotski { };
+
+  gnome-mahjongg = callPackage ./games/gnome-mahjongg { };
+
+  gnome-mines = callPackage ./games/gnome-mines { };
+
+  gnome-nibbles = callPackage ./games/gnome-nibbles { };
+
+  gnome-robots = callPackage ./games/gnome-robots { };
+
+  gnome-sudoku = callPackage ./games/gnome-sudoku { };
+
+  gnome-taquin = callPackage ./games/gnome-taquin { };
+
+  gnome-tetravex = callPackage ./games/gnome-tetravex { };
+
+  hitori = callPackage ./games/hitori { };
+
+  iagno = callPackage ./games/iagno { };
+
+  lightsoff = callPackage ./games/lightsoff { };
+
+  swell-foop = callPackage ./games/swell-foop { };
+
+  tali = callPackage ./games/tali { };
+
+  quadrapassel = callPackage ./games/quadrapassel { };
+
+#### Misc -- other packages on http://ftp.gnome.org/pub/GNOME/sources/
+
+  california = callPackage ./misc/california { };
+
+  geary = callPackage ./misc/geary { 
+    webkitgtk = webkitgtk24x;
+  };
+
+  gfbgraph = callPackage ./misc/gfbgraph { };
+
+  gitg = callPackage ./misc/gitg { 
+    webkitgtk = webkitgtk24x;
+  };
+
+  libgda = callPackage ./misc/libgda { };
+
+  libgit2-glib = callPackage ./misc/libgit2-glib {
+    libgit2 = pkgs.libgit2.override { libssh2 = null; };
+  };
+
+  libmediaart = callPackage ./misc/libmediaart { };
+
+  gexiv2 = callPackage ./misc/gexiv2 { };
+
+  gnome-tweak-tool = callPackage ./misc/gnome-tweak-tool { };
+
+  gpaste = callPackage ./misc/gpaste { };
+
+  gtkhtml = callPackage ./misc/gtkhtml { };
+
+  pomodoro = callPackage ./misc/pomodoro { };
+
+  gnome-video-effects = callPackage ./misc/gnome-video-effects { };
+
+    };
+  in self; # pkgsFun
+
+in pkgsFun {}
diff --git a/pkgs/desktops/gnome-3/3.18/desktop/rarian/default.nix b/pkgs/desktops/gnome-3/3.18/desktop/rarian/default.nix
new file mode 100644
index 00000000000..a1b38b21869
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/desktop/rarian/default.nix
@@ -0,0 +1,16 @@
+{stdenv, fetchurl, pkgconfig, perl, perlXMLParser, libxml2, libxslt, docbook_xml_dtd_42}:
+
+stdenv.mkDerivation rec {
+  name = "rarian-0.8.1";
+  src = fetchurl {
+    url = "mirror://gnome/sources/rarian/0.8/${name}.tar.bz2";
+    sha256 = "aafe886d46e467eb3414e91fa9e42955bd4b618c3e19c42c773026b205a84577";
+  };
+
+  buildInputs = [pkgconfig perl perlXMLParser libxml2 libxslt];
+  configureFlags = "--with-xml-catalog=${docbook_xml_dtd_42}/xml/dtd/docbook/docbook.cat";
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/anjuta/default.nix b/pkgs/desktops/gnome-3/3.18/devtools/anjuta/default.nix
new file mode 100644
index 00000000000..af74df4ad13
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/anjuta/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, flex, bison, libxml2, intltool,
+  itstool, python, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ pkgconfig flex bison gtk3 libxml2 gnome3.gjs gnome3.gdl
+    gnome3.libgda gnome3.gtksourceview intltool itstool python makeWrapper ];
+
+  preFixup = ''
+    wrapProgram $out/bin/anjuta \
+      --prefix XDG_DATA_DIRS : \
+        "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Software development studio";
+    homepage = http://anjuta.org/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/anjuta/src.nix b/pkgs/desktops/gnome-3/3.18/devtools/anjuta/src.nix
new file mode 100644
index 00000000000..835024c3447
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/anjuta/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "anjuta-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/anjuta/3.18/anjuta-3.18.0.tar.xz;
+    sha256 = "6a3fec0963f04bc62a9dfb951e577a3276d39c3414083ef73163c3fea8e741ba";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/devhelp/default.nix b/pkgs/desktops/gnome-3/3.18/devtools/devhelp/default.nix
new file mode 100644
index 00000000000..1cfae754cfe
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/devhelp/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, webkitgtk, intltool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook webkitgtk intltool gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://live.gnome.org/devhelp;
+    description = "API documentation browser for GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/devhelp/src.nix b/pkgs/desktops/gnome-3/3.18/devtools/devhelp/src.nix
new file mode 100644
index 00000000000..8da63dc2685
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/devhelp/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "devhelp-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/devhelp/3.18/devhelp-3.18.0.tar.xz;
+    sha256 = "2494af16fedc311d7bb50bc47c32a69035f7b95fd7995d9db4fe497926087fb5";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/gdl/default.nix b/pkgs/desktops/gnome-3/3.18/devtools/gdl/default.nix
new file mode 100644
index 00000000000..156d91b3eae
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/gdl/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, fetchurl, pkgconfig, libxml2, gtk3, gnome3, intltool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig libxml2 gtk3 intltool ];
+
+  meta = with stdenv.lib; {
+    description = "Gnome docking library";
+    homepage = https://developer.gnome.org/gdl/;
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/gdl/src.nix b/pkgs/desktops/gnome-3/3.18/devtools/gdl/src.nix
new file mode 100644
index 00000000000..3fd39139799
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/gdl/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gdl-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gdl/3.18/gdl-3.18.0.tar.xz;
+    sha256 = "1499884e4fce375a963cf2b98b90e6724144f9b1f1ac8b84d765f4c85a2140b2";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/default.nix b/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/default.nix
new file mode 100644
index 00000000000..50960f41a31
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, fetchurl, gnome3, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ intltool itstool libxml2 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/GNOME/gnome-devel-docs;
+    description = "Developer documentation for GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.fdl12;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/src.nix b/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/src.nix
new file mode 100644
index 00000000000..50a575945d7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/devtools/gnome-devel-docs/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-devel-docs-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-devel-docs/3.18/gnome-devel-docs-3.18.0.tar.xz;
+    sha256 = "f237fb8593ada0346ccc932ae17647a883cc9f7026f4cad16f084bb7420e0925";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/aisleriot/default.nix b/pkgs/desktops/gnome-3/3.18/games/aisleriot/default.nix
new file mode 100644
index 00000000000..e149a0b3126
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/aisleriot/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, intltool, itstool, gtk3
+, wrapGAppsHook, gconf, librsvg, libxml2, desktop_file_utils
+, guile, libcanberra_gtk3 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  configureFlags = [ "--with-card-theme-formats=svg" ];
+
+  buildInputs = [ pkgconfig intltool itstool gtk3 wrapGAppsHook gconf
+                  librsvg libxml2 desktop_file_utils guile libcanberra_gtk3 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Aisleriot;
+    description = "A collection of patience games written in guile scheme";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/aisleriot/src.nix b/pkgs/desktops/gnome-3/3.18/games/aisleriot/src.nix
new file mode 100644
index 00000000000..465fccd15b4
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/aisleriot/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "aisleriot-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/aisleriot/3.18/aisleriot-3.18.0.tar.xz;
+    sha256 = "3421f7dabe482ddae2fd2a053a13a2a9549fe960fec5838ab4fe6d89cff054dd";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/five-or-more/default.nix b/pkgs/desktops/gnome-3/3.18/games/five-or-more/default.nix
new file mode 100644
index 00000000000..50a7d2906a7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/five-or-more/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook librsvg intltool itstool libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Five_or_more;
+    description = "Remove colored balls from the board by forming lines";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/five-or-more/src.nix b/pkgs/desktops/gnome-3/3.18/games/five-or-more/src.nix
new file mode 100644
index 00000000000..37d9794dc1b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/five-or-more/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "five-or-more-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/five-or-more/3.18/five-or-more-3.18.0.tar.xz;
+    sha256 = "e1e7cc81b1281382da9a6ab466d97f09561dbaf39031a9b93f0a45221234fe62";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/default.nix b/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/default.nix
new file mode 100644
index 00000000000..68228750cd8
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, intltool, itstool, libcanberra_gtk3, librsvg, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool libcanberra_gtk3 librsvg
+    libxml2 gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Four-in-a-row;
+    description = "Make lines of the same color to win";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/src.nix b/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/src.nix
new file mode 100644
index 00000000000..dc24a4366e3
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/four-in-a-row/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "four-in-a-row-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/four-in-a-row/3.18/four-in-a-row-3.18.0.tar.xz;
+    sha256 = "a65fece60b66122fbf5fddf646ac2acffc58a802cf3e87e5985d5b962d53df48";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-chess/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-chess/default.nix
new file mode 100644
index 00000000000..a96dae3c12c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-chess/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, intltool, itstool, librsvg, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool librsvg libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Chess;
+    description = "Play the classic two-player boardgame of chess";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-chess/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-chess/src.nix
new file mode 100644
index 00000000000..5cbbb6c9025
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-chess/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-chess-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-chess/3.18/gnome-chess-3.18.0.tar.xz;
+    sha256 = "c841198935d807618c3cecbf10ed24643390d504e17961717bac455f4e1b37ad";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/default.nix
new file mode 100644
index 00000000000..b13bf8afbfa
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, libxml2, intltool, itstool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool librsvg libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Klotski;
+    description = "Slide blocks to solve the puzzle";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/src.nix
new file mode 100644
index 00000000000..c772988198c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-klotski/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-klotski-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-klotski/3.18/gnome-klotski-3.18.0.tar.xz;
+    sha256 = "75ef9f7b3b09edf660165f62f8797f3850a49d6be4de0c258ee7d828e67820f2";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/default.nix
new file mode 100644
index 00000000000..43db32e8857
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook librsvg intltool itstool libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Mahjongg;
+    description = "Disassemble a pile of tiles by removing matching pairs";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/src.nix
new file mode 100644
index 00000000000..214c4a7d6e0
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-mahjongg/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-mahjongg-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-mahjongg/3.18/gnome-mahjongg-3.18.0.tar.xz;
+    sha256 = "7034428f5ac04bfd90689ee66894a6948a2ff1bfa2d2548f7559d2134b967405";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-mines/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-mines/default.nix
new file mode 100644
index 00000000000..4d703bb37a7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-mines/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook librsvg intltool itstool libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Mines;
+    description = "Clear hidden mines from a minefield";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-mines/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-mines/src.nix
new file mode 100644
index 00000000000..e5099ac9575
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-mines/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-mines-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-mines/3.18/gnome-mines-3.18.0.tar.xz;
+    sha256 = "8b4c05ef0ab43031661e3cdb1b17ba551efe4e4488fe4462fee9557cd10a64f9";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/default.nix
new file mode 100644
index 00000000000..85ffeb3c50f
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, libcanberra_gtk3, clutter_gtk, intltool, itstool
+, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool libxml2
+    librsvg libcanberra_gtk3 clutter_gtk gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Nibbles;
+    description = "Guide a worm around a maze";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/src.nix
new file mode 100644
index 00000000000..d82422619f8
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-nibbles/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-nibbles-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-nibbles/3.18/gnome-nibbles-3.18.0.tar.xz;
+    sha256 = "9ffc549d574774905c79b391d3e59f8045f47504d96279d9b26cc602f59ad545";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-robots/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-robots/default.nix
new file mode 100644
index 00000000000..3c318fa847c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-robots/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, libcanberra_gtk3, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool librsvg libcanberra_gtk3
+    libxml2 gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Robots;
+    description = "Avoid the robots and make them crash into each other";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-robots/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-robots/src.nix
new file mode 100644
index 00000000000..228e2ca81b1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-robots/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-robots-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-robots/3.18/gnome-robots-3.18.0.tar.xz;
+    sha256 = "34311cb9de6a970f00fa9743dced2925e98f40f77b4a406e17b589412cb902fc";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/default.nix
new file mode 100644
index 00000000000..c8ba82c7246
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl, pkgconfig, intltool, gtk3, gnome3, wrapGAppsHook
+, json_glib, qqwing, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig intltool wrapGAppsHook gtk3 gnome3.libgee
+                  json_glib qqwing itstool libxml2 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Sudoku;
+    description = "Test your logic skills in this number grid puzzle";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/src.nix
new file mode 100644
index 00000000000..f7dd422bec5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-sudoku/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-sudoku-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-sudoku/3.18/gnome-sudoku-3.18.0.tar.xz;
+    sha256 = "e6180b14f7ccb9ec43e187cf358eceaf707edb4d9defff3386ae4ef8e53cce5b";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/default.nix
new file mode 100644
index 00000000000..78eaa23e63b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, librsvg, libcanberra_gtk3, intltool, itstool, libxml2 }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook librsvg libcanberra_gtk3
+    intltool itstool libxml2 gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Taquin;
+    description = "Move tiles so that they reach their places";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/src.nix
new file mode 100644
index 00000000000..41cb361edb3
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-taquin/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-taquin-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-taquin/3.18/gnome-taquin-3.18.0.tar.xz;
+    sha256 = "3cee6a52003ccec3147020d24c079a0cd01b6855fcd486ef20a60e0f862e8760";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/default.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/default.nix
new file mode 100644
index 00000000000..d6feab93dba
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, libxml2, intltool, itstool }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool libxml2 gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Tetravex;
+    description = "Complete the puzzle by matching numbered tiles";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/src.nix b/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/src.nix
new file mode 100644
index 00000000000..d73562835e4
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/gnome-tetravex/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-tetravex-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-tetravex/3.18/gnome-tetravex-3.18.0.tar.xz;
+    sha256 = "ea00ff5ea9a3b583c4d755cefa2725dd7b3b0781972af1c56377c7eda48cb579";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/hitori/default.nix b/pkgs/desktops/gnome-3/3.18/games/hitori/default.nix
new file mode 100644
index 00000000000..bd6be7d43c5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/hitori/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, pkgconfig, gnome3, gtk3, wrapGAppsHook
+, libxml2, intltool, itstool }:
+
+stdenv.mkDerivation rec {
+  name = "hitori-${gnome3.version}.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/hitori/${gnome3.version}/${name}.tar.xz";
+    sha256 = "07pm3xl05jgb8x151k1j2ap57dmfvk2nkz9dmqnn5iywfigsysd1";
+  };
+
+  buildInputs = [
+    pkgconfig gtk3 wrapGAppsHook intltool itstool libxml2
+    gnome3.defaultIconTheme
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Hitori;
+    description = "GTK+ application to generate and let you play games of Hitori";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/iagno/default.nix b/pkgs/desktops/gnome-3/3.18/games/iagno/default.nix
new file mode 100644
index 00000000000..1b6f08d1fd6
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/iagno/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, gdk_pixbuf, librsvg, wrapGAppsHook
+, intltool, itstool, libcanberra_gtk3, libxml2, dconf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 gnome3.defaultIconTheme gdk_pixbuf librsvg
+                  dconf libxml2 libcanberra_gtk3 wrapGAppsHook itstool intltool ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Iagno;
+    description = "Computer version of the game Reversi, more popularly called Othello";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/iagno/src.nix b/pkgs/desktops/gnome-3/3.18/games/iagno/src.nix
new file mode 100644
index 00000000000..09b30cf066b
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/iagno/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "iagno-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/iagno/3.18/iagno-3.18.0.tar.xz;
+    sha256 = "4a03b474f9b0f0812c8b22b4991aa6dd894dedc05959001fd9e3e09d0d323c56";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/lightsoff/default.nix b/pkgs/desktops/gnome-3/3.18/games/lightsoff/default.nix
new file mode 100644
index 00000000000..8ec54b48972
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/lightsoff/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, gdk_pixbuf, librsvg, wrapGAppsHook
+, intltool, itstool, clutter, clutter_gtk, libxml2, dconf }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 gnome3.defaultIconTheme gdk_pixbuf librsvg dconf
+                  libxml2 clutter clutter_gtk wrapGAppsHook itstool intltool ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Lightsoff;
+    description = "Puzzle game, where the objective is to turn off all of the tiles on the board";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/lightsoff/src.nix b/pkgs/desktops/gnome-3/3.18/games/lightsoff/src.nix
new file mode 100644
index 00000000000..6645182b3a4
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/lightsoff/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "lightsoff-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/lightsoff/3.18/lightsoff-3.18.0.tar.xz;
+    sha256 = "cd5126dae4506363d9196ce8ba083a769d9f8c287fb0008db53cecf6cdc55d61";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/quadrapassel/default.nix b/pkgs/desktops/gnome-3/3.18/games/quadrapassel/default.nix
new file mode 100644
index 00000000000..f319608764d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/quadrapassel/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, gdk_pixbuf
+, librsvg, libcanberra_gtk3
+, intltool, itstool, libxml2, clutter, clutter_gtk, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 gnome3.defaultIconTheme gdk_pixbuf librsvg
+                  libcanberra_gtk3 itstool intltool clutter
+                  libxml2 clutter_gtk wrapGAppsHook ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Quadrapassel;
+    description = "Classic falling-block game, Tetris";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/quadrapassel/src.nix b/pkgs/desktops/gnome-3/3.18/games/quadrapassel/src.nix
new file mode 100644
index 00000000000..55b70b7ec58
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/quadrapassel/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "quadrapassel-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/quadrapassel/3.18/quadrapassel-3.18.0.tar.xz;
+    sha256 = "2cd1d5328ab9e2c7041936e8e7e01157f292aa4428da81175fb1aa15d40ef8e1";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/swell-foop/default.nix b/pkgs/desktops/gnome-3/3.18/games/swell-foop/default.nix
new file mode 100644
index 00000000000..3d3e424d0da
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/swell-foop/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, gdk_pixbuf, librsvg, dconf
+, clutter, clutter_gtk, intltool, itstool, libxml2, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 gnome3.defaultIconTheme gdk_pixbuf librsvg
+                  dconf wrapGAppsHook itstool intltool clutter clutter_gtk libxml2 ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = "https://wiki.gnome.org/Apps/Swell%20Foop";
+    description = "Puzzle game, previously known as Same GNOME";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/swell-foop/src.nix b/pkgs/desktops/gnome-3/3.18/games/swell-foop/src.nix
new file mode 100644
index 00000000000..ea127d8c8dc
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/swell-foop/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "swell-foop-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/swell-foop/3.18/swell-foop-3.18.0.tar.xz;
+    sha256 = "b105a36e04dc33e2fe1c3200ed62efea0a68e2411453cb41269508aa739d2936";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/tali/default.nix b/pkgs/desktops/gnome-3/3.18/games/tali/default.nix
new file mode 100644
index 00000000000..c2b1f585712
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/tali/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, gnome3, gdk_pixbuf
+, librsvg, intltool, itstool, libxml2, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 gnome3.defaultIconTheme gdk_pixbuf librsvg
+                  libxml2 itstool intltool wrapGAppsHook ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Tali;
+    description = "Sort of poker with dice and less money";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/games/tali/src.nix b/pkgs/desktops/gnome-3/3.18/games/tali/src.nix
new file mode 100644
index 00000000000..12c8aefcd71
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/games/tali/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "tali-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/tali/3.18/tali-3.18.0.tar.xz;
+    sha256 = "fe785ed2c3eeca8706834a967c0011cfee016008b4e55c1f5e0529b348bc9864";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/california/0002-Build-with-evolution-data-server-3.13.90.patch b/pkgs/desktops/gnome-3/3.18/misc/california/0002-Build-with-evolution-data-server-3.13.90.patch
new file mode 100644
index 00000000000..c229cc96094
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/california/0002-Build-with-evolution-data-server-3.13.90.patch
@@ -0,0 +1,39 @@
+diff --git a/configure.ac b/configure.ac
+index 8a94642..1ca6426 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -27,7 +27,7 @@ AC_SUBST(LDFLAGS)
+ GLIB_REQUIRED=2.38.0
+ GTK_REQUIRED=3.12.2
+ GEE_REQUIRED=0.10.5
+-ECAL_REQUIRED=3.8.5
++ECAL_REQUIRED=3.13.90
+ LIBSOUP_REQUIRED=2.44
+ GDATA_REQUIRED=0.14.0
+ GOA_REQUIRED=3.8.3
+diff --git a/src/backing/eds/backing-eds-calendar-source.vala b/src/backing/eds/backing-eds-calendar-source.vala
+index ee6a572..5009b5d 100644
+--- a/src/backing/eds/backing-eds-calendar-source.vala
++++ b/src/backing/eds/backing-eds-calendar-source.vala
+@@ -256,7 +256,7 @@ internal class EdsCalendarSource : CalendarSource {
+
+     // Invoked by EdsStore prior to making it available outside of unit
+     internal async void open_async(Cancellable? cancellable) throws Error {
+-        client = (E.CalClient) yield E.CalClient.connect(eds_source, E.CalClientSourceType.EVENTS,
++        client = (E.CalClient) yield E.CalClient.connect(eds_source, E.CalClientSourceType.EVENTS, 1,
+             cancellable);
+
+         client.bind_property("readonly", this, PROP_READONLY, BindingFlags.SYNC_CREATE);
+diff --git a/vapi/libecal-1.2.vapi b/vapi/libecal-1.2.vapi
+index 6ead3ec..46fd711 100644
+--- a/vapi/libecal-1.2.vapi
++++ b/vapi/libecal-1.2.vapi
+@@ -23,7 +23,7 @@ namespace E {
+		public bool check_save_schedules ();
+		public static bool check_timezones (iCal.icalcomponent comp, GLib.List comps, GLib.Callback tzlookup, void* ecalclient, GLib.Cancellable cancellable) throws GLib.Error;
+		[CCode (finish_name = "e_cal_client_connect_finish")]
+-		public static async unowned E.Client connect (E.Source source, E.CalClientSourceType source_type, GLib.Cancellable cancellable) throws GLib.Error;
++		public static async unowned E.Client connect (E.Source source, E.CalClientSourceType source_type, uint32 wait_for_connected_seconds, GLib.Cancellable cancellable) throws GLib.Error;
+		public static unowned E.Client connect_sync (E.Source source, E.CalClientSourceType source_type, GLib.Cancellable cancellable) throws GLib.Error;
+		[CCode (finish_name = "e_cal_client_create_object_finish")]
+		public async void create_object (iCal.icalcomponent icalcomp, GLib.Cancellable? cancellable, out string out_uid) throws GLib.Error;
diff --git a/pkgs/desktops/gnome-3/3.18/misc/california/default.nix b/pkgs/desktops/gnome-3/3.18/misc/california/default.nix
new file mode 100644
index 00000000000..4bdeeb23a91
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/california/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gtk3, vala, makeWrapper
+, gnome3, glib, libsoup, libgdata, sqlite, itstool, xdg_utils }:
+
+let
+  majorVersion = "0.4";
+in
+stdenv.mkDerivation rec {
+  name = "california-${majorVersion}.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/california/${majorVersion}/${name}.tar.xz";
+    sha256 = "1dky2kllv469k8966ilnf4xrr7z35pq8mdvs7kwziy59cdikapxj";
+  };
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ makeWrapper intltool pkgconfig vala glib gtk3 gnome3.libgee
+    libsoup libgdata gnome3.gnome_online_accounts gnome3.evolution_data_server
+    sqlite itstool xdg_utils gnome3.gsettings_desktop_schemas ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/california" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gnome3.defaultIconTheme}/share:${gnome3.gnome_themes_standard}/share:$out/share:$GSETTINGS_SCHEMAS_PATH:${gnome3.gsettings_desktop_schemas}/share"
+  '';
+
+  enableParallelBuilding = true;
+
+  # Apply fedoras patch to build with evolution-data-server >3.13
+  patches = [ ./0002-Build-with-evolution-data-server-3.13.90.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/California;
+    description = "Calendar application for GNOME 3";
+    maintainers = with maintainers; [ pSub ];
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/geary/default.nix b/pkgs/desktops/gnome-3/3.18/misc/geary/default.nix
new file mode 100644
index 00000000000..11655edded0
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/geary/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gtk3, vala
+, makeWrapper, gdk_pixbuf, cmake, desktop_file_utils
+, libnotify, libcanberra, libsecret, gmime
+, libpthreadstubs, sqlite
+, gnome3, librsvg, gnome_doc_utils, webkitgtk }:
+
+let
+  majorVersion = "0.8";
+in
+stdenv.mkDerivation rec {
+  name = "geary-${majorVersion}.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/geary/${majorVersion}/${name}.tar.xz";
+    sha256 = "3cfa626168935acf49c9415fad54c7849f17fd833026cfd3c224ba0fb892d641";
+  };
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  buildInputs = [ intltool pkgconfig gtk3 makeWrapper cmake desktop_file_utils gnome_doc_utils
+                  vala webkitgtk libnotify libcanberra gnome3.libgee libsecret gmime sqlite
+                  libpthreadstubs gnome3.gsettings_desktop_schemas gnome3.gcr
+                  gdk_pixbuf librsvg gnome3.defaultIconTheme ];
+
+  preConfigure = ''
+    substituteInPlace src/CMakeLists.txt --replace '`pkg-config --variable=girdir gobject-introspection-1.0`' '${webkitgtk}/share/gir-1.0'
+  '';
+
+  postInstall = ''
+    mkdir -p $out/share/gsettings-schemas/${name}/
+    mv $out/share/glib-2.0 $out/share/gsettings-schemas/${name}
+  '';
+
+  preFixup = ''
+    wrapProgram "$out/bin/geary" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gnome3.gnome_themes_standard}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  enableParallelBuilding = true;
+
+  patches = [ ./disable_valadoc.patch ];
+  patchFlags = "-p0";
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Apps/Geary;
+    description = "Mail client for GNOME 3";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/geary/disable_valadoc.patch b/pkgs/desktops/gnome-3/3.18/misc/geary/disable_valadoc.patch
new file mode 100644
index 00000000000..e65c0dea747
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/geary/disable_valadoc.patch
@@ -0,0 +1,24 @@
+--- src/CMakeLists.txt.orig	2014-05-23 14:41:20.809160364 +0200
++++ src/CMakeLists.txt	2014-05-23 14:41:29.240261581 +0200
+@@ -696,21 +696,6 @@
+         ${CMAKE_COMMAND} -E copy geary-mailer ${CMAKE_BINARY_DIR}/
+ )
+ 
+-# Valadoc
+-#################################################
+-foreach(pkg ${ENGINE_PACKAGES})
+-    list(APPEND valadoc_pkg_opts "--pkg=${pkg}")
+-endforeach(pkg ${ENGINE_PACKAGES})
+-
+-include(FindValadoc)
+-add_custom_target(
+-    valadoc
+-    WORKING_DIRECTORY
+-        ${CMAKE_SOURCE_DIR}/src
+-    COMMAND
+-        ${VALADOC_EXECUTABLE} --force --no-protected -b ${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SOURCE_DIR}/valadoc --package-name=geary --package-version=${VERSION} ${ENGINE_SRC} ${valadoc_pkg_opts} --vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
+-)
+-
+ ## Make clean: remove copied files
+ ##################################################
+ set_property(
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gexiv2/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gexiv2/default.nix
new file mode 100644
index 00000000000..7cea9cd8d15
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gexiv2/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, exiv2, glib, libtool, m4, gnome3 }:
+
+let
+  majorVersion = "0.10";
+in
+stdenv.mkDerivation rec {
+  name = "gexiv2-${version}";
+  version = "${majorVersion}.3";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gexiv2/${majorVersion}/${name}.tar.xz";
+    sha256 = "390cfb966197fa9f3f32200bc578d7c7f3560358c235e6419657206a362d3988";
+  };
+
+  preConfigure = ''
+    patchShebangs .
+  '';
+
+  buildInputs = [ pkgconfig glib libtool m4 ];
+  propagatedBuildInputs = [ exiv2 ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/gexiv2;
+    description = "GObject wrapper around the Exiv2 photo metadata library";
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gfbgraph/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gfbgraph/default.nix
new file mode 100644
index 00000000000..e85b087fa41
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gfbgraph/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, intltool, fetchurl, pkgconfig, glib
+, gnome3, libsoup, json_glib }:
+
+stdenv.mkDerivation rec {
+  name = "gfbgraph-0.2.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gfbgraph/0.2/${name}.tar.xz";
+    sha256 = "66c7b1c951863565c179d0b4b5207f27b3b36f80afed9f6a9acfc5fc3ae775d4";
+  };
+
+  buildInputs = [ pkgconfig glib gnome3.gnome_online_accounts ];
+  propagatedBuildInputs = [ libsoup json_glib gnome3.rest ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "GLib/GObject wrapper for the Facebook Graph API";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gitg/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gitg/default.nix
new file mode 100644
index 00000000000..c517fca57bf
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gitg/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, fetchgit, vala, intltool, libgit2, pkgconfig, gtk3, glib
+, json_glib, webkitgtk,  makeWrapper, libpeas, bash, gobjectIntrospection
+, gnome3, gtkspell3, shared_mime_info, libgee, libgit2-glib, librsvg }:
+
+# TODO: icons and theme still does not work
+# use packaged gnome3.adwaita-icon-theme 
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  preCheck = ''
+    substituteInPlace tests/libgitg/test-commit.c --replace "/bin/bash" "${bash}/bin/bash"
+  '';
+  doCheck = true;
+
+  makeFlags = "INTROSPECTION_GIRDIR=$(out)/share/gir-1.0/ INTROSPECTION_TYPELIBDIR=$(out)/lib/girepository-1.0";
+
+  propagatedUserEnvPkgs = [ shared_mime_info
+                            gnome3.gnome_themes_standard ];
+
+  buildInputs = [ vala intltool libgit2 pkgconfig gtk3 glib json_glib webkitgtk libgee libpeas
+                  libgit2-glib gtkspell3 gnome3.gsettings_desktop_schemas gnome3.gtksourceview librsvg
+                  gobjectIntrospection makeWrapper gnome3.adwaita-icon-theme ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gitg" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3}/share:${gnome3.gnome_themes_standard}/share:$out/share:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Apps/Gitg;
+    description = "GNOME GUI client to view git repositories";
+    maintainers = with maintainers; [ iElectric ];
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gitg/src.nix b/pkgs/desktops/gnome-3/3.18/misc/gitg/src.nix
new file mode 100644
index 00000000000..ac95070b5f5
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gitg/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gitg-3.18.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gitg/3.18/gitg-3.18.0.tar.xz;
+    sha256 = "fa4b7b9c492f13f5f1d864af1281ea377ac8c7619c856e05f533b18989edf421";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0001-Search-for-themes-and-icons-in-system-data-dirs.patch b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0001-Search-for-themes-and-icons-in-system-data-dirs.patch
new file mode 100644
index 00000000000..d5a6f90e33d
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0001-Search-for-themes-and-icons-in-system-data-dirs.patch
@@ -0,0 +1,123 @@
+From 175218579aa2b4f4974ff1cf4fd1ac93082a4714 Mon Sep 17 00:00:00 2001
+From: Jascha Geerds <jg@ekby.de>
+Date: Sat, 1 Aug 2015 21:01:11 +0200
+Subject: [PATCH 1/1] Search for themes and icons in system data dirs
+
+---
+ gtweak/tweaks/tweak_group_interface.py | 17 ++++-------------
+ gtweak/tweaks/tweak_group_keymouse.py  |  7 ++-----
+ gtweak/utils.py                        | 17 +++++++++++++++++
+ 3 files changed, 23 insertions(+), 18 deletions(-)
+
+diff --git a/gtweak/tweaks/tweak_group_interface.py b/gtweak/tweaks/tweak_group_interface.py
+index ed2ad5f..a319907 100644
+--- a/gtweak/tweaks/tweak_group_interface.py
++++ b/gtweak/tweaks/tweak_group_interface.py
+@@ -26,7 +26,7 @@ from gi.repository import Gtk
+ from gi.repository import GLib
+ 
+ import gtweak
+-from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file
++from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file, get_resource_dirs
+ from gtweak.tweakmodel import Tweak, TWEAK_GROUP_APPEARANCE
+ from gtweak.gshellwrapper import GnomeShellFactory
+ from gtweak.gsettings import GSettingsSetting
+@@ -46,10 +46,7 @@ class GtkThemeSwitcher(GSettingsComboTweak):
+ 
+     def _get_valid_themes(self):
+         """ Only shows themes that have variations for gtk+-3 and gtk+-2 """
+-        dirs = ( os.path.join(gtweak.DATA_DIR, "themes"),
+-                 os.path.join(GLib.get_user_data_dir(), "themes"),
+-                 os.path.join(os.path.expanduser("~"), ".themes"))
+-        valid = walk_directories(dirs, lambda d:
++        valid = walk_directories(get_resource_dirs('themes'), lambda d:
+                     os.path.exists(os.path.join(d, "gtk-2.0")) and \
+                         os.path.exists(os.path.join(d, "gtk-3.0")))
+         return valid
+@@ -64,10 +61,7 @@ class IconThemeSwitcher(GSettingsComboTweak):
+             **options)
+ 
+     def _get_valid_icon_themes(self):
+-        dirs = ( os.path.join(gtweak.DATA_DIR, "icons"),
+-                 os.path.join(GLib.get_user_data_dir(), "icons"),
+-                 os.path.join(os.path.expanduser("~"), ".icons"))
+-        valid = walk_directories(dirs, lambda d:
++        valid = walk_directories(get_resource_dirs("icons"), lambda d:
+                     os.path.isdir(d) and \
+ 			os.path.exists(os.path.join(d, "index.theme")))
+         return valid
+@@ -82,10 +76,7 @@ class CursorThemeSwitcher(GSettingsComboTweak):
+             **options)
+ 
+     def _get_valid_cursor_themes(self):
+-        dirs = ( os.path.join(gtweak.DATA_DIR, "icons"),
+-                 os.path.join(GLib.get_user_data_dir(), "icons"),
+-                 os.path.join(os.path.expanduser("~"), ".icons"))
+-        valid = walk_directories(dirs, lambda d:
++        valid = walk_directories(get_resource_dirs("icons"), lambda d:
+                     os.path.isdir(d) and \
+                         os.path.exists(os.path.join(d, "cursors")))
+         return valid
+diff --git a/gtweak/tweaks/tweak_group_keymouse.py b/gtweak/tweaks/tweak_group_keymouse.py
+index b56a4f4..3486098 100644
+--- a/gtweak/tweaks/tweak_group_keymouse.py
++++ b/gtweak/tweaks/tweak_group_keymouse.py
+@@ -20,7 +20,7 @@ import os.path
+ from gi.repository import GLib
+ 
+ import gtweak
+-from gtweak.utils import XSettingsOverrides, walk_directories, make_combo_list_with_default
++from gtweak.utils import XSettingsOverrides, walk_directories, make_combo_list_with_default, get_resource_dirs
+ from gtweak.widgets import ListBoxTweakGroup, GSettingsComboTweak, GSettingsSwitchTweak, GetterSetterSwitchTweak, Title
+ 
+ class PrimaryPasteTweak(GetterSetterSwitchTweak):
+@@ -47,10 +47,7 @@ class KeyThemeSwitcher(GSettingsComboTweak):
+             **options)
+ 
+     def _get_valid_key_themes(self):
+-        dirs = ( os.path.join(gtweak.DATA_DIR, "themes"),
+-                 os.path.join(GLib.get_user_data_dir(), "themes"),
+-                 os.path.join(os.path.expanduser("~"), ".themes"))
+-        valid = walk_directories(dirs, lambda d:
++        valid = walk_directories(get_resource_dirs("themes"), lambda d:
+                     os.path.isfile(os.path.join(d, "gtk-3.0", "gtk-keys.css")) and \
+                     os.path.isfile(os.path.join(d, "gtk-2.0-key", "gtkrc")))
+         return valid
+diff --git a/gtweak/utils.py b/gtweak/utils.py
+index 3d20425..0fcb51d 100644
+--- a/gtweak/utils.py
++++ b/gtweak/utils.py
+@@ -21,6 +21,7 @@ import tempfile
+ import shutil
+ import subprocess
+ import glob
++import itertools
+ 
+ import gtweak
+ from gtweak.gsettings import GSettingsSetting
+@@ -114,6 +115,22 @@ def execute_subprocess(cmd_then_args, block=True):
+         stdout, stderr = p.communicate()
+         return stdout, stderr, p.returncode
+ 
++def get_resource_dirs(resource):
++    """Returns a list of all known resource dirs for a given resource.
++
++    :param str resource:
++        Name of the resource (e.g. "themes")
++    :return:
++        A list of resource dirs
++    """
++    dirs = [os.path.join(dir, resource)
++            for dir in itertools.chain(GLib.get_system_data_dirs(),
++                                       (gtweak.DATA_DIR,
++                                        GLib.get_user_data_dir()))]
++    dirs += [os.path.join(os.path.expanduser("~"), ".{}".format(resource))]
++
++    return [dir for dir in dirs if os.path.isdir(dir)]
++
+ @singleton
+ class AutostartManager:
+ 
+-- 
+2.4.5
+
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0002-Don-t-show-multiple-entries-for-a-single-theme.patch b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0002-Don-t-show-multiple-entries-for-a-single-theme.patch
new file mode 100644
index 00000000000..61ae2734979
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0002-Don-t-show-multiple-entries-for-a-single-theme.patch
@@ -0,0 +1,103 @@
+From edd3203c7b7d5ba596df9f148c443cdfc8a58d88 Mon Sep 17 00:00:00 2001
+From: Jascha Geerds <jg@ekby.de>
+Date: Sat, 1 Aug 2015 21:26:57 +0200
+Subject: [PATCH 1/1] Don't show multiple entries for a single theme
+
+---
+ gtweak/tweaks/tweak_group_interface.py |  8 ++++----
+ gtweak/tweaks/tweak_group_keymouse.py  |  4 ++--
+ gtweak/utils.py                        | 16 ++++++++++++++++
+ 3 files changed, 22 insertions(+), 6 deletions(-)
+
+diff --git a/gtweak/tweaks/tweak_group_interface.py b/gtweak/tweaks/tweak_group_interface.py
+index a319907..82c0286 100644
+--- a/gtweak/tweaks/tweak_group_interface.py
++++ b/gtweak/tweaks/tweak_group_interface.py
+@@ -26,7 +26,7 @@ from gi.repository import Gtk
+ from gi.repository import GLib
+ 
+ import gtweak
+-from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file, get_resource_dirs
++from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file, get_resource_dirs, get_unique_resources
+ from gtweak.tweakmodel import Tweak, TWEAK_GROUP_APPEARANCE
+ from gtweak.gshellwrapper import GnomeShellFactory
+ from gtweak.gsettings import GSettingsSetting
+@@ -49,7 +49,7 @@ class GtkThemeSwitcher(GSettingsComboTweak):
+         valid = walk_directories(get_resource_dirs('themes'), lambda d:
+                     os.path.exists(os.path.join(d, "gtk-2.0")) and \
+                         os.path.exists(os.path.join(d, "gtk-3.0")))
+-        return valid
++        return get_unique_resources(valid)
+ 
+ class IconThemeSwitcher(GSettingsComboTweak):
+     def __init__(self, **options):
+@@ -64,7 +64,7 @@ class IconThemeSwitcher(GSettingsComboTweak):
+         valid = walk_directories(get_resource_dirs("icons"), lambda d:
+                     os.path.isdir(d) and \
+ 			os.path.exists(os.path.join(d, "index.theme")))
+-        return valid
++        return get_unique_resources(valid)
+ 
+ class CursorThemeSwitcher(GSettingsComboTweak):
+     def __init__(self, **options):
+@@ -79,7 +79,7 @@ class CursorThemeSwitcher(GSettingsComboTweak):
+         valid = walk_directories(get_resource_dirs("icons"), lambda d:
+                     os.path.isdir(d) and \
+                         os.path.exists(os.path.join(d, "cursors")))
+-        return valid
++        return get_unique_resources(valid)
+ 
+ class ShellThemeTweak(Gtk.Box, Tweak):
+ 
+diff --git a/gtweak/tweaks/tweak_group_keymouse.py b/gtweak/tweaks/tweak_group_keymouse.py
+index 3486098..9f53425 100644
+--- a/gtweak/tweaks/tweak_group_keymouse.py
++++ b/gtweak/tweaks/tweak_group_keymouse.py
+@@ -20,7 +20,7 @@ import os.path
+ from gi.repository import GLib
+ 
+ import gtweak
+-from gtweak.utils import XSettingsOverrides, walk_directories, make_combo_list_with_default, get_resource_dirs
++from gtweak.utils import XSettingsOverrides, walk_directories, make_combo_list_with_default, get_resource_dirs, get_unique_resources
+ from gtweak.widgets import ListBoxTweakGroup, GSettingsComboTweak, GSettingsSwitchTweak, GetterSetterSwitchTweak, Title
+ 
+ class PrimaryPasteTweak(GetterSetterSwitchTweak):
+@@ -50,7 +50,7 @@ class KeyThemeSwitcher(GSettingsComboTweak):
+         valid = walk_directories(get_resource_dirs("themes"), lambda d:
+                     os.path.isfile(os.path.join(d, "gtk-3.0", "gtk-keys.css")) and \
+                     os.path.isfile(os.path.join(d, "gtk-2.0-key", "gtkrc")))
+-        return valid
++        return get_unique_resources(valid)
+ 
+ TWEAK_GROUPS = [
+     ListBoxTweakGroup(_("Keyboard and Mouse"),
+diff --git a/gtweak/utils.py b/gtweak/utils.py
+index 0fcb51d..ce8e12e 100644
+--- a/gtweak/utils.py
++++ b/gtweak/utils.py
+@@ -131,6 +131,22 @@ def get_resource_dirs(resource):
+ 
+     return [dir for dir in dirs if os.path.isdir(dir)]
+ 
++def get_unique_resources(dirs):
++    """Filter out duplicated resources.
++
++    :param list dirs:
++        List of resource dirs (e.g. /usr/share/themes/Adwaita)
++    :return:
++        List of dirs without duplicated resources
++    """
++    unique_dirs = {}
++    for dir in dirs:
++        basename = os.path.basename(dir)
++        if basename not in unique_dirs:
++            unique_dirs[basename] = dir
++
++    return unique_dirs
++
+ @singleton
+ class AutostartManager:
+ 
+-- 
+2.4.5
+
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0003-Create-config-dir-if-it-doesn-t-exist.patch b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0003-Create-config-dir-if-it-doesn-t-exist.patch
new file mode 100644
index 00000000000..840ebb82ec7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/0003-Create-config-dir-if-it-doesn-t-exist.patch
@@ -0,0 +1,29 @@
+From dea8fc3c37c43f4fbbcc658ee995a95b93452b3c Mon Sep 17 00:00:00 2001
+From: Jascha Geerds <jg@ekby.de>
+Date: Sun, 2 Aug 2015 12:01:20 +0200
+Subject: [PATCH 1/1] Create config dir if it doesn't exist
+
+Otherwise gnome-tweak-tool can't enable the dark theme and fails
+without a clear error message.
+---
+ gtweak/gtksettings.py | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/gtweak/gtksettings.py b/gtweak/gtksettings.py
+index bcec9f1..f39991b 100644
+--- a/gtweak/gtksettings.py
++++ b/gtweak/gtksettings.py
+@@ -35,6 +35,10 @@ class GtkSettingsManager:
+     def _get_keyfile(self):
+         keyfile = None
+         try:
++            config_dir = os.path.dirname(self._path)
++            if not os.path.isdir(config_dir):
++                os.makedirs(config_dir)
++
+             keyfile = GLib.KeyFile()
+             keyfile.load_from_file(self._path, 0)
+         except MemoryError:
+-- 
+2.4.5
+
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/default.nix
new file mode 100644
index 00000000000..986d4058af9
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, intltool, fetchurl, python, pygobject3, atk
+, pkgconfig, gtk3, glib, libsoup
+, bash, makeWrapper, itstool, libxml2, python3Packages
+, gnome3, librsvg, gdk_pixbuf, file, libnotify }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  doCheck = true;
+
+  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
+
+  makeFlags = [ "DESTDIR=/" ];
+
+  buildInputs = [ pkgconfig gtk3 glib intltool itstool libxml2
+                  gnome3.gsettings_desktop_schemas makeWrapper file
+                  gdk_pixbuf gnome3.defaultIconTheme librsvg
+                  python pygobject3 libnotify gnome3.gnome_shell
+                  libsoup gnome3.gnome_settings_daemon gnome3.nautilus
+                  gnome3.gnome_desktop ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/gnome-tweak-tool" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
+      --suffix XDG_DATA_DIRS : "${gtk3}/share:${gnome3.gnome_themes_standard}/share:$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
+      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
+      --prefix PYTHONPATH : "$PYTHONPATH:$(toPythonPath $out)"
+  '';
+
+  patches = [
+    ./find_gsettings.patch
+    ./0001-Search-for-themes-and-icons-in-system-data-dirs.patch
+    ./0002-Don-t-show-multiple-entries-for-a-single-theme.patch
+    ./0003-Create-config-dir-if-it-doesn-t-exist.patch
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/action/show/Apps/GnomeTweakTool;
+    description = "A tool to customize advanced GNOME 3 options";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/find_gsettings.patch b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/find_gsettings.patch
new file mode 100644
index 00000000000..3e68c04cb3a
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/find_gsettings.patch
@@ -0,0 +1,22 @@
+diff --git a/gtweak/gsettings.py b/gtweak/gsettings.py
+index a00fe19..dce74b2 100644
+--- a/gtweak/gsettings.py
++++ b/gtweak/gsettings.py
+@@ -33,10 +33,15 @@ class GSettingsMissingError(Exception):
+ 
+ class _GSettingsSchema:
+     def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options):
+-        if not schema_dir:
+-            schema_dir = gtweak.GSETTINGS_SCHEMA_DIR
+         if not schema_filename:
+             schema_filename = schema_name + ".gschema.xml"
++        if not schema_dir:
++            schema_dir = gtweak.GSETTINGS_SCHEMA_DIR
++            for xdg_dir in GLib.get_system_data_dirs():
++                dir = os.path.join(xdg_dir, "glib-2.0", "schemas")
++                if os.path.exists(os.path.join(dir, schema_filename)):
++                    schema_dir = dir
++                    break
+ 
+         schema_path = os.path.join(schema_dir, schema_filename)
+         if not os.path.exists(schema_path):
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/src.nix b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/src.nix
new file mode 100644
index 00000000000..abb957394e7
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-tweak-tool/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gnome-tweak-tool-3.16.2";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gnome-tweak-tool/3.16/gnome-tweak-tool-3.16.2.tar.xz;
+    sha256 = "b1e403725c3489be07e1d754f044d1128eddb38204a344bbe0baa523d531bd64";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gnome-video-effects/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gnome-video-effects/default.nix
new file mode 100644
index 00000000000..c0bd2fed3f2
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gnome-video-effects/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, pkgconfig, intltool, gnome3 }:
+
+stdenv.mkDerivation rec {
+  name = "gnome-video-effects-${version}";
+  version = "0.4.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gnome-video-effects/0.4/${name}.tar.xz";
+    sha256 = "0jl4iny2dqpcgi3sgxzpgnbw0752i8ay3rscp2cgdjlp79ql5gil";
+  };
+
+  buildInputs = [ pkgconfig intltool ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GnomeVideoEffects;
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gpaste/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gpaste/default.nix
new file mode 100644
index 00000000000..dee9caf444c
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gpaste/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, intltool, autoreconfHook, pkgconfig, vala, glib
+, pango, gtk3, gnome3, dbus, clutter, appstream-glib, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  version = "${gnome3.version}.3";
+  name = "gpaste-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/Keruspe/GPaste/archive/v${version}.tar.gz";
+    sha256 = "1czc707y2ksb8lgq1la0qkj3wpi202hjfiyshsndhw0pqn3qjj4a";
+  };
+
+  buildInputs = [ intltool autoreconfHook pkgconfig vala glib
+                  gtk3 gnome3.gnome_control_center dbus.libs
+                  clutter pango appstream-glib makeWrapper ];
+
+  preConfigure = "intltoolize -f";
+
+  configureFlags = [ "--with-controlcenterdir=$(out)/gnome-control-center/keybindings"
+                     "--with-dbusservicesdir=$(out)/share/dbus-1/services" ];
+
+  enableParallelBuilding = true;
+
+  preFixup = 
+    let
+      libPath = stdenv.lib.makeLibraryPath
+        [ glib gtk3 clutter pango ];
+    in
+    ''
+      for i in $out/libexec/gpaste/*; do
+        wrapProgram $i \
+          --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
+          --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"
+      done
+    '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/Keruspe/GPaste;
+    description = "Clipboard management system with GNOME3 integration";
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/default.nix b/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/default.nix
new file mode 100644
index 00000000000..89703b61932
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, fetchurl, pkgconfig, gtk3, intltool
+, gnome3, enchant, isocodes }:
+
+stdenv.mkDerivation rec {
+  inherit (import ./src.nix fetchurl) name src;
+
+  buildInputs = [ pkgconfig gtk3 intltool gnome3.adwaita-icon-theme
+                  gnome3.gsettings_desktop_schemas ];
+
+  propagatedBuildInputs = [ enchant isocodes ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/src.nix b/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/src.nix
new file mode 100644
index 00000000000..21876ec9c39
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/gtkhtml/src.nix
@@ -0,0 +1,10 @@
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gtkhtml-4.10.0";
+
+  src = fetchurl {
+    url = mirror://gnome/sources/gtkhtml/4.10/gtkhtml-4.10.0.tar.xz;
+    sha256 = "ca3b6424fb2c7ac5d9cb8fdafb69318fa2e825c9cf6ed17d1e38d9b29e5606c3";
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/libgda/default.nix b/pkgs/desktops/gnome-3/3.18/misc/libgda/default.nix
new file mode 100644
index 00000000000..1fcb411d120
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/libgda/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, pkgconfig, intltool, itstool, libxml2, gtk3, openssl }:
+
+let
+  major = "5.2";
+  minor = "2";
+
+in stdenv.mkDerivation rec {
+  version = "${major}.${minor}";
+  name = "libgda-${version}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgda/${major}/${name}.tar.xz";
+    sha256 = "c9b8b1c32f1011e47b73c5dcf36649aaef2f1edaa5f5d75be20d9caadc2bc3e4";
+  };
+
+  configureFlags = [
+    "--enable-gi-system-install=no"
+  ];
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ pkgconfig intltool itstool libxml2 gtk3 openssl ];
+
+  meta = with stdenv.lib; {
+    description = "Database access library";
+    homepage = http://www.gnome-db.org/;
+    license = [ licenses.lgpl2 licenses.gpl2 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/libgit2-glib/default.nix b/pkgs/desktops/gnome-3/3.18/misc/libgit2-glib/default.nix
new file mode 100644
index 00000000000..dbdd2cc7fd1
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/libgit2-glib/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, gnome3, libtool, pkgconfig, vala
+, gtk_doc, gobjectIntrospection, libgit2, glib }:
+
+let
+  majorVersion = "0.0";
+in
+stdenv.mkDerivation rec {
+  name = "libgit2-glib-${majorVersion}.24";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libgit2-glib/0.0/${name}.tar.xz";
+    sha256 = "8a0a6f65d86f2c8cb9bcb20c5e0ea6fd02271399292a71fc7e6852f13adbbdb8";
+  };
+
+  buildInputs = [ gnome3.gnome_common libtool pkgconfig vala
+                  gtk_doc gobjectIntrospection libgit2 glib ];
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/libmediaart/default.nix b/pkgs/desktops/gnome-3/3.18/misc/libmediaart/default.nix
new file mode 100644
index 00000000000..b8648012573
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/libmediaart/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, glib, gdk_pixbuf, gobjectIntrospection, gnome3 }:
+
+let
+  majorVersion = "1.9";
+in
+stdenv.mkDerivation rec {
+  name = "libmediaart-${majorVersion}.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libmediaart/${majorVersion}/${name}.tar.xz";
+    sha256 = "0vshvm3sfwqs365glamvkmgnzjnmxd15j47xn0ak3p6l57dqlrll";
+  };
+
+  buildInputs = [ pkgconfig glib gdk_pixbuf gobjectIntrospection ];
+
+  meta = with stdenv.lib; {
+    description = "Library tasked with managing, extracting and handling media art caches";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/gnome-3/3.18/misc/pomodoro/default.nix b/pkgs/desktops/gnome-3/3.18/misc/pomodoro/default.nix
new file mode 100644
index 00000000000..0440af440fe
--- /dev/null
+++ b/pkgs/desktops/gnome-3/3.18/misc/pomodoro/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub, which, automake113x, intltool, pkgconfig, libtool, makeWrapper,
+  dbus_glib, libcanberra, gst_all_1, vala, gnome3, gtk3, gst_plugins_base,
+  glib, gobjectIntrospection, telepathy_glib
+}:
+
+stdenv.mkDerivation rec {
+  rev = "624945d";
+  name = "gnome-shell-pomodoro-${gnome3.version}-${rev}";
+
+  src = fetchFromGitHub {
+      owner = "codito";
+      repo = "gnome-pomodoro";
+      rev = "${rev}";
+      sha256 = "0vjy95zvd309n8g13fa80qhqlv7k6wswhrjw7gddxrnmr662xdqq";
+  };
+
+  configureScript = ''./autogen.sh'';
+
+  buildInputs = [
+    which automake113x intltool glib gobjectIntrospection pkgconfig libtool
+    makeWrapper dbus_glib libcanberra vala gst_all_1.gstreamer
+    gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good
+    gnome3.gsettings_desktop_schemas gnome3.gnome_desktop
+    gnome3.gnome_common gnome3.gnome_shell gtk3 telepathy_glib
+    gnome3.defaultIconTheme
+  ];
+
+  preBuild = ''
+    sed -i 's|\$(INTROSPECTION_GIRDIR)|${gnome3.gnome_desktop}/share/gir-1.0|' \
+      vapi/Makefile
+  '';
+
+  preFixup = ''
+    wrapProgram $out/bin/gnome-pomodoro \
+        --prefix XDG_DATA_DIRS : \
+        "$out/share:$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/codito/gnome-shell-pomodoro;
+    description = "A time management utility for GNOME based on the pomodoro technique";
+    longDescription = ''
+      This GNOME utility helps to manage time according to Pomodoro Technique.
+      It intends to improve productivity and focus by taking short breaks.
+    '';
+    maintainers = with maintainers; [ DamienCassou jgeerds ];
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/desktops/xfce/core/thunar-volman.nix b/pkgs/desktops/xfce/core/thunar-volman.nix
index b53ee4c45c5..a3b8a619f17 100644
--- a/pkgs/desktops/xfce/core/thunar-volman.nix
+++ b/pkgs/desktops/xfce/core/thunar-volman.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, intltool, exo, gtk, libxfce4util, libxfce4ui
-, xfconf, udev, libnotify }:
+, xfconf, udev, libgudev, libnotify }:
 
 stdenv.mkDerivation rec {
   p_name  = "thunar-volman";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
 
   buildInputs =
-    [ pkgconfig intltool exo gtk udev libxfce4ui libxfce4util
+    [ pkgconfig intltool exo gtk udev libgudev libxfce4ui libxfce4util
       xfconf libnotify
     ];
   preFixup = "rm $out/share/icons/hicolor/icon-theme.cache";
diff --git a/pkgs/development/compilers/llvm/3.7/libc++/default.nix b/pkgs/development/compilers/llvm/3.7/libc++/default.nix
index cd985d89098..db1475cfc14 100644
--- a/pkgs/development/compilers/llvm/3.7/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/3.7/libc++/default.nix
@@ -12,15 +12,6 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
     cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include")
-  '' +
-  stdenv.lib.optionalString stdenv.isDarwin ''
-    # instead of allowing libc++ to link with /usr/lib/libc++abi.dylib,
-    # force it to link with our copy
-    substituteInPlace lib/CMakeLists.txt \
-      --replace 'OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib' \
-                'OSX_RE_EXPORT_LINE "${libcxxabi}/lib/libc++abi.dylib' \
-      --replace '"''${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"' \
-                '"${libcxxabi}/lib/libc++abi.dylib"'
   '';
 
   patches = [ ./darwin.patch ];
diff --git a/pkgs/development/compilers/llvm/3.7/libc++abi.nix b/pkgs/development/compilers/llvm/3.7/libc++abi.nix
index a1b300ffa04..97f182a9af8 100644
--- a/pkgs/development/compilers/llvm/3.7/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/3.7/libc++abi.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation {
       done
       make install
       install -d 755 $out/include
-      install -m 644 ../include/cxxabi.h $out/include
+      install -m 644 ../include/*.h $out/include
     ''
     else ''
       install -d -m 755 $out/include $out/lib
diff --git a/pkgs/development/compilers/llvm/3.7/llvm.nix b/pkgs/development/compilers/llvm/3.7/llvm.nix
index 863334576ee..ff038024d10 100644
--- a/pkgs/development/compilers/llvm/3.7/llvm.nix
+++ b/pkgs/development/compilers/llvm/3.7/llvm.nix
@@ -29,7 +29,7 @@ in stdenv.mkDerivation rec {
     mv compiler-rt-* $sourceRoot/projects/compiler-rt
   '';
 
-  buildInputs = [ perl groff cmake libxml2 python libffi ] /* ++ stdenv.lib.optional stdenv.isLinux valgrind */
+  buildInputs = [ perl groff cmake libxml2 python libffi ]
     ++ stdenv.lib.optional stdenv.isDarwin libcxxabi;
 
   propagatedBuildInputs = [ ncurses zlib ];
@@ -50,7 +50,7 @@ in stdenv.mkDerivation rec {
     "-DBUILD_SHARED_LIBS=ON"
     "-DLLVM_BINUTILS_INCDIR=${binutils}/include"
   ] ++ stdenv.lib.optionals ( isDarwin) [
-    "-DCMAKE_CXX_FLAGS=-stdlib=libc++"
+    "-DLLVM_ENABLE_LIBCXX=ON"
     "-DCAN_TARGET_i386=false"
   ];
 
diff --git a/pkgs/development/compilers/sbcl/bootstrap.nix b/pkgs/development/compilers/sbcl/bootstrap.nix
index 6e9124af611..43002aa72f5 100644
--- a/pkgs/development/compilers/sbcl/bootstrap.nix
+++ b/pkgs/development/compilers/sbcl/bootstrap.nix
@@ -38,6 +38,9 @@ stdenv.mkDerivation rec {
   buildInputs = [ makeWrapper ];
 
   installPhase = ''
+    mkdir -p $out/bin
+    cp -p src/runtime/sbcl $out/bin
+
     mkdir -p $out/share/sbcl
     cp -p src/runtime/sbcl $out/share/sbcl
     cp -p output/sbcl.core $out/share/sbcl
diff --git a/pkgs/development/interpreters/perl/5.22/default.nix b/pkgs/development/interpreters/perl/5.22/default.nix
index e0be8610fb7..4b0f4364ea2 100644
--- a/pkgs/development/interpreters/perl/5.22/default.nix
+++ b/pkgs/development/interpreters/perl/5.22/default.nix
@@ -59,9 +59,14 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postPatch = ''
+    pwd="$(type -P pwd)"
+    substituteInPlace dist/PathTools/Cwd.pm \
+      --replace "pwd_cmd = 'pwd'" "pwd_cmd = '$pwd'"
+  '';
+
   preConfigure =
     ''
-
       configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
 
       ${optionalString stdenv.isArm ''
diff --git a/pkgs/development/interpreters/perl/5.22/no-libutil.patch b/pkgs/development/interpreters/perl/5.22/no-libutil.patch
index 68d44612bfe..d6356a52437 100644
--- a/pkgs/development/interpreters/perl/5.22/no-libutil.patch
+++ b/pkgs/development/interpreters/perl/5.22/no-libutil.patch
@@ -1,12 +1,14 @@
-diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
---- perl-5.14.2-orig/Configure	2011-09-26 11:44:34.000000000 +0200
-+++ perl-5.14.2/Configure	2012-02-16 17:24:50.779839039 +0100
-@@ -1368,7 +1368,7 @@
+diff --git a/Configure b/Configure
+index 0a405d3..1871298 100755
+--- a/Configure
++++ b/Configure
+@@ -1455,7 +1455,7 @@ libswanted_uselargefiles=''
  : List of libraries we want.
  : If anyone needs extra -lxxx, put those in a hint file.
- libswanted="socket bind inet nsl nm ndbm gdbm dbm db malloc dl ld sun"
--libswanted="$libswanted m crypt sec util c cposix posix ucb bsd BSD"
-+libswanted="$libswanted m crypt sec c cposix posix ucb bsd BSD"
+ libswanted="cl pthread socket bind inet nsl nm ndbm gdbm dbm db malloc dl ld"
+-libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
++libswanted="$libswanted sun m crypt sec c cposix posix ucb bsd BSD"
  : We probably want to search /usr/shlib before most other libraries.
  : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
  glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
+
diff --git a/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix b/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix
index 3ae74057a54..b4e04f6ec90 100644
--- a/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix
+++ b/pkgs/development/interpreters/ruby/bundler-env/default-gem-config.nix
@@ -20,7 +20,7 @@
 { lib, fetchurl, writeScript, ruby, libxml2, libxslt, python, stdenv, which
 , libiconv, postgresql, v8_3_16_14, clang, sqlite, zlib, imagemagick
 , pkgconfig , ncurses, xapian, gpgme, utillinux, fetchpatch, tzdata, icu, libffi
-, cmake, libssh2, openssl, mysql, darwin
+, cmake, libssh2, openssl, mysql
 }:
 
 let
@@ -70,7 +70,6 @@ in
       "--with-exslt-lib=${libxslt}/lib"
       "--with-exslt-include=${libxslt}/include"
     ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
-    buildInputs = lib.optional stdenv.isDarwin darwin.libobjc;
   };
 
   pg = attrs: {
@@ -120,10 +119,6 @@ in
     '';
   };
 
-  unf_ext = attrs: {
-    buildInputs = lib.optional stdenv.isDarwin darwin.libobjc;
-  };
-
   xapian-ruby = attrs: {
     # use the system xapian
     buildInputs = [ xapian pkgconfig zlib ];
diff --git a/pkgs/development/libraries/at-spi2-atk/default.nix b/pkgs/development/libraries/at-spi2-atk/default.nix
index 7e6286abcce..f5d806ff67a 100644
--- a/pkgs/development/libraries/at-spi2-atk/default.nix
+++ b/pkgs/development/libraries/at-spi2-atk/default.nix
@@ -2,14 +2,14 @@
 , intltool, dbus_glib, at_spi2_core, libSM }:
 
 stdenv.mkDerivation rec {
-  versionMajor = "2.16";
+  versionMajor = "2.18";
   versionMinor = "0";
   moduleName   = "at-spi2-atk";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "1y9gfz1iz3wpja7s000f0bmyyvc6im5fcdl6bxwbz0v3qdgc9vvq";
+    sha256 = "0xgkrnx04vaklbkzc7bzym9s0qhj8aiz4knqlxgx3vxnacsb6vaa";
   };
 
   buildInputs = [ python pkgconfig popt atk libX11 libICE xorg.libXtst libXi
diff --git a/pkgs/development/libraries/at-spi2-core/default.nix b/pkgs/development/libraries/at-spi2-core/default.nix
index 0fc28185501..b49d1ddb804 100644
--- a/pkgs/development/libraries/at-spi2-core/default.nix
+++ b/pkgs/development/libraries/at-spi2-core/default.nix
@@ -2,14 +2,14 @@
 , libX11, xextproto, libSM, libICE, libXtst, libXi, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
-  versionMajor = "2.16";
+  versionMajor = "2.18";
   versionMinor = "0";
   moduleName   = "at-spi2-core";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "1l3l39mw23zyjlcqidvkyqlr4gwbhplzw2hcv3qvn6p8ikxpf2qw";
+    sha256 = "0xna0gnlqvzy6209klirywcm7ianazshg6pkk828g07bnrywgvhs";
   };
 
   outputs = [ "out" "doc" ];
diff --git a/pkgs/development/libraries/atk/default.nix b/pkgs/development/libraries/atk/default.nix
index d5e442c738c..dcb90aa16cd 100644
--- a/pkgs/development/libraries/atk/default.nix
+++ b/pkgs/development/libraries/atk/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, pkgconfig, perl, glib, libintlOrEmpty, gobjectIntrospection }:
 
 let
-  ver_maj = "2.16";
+  ver_maj = "2.18";
   ver_min = "0";
 in
 stdenv.mkDerivation rec {
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/atk/${ver_maj}/${name}.tar.xz";
-    sha256 = "0qp5i91kfk6rhrlam3s8ha0cz88lkyp89vsyn4pb5856c1h9hpq9";
+    sha256 = "ce6c48d77bf951083029d5a396dd552d836fff3c1715d3a7022e917e46d0c92b";
   };
 
   buildInputs = libintlOrEmpty;
diff --git a/pkgs/development/libraries/audiofile/CVE-2015-7747.patch b/pkgs/development/libraries/audiofile/CVE-2015-7747.patch
new file mode 100644
index 00000000000..a01aaa14dce
--- /dev/null
+++ b/pkgs/development/libraries/audiofile/CVE-2015-7747.patch
@@ -0,0 +1,161 @@
+Description: fix buffer overflow when changing both sample format and
+ number of channels
+Origin: backport, https://github.com/mpruett/audiofile/pull/25
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/audiofile/+bug/1502721
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801102
+
+Index: audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp
+===================================================================
+--- audiofile-0.3.6.orig/libaudiofile/modules/ModuleState.cpp	2015-10-20 08:00:58.036128202 -0400
++++ audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp	2015-10-20 08:00:58.036128202 -0400
+@@ -402,7 +402,7 @@
+		addModule(new Transform(outfc, in.pcm, out.pcm));
+
+	if (in.channelCount != out.channelCount)
+-		addModule(new ApplyChannelMatrix(infc, isReading,
++		addModule(new ApplyChannelMatrix(outfc, isReading,
+			in.channelCount, out.channelCount,
+			in.pcm.minClip, in.pcm.maxClip,
+			track->channelMatrix));
+Index: audiofile-0.3.6/test/Makefile.am
+===================================================================
+--- audiofile-0.3.6.orig/test/Makefile.am	2015-10-20 08:00:58.036128202 -0400
++++ audiofile-0.3.6/test/Makefile.am	2015-10-20 08:00:58.036128202 -0400
+@@ -26,6 +26,7 @@
+	VirtualFile \
+	floatto24 \
+	query2 \
++	sixteen-stereo-to-eight-mono \
+	sixteen-to-eight \
+	testchannelmatrix \
+	testdouble \
+@@ -139,6 +140,7 @@
+ printmarkers_LDADD = $(LIBAUDIOFILE) -lm
+
+ sixteen_to_eight_SOURCES = sixteen-to-eight.c TestUtilities.cpp TestUtilities.h
++sixteen_stereo_to_eight_mono_SOURCES = sixteen-stereo-to-eight-mono.c TestUtilities.cpp TestUtilities.h
+
+ testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h
+
+Index: audiofile-0.3.6/test/sixteen-stereo-to-eight-mono.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ audiofile-0.3.6/test/sixteen-stereo-to-eight-mono.c	2015-10-20 08:33:57.512286416 -0400
+@@ -0,0 +1,117 @@
++/*
++	Audio File Library
++
++	Copyright 2000, Silicon Graphics, Inc.
++
++	This program is free software; you can redistribute it and/or modify
++	it under the terms of the GNU General Public License as published by
++	the Free Software Foundation; either version 2 of the License, or
++	(at your option) any later version.
++
++	This program is distributed in the hope that it will be useful,
++	but WITHOUT ANY WARRANTY; without even the implied warranty of
++	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++	GNU General Public License for more details.
++
++	You should have received a copy of the GNU General Public License along
++	with this program; if not, write to the Free Software Foundation, Inc.,
++	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++*/
++
++/*
++	sixteen-stereo-to-eight-mono.c
++
++	This program tests the conversion from 2-channel 16-bit integers to
++	1-channel 8-bit	integers.
++*/
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <stdint.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <limits.h>
++
++#include <audiofile.h>
++
++#include "TestUtilities.h"
++
++int main (int argc, char **argv)
++{
++	AFfilehandle file;
++	AFfilesetup setup;
++	int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
++	int8_t frames8[] = {28, 6, -2};
++	int i, frameCount = 3;
++	int8_t byte;
++	AFframecount result;
++
++	setup = afNewFileSetup();
++
++	afInitFileFormat(setup, AF_FILE_WAVE);
++
++	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
++	afInitChannels(setup, AF_DEFAULT_TRACK, 2);
++
++	char testFileName[PATH_MAX];
++	if (!createTemporaryFile("sixteen-to-eight", testFileName))
++	{
++		fprintf(stderr, "Could not create temporary file.\n");
++		exit(EXIT_FAILURE);
++	}
++
++	file = afOpenFile(testFileName, "w", setup);
++	if (file == AF_NULL_FILEHANDLE)
++	{
++		fprintf(stderr, "could not open file for writing\n");
++		exit(EXIT_FAILURE);
++	}
++
++	afFreeFileSetup(setup);
++
++	afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
++
++	afCloseFile(file);
++
++	file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
++	if (file == AF_NULL_FILEHANDLE)
++	{
++		fprintf(stderr, "could not open file for reading\n");
++		exit(EXIT_FAILURE);
++	}
++
++	afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
++	afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
++
++	for (i=0; i<frameCount; i++)
++	{
++		/* Read one frame. */
++		result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
++
++		if (result != 1)
++			break;
++
++		/* Compare the byte read with its precalculated value. */
++		if (memcmp(&byte, &frames8[i], 1) != 0)
++		{
++			printf("error\n");
++			printf("expected %d, got %d\n", frames8[i], byte);
++			exit(EXIT_FAILURE);
++		}
++		else
++		{
++#ifdef DEBUG
++			printf("got what was expected: %d\n", byte);
++#endif
++		}
++	}
++
++	afCloseFile(file);
++	unlink(testFileName);
++
++	exit(EXIT_SUCCESS);
++}
diff --git a/pkgs/development/libraries/audiofile/default.nix b/pkgs/development/libraries/audiofile/default.nix
index c8fb8c53dc0..1fe6d7b15a8 100644
--- a/pkgs/development/libraries/audiofile/default.nix
+++ b/pkgs/development/libraries/audiofile/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
     sha256 = "0rb927zknk9kmhprd8rdr4azql4gn2dp75a36iazx2xhkbqhvind";
   };
 
+  patches = [ ./CVE-2015-7747.patch ];
+
   meta = with stdenv.lib; {
     description = "Library for reading and writing audio files in various formats";
     homepage    = http://www.68k.org/~michael/audiofile/; 
diff --git a/pkgs/development/libraries/boost/1.55.nix b/pkgs/development/libraries/boost/1.55.nix
index a10cd8ce220..0a38f35af75 100644
--- a/pkgs/development/libraries/boost/1.55.nix
+++ b/pkgs/development/libraries/boost/1.55.nix
@@ -3,7 +3,7 @@
 callPackage ./generic.nix (args // rec {
   version = "1.55.0";
 
-  patches = [ ./clang-math.patch ./clang-math-2.patch ];
+  patches = [ ./clang-math.patch ./clang-math-2.patch ./gcc-5.patch ];
 
   src = fetchurl {
     url = "mirror://sourceforge/boost/boost_1_55_0.tar.bz2";
diff --git a/pkgs/development/libraries/boost/gcc-5.patch b/pkgs/development/libraries/boost/gcc-5.patch
new file mode 100644
index 00000000000..2b2713590ca
--- /dev/null
+++ b/pkgs/development/libraries/boost/gcc-5.patch
@@ -0,0 +1,64 @@
+https://svn.boost.org/trac/boost/ticket/10125
+
+ boost/thread/pthread/once.hpp        | 6 +++---
+ boost/thread/pthread/once_atomic.hpp | 2 +-
+ boost/thread/win32/once.hpp          | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/boost/thread/pthread/once.hpp b/boost/thread/pthread/once.hpp
+index ccfb051..0bef038 100644
+--- a/boost/thread/pthread/once.hpp
++++ b/boost/thread/pthread/once.hpp
+@@ -42,7 +42,7 @@ namespace boost
+   }
+ 
+ #ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
+-#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+     template<typename Function, class ...ArgTypes>
+     inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args);
+ #else
+@@ -65,7 +65,7 @@ namespace boost
+   private:
+       volatile thread_detail::uintmax_atomic_t epoch;
+ 
+-#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+       template<typename Function, class ...ArgTypes>
+       friend void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args);
+ #else
+@@ -118,7 +118,7 @@ namespace boost
+     // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html
+ 
+ 
+-#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ 
+ 
+   template<typename Function, class ...ArgTypes>
+diff --git a/boost/thread/pthread/once_atomic.hpp b/boost/thread/pthread/once_atomic.hpp
+index 9e2f876..923f07b 100644
+--- a/boost/thread/pthread/once_atomic.hpp
++++ b/boost/thread/pthread/once_atomic.hpp
+@@ -115,7 +115,7 @@ namespace boost
+ #endif
+ 
+ 
+-#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ 
+   template<typename Function, class ...ArgTypes>
+   inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args)
+diff --git a/boost/thread/win32/once.hpp b/boost/thread/win32/once.hpp
+index cafcfd4..9b37b31 100644
+--- a/boost/thread/win32/once.hpp
++++ b/boost/thread/win32/once.hpp
+@@ -227,7 +227,7 @@ namespace boost
+         }
+     }
+ 
+-#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#if !defined BOOST_NO_CXX11_VARIADIC_TEMPLATES && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ //#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
+     inline void call_once(once_flag& flag, void (*f)())
+     {
diff --git a/pkgs/development/libraries/cairo/default.nix b/pkgs/development/libraries/cairo/default.nix
index e2d6b25e137..5add4e45129 100644
--- a/pkgs/development/libraries/cairo/default.nix
+++ b/pkgs/development/libraries/cairo/default.nix
@@ -11,11 +11,11 @@ assert glSupport -> mesa_noglu != null;
 with { inherit (stdenv.lib) optional optionals; };
 
 stdenv.mkDerivation rec {
-  name = "cairo-1.14.2";
+  name = "cairo-1.14.4";
 
   src = fetchurl {
     url = "http://cairographics.org/releases/${name}.tar.xz";
-    sha1 = "c8da68aa66ca0855b5d0ff552766d3e8679e1d24";
+    sha256 = "05p75r914d809711yg9rapgmmi4hymzbarhd3w0yrfadhiy9rv7n";
   };
 
   nativeBuildInputs = [ pkgconfig libiconv ] ++ libintlOrEmpty;
diff --git a/pkgs/development/libraries/clutter/1.24.nix b/pkgs/development/libraries/clutter/1.24.nix
new file mode 100644
index 00000000000..b9d45b6c62b
--- /dev/null
+++ b/pkgs/development/libraries/clutter/1.24.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, glib, pkgconfig, mesa, libX11, libXext, libXfixes
+, libXdamage, libXcomposite, libXi, cogl, pango, atk, json_glib, 
+gobjectIntrospection 
+}:
+
+let
+  ver_maj = "1.24";
+  ver_min = "0";
+in
+stdenv.mkDerivation rec {
+  name = "clutter-${ver_maj}.${ver_min}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/clutter/${ver_maj}/${name}.tar.xz";
+    sha256 = "85c87d5745b97af7633776419a47421aae7cea66c1b870f88cc5e06a4c5626e6";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  propagatedBuildInputs =
+    [ libX11 mesa libXext libXfixes libXdamage libXcomposite libXi cogl pango
+      atk json_glib gobjectIntrospection
+    ];
+
+  configureFlags = [ "--enable-introspection" ]; # needed by muffin AFAIK
+
+  #doCheck = true; # no tests possible without a display
+
+  meta = {
+    description = "Clutter, a library for creating fast, dynamic graphical user interfaces";
+
+    longDescription =
+      '' Clutter is free software library for creating fast, compelling,
+         portable, and dynamic graphical user interfaces.  It is a core part
+         of MeeGo, and is supported by the open source community.  Its
+         development is sponsored by Intel.
+
+         Clutter uses OpenGL for rendering (and optionally OpenGL|ES for use
+         on mobile and embedded platforms), but wraps an easy to use,
+         efficient, flexible API around GL's complexity.
+
+         Clutter enforces no particular user interface style, but provides a
+         rich, generic foundation for higher-level toolkits tailored to
+         specific needs.
+      '';
+
+    license = stdenv.lib.licenses.lgpl2Plus;
+    homepage = http://www.clutter-project.org/;
+
+    maintainers = with stdenv.lib.maintainers; [ urkud lethalman ];
+    platforms = stdenv.lib.platforms.mesaPlatforms;
+  };
+}
diff --git a/pkgs/development/libraries/cogl/1.22.nix b/pkgs/development/libraries/cogl/1.22.nix
new file mode 100644
index 00000000000..ce4fda5bd46
--- /dev/null
+++ b/pkgs/development/libraries/cogl/1.22.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchurl, pkgconfig, mesa_noglu, glib, gdk_pixbuf, xorg, libintlOrEmpty
+, pangoSupport ? true, pango, cairo, gobjectIntrospection
+, gstreamerSupport ? true, gst_all_1 }:
+
+let
+  ver_maj = "1.22";
+  ver_min = "0";
+in
+stdenv.mkDerivation rec {
+  name = "cogl-${ver_maj}.${ver_min}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/cogl/${ver_maj}/${name}.tar.xz";
+    sha256 = "689dfb5d14fc1106e9d2ded0f7930dcf7265d0bc84fa846b4f03941633eeaa91";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  configureFlags = [
+    "--enable-introspection"
+    "--enable-kms-egl-platform"
+  ] ++ stdenv.lib.optional gstreamerSupport "--enable-cogl-gst"
+    ++ stdenv.lib.optionals (!stdenv.isDarwin) [ "--enable-gles1" "--enable-gles2" ];
+
+  propagatedBuildInputs = with xorg; [
+      glib gdk_pixbuf gobjectIntrospection
+      mesa_noglu libXrandr libXfixes libXcomposite libXdamage
+    ]
+    ++ libintlOrEmpty
+    ++ stdenv.lib.optionals gstreamerSupport [ gst_all_1.gstreamer
+                                               gst_all_1.gst-plugins-base ];
+
+  buildInputs = stdenv.lib.optionals pangoSupport [ pango cairo ];
+
+  COGL_PANGO_DEP_CFLAGS
+    = stdenv.lib.optionalString (stdenv.isDarwin && pangoSupport)
+      "-I${pango}/include/pango-1.0 -I${cairo}/include/cairo";
+
+  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
+
+  #doCheck = true; # all tests fail (no idea why)
+
+  meta = with stdenv.lib; {
+    description = "A small open source library for using 3D graphics hardware for rendering";
+    maintainers = with maintainers; [ lovek323 ];
+
+    longDescription = ''
+      Cogl is a small open source library for using 3D graphics hardware for
+      rendering. The API departs from the flat state machine style of OpenGL
+      and is designed to make it easy to write orthogonal components that can
+      render without stepping on each other's toes.
+    '';
+
+    platforms = stdenv.lib.platforms.mesaPlatforms;
+  };
+}
diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix
index a7d081c565d..fadb3feb4cc 100644
--- a/pkgs/development/libraries/ffmpeg-full/default.nix
+++ b/pkgs/development/libraries/ffmpeg-full/default.nix
@@ -235,11 +235,11 @@ assert x11grabExtlib -> libX11 != null && libXv != null;
 
 stdenv.mkDerivation rec {
   name = "ffmpeg-full-${version}";
-  version = "2.7.2";
+  version = "2.8.1";
 
   src = fetchurl {
     url = "https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.bz2";
-    sha256 = "1wlygd0jp34dk4qagi4h9psn4yk8zgyj7zy9lrpm5332mm87bsvw";
+    sha256 = "1qk6g2h993i0wgs9d2p3ahdc5bqr03mp74bk6r1zj6pfinr5mvg2";
   };
 
   patchPhase = ''patchShebangs .'';
diff --git a/pkgs/development/libraries/ffmpeg/2.6.nix b/pkgs/development/libraries/ffmpeg/2.6.nix
deleted file mode 100644
index 60fc32e030e..00000000000
--- a/pkgs/development/libraries/ffmpeg/2.6.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic.nix (args // rec {
-  version = "${branch}.3";
-  branch = "2.6";
-  sha256 = "1yqc3vm1xrwf866q262qd4nr9d6ifp4gg183pjdc4sl9np0rissr";
-})
diff --git a/pkgs/development/libraries/ffmpeg/2.7.nix b/pkgs/development/libraries/ffmpeg/2.7.nix
deleted file mode 100644
index 105239c48c9..00000000000
--- a/pkgs/development/libraries/ffmpeg/2.7.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic.nix (args // rec {
-  version = "${branch}.2";
-  branch = "2.7";
-  sha256 = "1wlygd0jp34dk4qagi4h9psn4yk8zgyj7zy9lrpm5332mm87bsvw";
-})
diff --git a/pkgs/development/libraries/ffmpeg/2.8.nix b/pkgs/development/libraries/ffmpeg/2.8.nix
new file mode 100644
index 00000000000..e585ea14997
--- /dev/null
+++ b/pkgs/development/libraries/ffmpeg/2.8.nix
@@ -0,0 +1,7 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "${branch}.1";
+  branch = "2.8";
+  sha256 = "1qk6g2h993i0wgs9d2p3ahdc5bqr03mp74bk6r1zj6pfinr5mvg2";
+})
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index ef0baeabeed..dbd3a679d48 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -2,15 +2,15 @@
 , jasper, libintlOrEmpty, gobjectIntrospection, doCheck ? false }:
 
 let
-  ver_maj = "2.31";
-  ver_min = "7";
+  ver_maj = "2.32";
+  ver_min = "1";
 in
 stdenv.mkDerivation rec {
   name = "gdk-pixbuf-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gdk-pixbuf/${ver_maj}/${name}.tar.xz";
-    sha256 = "046n9wz16kh3rpzxaiiwphf5bihxgj4g14cjn65wwmw82q4y0dj7";
+    sha256 = "1g7kjxv67jcdasi14n7jan4icrnnppd1m99wrdmpv32k4m7vfcj4";
   };
 
   setupHook = ./setup-hook.sh;
diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix
index cbdc2831187..6595d97b01a 100644
--- a/pkgs/development/libraries/glew/default.nix
+++ b/pkgs/development/libraries/glew/default.nix
@@ -3,11 +3,11 @@
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "glew-1.11.0";
+  name = "glew-1.13.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/glew/${name}.tgz";
-    sha256 = "1mhkllxz49l1x680dmzrv2i82qjrq017sykah3xc90f2d8qcxfv9";
+    sha256 = "1iwb2a6wfhkzv6fa7zx2gz1lkwa0iwnd9ka1im5vdc44xm4dq9da";
   };
 
   nativeBuildInputs = [ xlibsWrapper libXmu libXi ];
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index fb9c361c530..bafe8949e93 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -39,8 +39,8 @@ let
     ln -sr -t "$out/include/" "$out"/lib/*/include/* 2>/dev/null || true
   '';
 
-  ver_maj = "2.44";
-  ver_min = "1";
+  ver_maj = "2.46";
+  ver_min = "2";
 in
 
 stdenv.mkDerivation rec {
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/glib/${ver_maj}/${name}.tar.xz";
-    sha256 = "01yabrfp64i11mrks3p1gcks99lw0zm7f5vhkc53sl4amyndw4c8";
+    sha256 = "5031722e37036719c1a09163cc6cf7c326e4c4f1f1e074b433c156862bd733db";
   };
 
   patches = optional stdenv.isDarwin ./darwin-compilation.patch ++ optional doCheck ./skip-timer-test.patch;
diff --git a/pkgs/development/libraries/glpk/default.nix b/pkgs/development/libraries/glpk/default.nix
index d4ff7d9603f..2b1a5b571ef 100644
--- a/pkgs/development/libraries/glpk/default.nix
+++ b/pkgs/development/libraries/glpk/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "glpk-4.56";
+  name = "glpk-4.52.1";
 
   src = fetchurl {
     url = "mirror://gnu/glpk/${name}.tar.gz";
-    sha256 = "0syzix6qvpn0fzp08c84c8snansf1cam5vd0dk2w91mz2c85d18h";
+    sha256 = "0nz9ngmx23c8gbjr8l8ygnfaanxj2mwbl8awpg630bgrkxdnhc9j";
   };
 
   doCheck = true;
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index 50fddd9da9f..f429e1dc6c3 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -5,7 +5,7 @@
 # In that case its about 6MB which could be separated
 
 let
-  ver_maj = "1.44";
+  ver_maj = "1.46";
   ver_min = "0";
 in
 stdenv.mkDerivation rec {
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/gobject-introspection/${ver_maj}/${name}.tar.xz";
-    sha256 = "1b972qg2yb51sdavfvb6kc19akwc15c1bwnbg81vadxamql2q33g";
+    sha256 = "6658bd3c2b8813eb3e2511ee153238d09ace9d309e4574af27443d87423e4233";
   };
 
   buildInputs = [ flex bison pkgconfig python ]
@@ -25,6 +25,10 @@ stdenv.mkDerivation rec {
   # other dependencies).
   configureFlags = [ "--disable-tests" ];
 
+  preConfigure = ''
+    sed 's|/usr/bin/env ||' -i tools/g-ir-tool-template.in
+  '';
+
   postInstall = "rm -rf $out/share/gtk-doc";
 
   setupHook = ./setup-hook.sh;
diff --git a/pkgs/development/libraries/gtk+/3.x.nix b/pkgs/development/libraries/gtk+/3.x.nix
index 8422f71985a..2a7c7b88c38 100644
--- a/pkgs/development/libraries/gtk+/3.x.nix
+++ b/pkgs/development/libraries/gtk+/3.x.nix
@@ -1,16 +1,16 @@
 { stdenv, fetchurl, pkgconfig, gettext, perl
 , expat, glib, cairo, pango, gdk_pixbuf, atk, at_spi2_atk, gobjectIntrospection
-, xorg, xlibsWrapper, wayland, libxkbcommon, epoxy
+, xlibs, x11, wayland, libxkbcommon, epoxy
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? stdenv.isLinux, cups ? null
 }:
 
-assert xineramaSupport -> xorg.libXinerama != null;
+assert xineramaSupport -> xlibs.libXinerama != null;
 assert cupsSupport -> cups != null;
 
 let
-  ver_maj = "3.16";
-  ver_min = "7";
+  ver_maj = "3.18";
+  ver_min = "3";
   version = "${ver_maj}.${ver_min}";
 in
 stdenv.mkDerivation rec {
@@ -18,25 +18,25 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/gtk+/${ver_maj}/gtk+-${version}.tar.xz";
-    sha256 = "1fkzdhqa1pjzb1qsh2ll3y2567ylyszks59qspx85lalvqa9ss0r";
+    sha256 = "f3c76791f93f51e260b03676f83007730b9875a0a9bf5cd42442e2f14e593546";
   };
 
   nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection perl ];
 
   buildInputs = [ libxkbcommon epoxy ];
-  propagatedBuildInputs = with xorg; with stdenv.lib;
+  propagatedBuildInputs = with xlibs; with stdenv.lib;
     [ expat glib cairo pango gdk_pixbuf atk at_spi2_atk libXrandr libXrender libXcomposite libXi libXcursor ]
     ++ optionals stdenv.isLinux [ wayland ]
     ++ optional xineramaSupport libXinerama
     ++ optional cupsSupport cups;
 
+  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+
   # demos fail to install, no idea where's the problem
   preConfigure = "sed '/^SRC_SUBDIRS /s/demos//' -i Makefile.in";
 
   enableParallelBuilding = true;
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   postInstall = "rm -rf $out/share/gtk-doc";
 
   passthru = {
@@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
     ''; # workaround for bug of nix-mode for Emacs */ '';
   };
 
-  meta = with stdenv.lib; {
+  meta = {
     description = "A multi-platform toolkit for creating graphical user interfaces";
 
     longDescription = ''
@@ -62,9 +62,9 @@ stdenv.mkDerivation rec {
 
     homepage = http://www.gtk.org/;
 
-    license = licenses.lgpl2Plus;
+    license = stdenv.lib.licenses.lgpl2Plus;
 
-    maintainers = with maintainers; [ urkud raskin vcunat lethalman ];
-    platforms = platforms.all;
+    maintainers = with stdenv.lib.maintainers; [ urkud raskin vcunat lethalman ];
+    platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/gvfs/default.nix b/pkgs/development/libraries/gvfs/default.nix
index dcdef696ffd..d2a958faed8 100644
--- a/pkgs/development/libraries/gvfs/default.nix
+++ b/pkgs/development/libraries/gvfs/default.nix
@@ -1,25 +1,25 @@
 { stdenv, fetchurl, pkgconfig, intltool, libtool
-, glib, dbus, udev, udisks2, libgcrypt
+, glib, dbus, udev, libgudev, udisks2, libgcrypt
 , libgphoto2, avahi, libarchive, fuse, libcdio
 , libxml2, libxslt, docbook_xsl, samba, libmtp
 , gnomeSupport ? false, gnome,libgnome_keyring, gconf, makeWrapper }:
 
 let
   ver_maj = "1.22";
-  version = "${ver_maj}.2";
+  version = "${ver_maj}.4";
 in
 stdenv.mkDerivation rec {
   name = "gvfs-${version}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gvfs/${ver_maj}/${name}.tar.xz";
-    sha256 = "8d08c4927b6c20d990498c23280017e7033b31a386f09b4c3ce5bedd20316250";
+    sha256 = "57e33faad35aba72be3822099856aca847f391626cf3ec734b42e64ba31f6484";
   };
 
   nativeBuildInputs = [ pkgconfig intltool libtool ];
 
   buildInputs =
-    [ makeWrapper glib dbus.libs udev udisks2 libgcrypt
+    [ makeWrapper glib dbus.libs udev libgudev udisks2 libgcrypt
       libgphoto2 avahi libarchive fuse libcdio
       libxml2 libxslt docbook_xsl samba libmtp
       # ToDo: a ligther version of libsoup to have FTP/HTTP support?
diff --git a/pkgs/development/libraries/harfbuzz/default.nix b/pkgs/development/libraries/harfbuzz/default.nix
index d2f8416b3ea..26c5d2fa825 100644
--- a/pkgs/development/libraries/harfbuzz/default.nix
+++ b/pkgs/development/libraries/harfbuzz/default.nix
@@ -8,11 +8,11 @@
 # (icu is a ~30 MB dependency, the rest is very small in comparison)
 
 stdenv.mkDerivation rec {
-  name = "harfbuzz-1.0.3";
+  name = "harfbuzz-1.0.6";
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/harfbuzz/release/${name}.tar.bz2";
-    sha256 = "1xrxlrvgyr6mm9qjxmkif2kvcah082y94gf1vqi0f0bdl1g8gp7b";
+    sha256 = "09ivk5m4y09ar4zi9r6db7gp234cy05h0ach7w22g9kqvkxsf5pn";
   };
 
   outputs = [ "out" "doc" ];
diff --git a/pkgs/development/libraries/icu/default.nix b/pkgs/development/libraries/icu/default.nix
index 909f4e936a9..a2196d26524 100644
--- a/pkgs/development/libraries/icu/default.nix
+++ b/pkgs/development/libraries/icu/default.nix
@@ -2,7 +2,7 @@
 
 let
   pname = "icu4c";
-  version = "55.1";
+  version = "56.1";
 in
 stdenv.mkDerivation {
   name = pname + "-" + version;
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   src = fetchurl {
     url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
       + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
-    sha256 = "0ys5f5spizg45qlaa31j2lhgry0jka2gfha527n4ndfxxz5j4sz1";
+    sha256 = "05j86714qaj0lvhvyr2s1xncw6sk0h2dcghb3iiwykbkbh8fjr1s";
   };
 
   makeFlags = stdenv.lib.optionalString stdenv.isDarwin
diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix
index 4e13c9b1d93..746ebd2bfcd 100644
--- a/pkgs/development/libraries/jemalloc/default.nix
+++ b/pkgs/development/libraries/jemalloc/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "jemalloc-4.0.2";
+  name = "jemalloc-4.0.3";
 
   src = fetchurl {
     url = "http://www.canonware.com/download/jemalloc/${name}.tar.bz2";
-    sha256 = "04a6iw9wiwiknd7v3l3i7vpmc5nvv52islnb1hz9idmdk259r2hd";
+    sha256 = "1mpnfaniaybv8kh7yjqq2g595l2i08m7adg238k5igzf61n6ixzi";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libaccounts-glib/default.nix b/pkgs/development/libraries/libaccounts-glib/default.nix
index aa029ede953..2e2bdb11d50 100644
--- a/pkgs/development/libraries/libaccounts-glib/default.nix
+++ b/pkgs/development/libraries/libaccounts-glib/default.nix
@@ -22,4 +22,6 @@ stdenv.mkDerivation rec {
   configurePhase = ''
     HAVE_GCOV_FALSE="#" ./configure $configureFlags --prefix=$out
   '';
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations"; # since glib-2.46
 }
diff --git a/pkgs/development/libraries/libarchive/default.nix b/pkgs/development/libraries/libarchive/default.nix
index 1ec253dccd6..ff33043dbae 100644
--- a/pkgs/development/libraries/libarchive/default.nix
+++ b/pkgs/development/libraries/libarchive/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, acl, openssl, libxml2, attr, zlib, bzip2, e2fsprogs, xz
+{ fetchurl, stdenv, acl, openssl, libxml2, attr, zlib, bzip2, e2fsprogs, xz, lzo
 , sharutils }:
 
 stdenv.mkDerivation rec {
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
       # ^ it's CVE-2015-2304 specific to libarchive
   ];
 
-  buildInputs = [ sharutils libxml2 zlib bzip2 openssl xz ] ++
+  buildInputs = [ sharutils libxml2 zlib bzip2 openssl xz lzo ] ++
     stdenv.lib.optionals stdenv.isLinux [ e2fsprogs attr acl ];
 
   preBuild = if stdenv.isCygwin then ''
@@ -26,7 +26,9 @@ stdenv.mkDerivation rec {
   '' else null;
 
   preFixup = ''
-    sed 's|-lcrypto|-L${openssl}/lib -lcrypto|' -i $out/lib/libarchive.la
+    sed -i $out/lib/libarchive.la \
+      -e 's|-lcrypto|-L${openssl}/lib -lcrypto|' \
+      -e 's|-llzo2|-L${lzo}/lib -llzo2|'
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/libdnet/default.nix b/pkgs/development/libraries/libdnet/default.nix
index 8911539d7b0..2bdeffb204d 100644
--- a/pkgs/development/libraries/libdnet/default.nix
+++ b/pkgs/development/libraries/libdnet/default.nix
@@ -10,9 +10,9 @@ stdenv.mkDerivation {
     sha1 = "71302be302e84fc19b559e811951b5d600d976f8";
   };
 
-  buildInputs = [ automake autoconf libtool ];
+  configureFlags = [ "--enable-shared" ]; # shared libs required by hyenae
 
-  CFLAGS="-fPIC";
+  buildInputs = [ automake autoconf libtool ];
 
   # .so endings are missing (quick and dirty fix)
   postInstall = ''
diff --git a/pkgs/development/libraries/libgudev/default.nix b/pkgs/development/libraries/libgudev/default.nix
new file mode 100644
index 00000000000..e751c6ee6c0
--- /dev/null
+++ b/pkgs/development/libraries/libgudev/default.nix
@@ -0,0 +1,21 @@
+{ lib, stdenv, fetchurl, pkgconfig, udev, glib }:
+
+let version = "230"; in
+
+stdenv.mkDerivation rec {
+  name = "libgudev-${version}";
+
+  src = fetchurl {
+    url = "https://download.gnome.org/sources/libgudev/${version}/${name}.tar.xz";
+    sha256 = "a2e77faced0c66d7498403adefcc0707105e03db71a2b2abd620025b86347c18";
+  };
+
+  buildInputs = [ pkgconfig udev glib ];
+
+  meta = {
+    homepage = https://wiki.gnome.org/Projects/libgudev;
+    maintainers = [ lib.maintainers.eelco ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.lgpl2Plus;
+  };
+}
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index 158b8825db4..3660a652e79 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, nasm }:
 
 stdenv.mkDerivation rec {
-  name = "libjpeg-turbo-1.4.1";
+  name = "libjpeg-turbo-1.4.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/libjpeg-turbo/${name}.tar.gz";
-    sha256 = "027vz97064bjmwj7gdw2p47y1437w08j54frpgzmnql5rvabmxab";
+    sha256 = "0gi349hp1x7mb98s4mf66sb2xay2kjjxj9ihrriw0yiy0k9va6sj";
   };
 
   buildInputs = [ nasm ];
diff --git a/pkgs/development/libraries/libmbim/default.nix b/pkgs/development/libraries/libmbim/default.nix
index d58f031f376..f910741c446 100644
--- a/pkgs/development/libraries/libmbim/default.nix
+++ b/pkgs/development/libraries/libmbim/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, python, udev }:
+{ stdenv, fetchurl, pkgconfig, glib, python, udev, libgudev }:
 
 stdenv.mkDerivation rec {
   name = "libmbim-1.12.2";
@@ -12,11 +12,11 @@ stdenv.mkDerivation rec {
     patchShebangs .
   '';
 
-  buildInputs = [ pkgconfig glib udev python ];
+  buildInputs = [ pkgconfig glib udev libgudev python ];
 
   meta = with stdenv.lib; {
     homepage = http://www.freedesktop.org/software/libmbim/;
-    description = "talking to WWAN modems and devices which speak the Mobile Interface Broadband Model (MBIM) protocol";
+    description = "Library for talking to WWAN modems and devices which speak the Mobile Interface Broadband Model (MBIM) protocol";
     platforms = platforms.linux;
     license = licenses.gpl2;
     maintainers = with maintainers; [ wkennington ];
diff --git a/pkgs/development/libraries/libpsl/default.nix b/pkgs/development/libraries/libpsl/default.nix
index 2eb6c45d36a..903dcd9305e 100644
--- a/pkgs/development/libraries/libpsl/default.nix
+++ b/pkgs/development/libraries/libpsl/default.nix
@@ -28,6 +28,10 @@ in stdenv.mkDerivation {
   buildInputs = [ icu libxslt ];
   nativeBuildInputs = [ autoreconfHook docbook_xsl gtk_doc pkgconfig ];
 
+  postPatch = ''
+    substituteInPlace src/psl.c --replace bits/stat.h sys/stat.h
+  '';
+
   preAutoreconf = ''
     mkdir m4
     gtkdocize
diff --git a/pkgs/development/libraries/libseccomp/default.nix b/pkgs/development/libraries/libseccomp/default.nix
index af9f017ac73..444b68a23ee 100644
--- a/pkgs/development/libraries/libseccomp/default.nix
+++ b/pkgs/development/libraries/libseccomp/default.nix
@@ -1,17 +1,16 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, getopt }:
+{ stdenv, fetchurl, getopt }:
+
+let version = "2.2.3"; in
 
 stdenv.mkDerivation rec {
-  name    = "libseccomp-${version}";
-  version = "2.2.3";
+  name = "libseccomp-${version}";
 
-  src = fetchFromGitHub {
-    owner = "seccomp";
-    repo = "libseccomp";
-    rev = "v${version}";
-    sha256 = "0pl827qjls5b6kjj8qxxdwcn6rviqbm5xjqf0hgx6b04c836mswx";
+  src = fetchurl {
+    url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz";
+    sha256 = "d9b400b703cab7bb04b84b9b6e52076a630b673819d7541757bcc16467b6d49e";
   };
 
-  buildInputs = [ autoreconfHook getopt ];
+  buildInputs = [ getopt ];
 
   patchPhase = ''
     patchShebangs .
diff --git a/pkgs/development/libraries/libunwind/native.nix b/pkgs/development/libraries/libunwind/native.nix
new file mode 100644
index 00000000000..6ce485ecaec
--- /dev/null
+++ b/pkgs/development/libraries/libunwind/native.nix
@@ -0,0 +1,17 @@
+{ stdenv }:
+
+assert stdenv.isDarwin;
+
+stdenv.mkDerivation {
+  name = "libunwind-native";
+
+  unpackPhase = ":";
+  dontBuild = true;
+
+  installPhase = ''
+    mkdir -p $out/lib
+    cat /usr/lib/system/libunwind.dylib > $out/lib/libunwind.dylib
+  '';
+
+  meta.platforms = stdenv.lib.platforms.darwin;
+}
diff --git a/pkgs/development/libraries/libwacom/default.nix b/pkgs/development/libraries/libwacom/default.nix
index a0dd711e815..12bb7c785ac 100644
--- a/pkgs/development/libraries/libwacom/default.nix
+++ b/pkgs/development/libraries/libwacom/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, glib, pkgconfig, udev }:
+{ fetchurl, stdenv, glib, pkgconfig, udev, libgudev }:
 
 stdenv.mkDerivation rec {
   name = "libwacom-0.15";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "04vppdj99cc0ya44n8p7zjk9yyw03v6fksw0a9n1gpnnsn4wardb";
   };
 
-  buildInputs = [ glib pkgconfig udev ];
+  buildInputs = [ glib pkgconfig udev libgudev ];
 
   meta = with stdenv.lib; {
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 90db53ae7eb..b0c26def14a 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -22,7 +22,7 @@ else
 */
 
 let
-  version = "10.6.8";
+  version = "11.0.4";
   # this is the default search path for DRI drivers
   driverLink = "/run/opengl-driver" + stdenv.lib.optionalString stdenv.isi686 "-32";
 in
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
       "https://launchpad.net/mesa/trunk/${version}/+download/mesa-${version}.tar.xz"
       "ftp://ftp.freedesktop.org/pub/mesa/${version}/mesa-${version}.tar.xz"
     ];
-    sha256 = "e36ee5ceeadb3966fb5ce5b4cf18322dbb76a4f075558ae49c3bba94f57d58fd";
+    sha256 = "40201bf7fc6fa12a6d9edfe870b41eb4dd6669154e3c42c48a96f70805f5483d";
   };
 
   prePatch = "patchShebangs .";
diff --git a/pkgs/development/libraries/neon/default.nix b/pkgs/development/libraries/neon/default.nix
index 0ca64c9bb07..ffc409d271e 100644
--- a/pkgs/development/libraries/neon/default.nix
+++ b/pkgs/development/libraries/neon/default.nix
@@ -14,12 +14,11 @@ let
 in
 
 stdenv.mkDerivation rec {
-  version = "0.30.1";
-  name = "neon-${version}";
+  name = "neon-0.29.6";
 
   src = fetchurl {
     url = "http://www.webdav.org/neon/${name}.tar.gz";
-    sha256 = "1pawhk02x728xn396a1kcivy9gqm94srmgad6ymr9l0qvk02dih0";
+    sha256 = "0hzbjqdx1z8zw0vmbknf159wjsxbcq8ii0wgwkqhxj3dimr0nr4w";
   };
 
   patches = optionals stdenv.isDarwin [ ./0.29.6-darwin-fix-configure.patch ];
diff --git a/pkgs/development/libraries/nghttp2/default.nix b/pkgs/development/libraries/nghttp2/default.nix
index c4257fe97d2..5cd5f0cb629 100644
--- a/pkgs/development/libraries/nghttp2/default.nix
+++ b/pkgs/development/libraries/nghttp2/default.nix
@@ -34,12 +34,12 @@ let
 in
 stdenv.mkDerivation rec {
   name = "${prefix}nghttp2-${version}";
-  version = "1.2.1";
+  version = "1.3.4";
 
   # Don't use fetchFromGitHub since this needs a bootstrap curl
   src = fetchurl {
     url = "http://pub.wak.io/nixos/tarballs/nghttp2-${version}.tar.bz2";
-    sha256 = "8027461a231d205394890b2fee34d1c3751e28e7d3f7c1ebc1b557993ea4045e";
+    sha256 = "63c1d70e50f0c8514e261be88b66720df095269791aa008d76c09e0c3a4c085f";
   };
 
   # Configure script searches for a symbol which does not exist in jemalloc on Darwin
@@ -66,6 +66,7 @@ stdenv.mkDerivation rec {
     (mkWith   (optJemalloc != null) "jemalloc"        null)
     (mkWith   false                 "spdylay"         null)
     (mkWith   false                 "cython"          null)
+    (mkWith   false                 "mruby"           null)
   ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/pango/default.nix b/pkgs/development/libraries/pango/default.nix
index 2db67041ec3..e7106b9877e 100644
--- a/pkgs/development/libraries/pango/default.nix
+++ b/pkgs/development/libraries/pango/default.nix
@@ -3,26 +3,26 @@
 }:
 
 let
-  ver_maj = "1.36";
-  ver_min = "8";
+  ver_maj = "1.38";
+  ver_min = "0";
 in
 stdenv.mkDerivation rec {
   name = "pango-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/pango/${ver_maj}/${name}.tar.xz";
-    sha256 = "01rdzjh68w8l5zn0648yibyarj8p6g7yfn59nw5awaz1i8dvbnqq";
+    sha256 = "0v12gi7f01iq3z852pclpnmkbcksbvpcmiazmklkx1dd9fbpakhx";
   };
 
   buildInputs = with stdenv.lib; [ gobjectIntrospection ]
-    ++ optionals stdenv.isDarwin [ fontconfig ];
+    ++ optional stdenv.isDarwin fontconfig;
   nativeBuildInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ xlibsWrapper glib cairo libpng fontconfig freetype harfbuzz ] ++ libintlOrEmpty;
 
   enableParallelBuilding = true;
 
-  doCheck = false; # test-layout fails on 1.36.8
+  doCheck = false; # test-layout fails on 1.38.0
   # jww (2014-05-05): The tests currently fail on Darwin:
   #
   # ERROR:testiter.c:139:iter_char_test: assertion failed: (extents.width == x1 - x0)
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
 
   postInstall = "rm -rf $out/share/gtk-doc";
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A library for laying out and rendering of text, with an emphasis on internationalization";
 
     longDescription = ''
@@ -43,9 +43,9 @@ stdenv.mkDerivation rec {
     '';
 
     homepage = http://www.pango.org/;
-    license = stdenv.lib.licenses.lgpl2Plus;
+    license = licenses.lgpl2Plus;
 
-    maintainers = with stdenv.lib.maintainers; [ raskin urkud ];
-    hydraPlatforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+    maintainers = with maintainers; [ raskin urkud ];
+    platforms = with platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/development/libraries/pcre/cve-2015-3210.patch b/pkgs/development/libraries/pcre/cve-2015-3210.patch
new file mode 100644
index 00000000000..c97849fb70c
--- /dev/null
+++ b/pkgs/development/libraries/pcre/cve-2015-3210.patch
@@ -0,0 +1,87 @@
+From 68ff1beb43bb3d4d8838f3285c97023d1e50513a Mon Sep 17 00:00:00 2001
+From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Fri, 15 May 2015 17:17:03 +0000
+Subject: [PATCH] Fix buffer overflow for named recursive back reference when
+ the name is duplicated.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream commit ported to pcre-8.37:
+
+commit 4b79af6b4cbeb5326ae5e4d83f3e935e00286c19
+Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date:   Fri May 15 17:17:03 2015 +0000
+
+    Fix buffer overflow for named recursive back reference when the name is
+    duplicated.
+
+    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1558 2f5784b3-3f2a-0410-8824-cb99058d5e15
+
+This fixes CVE-2015-3210.
+
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+---
+ pcre_compile.c       | 16 ++++++++++++++--
+ testdata/testinput2  |  2 ++
+ testdata/testoutput2 |  2 ++
+ 3 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/pcre_compile.c b/pcre_compile.c
+index 0efad26..6f06912 100644
+--- a/pcre_compile.c
++++ b/pcre_compile.c
+@@ -7173,14 +7173,26 @@ for (;; ptr++)
+           number. If the name is not found, set the value to 0 for a forward
+           reference. */
+ 
++          recno = 0;
+           ng = cd->named_groups;
+           for (i = 0; i < cd->names_found; i++, ng++)
+             {
+             if (namelen == ng->length &&
+                 STRNCMP_UC_UC(name, ng->name, namelen) == 0)
+-              break;
++              {
++              open_capitem *oc;
++              recno = ng->number;
++              if (is_recurse) break;
++              for (oc = cd->open_caps; oc != NULL; oc = oc->next)         
++                {          
++                if (oc->number == recno)                                     
++                  {               
++                  oc->flag = TRUE;                                      
++                  break;
++                  }                                                         
++                }                          
++              }    
+             }
+-          recno = (i < cd->names_found)? ng->number : 0;
+ 
+           /* Count named back references. */
+ 
+diff --git a/testdata/testinput2 b/testdata/testinput2
+index 58fe53b..83bb471 100644
+--- a/testdata/testinput2
++++ b/testdata/testinput2
+@@ -4152,4 +4152,6 @@ backtracking verbs. --/
+ 
+ /((?2){73}(?2))((?1))/
+ 
++"(?J)(?'d'(?'d'\g{d}))"
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testoutput2 b/testdata/testoutput2
+index b718df0..7dff52a 100644
+--- a/testdata/testoutput2
++++ b/testdata/testoutput2
+@@ -14423,4 +14423,6 @@ Failed: lookbehind assertion is not fixed length at offset 17
+ 
+ /((?2){73}(?2))((?1))/
+ 
++"(?J)(?'d'(?'d'\g{d}))"
++
+ /-- End of testinput2 --/
+-- 
+2.4.3
+
diff --git a/pkgs/development/libraries/pcre/cve-2015-5073.patch b/pkgs/development/libraries/pcre/cve-2015-5073.patch
new file mode 100644
index 00000000000..16fd45c87b1
--- /dev/null
+++ b/pkgs/development/libraries/pcre/cve-2015-5073.patch
@@ -0,0 +1,68 @@
+From 354e1f8e921dcb9cf2f3a5eac93cd826d01a7d8a Mon Sep 17 00:00:00 2001
+From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Tue, 23 Jun 2015 16:34:53 +0000
+Subject: [PATCH] Fix buffer overflow for forward reference within backward
+ assertion with excess closing parenthesis. Bugzilla 1651.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This is upstream commit ported to 8.37:
+
+commit 764692f9aea9eab50fdba6cb537441d8b34c6c37
+Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date:   Tue Jun 23 16:34:53 2015 +0000
+
+    Fix buffer overflow for forward reference within backward assertion with excess
+    closing parenthesis. Bugzilla 1651.
+
+    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1571 2f5784b3-3f2a-0410-8824-cb99058d5e15
+
+It fixes CVE-2015-5073.
+
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+---
+ pcre_compile.c       | 2 +-
+ testdata/testinput2  | 2 ++
+ testdata/testoutput2 | 3 +++
+ 3 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/pcre_compile.c b/pcre_compile.c
+index 6f06912..b66b1f6 100644
+--- a/pcre_compile.c
++++ b/pcre_compile.c
+@@ -9392,7 +9392,7 @@ OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The
+ exceptional ones forgo this. We scan the pattern to check that they are fixed
+ length, and set their lengths. */
+ 
+-if (cd->check_lookbehind)
++if (errorcode == 0 && cd->check_lookbehind)
+   {
+   pcre_uchar *cc = (pcre_uchar *)codestart;
+ 
+diff --git a/testdata/testinput2 b/testdata/testinput2
+index 83bb471..5cc9ce6 100644
+--- a/testdata/testinput2
++++ b/testdata/testinput2
+@@ -4154,4 +4154,6 @@ backtracking verbs. --/
+ 
+ "(?J)(?'d'(?'d'\g{d}))"
+ 
++/(?=di(?<=(?1))|(?=(.))))/
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testoutput2 b/testdata/testoutput2
+index 7dff52a..4decb8d 100644
+--- a/testdata/testoutput2
++++ b/testdata/testoutput2
+@@ -14425,4 +14425,7 @@ Failed: lookbehind assertion is not fixed length at offset 17
+ 
+ "(?J)(?'d'(?'d'\g{d}))"
+ 
++/(?=di(?<=(?1))|(?=(.))))/
++Failed: unmatched parentheses at offset 23
++
+ /-- End of testinput2 --/
+-- 
+2.4.3
+
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index f32af2a0e1e..3370e910565 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoreconfHook, unicodeSupport ? true, cplusplusSupport ? true
+{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true
 , windows ? null
 }:
 
@@ -12,12 +12,10 @@ stdenv.mkDerivation rec {
     sha256 = "17bqykp604p7376wj3q2nmjdhrb6v1ny8q08zdwi7qvc02l9wrsi";
   };
 
-  nativeBuildInputs = [ autoreconfHook ];
-
-  # A bundle of fixes which should be removed for 8.38
-  patchPhase = ''
-    patch -p0 -i ${./fixes.patch}
-  '';
+  patches =
+    [ ./cve-2015-3210.patch
+      ./cve-2015-5073.patch
+    ];
 
   outputs = [ "out" "doc" "man" ];
 
diff --git a/pkgs/development/libraries/pcre/fixes.patch b/pkgs/development/libraries/pcre/fixes.patch
deleted file mode 100644
index 3b39128d7e4..00000000000
--- a/pkgs/development/libraries/pcre/fixes.patch
+++ /dev/null
@@ -1,3538 +0,0 @@
-Index: pcre_jit_compile.c
-===================================================================
---- pcre_jit_compile.c	(revision 1554)
-+++ pcre_jit_compile.c	(working copy)
-@@ -1064,6 +1064,7 @@
- pcre_uchar *end = NULL;
- int private_data_ptr = *private_data_start;
- int space, size, bracketlen;
-+BOOL repeat_check = TRUE;
- 
- while (cc < ccend)
-   {
-@@ -1071,9 +1072,10 @@
-   size = 0;
-   bracketlen = 0;
-   if (private_data_ptr > SLJIT_MAX_LOCAL_SIZE)
--    return;
-+    break;
- 
--  if (*cc == OP_ONCE || *cc == OP_ONCE_NC || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND)
-+  if (repeat_check && (*cc == OP_ONCE || *cc == OP_ONCE_NC || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND))
-+    {
-     if (detect_repeat(common, cc))
-       {
-       /* These brackets are converted to repeats, so no global
-@@ -1081,6 +1083,8 @@
-       if (cc >= end)
-         end = bracketend(cc);
-       }
-+    }
-+  repeat_check = TRUE;
- 
-   switch(*cc)
-     {
-@@ -1136,6 +1140,13 @@
-     bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
-     break;
- 
-+    case OP_BRAZERO:
-+    case OP_BRAMINZERO:
-+    case OP_BRAPOSZERO:
-+    repeat_check = FALSE;
-+    size = 1;
-+    break;
-+
-     CASE_ITERATOR_PRIVATE_DATA_1
-     space = 1;
-     size = -2;
-@@ -1162,12 +1173,17 @@
-     size = 1;
-     break;
- 
--    CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
-+    case OP_TYPEUPTO:
-     if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
-       space = 2;
-     size = 1 + IMM2_SIZE;
-     break;
- 
-+    case OP_TYPEMINUPTO:
-+    space = 2;
-+    size = 1 + IMM2_SIZE;
-+    break;
-+
-     case OP_CLASS:
-     case OP_NCLASS:
-     size += 1 + 32 / sizeof(pcre_uchar);
-@@ -1316,6 +1332,13 @@
-     cc += 1 + LINK_SIZE + IMM2_SIZE;
-     break;
- 
-+    case OP_THEN:
-+    stack_restore = TRUE;
-+    if (common->control_head_ptr != 0)
-+      *needs_control_head = TRUE;
-+    cc ++;
-+    break;
-+
-     default:
-     stack_restore = TRUE;
-     /* Fall through. */
-@@ -2220,6 +2243,7 @@
-     SLJIT_ASSERT_STOP();
-     break;
-     }
-+  SLJIT_ASSERT(current > (sljit_sw*)current[-1]);
-   current = (sljit_sw*)current[-1];
-   }
- return -1;
-@@ -3209,7 +3233,7 @@
- bytes[0] = len;
- }
- 
--static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars)
-+static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars, pcre_uint32 *rec_count)
- {
- /* Recursive function, which scans prefix literals. */
- BOOL last, any, caseless;
-@@ -3227,9 +3251,14 @@
- repeat = 1;
- while (TRUE)
-   {
-+  if (*rec_count == 0)
-+    return 0;
-+  (*rec_count)--;
-+
-   last = TRUE;
-   any = FALSE;
-   caseless = FALSE;
-+
-   switch (*cc)
-     {
-     case OP_CHARI:
-@@ -3291,7 +3320,7 @@
- #ifdef SUPPORT_UTF
-     if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc);
- #endif
--    max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars);
-+    max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars, rec_count);
-     if (max_chars == 0)
-       return consumed;
-     last = FALSE;
-@@ -3314,7 +3343,7 @@
-     alternative = cc + GET(cc, 1);
-     while (*alternative == OP_ALT)
-       {
--      max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars);
-+      max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars, rec_count);
-       if (max_chars == 0)
-         return consumed;
-       alternative += GET(alternative, 1);
-@@ -3556,6 +3585,7 @@
- int range_right = -1, range_len = 3 - 1;
- sljit_ub *update_table = NULL;
- BOOL in_range;
-+pcre_uint32 rec_count;
- 
- for (i = 0; i < MAX_N_CHARS; i++)
-   {
-@@ -3564,7 +3594,8 @@
-   bytes[i * MAX_N_BYTES] = 0;
-   }
- 
--max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS);
-+rec_count = 10000;
-+max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS, &rec_count);
- 
- if (max <= 1)
-   return FALSE;
-@@ -4311,8 +4342,10 @@
-   case 4:
-   if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])
-       && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]
-+      && (ranges[1] & (ranges[2] - ranges[0])) == 0
-       && is_powerof2(ranges[2] - ranges[0]))
-     {
-+    SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0);
-     OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]);
-     if (ranges[2] + 1 != ranges[3])
-       {
-@@ -4900,9 +4933,10 @@
-   if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list))
-     {
- #ifdef COMPILE_PCRE8
--    SLJIT_ASSERT(common->utf);
-+    jump = NULL;
-+    if (common->utf)
- #endif
--    jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-+      jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
- 
-     OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
-     OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
-@@ -4911,7 +4945,10 @@
-     OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
-     add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));
- 
--    JUMPHERE(jump);
-+#ifdef COMPILE_PCRE8
-+    if (common->utf)
-+#endif
-+      JUMPHERE(jump);
-     }
- 
-   OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
-@@ -7665,6 +7702,10 @@
-       OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
-       }
- 
-+    /* Even if the match is empty, we need to reset the control head. */
-+    if (needs_control_head)
-+      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
-+
-     if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
-       add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
- 
-@@ -7692,6 +7733,10 @@
-       OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
-       }
- 
-+    /* Even if the match is empty, we need to reset the control head. */
-+    if (needs_control_head)
-+      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
-+
-     if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
-       add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
- 
-@@ -7704,9 +7749,6 @@
-       }
-     }
- 
--  if (needs_control_head)
--    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
--
-   JUMPTO(SLJIT_JUMP, loop);
-   flush_stubs(common);
- 
-@@ -8441,8 +8483,7 @@
-       OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), STR_PTR, 0);
-       }
-     BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();
--    if (cc[1] > OP_ASSERTBACK_NOT)
--      count_match(common);
-+    count_match(common);
-     break;
- 
-     case OP_ONCE:
-@@ -9624,7 +9665,7 @@
- DEFINE_COMPILER;
- pcre_uchar *cc = common->start + common->currententry->start;
- pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
--pcre_uchar *ccend = bracketend(cc);
-+pcre_uchar *ccend = bracketend(cc) - (1 + LINK_SIZE);
- BOOL needs_control_head;
- int framesize = get_framesize(common, cc, NULL, TRUE, &needs_control_head);
- int private_data_size = get_private_data_copy_length(common, ccbegin, ccend, needs_control_head);
-@@ -9648,6 +9689,7 @@
- 
- sljit_emit_fast_enter(compiler, TMP2, 0);
- allocate_stack(common, private_data_size + framesize + alternativesize);
-+count_match(common);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);
- copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize, needs_control_head);
- if (needs_control_head)
-@@ -9992,6 +10034,7 @@
- OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match));
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));
- OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));
-+OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH, TMP1, 0);
- 
- if (mode == JIT_PARTIAL_SOFT_COMPILE)
-Index: RunGrepTest
-===================================================================
---- RunGrepTest	(revision 1554)
-+++ RunGrepTest	(working copy)
-@@ -512,6 +512,14 @@
- (cd $srcdir; $valgrind $pcregrep  --line-offsets '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1
- echo "RC=$?" >>testtrygrep
- 
-+echo "---------------------------- Test 108 ------------------------------" >>testtrygrep
-+(cd $srcdir; $valgrind $pcregrep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
-+echo "RC=$?" >>testtrygrep
-+
-+echo "---------------------------- Test 109 -----------------------------" >>testtrygrep
-+(cd $srcdir; $valgrind $pcregrep -cq lazy ./testdata/grepinput*) >>testtrygrep
-+echo "RC=$?" >>testtrygrep
-+
- # Now compare the results.
- 
- $cf $srcdir/testdata/grepoutput testtrygrep
-Index: pcre_compile.c
-===================================================================
---- pcre_compile.c	(revision 1554)
-+++ pcre_compile.c	(working copy)
-@@ -174,7 +174,7 @@
-      -ESC_Z,                  CHAR_LEFT_SQUARE_BRACKET,
-      CHAR_BACKSLASH,          CHAR_RIGHT_SQUARE_BRACKET,
-      CHAR_CIRCUMFLEX_ACCENT,  CHAR_UNDERSCORE,
--     CHAR_GRAVE_ACCENT,       7,
-+     CHAR_GRAVE_ACCENT,       ESC_a,
-      -ESC_b,                  0,
-      -ESC_d,                  ESC_e,
-      ESC_f,                   0,
-@@ -202,9 +202,9 @@
- /*  68 */     0,     0,    '|',     ',',    '%',   '_',    '>',    '?',
- /*  70 */     0,     0,      0,       0,      0,     0,      0,      0,
- /*  78 */     0,   '`',    ':',     '#',    '@',  '\'',    '=',    '"',
--/*  80 */     0,     7, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,
-+/*  80 */     0, ESC_a, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,
- /*  88 */-ESC_h,     0,      0,     '{',      0,     0,      0,      0,
--/*  90 */     0,     0, -ESC_k,     'l',      0, ESC_n,      0, -ESC_p,
-+/*  90 */     0,     0, -ESC_k,       0,      0, ESC_n,      0, -ESC_p,
- /*  98 */     0, ESC_r,      0,     '}',      0,     0,      0,      0,
- /*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,-ESC_v, -ESC_w,      0,
- /*  A8 */     0,-ESC_z,      0,       0,      0,   '[',      0,      0,
-@@ -219,6 +219,12 @@
- /*  F0 */     0,     0,      0,       0,      0,     0,      0,      0,
- /*  F8 */     0,     0,      0,       0,      0,     0,      0,      0
- };
-+
-+/* We also need a table of characters that may follow \c in an EBCDIC
-+environment for characters 0-31. */
-+
-+static unsigned char ebcdic_escape_c[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
-+
- #endif
- 
- 
-@@ -458,7 +464,7 @@
-   "range out of order in character class\0"
-   "nothing to repeat\0"
-   /* 10 */
--  "operand of unlimited repeat could match the empty string\0"  /** DEAD **/
-+  "internal error: invalid forward reference offset\0"
-   "internal error: unexpected repeat\0"
-   "unrecognized character after (? or (?-\0"
-   "POSIX named classes are supported only within a class\0"
-@@ -527,7 +533,11 @@
-   "different names for subpatterns of the same number are not allowed\0"
-   "(*MARK) must have an argument\0"
-   "this version of PCRE is not compiled with Unicode property support\0"
-+#ifndef EBCDIC
-   "\\c must be followed by an ASCII character\0"
-+#else
-+  "\\c must be followed by a letter or one of [\\]^_?\0"
-+#endif
-   "\\k is not followed by a braced, angle-bracketed, or quoted name\0"
-   /* 70 */
-   "internal error: unknown opcode in find_fixedlength()\0"
-@@ -1425,7 +1435,16 @@
-     c ^= 0x40;
- #else             /* EBCDIC coding */
-     if (c >= CHAR_a && c <= CHAR_z) c += 64;
--    c ^= 0xC0;
-+    if (c == CHAR_QUESTION_MARK)
-+      c = ('\\' == 188 && '`' == 74)? 0x5f : 0xff;
-+    else
-+      {
-+      for (i = 0; i < 32; i++)
-+        {
-+        if (c == ebcdic_escape_c[i]) break;
-+        }
-+      if (i < 32) c = i; else *errorcodeptr = ERR68;
-+      }
- #endif
-     break;
- 
-@@ -1799,7 +1818,7 @@
-     case OP_ASSERTBACK:
-     case OP_ASSERTBACK_NOT:
-     do cc += GET(cc, 1); while (*cc == OP_ALT);
--    cc += PRIV(OP_lengths)[*cc];
-+    cc += 1 + LINK_SIZE;
-     break;
- 
-     /* Skip over things that don't match chars */
-@@ -2487,7 +2506,7 @@
-   if (c == OP_BRA  || c == OP_BRAPOS ||
-       c == OP_CBRA || c == OP_CBRAPOS ||
-       c == OP_ONCE || c == OP_ONCE_NC ||
--      c == OP_COND)
-+      c == OP_COND || c == OP_SCOND)
-     {
-     BOOL empty_branch;
-     if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */
-@@ -3886,11 +3905,11 @@
- The problem in trying to be exactly like Perl is in the handling of escapes. We
- have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX
- class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code
--below handles the special case of \], but does not try to do any other escape
--processing. This makes it different from Perl for cases such as [:l\ower:]
--where Perl recognizes it as the POSIX class "lower" but PCRE does not recognize
--"l\ower". This is a lesser evil than not diagnosing bad classes when Perl does,
--I think.
-+below handles the special cases \\ and \], but does not try to do any other
-+escape processing. This makes it different from Perl for cases such as
-+[:l\ower:] where Perl recognizes it as the POSIX class "lower" but PCRE does
-+not recognize "l\ower". This is a lesser evil than not diagnosing bad classes
-+when Perl does, I think.
- 
- A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
- It seems that the appearance of a nested POSIX class supersedes an apparent
-@@ -3917,21 +3936,16 @@
- terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
- for (++ptr; *ptr != CHAR_NULL; ptr++)
-   {
--  if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
-+  if (*ptr == CHAR_BACKSLASH &&
-+      (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
-+       ptr[1] == CHAR_BACKSLASH))
-     ptr++;
--  else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
--  else
-+  else if ((*ptr == CHAR_LEFT_SQUARE_BRACKET && ptr[1] == terminator) ||
-+            *ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
-+  else if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
-     {
--    if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
--      {
--      *endptr = ptr;
--      return TRUE;
--      }
--    if (*ptr == CHAR_LEFT_SQUARE_BRACKET &&
--         (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
--          ptr[1] == CHAR_EQUALS_SIGN) &&
--        check_posix_syntax(ptr, endptr))
--      return FALSE;
-+    *endptr = ptr;
-+    return TRUE;
-     }
-   }
- return FALSE;
-@@ -3985,11 +3999,12 @@
- is called, the partially compiled regex must be temporarily terminated with
- OP_END.
- 
--This function has been extended with the possibility of forward references for
--recursions and subroutine calls. It must also check the list of such references
--for the group we are dealing with. If it finds that one of the recursions in
--the current group is on this list, it adjusts the offset in the list, not the
--value in the reference (which is a group number).
-+This function has been extended to cope with forward references for recursions
-+and subroutine calls. It must check the list of such references for the
-+group we are dealing with. If it finds that one of the recursions in the
-+current group is on this list, it does not adjust the value in the reference
-+(which is a group number). After the group has been scanned, all the offsets in
-+the forward reference list for the group are adjusted.
- 
- Arguments:
-   group      points to the start of the group
-@@ -4005,29 +4020,21 @@
- adjust_recurse(pcre_uchar *group, int adjust, BOOL utf, compile_data *cd,
-   size_t save_hwm_offset)
- {
-+int offset;
-+pcre_uchar *hc;
- pcre_uchar *ptr = group;
- 
- while ((ptr = (pcre_uchar *)find_recurse(ptr, utf)) != NULL)
-   {
--  int offset;
--  pcre_uchar *hc;
--
--  /* See if this recursion is on the forward reference list. If so, adjust the
--  reference. */
--
-   for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
-        hc += LINK_SIZE)
-     {
-     offset = (int)GET(hc, 0);
--    if (cd->start_code + offset == ptr + 1)
--      {
--      PUT(hc, 0, offset + adjust);
--      break;
--      }
-+    if (cd->start_code + offset == ptr + 1) break;
-     }
- 
--  /* Otherwise, adjust the recursion offset if it's after the start of this
--  group. */
-+  /* If we have not found this recursion on the forward reference list, adjust
-+  the recursion's offset if it's after the start of this group. */
- 
-   if (hc >= cd->hwm)
-     {
-@@ -4037,6 +4044,15 @@
- 
-   ptr += 1 + LINK_SIZE;
-   }
-+
-+/* Now adjust all forward reference offsets for the group. */
-+
-+for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
-+     hc += LINK_SIZE)
-+  {
-+  offset = (int)GET(hc, 0);
-+  PUT(hc, 0, offset + adjust);
-+  }
- }
- 
- 
-@@ -4465,7 +4481,7 @@
- const pcre_uchar *nestptr = NULL;
- pcre_uchar *previous = NULL;
- pcre_uchar *previous_callout = NULL;
--size_t save_hwm_offset = 0;
-+size_t item_hwm_offset = 0;
- pcre_uint8 classbits[32];
- 
- /* We can fish out the UTF-8 setting once and for all into a BOOL, but we
-@@ -4623,8 +4639,7 @@
-   /* In the real compile phase, just check the workspace used by the forward
-   reference list. */
- 
--  else if (cd->hwm > cd->start_workspace + cd->workspace_size -
--           WORK_SIZE_SAFETY_MARGIN)
-+  else if (cd->hwm > cd->start_workspace + cd->workspace_size)
-     {
-     *errorcodeptr = ERR52;
-     goto FAILED;
-@@ -4767,6 +4782,7 @@
-     zeroreqchar = reqchar;
-     zeroreqcharflags = reqcharflags;
-     previous = code;
-+    item_hwm_offset = cd->hwm - cd->start_workspace;
-     *code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;
-     break;
- 
-@@ -4818,6 +4834,7 @@
-     /* Handle a real character class. */
- 
-     previous = code;
-+    item_hwm_offset = cd->hwm - cd->start_workspace;
- 
-     /* PCRE supports POSIX class stuff inside a class. Perl gives an error if
-     they are encountered at the top level, so we'll do that too. */
-@@ -5195,9 +5212,9 @@
-               cd, PRIV(vspace_list));
-             continue;
- 
--#ifdef SUPPORT_UCP
-             case ESC_p:
-             case ESC_P:
-+#ifdef SUPPORT_UCP
-               {
-               BOOL negated;
-               unsigned int ptype = 0, pdata = 0;
-@@ -5211,6 +5228,9 @@
-               class_has_8bitchar--;                /* Undo! */
-               continue;
-               }
-+#else
-+            *errorcodeptr = ERR45;
-+            goto FAILED;
- #endif
-             /* Unrecognized escapes are faulted if PCRE is running in its
-             strict mode. By default, for compatibility with Perl, they are
-@@ -5930,7 +5950,7 @@
-       {
-       register int i;
-       int len = (int)(code - previous);
--      size_t base_hwm_offset = save_hwm_offset;
-+      size_t base_hwm_offset = item_hwm_offset;
-       pcre_uchar *bralink = NULL;
-       pcre_uchar *brazeroptr = NULL;
- 
-@@ -5985,7 +6005,7 @@
-         if (repeat_max <= 1)    /* Covers 0, 1, and unlimited */
-           {
-           *code = OP_END;
--          adjust_recurse(previous, 1, utf, cd, save_hwm_offset);
-+          adjust_recurse(previous, 1, utf, cd, item_hwm_offset);
-           memmove(previous + 1, previous, IN_UCHARS(len));
-           code++;
-           if (repeat_max == 0)
-@@ -6009,7 +6029,7 @@
-           {
-           int offset;
-           *code = OP_END;
--          adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, save_hwm_offset);
-+          adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, item_hwm_offset);
-           memmove(previous + 2 + LINK_SIZE, previous, IN_UCHARS(len));
-           code += 2 + LINK_SIZE;
-           *previous++ = OP_BRAZERO + repeat_type;
-@@ -6254,6 +6274,12 @@
-             while (*scode == OP_ALT);
-             }
- 
-+          /* A conditional group with only one branch has an implicit empty
-+          alternative branch. */
-+
-+          if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
-+            *bracode = OP_SCOND;
-+
-           /* Handle possessive quantifiers. */
- 
-           if (possessive_quantifier)
-@@ -6267,11 +6293,11 @@
-               {
-               int nlen = (int)(code - bracode);
-               *code = OP_END;
--              adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
-+              adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
-               memmove(bracode + 1 + LINK_SIZE, bracode, IN_UCHARS(nlen));
-               code += 1 + LINK_SIZE;
-               nlen += 1 + LINK_SIZE;
--              *bracode = OP_BRAPOS;
-+              *bracode = (*bracode == OP_COND)? OP_BRAPOS : OP_SBRAPOS;
-               *code++ = OP_KETRPOS;
-               PUTINC(code, 0, nlen);
-               PUT(bracode, 1, nlen);
-@@ -6401,7 +6427,7 @@
-         else
-           {
-           *code = OP_END;
--          adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
-+          adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
-           memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
-           code += 1 + LINK_SIZE;
-           len += 1 + LINK_SIZE;
-@@ -6450,7 +6476,7 @@
- 
-         default:
-         *code = OP_END;
--        adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, save_hwm_offset);
-+        adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
-         memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
-         code += 1 + LINK_SIZE;
-         len += 1 + LINK_SIZE;
-@@ -6623,7 +6649,7 @@
-     newoptions = options;
-     skipbytes = 0;
-     bravalue = OP_CBRA;
--    save_hwm_offset = cd->hwm - cd->start_workspace;
-+    item_hwm_offset = cd->hwm - cd->start_workspace;
-     reset_bracount = FALSE;
- 
-     /* Deal with the extended parentheses; all are introduced by '?', and the
-@@ -6641,6 +6667,7 @@
-         /* ------------------------------------------------------------ */
-         case CHAR_VERTICAL_LINE:  /* Reset capture count for each branch */
-         reset_bracount = TRUE;
-+        cd->dupgroups = TRUE;     /* Record (?| encountered */ 
-         /* Fall through */
- 
-         /* ------------------------------------------------------------ */
-@@ -6741,6 +6768,12 @@
-           {
-           while (IS_DIGIT(*ptr))
-             {
-+            if (recno > INT_MAX / 10 - 1)  /* Integer overflow */              
-+              {                                                             
-+              while (IS_DIGIT(*ptr)) ptr++;                                 
-+              *errorcodeptr = ERR61;                                        
-+              goto FAILED; 
-+              }
-             recno = recno * 10 + (int)(*ptr - CHAR_0);
-             ptr++;
-             }
-@@ -6769,7 +6802,7 @@
-             ptr++;
-             }
-           namelen = (int)(ptr - name);
--          if (lengthptr != NULL) *lengthptr += IMM2_SIZE;
-+          if (lengthptr != NULL) skipbytes += IMM2_SIZE;
-           }
- 
-         /* Check the terminator */
-@@ -6875,6 +6908,11 @@
-               *errorcodeptr = ERR15;
-               goto FAILED;
-               }
-+            if (recno > INT_MAX / 10 - 1)   /* Integer overflow */          
-+              {                                                                
-+              *errorcodeptr = ERR61;                                        
-+              goto FAILED;                                
-+              }   
-             recno = recno * 10 + name[i] - CHAR_0;
-             }
-           if (recno == 0) recno = RREF_ANY;
-@@ -7151,7 +7189,8 @@
-         if (lengthptr != NULL)
-           {
-           named_group *ng;
--
-+          recno = 0;
-+           
-           if (namelen == 0)
-             {
-             *errorcodeptr = ERR62;
-@@ -7168,20 +7207,6 @@
-             goto FAILED;
-             }
- 
--          /* The name table does not exist in the first pass; instead we must
--          scan the list of names encountered so far in order to get the
--          number. If the name is not found, set the value to 0 for a forward
--          reference. */
--
--          ng = cd->named_groups;
--          for (i = 0; i < cd->names_found; i++, ng++)
--            {
--            if (namelen == ng->length &&
--                STRNCMP_UC_UC(name, ng->name, namelen) == 0)
--              break;
--            }
--          recno = (i < cd->names_found)? ng->number : 0;
--
-           /* Count named back references. */
- 
-           if (!is_recurse) cd->namedrefcount++;
-@@ -7191,6 +7216,56 @@
-           16-bit data item. */
- 
-           *lengthptr += IMM2_SIZE;
-+
-+          /* If this is a forward reference and we are within a (?|...) group,
-+          the reference may end up as the number of a group which we are
-+          currently inside, that is, it could be a recursive reference. In the
-+          real compile this will be picked up and the reference wrapped with
-+          OP_ONCE to make it atomic, so we must space in case this occurs. */
-+
-+          /* In fact, this can happen for a non-forward reference because
-+          another group with the same number might be created later. This
-+          issue is fixed "properly" in PCRE2. As PCRE1 is now in maintenance
-+          only mode, we finesse the bug by allowing more memory always. */
-+
-+          *lengthptr += 2 + 2*LINK_SIZE;
-+          
-+          /* It is even worse than that. The current reference may be to an
-+          existing named group with a different number (so apparently not
-+          recursive) but which later on is also attached to a group with the
-+          current number. This can only happen if $(| has been previous 
-+          encountered. In that case, we allow yet more memory, just in case. 
-+          (Again, this is fixed "properly" in PCRE2. */
-+          
-+          if (cd->dupgroups) *lengthptr += 4 + 4*LINK_SIZE;
-+
-+          /* Otherwise, check for recursion here. The name table does not exist
-+          in the first pass; instead we must scan the list of names encountered
-+          so far in order to get the number. If the name is not found, leave
-+          the value of recno as 0 for a forward reference. */
-+           
-+          else
-+            { 
-+            ng = cd->named_groups;
-+            for (i = 0; i < cd->names_found; i++, ng++)
-+              {
-+              if (namelen == ng->length &&
-+                  STRNCMP_UC_UC(name, ng->name, namelen) == 0)
-+                {
-+                open_capitem *oc;
-+                recno = ng->number;
-+                if (is_recurse) break;
-+                for (oc = cd->open_caps; oc != NULL; oc = oc->next)
-+                  {
-+                  if (oc->number == recno)
-+                    {
-+                    oc->flag = TRUE;
-+                    break;
-+                    }
-+                  }
-+                }
-+              }
-+            }   
-           }
- 
-         /* In the real compile, search the name table. We check the name
-@@ -7237,8 +7312,6 @@
-           for (i++; i < cd->names_found; i++)
-             {
-             if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;
--
--
-             count++;
-             cslot += cd->name_entry_size;
-             }
-@@ -7247,6 +7320,7 @@
-             {
-             if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
-             previous = code;
-+            item_hwm_offset = cd->hwm - cd->start_workspace;
-             *code++ = ((options & PCRE_CASELESS) != 0)? OP_DNREFI : OP_DNREF;
-             PUT2INC(code, 0, index);
-             PUT2INC(code, 0, count);
-@@ -7284,9 +7358,14 @@
- 
- 
-         /* ------------------------------------------------------------ */
--        case CHAR_R:              /* Recursion */
--        ptr++;                    /* Same as (?0)      */
--        /* Fall through */
-+        case CHAR_R:              /* Recursion, same as (?0) */
-+        recno = 0;
-+        if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
-+          {
-+          *errorcodeptr = ERR29;
-+          goto FAILED;
-+          }
-+        goto HANDLE_RECURSION;
- 
- 
-         /* ------------------------------------------------------------ */
-@@ -7323,7 +7402,15 @@
- 
-           recno = 0;
-           while(IS_DIGIT(*ptr))
-+            {
-+            if (recno > INT_MAX / 10 - 1) /* Integer overflow */
-+              {
-+              while (IS_DIGIT(*ptr)) ptr++;
-+              *errorcodeptr = ERR61;
-+              goto FAILED;
-+              }
-             recno = recno * 10 + *ptr++ - CHAR_0;
-+            }
- 
-           if (*ptr != (pcre_uchar)terminator)
-             {
-@@ -7360,6 +7447,7 @@
-           HANDLE_RECURSION:
- 
-           previous = code;
-+          item_hwm_offset = cd->hwm - cd->start_workspace;
-           called = cd->start_code;
- 
-           /* When we are actually compiling, find the bracket that is being
-@@ -7561,7 +7649,11 @@
-       previous = NULL;
-       cd->iscondassert = FALSE;
-       }
--    else previous = code;
-+    else
-+      {
-+      previous = code;
-+      item_hwm_offset = cd->hwm - cd->start_workspace;
-+      }
- 
-     *code = bravalue;
-     tempcode = code;
-@@ -7809,7 +7901,7 @@
-         const pcre_uchar *p;
-         pcre_uint32 cf;
- 
--        save_hwm_offset = cd->hwm - cd->start_workspace;   /* Normally this is set when '(' is read */
-+        item_hwm_offset = cd->hwm - cd->start_workspace;   /* Normally this is set when '(' is read */
-         terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
-           CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
- 
-@@ -7838,7 +7930,7 @@
-         if (*p != (pcre_uchar)terminator)
-           {
-           *errorcodeptr = ERR57;
--          break;
-+          goto FAILED;
-           }
-         ptr++;
-         goto HANDLE_NUMERICAL_RECURSION;
-@@ -7853,7 +7945,7 @@
-           ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))
-           {
-           *errorcodeptr = ERR69;
--          break;
-+          goto FAILED;
-           }
-         is_recurse = FALSE;
-         terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
-@@ -7877,6 +7969,7 @@
-         HANDLE_REFERENCE:
-         if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
-         previous = code;
-+        item_hwm_offset = cd->hwm - cd->start_workspace;
-         *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
-         PUT2INC(code, 0, recno);
-         cd->backref_map |= (recno < 32)? (1 << recno) : 1;
-@@ -7906,6 +7999,7 @@
-         if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
-           goto FAILED;
-         previous = code;
-+        item_hwm_offset = cd->hwm - cd->start_workspace;
-         *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
-         *code++ = ptype;
-         *code++ = pdata;
-@@ -7946,6 +8040,7 @@
- 
-           {
-           previous = (escape > ESC_b && escape < ESC_Z)? code : NULL;
-+          item_hwm_offset = cd->hwm - cd->start_workspace;
-           *code++ = (!utf && escape == ESC_C)? OP_ALLANY : escape;
-           }
-         }
-@@ -7989,6 +8084,7 @@
- 
-     ONE_CHAR:
-     previous = code;
-+    item_hwm_offset = cd->hwm - cd->start_workspace;
- 
-     /* For caseless UTF-8 mode when UCP support is available, check whether
-     this character has more than one other case. If so, generate a special
-@@ -9164,6 +9260,7 @@
- cd->name_entry_size = 0;
- cd->name_table = NULL;
- cd->dupnames = FALSE;
-+cd->dupgroups = FALSE;
- cd->namedrefcount = 0;
- cd->start_code = cworkspace;
- cd->hwm = cworkspace;
-@@ -9198,7 +9295,7 @@
- 
- DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
-   (int)(cd->hwm - cworkspace)));
--
-+  
- if (length > MAX_PATTERN_SIZE)
-   {
-   errorcode = ERR20;
-@@ -9336,6 +9433,16 @@
-     int offset, recno;
-     cd->hwm -= LINK_SIZE;
-     offset = GET(cd->hwm, 0);
-+    
-+    /* Check that the hwm handling hasn't gone wrong. This whole area is
-+    rewritten in PCRE2 because there are some obscure cases. */ 
-+     
-+    if (offset == 0 || codestart[offset-1] != OP_RECURSE)
-+      {
-+      errorcode = ERR10; 
-+      break;
-+      }  
-+ 
-     recno = GET(codestart, offset);
-     if (recno != prev_recno)
-       {
-@@ -9366,7 +9473,7 @@
- "const" attribute if the cast (pcre_uchar *)codestart is used directly in the
- function call. */
- 
--if ((options & PCRE_NO_AUTO_POSSESS) == 0)
-+if (errorcode == 0 && (options & PCRE_NO_AUTO_POSSESS) == 0)
-   {
-   pcre_uchar *temp = (pcre_uchar *)codestart;
-   auto_possessify(temp, utf, cd);
-@@ -9380,7 +9487,7 @@
- exceptional ones forgo this. We scan the pattern to check that they are fixed
- length, and set their lengths. */
- 
--if (cd->check_lookbehind)
-+if (errorcode == 0 && cd->check_lookbehind)
-   {
-   pcre_uchar *cc = (pcre_uchar *)codestart;
- 
-@@ -9593,4 +9700,3 @@
- }
- 
- /* End of pcre_compile.c */
--
-Index: ChangeLog
-===================================================================
---- ChangeLog	(revision 1554)
-+++ ChangeLog	(working copy)
-@@ -1,6 +1,162 @@
- ChangeLog for PCRE
- ------------------
- 
-+Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All 
-+development is happening in the PCRE2 10.xx series.
-+
-+Version 8.38 xx-xxx-xxxx
-+------------------------
-+
-+1.  If a group that contained a recursive back reference also contained a
-+    forward reference subroutine call followed by a non-forward-reference
-+    subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
-+    compile correct code, leading to undefined behaviour or an internally
-+    detected error. This bug was discovered by the LLVM fuzzer.
-+    
-+2.  Quantification of certain items (e.g. atomic back references) could cause
-+    incorrect code to be compiled when recursive forward references were
-+    involved. For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/.
-+    This bug was discovered by the LLVM fuzzer.
-+    
-+3.  A repeated conditional group whose condition was a reference by name caused
-+    a buffer overflow if there was more than one group with the given name.
-+    This bug was discovered by the LLVM fuzzer.
-+    
-+4.  A recursive back reference by name within a group that had the same name as
-+    another group caused a buffer overflow. For example:
-+    /(?J)(?'d'(?'d'\g{d}))/. This bug was discovered by the LLVM fuzzer.
-+
-+5.  A forward reference by name to a group whose number is the same as the
-+    current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused
-+    a buffer overflow at compile time. This bug was discovered by the LLVM
-+    fuzzer.
-+    
-+6.  A lookbehind assertion within a set of mutually recursive subpatterns could
-+    provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
-+    
-+7.  Another buffer overflow bug involved duplicate named groups with a 
-+    reference between their definition, with a group that reset capture 
-+    numbers, for example: /(?J:(?|(?'R')(\k'R')|((?'R'))))/. This has been 
-+    fixed by always allowing for more memory, even if not needed. (A proper fix 
-+    is implemented in PCRE2, but it involves more refactoring.) 
-+    
-+8.  There was no check for integer overflow in subroutine calls such as (?123).
-+
-+9.  The table entry for \l in EBCDIC environments was incorrect, leading to its
-+    being treated as a literal 'l' instead of causing an error. 
-+    
-+10. There was a buffer overflow if pcre_exec() was called with an ovector of 
-+    size 1. This bug was found by american fuzzy lop.
-+    
-+11. If a non-capturing group containing a conditional group that could match
-+    an empty string was repeated, it was not identified as matching an empty
-+    string itself. For example: /^(?:(?(1)x|)+)+$()/.
-+    
-+12. In an EBCDIC environment, pcretest was mishandling the escape sequences
-+    \a and \e in test subject lines. 
-+    
-+13. In an EBCDIC environment, \a in a pattern was converted to the ASCII 
-+    instead of the EBCDIC value. 
-+    
-+14. The handling of \c in an EBCDIC environment has been revised so that it is
-+    now compatible with the specification in Perl's perlebcdic page.
-+    
-+15. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
-+    ASCII/Unicode. This has now been added to the list of characters that are
-+    recognized as white space in EBCDIC.  
-+    
-+16. When PCRE was compiled without UCP support, the use of \p and \P gave an 
-+    error (correctly) when used outside a class, but did not give an error 
-+    within a class.
-+    
-+17. \h within a class was incorrectly compiled in EBCDIC environments. 
-+
-+18. A pattern with an unmatched closing parenthesis that contained a backward 
-+    assertion which itself contained a forward reference caused buffer 
-+    overflow. And example pattern is: /(?=di(?<=(?1))|(?=(.))))/.
-+
-+19. JIT should return with error when the compiled pattern requires more stack
-+    space than the maximum.
-+
-+20. A possessively repeated conditional group that could match an empty string,
-+    for example, /(?(R))*+/, was incorrectly compiled.
-+
-+21. Fix infinite recursion in the JIT compiler when certain patterns such as
-+    /(?:|a|){100}x/ are analysed.
-+
-+22. Some patterns with character classes involving [: and \\ were incorrectly
-+    compiled and could cause reading from uninitialized memory or an incorrect
-+    error diagnosis.
-+
-+23. Pathological patterns containing many nested occurrences of [: caused 
-+    pcre_compile() to run for a very long time.
-+
-+24. A conditional group with only one branch has an implicit empty alternative
-+    branch and must therefore be treated as potentially matching an empty
-+    string.
-+
-+25. If (?R was followed by - or + incorrect behaviour happened instead of a
-+    diagnostic. 
-+    
-+26. Arrange to give up on finding the minimum matching length for overly 
-+    complex patterns. 
-+    
-+27. Similar to (4) above: in a pattern with duplicated named groups and an 
-+    occurrence of (?| it is possible for an apparently non-recursive back 
-+    reference to become recursive if a later named group with the relevant 
-+    number is encountered. This could lead to a buffer overflow. Wen Guanxing 
-+    from Venustech ADLAB discovered this bug.
-+
-+28. If pcregrep was given the -q option with -c or -l, or when handling a 
-+    binary file, it incorrectly wrote output to stdout.
-+     
-+29. The JIT compiler did not restore the control verb head in case of *THEN
-+    control verbs. This issue was found by Karl Skomski with a custom LLVM
-+    fuzzer.
-+
-+30. Error messages for syntax errors following \g and \k were giving inaccurate 
-+    offsets in the pattern.
-+    
-+31. Added a check for integer overflow in conditions (?(<digits>) and
-+    (?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
-+    fuzzer.
-+    
-+32. Handling recursive references such as (?2) when the reference is to a group 
-+    later in the pattern uses code that is very hacked about and error-prone.
-+    It has been re-written for PCRE2. Here in PCRE1, a check has been added to
-+    give an internal error if it is obvious that compiling has gone wrong.
-+
-+33. The JIT compiler should not check repeats after a {0,1} repeat byte code.
-+    This issue was found by Karl Skomski with a custom LLVM fuzzer.
-+
-+34. The JIT compiler should restore the control chain for empty possessive
-+    repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
-+
-+35. Match limit check added to JIT recursion. This issue was found by Karl
-+    Skomski with a custom LLVM fuzzer.
-+    
-+36. Yet another case similar to 27 above has been circumvented by an 
-+    unconditional allocation of extra memory. This issue is fixed "properly" in 
-+    PCRE2 by refactoring the way references are handled. Wen Guanxing 
-+    from Venustech ADLAB discovered this bug. 
-+
-+37. Fix two assertion fails in JIT. These issues were found by Karl Skomski
-+    with a custom LLVM fuzzer.
-+    
-+38. Fixed a corner case of range optimization in JIT.
-+
-+39. An incorrect error "overran compiling workspace" was given if there were 
-+    exactly enough group forward references such that the last one extended
-+    into the workspace safety margin. The next one would have expanded the 
-+    workspace. The test for overflow was not including the safety margin.
-+    
-+40. A match limit issue is fixed in JIT which was found by Karl Skomski
-+    with a custom LLVM fuzzer.
-+
-+41. Remove the use of /dev/null in testdata/testinput2, because it doesn't
-+    work under Windows. (Why has it taken so long for anyone to notice?) 
-+
-+
- Version 8.37 28-April-2015
- --------------------------
- 
-Index: pcretest.c
-===================================================================
---- pcretest.c	(revision 1554)
-+++ pcretest.c	(working copy)
-@@ -4621,9 +4621,9 @@
- 
-       else switch ((c = *p++))
-         {
--        case 'a': c =    7; break;
-+        case 'a': c =  CHAR_BEL; break;
-         case 'b': c = '\b'; break;
--        case 'e': c =   27; break;
-+        case 'e': c =  CHAR_ESC; break;
-         case 'f': c = '\f'; break;
-         case 'n': c = '\n'; break;
-         case 'r': c = '\r'; break;
-Index: sljit/sljitLir.c
-===================================================================
---- sljit/sljitLir.c	(revision 1554)
-+++ sljit/sljitLir.c	(working copy)
-@@ -845,8 +845,8 @@
- 	}
- 
- static SLJIT_CONST char* op0_names[] = {
--	(char*)"breakpoint", (char*)"nop",
--	(char*)"lumul", (char*)"lsmul", (char*)"ludiv", (char*)"lsdiv",
-+	(char*)"breakpoint", (char*)"nop", (char*)"lumul", (char*)"lsmul",
-+	(char*)"udivmod", (char*)"sdivmod", (char*)"udivi", (char*)"sdivi"
- };
- 
- static SLJIT_CONST char* op1_names[] = {
-@@ -1036,7 +1036,7 @@
- {
- #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- 	CHECK_ARGUMENT((op >= SLJIT_BREAKPOINT && op <= SLJIT_LSMUL)
--		|| ((op & ~SLJIT_INT_OP) >= SLJIT_LUDIV && (op & ~SLJIT_INT_OP) <= SLJIT_LSDIV));
-+		|| ((op & ~SLJIT_INT_OP) >= SLJIT_UDIVMOD && (op & ~SLJIT_INT_OP) <= SLJIT_SDIVI));
- 	CHECK_ARGUMENT(op < SLJIT_LUMUL || compiler->scratches >= 2);
- #endif
- #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-@@ -1447,6 +1447,8 @@
- 
- static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
- {
-+	SLJIT_UNUSED_ARG(offset);
-+
- #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- 	FUNCTION_CHECK_DST(dst, dstw);
- #endif
-@@ -1462,6 +1464,8 @@
- 
- static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
- {
-+	SLJIT_UNUSED_ARG(init_value);
-+
- #if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- 	FUNCTION_CHECK_DST(dst, dstw);
- #endif
-Index: sljit/sljitNativeSPARC_common.c
-===================================================================
---- sljit/sljitNativeSPARC_common.c	(revision 1554)
-+++ sljit/sljitNativeSPARC_common.c	(working copy)
-@@ -777,20 +777,25 @@
- #else
- #error "Implementation required"
- #endif
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+		SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
- #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
--		if (op == SLJIT_LUDIV)
-+		if ((op | 0x2) == SLJIT_UDIVI)
- 			FAIL_IF(push_inst(compiler, WRY | S1(0), MOVABLE_INS));
- 		else {
- 			FAIL_IF(push_inst(compiler, SRA | D(TMP_REG1) | S1(SLJIT_R0) | IMM(31), DR(TMP_REG1)));
- 			FAIL_IF(push_inst(compiler, WRY | S1(TMP_REG1), MOVABLE_INS));
- 		}
--		FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
--		FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
-+		if (op <= SLJIT_SDIVMOD)
-+			FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
-+		FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
-+		if (op >= SLJIT_UDIVI)
-+			return SLJIT_SUCCESS;
- 		FAIL_IF(push_inst(compiler, SMUL | D(SLJIT_R1) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R1)));
--		FAIL_IF(push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1)));
--		return SLJIT_SUCCESS;
-+		return push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1));
- #else
- #error "Implementation required"
- #endif
-Index: sljit/sljitNativeMIPS_common.c
-===================================================================
---- sljit/sljitNativeMIPS_common.c	(revision 1554)
-+++ sljit/sljitNativeMIPS_common.c	(working copy)
-@@ -1053,8 +1053,11 @@
- #endif
- 		FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
- 		return push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+		SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
- #if !(defined SLJIT_MIPS_R1 && SLJIT_MIPS_R1)
- 		FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
- 		FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
-@@ -1062,15 +1065,15 @@
- 
- #if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
- 		if (int_op)
--			FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
-+			FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
- 		else
--			FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
-+			FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
- #else
--		FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
-+		FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
- #endif
- 
- 		FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
--		return push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
-+		return (op >= SLJIT_UDIVI) ? SLJIT_SUCCESS : push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
- 	}
- 
- 	return SLJIT_SUCCESS;
-Index: sljit/sljitNativeARM_32.c
-===================================================================
---- sljit/sljitNativeARM_32.c	(revision 1554)
-+++ sljit/sljitNativeARM_32.c	(working copy)
-@@ -1833,18 +1833,33 @@
- 			| (reg_map[SLJIT_R0] << 8)
- 			| reg_map[TMP_REG1]);
- #endif
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
--		if (compiler->scratches >= 3)
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+		SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
-+		SLJIT_COMPILE_ASSERT(reg_map[2] == 1 && reg_map[3] == 2, bad_register_mapping);
-+
-+		if ((op >= SLJIT_UDIVI) && (compiler->scratches >= 3)) {
- 			FAIL_IF(push_inst(compiler, 0xe52d2008 /* str r2, [sp, #-8]! */));
-+			FAIL_IF(push_inst(compiler, 0xe58d1004 /* str r1, [sp, #4] */));
-+		}
-+		else if ((op >= SLJIT_UDIVI) || (compiler->scratches >= 3))
-+			FAIL_IF(push_inst(compiler, 0xe52d0008 | (op >= SLJIT_UDIVI ? 0x1000 : 0x2000) /* str r1/r2, [sp, #-8]! */));
-+
- #if defined(__GNUC__)
- 		FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
--			(op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
-+			((op | 0x2) == SLJIT_UDIVI ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
- #else
- #error "Software divmod functions are needed"
- #endif
--		if (compiler->scratches >= 3)
--			return push_inst(compiler, 0xe49d2008 /* ldr r2, [sp], #8 */);
-+
-+		if ((op >= SLJIT_UDIVI) && (compiler->scratches >= 3)) {
-+			FAIL_IF(push_inst(compiler, 0xe59d1004 /* ldr r1, [sp, #4] */));
-+			FAIL_IF(push_inst(compiler, 0xe49d2008 /* ldr r2, [sp], #8 */));
-+		}
-+		else if ((op >= SLJIT_UDIVI) || (compiler->scratches >= 3))
-+			return push_inst(compiler, 0xe49d0008 | (op >= SLJIT_UDIVI ? 0x1000 : 0x2000) /* ldr r1/r2, [sp], #8 */);
- 		return SLJIT_SUCCESS;
- 	}
- 
-Index: sljit/sljitLir.h
-===================================================================
---- sljit/sljitLir.h	(revision 1554)
-+++ sljit/sljitLir.h	(working copy)
-@@ -687,7 +687,7 @@
- #define SLJIT_OP0_BASE			0
- 
- /* Flags: - (never set any flags)
--   Note: breakpoint instruction is not supported by all architectures (namely ppc)
-+   Note: breakpoint instruction is not supported by all architectures (e.g. ppc)
-          It falls back to SLJIT_NOP in those cases. */
- #define SLJIT_BREAKPOINT		(SLJIT_OP0_BASE + 0)
- /* Flags: - (never set any flags)
-@@ -696,24 +696,42 @@
- #define SLJIT_NOP			(SLJIT_OP0_BASE + 1)
- /* Flags: - (may destroy flags)
-    Unsigned multiplication of SLJIT_R0 and SLJIT_R1.
--   Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
-+   Result is placed into SLJIT_R1:SLJIT_R0 (high:low) word */
- #define SLJIT_LUMUL			(SLJIT_OP0_BASE + 2)
- /* Flags: - (may destroy flags)
-    Signed multiplication of SLJIT_R0 and SLJIT_R1.
--   Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
-+   Result is placed into SLJIT_R1:SLJIT_R0 (high:low) word */
- #define SLJIT_LSMUL			(SLJIT_OP0_BASE + 3)
- /* Flags: I - (may destroy flags)
-    Unsigned divide of the value in SLJIT_R0 by the value in SLJIT_R1.
--   The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
--   Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
--#define SLJIT_LUDIV			(SLJIT_OP0_BASE + 4)
--#define SLJIT_ILUDIV			(SLJIT_LUDIV | SLJIT_INT_OP)
-+   The result is placed into SLJIT_R0 and the remainder into SLJIT_R1.
-+   Note: if SLJIT_R1 is 0, the behaviour is undefined. */
-+#define SLJIT_UDIVMOD			(SLJIT_OP0_BASE + 4)
-+#define SLJIT_IUDIVMOD			(SLJIT_UDIVMOD | SLJIT_INT_OP)
- /* Flags: I - (may destroy flags)
-    Signed divide of the value in SLJIT_R0 by the value in SLJIT_R1.
--   The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
--   Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
--#define SLJIT_LSDIV			(SLJIT_OP0_BASE + 5)
--#define SLJIT_ILSDIV			(SLJIT_LSDIV | SLJIT_INT_OP)
-+   The result is placed into SLJIT_R0 and the remainder into SLJIT_R1.
-+   Note: if SLJIT_R1 is 0, the behaviour is undefined.
-+   Note: if SLJIT_R1 is -1 and SLJIT_R0 is integer min (0x800..00),
-+         the behaviour is undefined. */
-+#define SLJIT_SDIVMOD			(SLJIT_OP0_BASE + 5)
-+#define SLJIT_ISDIVMOD			(SLJIT_SDIVMOD | SLJIT_INT_OP)
-+/* Flags: I - (may destroy flags)
-+   Unsigned divide of the value in SLJIT_R0 by the value in SLJIT_R1.
-+   The result is placed into SLJIT_R0. SLJIT_R1 preserves its value.
-+   Note: if SLJIT_R1 is 0, the behaviour is undefined.
-+   Note: SLJIT_SDIV is single precision divide. */
-+#define SLJIT_UDIVI			(SLJIT_OP0_BASE + 6)
-+#define SLJIT_IUDIVI			(SLJIT_UDIVI | SLJIT_INT_OP)
-+/* Flags: I - (may destroy flags)
-+   Signed divide of the value in SLJIT_R0 by the value in SLJIT_R1.
-+   The result is placed into SLJIT_R0. SLJIT_R1 preserves its value.
-+   Note: if SLJIT_R1 is 0, the behaviour is undefined.
-+   Note: if SLJIT_R1 is -1 and SLJIT_R0 is integer min (0x800..00),
-+         the behaviour is undefined.
-+   Note: SLJIT_SDIV is single precision divide. */
-+#define SLJIT_SDIVI			(SLJIT_OP0_BASE + 7)
-+#define SLJIT_ISDIVI			(SLJIT_SDIVI | SLJIT_INT_OP)
- 
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op);
- 
-@@ -851,34 +869,6 @@
- 	sljit_si src1, sljit_sw src1w,
- 	sljit_si src2, sljit_sw src2w);
- 
--/* The following function is a helper function for sljit_emit_op_custom.
--   It returns with the real machine register index ( >=0 ) of any SLJIT_R,
--   SLJIT_S and SLJIT_SP registers.
--
--   Note: it returns with -1 for virtual registers (only on x86-32). */
--
--SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
--
--/* The following function is a helper function for sljit_emit_op_custom.
--   It returns with the real machine register index of any SLJIT_FLOAT register.
--
--   Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
--
--SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
--
--/* Any instruction can be inserted into the instruction stream by
--   sljit_emit_op_custom. It has a similar purpose as inline assembly.
--   The size parameter must match to the instruction size of the target
--   architecture:
--
--         x86: 0 < size <= 15. The instruction argument can be byte aligned.
--      Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
--              if size == 4, the instruction argument must be 4 byte aligned.
--   Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
--
--SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
--	void *instruction, sljit_si size);
--
- /* Returns with non-zero if fpu is available. */
- 
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void);
-@@ -1196,4 +1186,64 @@
- 
- #endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
- 
-+/* --------------------------------------------------------------------- */
-+/*  CPU specific functions                                               */
-+/* --------------------------------------------------------------------- */
-+
-+/* The following function is a helper function for sljit_emit_op_custom.
-+   It returns with the real machine register index ( >=0 ) of any SLJIT_R,
-+   SLJIT_S and SLJIT_SP registers.
-+
-+   Note: it returns with -1 for virtual registers (only on x86-32). */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
-+
-+/* The following function is a helper function for sljit_emit_op_custom.
-+   It returns with the real machine register index of any SLJIT_FLOAT register.
-+
-+   Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
-+
-+/* Any instruction can be inserted into the instruction stream by
-+   sljit_emit_op_custom. It has a similar purpose as inline assembly.
-+   The size parameter must match to the instruction size of the target
-+   architecture:
-+
-+         x86: 0 < size <= 15. The instruction argument can be byte aligned.
-+      Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
-+              if size == 4, the instruction argument must be 4 byte aligned.
-+   Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
-+	void *instruction, sljit_si size);
-+
-+#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-+
-+/* Returns with non-zero if sse2 is available. */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void);
-+
-+/* Returns with non-zero if cmov instruction is available. */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void);
-+
-+/* Emit a conditional mov instruction on x86 CPUs. This instruction
-+   moves src to destination, if the condition is satisfied. Unlike
-+   other arithmetic instructions, destination must be a register.
-+   Before such instructions are emitted, cmov support should be
-+   checked by sljit_x86_is_cmov_available function.
-+    type must be between SLJIT_EQUAL and SLJIT_S_ORDERED
-+    dst_reg must be a valid register and it can be combined
-+      with SLJIT_INT_OP to perform 32 bit arithmetic
-+   Flags: I - (never set any flags)
-+ */
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
-+	sljit_si type,
-+	sljit_si dst_reg,
-+	sljit_si src, sljit_sw srcw);
-+
-+#endif
-+
- #endif /* _SLJIT_LIR_H_ */
-Index: sljit/sljitNativeARM_64.c
-===================================================================
---- sljit/sljitNativeARM_64.c	(revision 1554)
-+++ sljit/sljitNativeARM_64.c	(working copy)
-@@ -1087,7 +1087,8 @@
- 			saved_regs_size += sizeof(sljit_sw);
- 		}
- 		local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
--		FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
-+		if (saved_regs_size > 0)
-+			FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
- 	}
- 
- 	tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
-@@ -1094,7 +1095,12 @@
- 	prev = -1;
- 	for (i = SLJIT_S0; i >= tmp; i--) {
- 		if (prev == -1) {
--			prev = i;
-+			if (!(offs & (1 << 15))) {
-+				prev = i;
-+				continue;
-+			}
-+			FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
-+			offs += 1 << 15;
- 			continue;
- 		}
- 		FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
-@@ -1104,7 +1110,12 @@
- 
- 	for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
- 		if (prev == -1) {
--			prev = i;
-+			if (!(offs & (1 << 15))) {
-+				prev = i;
-+				continue;
-+			}
-+			FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
-+			offs += 1 << 15;
- 			continue;
- 		}
- 		FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
-@@ -1112,8 +1123,7 @@
- 		prev = -1;
- 	}
- 
--	if (prev != -1)
--		FAIL_IF(push_inst(compiler, STRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
-+	SLJIT_ASSERT(prev == -1);
- 
- 	if (compiler->local_size > (63 * sizeof(sljit_sw))) {
- 		/* The local_size is already adjusted by the saved registers. */
-@@ -1188,7 +1198,12 @@
- 	prev = -1;
- 	for (i = SLJIT_S0; i >= tmp; i--) {
- 		if (prev == -1) {
--			prev = i;
-+			if (!(offs & (1 << 15))) {
-+				prev = i;
-+				continue;
-+			}
-+			FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
-+			offs += 1 << 15;
- 			continue;
- 		}
- 		FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
-@@ -1198,7 +1213,12 @@
- 
- 	for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
- 		if (prev == -1) {
--			prev = i;
-+			if (!(offs & (1 << 15))) {
-+				prev = i;
-+				continue;
-+			}
-+			FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5)));
-+			offs += 1 << 15;
- 			continue;
- 		}
- 		FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs));
-@@ -1206,13 +1226,12 @@
- 		prev = -1;
- 	}
- 
--	if (prev != -1)
--		FAIL_IF(push_inst(compiler, LDRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
-+	SLJIT_ASSERT(prev == -1);
- 
- 	if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
- 		FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
- 			| RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
--	} else {
-+	} else if (saved_regs_size > 0) {
- 		FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
- 	}
- 
-@@ -1242,12 +1261,15 @@
- 		FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
- 		FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
- 		return push_inst(compiler, (op == SLJIT_LUMUL ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
- 		FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
--		FAIL_IF(push_inst(compiler, ((op == SLJIT_LUDIV ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
-+		FAIL_IF(push_inst(compiler, ((op == SLJIT_UDIVMOD ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
- 		FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
- 		return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+		return push_inst(compiler, ((op == SLJIT_UDIVI ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1));
- 	}
- 
- 	return SLJIT_SUCCESS;
-Index: sljit/sljitNativeARM_T2_32.c
-===================================================================
---- sljit/sljitNativeARM_T2_32.c	(revision 1554)
-+++ sljit/sljitNativeARM_T2_32.c	(working copy)
-@@ -1239,6 +1239,9 @@
- 
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
- {
-+	sljit_sw saved_reg_list[3];
-+	sljit_sw saved_reg_count;
-+
- 	CHECK_ERROR();
- 	CHECK(check_sljit_emit_op0(compiler, op));
- 
-@@ -1255,24 +1258,53 @@
- 			| (reg_map[SLJIT_R0] << 12)
- 			| (reg_map[SLJIT_R0] << 16)
- 			| reg_map[SLJIT_R1]);
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
--		if (compiler->scratches >= 4) {
--			FAIL_IF(push_inst32(compiler, 0xf84d2d04 /* str r2, [sp, #-4]! */));
--			FAIL_IF(push_inst32(compiler, 0xf84dcd04 /* str ip, [sp, #-4]! */));
--		} else if (compiler->scratches >= 3)
--			FAIL_IF(push_inst32(compiler, 0xf84d2d08 /* str r2, [sp, #-8]! */));
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+		SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
-+		SLJIT_COMPILE_ASSERT(reg_map[2] == 1 && reg_map[3] == 2 && reg_map[4] == 12, bad_register_mapping);
-+
-+		saved_reg_count = 0;
-+		if (compiler->scratches >= 4)
-+			saved_reg_list[saved_reg_count++] = 12;
-+		if (compiler->scratches >= 3)
-+			saved_reg_list[saved_reg_count++] = 2;
-+		if (op >= SLJIT_UDIVI)
-+			saved_reg_list[saved_reg_count++] = 1;
-+
-+		if (saved_reg_count > 0) {
-+			FAIL_IF(push_inst32(compiler, 0xf84d0d00 | (saved_reg_count >= 3 ? 16 : 8)
-+						| (saved_reg_list[0] << 12) /* str rX, [sp, #-8/-16]! */));
-+			if (saved_reg_count >= 2) {
-+				SLJIT_ASSERT(saved_reg_list[1] < 8);
-+				FAIL_IF(push_inst16(compiler, 0x9001 | (saved_reg_list[1] << 8) /* str rX, [sp, #4] */));
-+			}
-+			if (saved_reg_count >= 3) {
-+				SLJIT_ASSERT(saved_reg_list[2] < 8);
-+				FAIL_IF(push_inst16(compiler, 0x9002 | (saved_reg_list[2] << 8) /* str rX, [sp, #8] */));
-+			}
-+		}
-+
- #if defined(__GNUC__)
- 		FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
--			(op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
-+			((op | 0x2) == SLJIT_UDIVI ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
- #else
- #error "Software divmod functions are needed"
- #endif
--		if (compiler->scratches >= 4) {
--			FAIL_IF(push_inst32(compiler, 0xf85dcb04 /* ldr ip, [sp], #4 */));
--			return push_inst32(compiler, 0xf85d2b04 /* ldr r2, [sp], #4 */);
--		} else if (compiler->scratches >= 3)
--			return push_inst32(compiler, 0xf85d2b08 /* ldr r2, [sp], #8 */);
-+
-+		if (saved_reg_count > 0) {
-+			if (saved_reg_count >= 3) {
-+				SLJIT_ASSERT(saved_reg_list[2] < 8);
-+				FAIL_IF(push_inst16(compiler, 0x9802 | (saved_reg_list[2] << 8) /* ldr rX, [sp, #8] */));
-+			}
-+			if (saved_reg_count >= 2) {
-+				SLJIT_ASSERT(saved_reg_list[1] < 8);
-+				FAIL_IF(push_inst16(compiler, 0x9801 | (saved_reg_list[1] << 8) /* ldr rX, [sp, #4] */));
-+			}
-+			return push_inst32(compiler, 0xf85d0b00 | (saved_reg_count >= 3 ? 16 : 8)
-+						| (saved_reg_list[0] << 12) /* ldr rX, [sp], #8/16 */);
-+		}
- 		return SLJIT_SUCCESS;
- 	}
- 
-Index: sljit/sljitNativePPC_common.c
-===================================================================
---- sljit/sljitNativePPC_common.c	(revision 1554)
-+++ sljit/sljitNativePPC_common.c	(working copy)
-@@ -1267,22 +1267,23 @@
- 		FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
- 		return push_inst(compiler, (op == SLJIT_LUMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
- #endif
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
- 		FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
- #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
--		if (int_op) {
--			FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
--			FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
--		} else {
--			FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVDU : DIVD) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
--			FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
--		}
--		return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
-+		FAIL_IF(push_inst(compiler, (int_op ? (op == SLJIT_UDIVMOD ? DIVWU : DIVW) : (op == SLJIT_UDIVMOD ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
-+		FAIL_IF(push_inst(compiler, (int_op ? MULLW : MULLD) | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
- #else
--		FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
-+		FAIL_IF(push_inst(compiler, (op == SLJIT_UDIVMOD ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
- 		FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
-+#endif
- 		return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
-+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-+		return push_inst(compiler, (int_op ? (op == SLJIT_UDIVI ? DIVWU : DIVW) : (op == SLJIT_UDIVI ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
-+#else
-+		return push_inst(compiler, (op == SLJIT_UDIVI ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
- #endif
- 	}
- 
-Index: sljit/sljitNativeX86_common.c
-===================================================================
---- sljit/sljitNativeX86_common.c	(revision 1554)
-+++ sljit/sljitNativeX86_common.c	(working copy)
-@@ -273,7 +273,9 @@
- #endif
- static sljit_si cpu_has_cmov = -1;
- 
--#if defined(_MSC_VER) && _MSC_VER >= 1400
-+#ifdef _WIN32_WCE
-+#include <cmnintrin.h>
-+#elif defined(_MSC_VER) && _MSC_VER >= 1400
- #include <intrin.h>
- #endif
- 
-@@ -742,8 +744,10 @@
- 		break;
- 	case SLJIT_LUMUL:
- 	case SLJIT_LSMUL:
--	case SLJIT_LUDIV:
--	case SLJIT_LSDIV:
-+	case SLJIT_UDIVMOD:
-+	case SLJIT_SDIVMOD:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
- 		compiler->flags_saved = 0;
- #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- #ifdef _WIN64
-@@ -761,9 +765,10 @@
- #endif
- 		compiler->mode32 = op & SLJIT_INT_OP;
- #endif
-+		SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
- 
- 		op = GET_OPCODE(op);
--		if (op == SLJIT_LUDIV) {
-+		if ((op | 0x2) == SLJIT_UDIVI) {
- #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
- 			EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
- 			inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0);
-@@ -774,7 +779,7 @@
- 			*inst = XOR_r_rm;
- 		}
- 
--		if (op == SLJIT_LSDIV) {
-+		if ((op | 0x2) == SLJIT_SDIVI) {
- #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
- 			EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
- #endif
-@@ -805,10 +810,10 @@
- 		FAIL_IF(!inst);
- 		INC_SIZE(2);
- 		*inst++ = GROUP_F7;
--		*inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
-+		*inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
- #else
- #ifdef _WIN64
--		size = (!compiler->mode32 || op >= SLJIT_LUDIV) ? 3 : 2;
-+		size = (!compiler->mode32 || op >= SLJIT_UDIVMOD) ? 3 : 2;
- #else
- 		size = (!compiler->mode32) ? 3 : 2;
- #endif
-@@ -817,11 +822,11 @@
- 		INC_SIZE(size);
- #ifdef _WIN64
- 		if (!compiler->mode32)
--			*inst++ = REX_W | ((op >= SLJIT_LUDIV) ? REX_B : 0);
--		else if (op >= SLJIT_LUDIV)
-+			*inst++ = REX_W | ((op >= SLJIT_UDIVMOD) ? REX_B : 0);
-+		else if (op >= SLJIT_UDIVMOD)
- 			*inst++ = REX_B;
- 		*inst++ = GROUP_F7;
--		*inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
-+		*inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
- #else
- 		if (!compiler->mode32)
- 			*inst++ = REX_W;
-@@ -836,15 +841,21 @@
- 		case SLJIT_LSMUL:
- 			*inst |= IMUL;
- 			break;
--		case SLJIT_LUDIV:
-+		case SLJIT_UDIVMOD:
-+		case SLJIT_UDIVI:
- 			*inst |= DIV;
- 			break;
--		case SLJIT_LSDIV:
-+		case SLJIT_SDIVMOD:
-+		case SLJIT_SDIVI:
- 			*inst |= IDIV;
- 			break;
- 		}
- #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !defined(_WIN64)
--		EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
-+		if (op <= SLJIT_SDIVMOD)
-+			EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
-+#else
-+		if (op >= SLJIT_UDIVI)
-+			EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
- #endif
- 		break;
- 	}
-@@ -1905,60 +1916,62 @@
- 		return SLJIT_SUCCESS;
- 	}
- 
--	if (FAST_IS_REG(src1)) {
-+	if (!(src1 & SLJIT_IMM)) {
- 		if (src2 & SLJIT_IMM) {
- #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- 			if (IS_HALFWORD(src2w) || compiler->mode32) {
--				inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
-+				inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
- 				FAIL_IF(!inst);
- 				*inst = GROUP_F7;
- 			}
- 			else {
- 				FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
--				inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, 0);
-+				inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
- 				FAIL_IF(!inst);
- 				*inst = TEST_rm_r;
- 			}
- #else
--			inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, 0);
-+			inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
- 			FAIL_IF(!inst);
- 			*inst = GROUP_F7;
- #endif
-+			return SLJIT_SUCCESS;
- 		}
--		else {
-+		else if (FAST_IS_REG(src1)) {
- 			inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
- 			FAIL_IF(!inst);
- 			*inst = TEST_rm_r;
-+			return SLJIT_SUCCESS;
- 		}
--		return SLJIT_SUCCESS;
- 	}
- 
--	if (FAST_IS_REG(src2)) {
-+	if (!(src2 & SLJIT_IMM)) {
- 		if (src1 & SLJIT_IMM) {
- #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- 			if (IS_HALFWORD(src1w) || compiler->mode32) {
--				inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, 0);
-+				inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
- 				FAIL_IF(!inst);
- 				*inst = GROUP_F7;
- 			}
- 			else {
- 				FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
--				inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, 0);
-+				inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
- 				FAIL_IF(!inst);
- 				*inst = TEST_rm_r;
- 			}
- #else
--			inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, 0);
-+			inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
- 			FAIL_IF(!inst);
- 			*inst = GROUP_F7;
- #endif
-+			return SLJIT_SUCCESS;
- 		}
--		else {
-+		else if (FAST_IS_REG(src2)) {
- 			inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
- 			FAIL_IF(!inst);
- 			*inst = TEST_rm_r;
-+			return SLJIT_SUCCESS;
- 		}
--		return SLJIT_SUCCESS;
- 	}
- 
- 	EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
-@@ -2923,3 +2936,69 @@
- {
- 	*(sljit_sw*)addr = new_constant;
- }
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void)
-+{
-+#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
-+	if (cpu_has_sse2 == -1)
-+		get_cpu_features();
-+	return cpu_has_sse2;
-+#else
-+	return 1;
-+#endif
-+}
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void)
-+{
-+	if (cpu_has_cmov == -1)
-+		get_cpu_features();
-+	return cpu_has_cmov;
-+}
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
-+	sljit_si type,
-+	sljit_si dst_reg,
-+	sljit_si src, sljit_sw srcw)
-+{
-+	sljit_ub* inst;
-+
-+	CHECK_ERROR();
-+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
-+	CHECK_ARGUMENT(sljit_x86_is_cmov_available());
-+	CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_INT_OP)));
-+	CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
-+	CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(dst_reg & ~SLJIT_INT_OP));
-+	FUNCTION_CHECK_SRC(src, srcw);
-+#endif
-+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-+	if (SLJIT_UNLIKELY(!!compiler->verbose)) {
-+		fprintf(compiler->verbose, "  x86_cmov%s %s%s, ",
-+			!(dst_reg & SLJIT_INT_OP) ? "" : ".i",
-+			JUMP_PREFIX(type), jump_names[type & 0xff]);
-+		sljit_verbose_reg(compiler, dst_reg & ~SLJIT_INT_OP);
-+		fprintf(compiler->verbose, ", ");
-+		sljit_verbose_param(compiler, src, srcw);
-+		fprintf(compiler->verbose, "\n");
-+	}
-+#endif
-+
-+	ADJUST_LOCAL_OFFSET(src, srcw);
-+	CHECK_EXTRA_REGS(src, srcw, (void)0);
-+
-+#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-+	compiler->mode32 = dst_reg & SLJIT_INT_OP;
-+#endif
-+	dst_reg &= ~SLJIT_INT_OP;
-+
-+	if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
-+		EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
-+		src = TMP_REG1;
-+		srcw = 0;
-+	}
-+
-+	inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);
-+	FAIL_IF(!inst);
-+	*inst++ = GROUP_0F;
-+	*inst = get_jump_code(type & 0xff) - 0x40;
-+	return SLJIT_SUCCESS;
-+}
-Index: sljit/sljitConfigInternal.h
-===================================================================
---- sljit/sljitConfigInternal.h	(revision 1554)
-+++ sljit/sljitConfigInternal.h	(working copy)
-@@ -468,8 +468,13 @@
- 
- #ifndef SLJIT_CALL
- 
--#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-+#if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION)
- 
-+/* Force cdecl. */
-+#define SLJIT_CALL
-+
-+#elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-+
- #if defined(__GNUC__) && !defined(__APPLE__)
- 
- #define SLJIT_CALL __attribute__ ((fastcall))
-@@ -608,6 +613,12 @@
- #define SLJIT_LOCALS_OFFSET_BASE ((23 + 1) * sizeof(sljit_sw))
- #endif
- 
-+#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
-+
-+#define SLJIT_NUMBER_OF_REGISTERS 10
-+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 5
-+#define SLJIT_LOCALS_OFFSET_BASE 0
-+
- #elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
- 
- #define SLJIT_NUMBER_OF_REGISTERS 0
-Index: sljit/sljitConfig.h
-===================================================================
---- sljit/sljitConfig.h	(revision 1554)
-+++ sljit/sljitConfig.h	(working copy)
-@@ -96,6 +96,15 @@
- #define SLJIT_EXECUTABLE_ALLOCATOR 1
- #endif
- 
-+/* Force cdecl calling convention even if a better calling
-+   convention (e.g. fastcall) is supported by the C compiler.
-+   If this option is enabled, C functions without
-+   SLJIT_CALL can also be called from JIT code. */
-+#ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
-+/* Disabled by default */
-+#define SLJIT_USE_CDECL_CALLING_CONVENTION 0
-+#endif
-+
- /* Return with error when an invalid argument is passed. */
- #ifndef SLJIT_ARGUMENT_CHECKS
- /* Disabled by default */
-Index: sljit/sljitNativeTILEGX_64.c
-===================================================================
---- sljit/sljitNativeTILEGX_64.c	(revision 1554)
-+++ sljit/sljitNativeTILEGX_64.c	(working copy)
-@@ -35,21 +35,21 @@
- #define SIMM_16BIT_MIN (-0x8000)
- #define SIMM_17BIT_MAX (0xffff)
- #define SIMM_17BIT_MIN (-0x10000)
--#define SIMM_32BIT_MIN (-0x80000000)
- #define SIMM_32BIT_MAX (0x7fffffff)
--#define SIMM_48BIT_MIN (0x800000000000L)
-+#define SIMM_32BIT_MIN (-0x7fffffff - 1)
- #define SIMM_48BIT_MAX (0x7fffffff0000L)
-+#define SIMM_48BIT_MIN (-0x800000000000L)
- #define IMM16(imm) ((imm) & 0xffff)
- 
- #define UIMM_16BIT_MAX (0xffff)
- 
--#define TMP_REG1 (SLJIT_NO_REGISTERS + 1)
--#define TMP_REG2 (SLJIT_NO_REGISTERS + 2)
--#define TMP_REG3 (SLJIT_NO_REGISTERS + 3)
--#define ADDR_TMP (SLJIT_NO_REGISTERS + 4)
-+#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
-+#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
-+#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
-+#define ADDR_TMP (SLJIT_NUMBER_OF_REGISTERS + 5)
- #define PIC_ADDR_REG TMP_REG2
- 
--static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 5] = {
-+static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 6] = {
- 	63, 0, 1, 2, 3, 4, 30, 31, 32, 33, 34, 54, 5, 16, 6, 7
- };
- 
-@@ -58,11 +58,6 @@
- #define TMP_REG2_mapped 16
- #define TMP_REG3_mapped 6
- #define ADDR_TMP_mapped 7
--#define SLJIT_SAVED_REG1_mapped 30
--#define SLJIT_SAVED_REG2_mapped 31
--#define SLJIT_SAVED_REG3_mapped 32
--#define SLJIT_SAVED_EREG1_mapped 33
--#define SLJIT_SAVED_EREG2_mapped 34
- 
- /* Flags are keept in volatile registers. */
- #define EQUAL_FLAG 8
-@@ -399,6 +394,9 @@
- #define SUB(dst, srca, srcb) \
- 	push_3_buffer(compiler, TILEGX_OPC_SUB, dst, srca, srcb, __LINE__)
- 
-+#define MUL(dst, srca, srcb) \
-+	push_3_buffer(compiler, TILEGX_OPC_MULX, dst, srca, srcb, __LINE__)
-+
- #define NOR(dst, srca, srcb) \
- 	push_3_buffer(compiler, TILEGX_OPC_NOR, dst, srca, srcb, __LINE__)
- 
-@@ -547,8 +545,8 @@
- 
- 	const struct Format* match = NULL;
- 	const struct Format *b = NULL;
--	unsigned int i = 0;
--	for (i; i < sizeof formats / sizeof formats[0]; i++) {
-+	unsigned int i;
-+	for (i = 0; i < sizeof formats / sizeof formats[0]; i++) {
- 		b = &formats[i];
- 		if ((b->pipe_mask & compatible_pipes) == b->pipe_mask) {
- 			match = b;
-@@ -625,7 +623,6 @@
- 
- static sljit_si update_buffer(struct sljit_compiler *compiler)
- {
--	int count;
- 	int i;
- 	int orig_index = inst_buf_index;
- 	struct jit_instr inst0 = inst_buf[0];
-@@ -738,8 +735,10 @@
- 
- static sljit_si flush_buffer(struct sljit_compiler *compiler)
- {
--	while (inst_buf_index != 0)
--		update_buffer(compiler);
-+	while (inst_buf_index != 0) {
-+		FAIL_IF(update_buffer(compiler));
-+	}
-+	return SLJIT_SUCCESS;
- }
- 
- static sljit_si push_4_buffer(struct sljit_compiler *compiler, tilegx_mnemonic opc, int op0, int op1, int op2, int op3, int line)
-@@ -787,6 +786,7 @@
- 	case TILEGX_OPC_ADD:
- 	case TILEGX_OPC_AND:
- 	case TILEGX_OPC_SUB:
-+	case TILEGX_OPC_MULX:
- 	case TILEGX_OPC_OR:
- 	case TILEGX_OPC_XOR:
- 	case TILEGX_OPC_NOR:
-@@ -905,7 +905,6 @@
- 	sljit_sw diff;
- 	sljit_uw target_addr;
- 	sljit_ins *inst;
--	sljit_ins saved_inst;
- 
- 	if (jump->flags & SLJIT_REWRITABLE_JUMP)
- 		return code_ptr;
-@@ -1009,7 +1008,7 @@
- 	struct sljit_const *const_;
- 
- 	CHECK_ERROR_PTR();
--	check_sljit_generate_code(compiler);
-+	CHECK_PTR(check_sljit_generate_code(compiler));
- 	reverse_buf(compiler);
- 
- 	code = (sljit_ins *)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
-@@ -1178,13 +1177,13 @@
- 	sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
- {
- 	sljit_ins base;
--	sljit_ins bundle = 0;
--
-+	sljit_si i, tmp;
-+ 
- 	CHECK_ERROR();
--	check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-+	CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- 	set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- 
--	local_size += (saveds + 1) * sizeof(sljit_sw);
-+	local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
- 	local_size = (local_size + 7) & ~7;
- 	compiler->local_size = local_size;
- 
-@@ -1200,46 +1199,41 @@
- 		local_size = 0;
- 	}
- 
-+	/* Save the return address. */
- 	FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 8));
- 	FAIL_IF(ST_ADD(ADDR_TMP_mapped, RA, -8));
- 
--	if (saveds >= 1)
--		FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG1_mapped, -8));
-+	/* Save the S registers. */
-+	tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
-+	for (i = SLJIT_S0; i >= tmp; i--) {
-+		FAIL_IF(ST_ADD(ADDR_TMP_mapped, reg_map[i], -8));
-+	}
- 
--	if (saveds >= 2)
--		FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG2_mapped, -8));
-+	/* Save the R registers that need to be reserved. */
-+	for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
-+		FAIL_IF(ST_ADD(ADDR_TMP_mapped, reg_map[i], -8));
-+	}
- 
--	if (saveds >= 3)
--		FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_REG3_mapped, -8));
-+	/* Move the arguments to S registers. */
-+	for (i = 0; i < args; i++) {
-+		FAIL_IF(ADD(reg_map[SLJIT_S0 - i], i, ZERO));
-+	}
- 
--	if (saveds >= 4)
--		FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_EREG1_mapped, -8));
--
--	if (saveds >= 5)
--		FAIL_IF(ST_ADD(ADDR_TMP_mapped, SLJIT_SAVED_EREG2_mapped, -8));
--
--	if (args >= 1)
--		FAIL_IF(ADD(SLJIT_SAVED_REG1_mapped, 0, ZERO));
--
--	if (args >= 2)
--		FAIL_IF(ADD(SLJIT_SAVED_REG2_mapped, 1, ZERO));
--
--	if (args >= 3)
--		FAIL_IF(ADD(SLJIT_SAVED_REG3_mapped, 2, ZERO));
--
- 	return SLJIT_SUCCESS;
- }
- 
--SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- 	sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- 	sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
- {
--	CHECK_ERROR_VOID();
--	check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-+	CHECK_ERROR();
-+	CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- 	set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- 
--	local_size += (saveds + 1) * sizeof(sljit_sw);
-+	local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
- 	compiler->local_size = (local_size + 7) & ~7;
-+
-+	return SLJIT_SUCCESS;
- }
- 
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-@@ -1246,10 +1240,11 @@
- {
- 	sljit_si local_size;
- 	sljit_ins base;
--	int addr_initialized = 0;
-+	sljit_si i, tmp;
-+	sljit_si saveds;
- 
- 	CHECK_ERROR();
--	check_sljit_emit_return(compiler, op, src, srcw);
-+	CHECK(check_sljit_emit_return(compiler, op, src, srcw));
- 
- 	FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
- 
-@@ -1263,52 +1258,22 @@
- 		local_size = 0;
- 	}
- 
-+	/* Restore the return address. */
- 	FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 8));
--	FAIL_IF(LD(RA, ADDR_TMP_mapped));
-+	FAIL_IF(LD_ADD(RA, ADDR_TMP_mapped, -8));
- 
--	if (compiler->saveds >= 5) {
--		FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 48));
--		addr_initialized = 1;
--
--		FAIL_IF(LD_ADD(SLJIT_SAVED_EREG2_mapped, ADDR_TMP_mapped, 8));
-+	/* Restore the S registers. */
-+	saveds = compiler->saveds;
-+	tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
-+	for (i = SLJIT_S0; i >= tmp; i--) {
-+		FAIL_IF(LD_ADD(reg_map[i], ADDR_TMP_mapped, -8));
- 	}
- 
--	if (compiler->saveds >= 4) {
--		if (addr_initialized == 0) {
--			FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 40));
--			addr_initialized = 1;
--		}
--
--		FAIL_IF(LD_ADD(SLJIT_SAVED_EREG1_mapped, ADDR_TMP_mapped, 8));
-+	/* Restore the R registers that need to be reserved. */
-+	for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
-+		FAIL_IF(LD_ADD(reg_map[i], ADDR_TMP_mapped, -8));
- 	}
- 
--	if (compiler->saveds >= 3) {
--		if (addr_initialized == 0) {
--			FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 32));
--			addr_initialized = 1;
--		}
--
--		FAIL_IF(LD_ADD(SLJIT_SAVED_REG3_mapped, ADDR_TMP_mapped, 8));
--	}
--
--	if (compiler->saveds >= 2) {
--		if (addr_initialized == 0) {
--			FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 24));
--			addr_initialized = 1;
--		}
--
--		FAIL_IF(LD_ADD(SLJIT_SAVED_REG2_mapped, ADDR_TMP_mapped, 8));
--	}
--
--	if (compiler->saveds >= 1) {
--		if (addr_initialized == 0) {
--			FAIL_IF(ADDLI(ADDR_TMP_mapped, base, local_size - 16));
--			/* addr_initialized = 1; no need to initialize as it's the last one. */
--		}
--
--		FAIL_IF(LD_ADD(SLJIT_SAVED_REG1_mapped, ADDR_TMP_mapped, 8));
--	}
--
- 	if (compiler->local_size <= SIMM_16BIT_MAX)
- 		FAIL_IF(ADDLI(SLJIT_LOCALS_REG_mapped, SLJIT_LOCALS_REG_mapped, compiler->local_size));
- 	else
-@@ -1585,7 +1550,7 @@
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
- {
- 	CHECK_ERROR();
--	check_sljit_emit_fast_enter(compiler, dst, dstw);
-+	CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
- 	ADJUST_LOCAL_OFFSET(dst, dstw);
- 
- 	/* For UNUSED dst. Uncommon, but possible. */
-@@ -1602,7 +1567,7 @@
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
- {
- 	CHECK_ERROR();
--	check_sljit_emit_fast_return(compiler, src, srcw);
-+	CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
- 	ADJUST_LOCAL_OFFSET(src, srcw);
- 
- 	if (FAST_IS_REG(src))
-@@ -1636,9 +1601,11 @@
- 			if (op == SLJIT_MOV_SI)
- 				return BFEXTS(reg_map[dst], reg_map[src2], 0, 31);
- 
--		return BFEXTU(reg_map[dst], reg_map[src2], 0, 31);
--		} else if (dst != src2)
--			SLJIT_ASSERT_STOP();
-+			return BFEXTU(reg_map[dst], reg_map[src2], 0, 31);
-+		} else if (dst != src2) {
-+			SLJIT_ASSERT(src2 == 0);
-+			return ADD(reg_map[dst], reg_map[src2], ZERO);
-+		}
- 
- 		return SLJIT_SUCCESS;
- 
-@@ -1650,8 +1617,10 @@
- 				return BFEXTS(reg_map[dst], reg_map[src2], 0, 7);
- 
- 			return BFEXTU(reg_map[dst], reg_map[src2], 0, 7);
--		} else if (dst != src2)
--			SLJIT_ASSERT_STOP();
-+		} else if (dst != src2) {
-+			SLJIT_ASSERT(src2 == 0);
-+			return ADD(reg_map[dst], reg_map[src2], ZERO);
-+		}
- 
- 		return SLJIT_SUCCESS;
- 
-@@ -1663,8 +1632,10 @@
- 				return BFEXTS(reg_map[dst], reg_map[src2], 0, 15);
- 
- 			return BFEXTU(reg_map[dst], reg_map[src2], 0, 15);
--		} else if (dst != src2)
--			SLJIT_ASSERT_STOP();
-+		} else if (dst != src2) {
-+			SLJIT_ASSERT(src2 == 0);
-+			return ADD(reg_map[dst], reg_map[src2], ZERO);
-+		}
- 
- 		return SLJIT_SUCCESS;
- 
-@@ -1811,7 +1782,6 @@
- 				else {
- 					/* Rare ocasion. */
- 					FAIL_IF(ADD(TMP_EREG2, reg_map[src1], ZERO));
--	
- 					overflow_ra = TMP_EREG2;
- 				}
- 			}
-@@ -1903,6 +1873,17 @@
- 
- 		return SLJIT_SUCCESS;
- 
-+	case SLJIT_MUL:
-+		if (flags & SRC2_IMM) {
-+			FAIL_IF(load_immediate(compiler, TMP_REG2_mapped, src2));
-+			src2 = TMP_REG2;
-+			flags &= ~SRC2_IMM;
-+		}
-+
-+		FAIL_IF(MUL(reg_map[dst], reg_map[src1], reg_map[src2]));
-+
-+		return SLJIT_SUCCESS;
-+
- #define EMIT_LOGICAL(op_imm, op_norm) \
- 	if (flags & SRC2_IMM) { \
- 		FAIL_IF(load_immediate(compiler, ADDR_TMP_mapped, src2)); \
-@@ -1950,8 +1931,8 @@
- 	} else { \
- 		if (op & SLJIT_SET_E) \
- 			FAIL_IF(push_3_buffer( \
--				compiler, op_imm, reg_map[dst], reg_map[src1], \
--				src2 & 0x3F, __LINE__)); \
-+				compiler, op_norm, EQUAL_FLAG, reg_map[src1], \
-+				reg_map[src2], __LINE__)); \
- 		if (CHECK_FLAGS(SLJIT_SET_E)) \
- 			FAIL_IF(push_3_buffer( \
- 				compiler, op_norm, reg_map[dst], reg_map[src1], \
-@@ -2105,9 +2086,10 @@
- {
- 	sljit_si sugg_dst_ar, dst_ar;
- 	sljit_si flags = GET_ALL_FLAGS(op);
-+	sljit_si mem_type = (op & SLJIT_INT_OP) ? (INT_DATA | SIGNED_DATA) : WORD_DATA;
- 
- 	CHECK_ERROR();
--	check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
-+	CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
- 	ADJUST_LOCAL_OFFSET(dst, dstw);
- 
- 	if (dst == SLJIT_UNUSED)
-@@ -2114,6 +2096,8 @@
- 		return SLJIT_SUCCESS;
- 
- 	op = GET_OPCODE(op);
-+	if (op == SLJIT_MOV_SI || op == SLJIT_MOV_UI)
-+		mem_type = INT_DATA | SIGNED_DATA;
- 	sugg_dst_ar = reg_map[(op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2];
- 
- 	compiler->cache_arg = 0;
-@@ -2120,51 +2104,43 @@
- 	compiler->cache_argw = 0;
- 	if (op >= SLJIT_ADD && (src & SLJIT_MEM)) {
- 		ADJUST_LOCAL_OFFSET(src, srcw);
--		FAIL_IF(emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, TMP_REG1_mapped, src, srcw, dst, dstw));
-+		FAIL_IF(emit_op_mem2(compiler, mem_type | LOAD_DATA, TMP_REG1_mapped, src, srcw, dst, dstw));
- 		src = TMP_REG1;
- 		srcw = 0;
- 	}
- 
--	switch (type) {
--	case SLJIT_C_EQUAL:
--	case SLJIT_C_NOT_EQUAL:
-+	switch (type & 0xff) {
-+	case SLJIT_EQUAL:
-+	case SLJIT_NOT_EQUAL:
- 		FAIL_IF(CMPLTUI(sugg_dst_ar, EQUAL_FLAG, 1));
- 		dst_ar = sugg_dst_ar;
- 		break;
--	case SLJIT_C_LESS:
--	case SLJIT_C_GREATER_EQUAL:
--	case SLJIT_C_FLOAT_LESS:
--	case SLJIT_C_FLOAT_GREATER_EQUAL:
-+	case SLJIT_LESS:
-+	case SLJIT_GREATER_EQUAL:
- 		dst_ar = ULESS_FLAG;
- 		break;
--	case SLJIT_C_GREATER:
--	case SLJIT_C_LESS_EQUAL:
--	case SLJIT_C_FLOAT_GREATER:
--	case SLJIT_C_FLOAT_LESS_EQUAL:
-+	case SLJIT_GREATER:
-+	case SLJIT_LESS_EQUAL:
- 		dst_ar = UGREATER_FLAG;
- 		break;
--	case SLJIT_C_SIG_LESS:
--	case SLJIT_C_SIG_GREATER_EQUAL:
-+	case SLJIT_SIG_LESS:
-+	case SLJIT_SIG_GREATER_EQUAL:
- 		dst_ar = LESS_FLAG;
- 		break;
--	case SLJIT_C_SIG_GREATER:
--	case SLJIT_C_SIG_LESS_EQUAL:
-+	case SLJIT_SIG_GREATER:
-+	case SLJIT_SIG_LESS_EQUAL:
- 		dst_ar = GREATER_FLAG;
- 		break;
--	case SLJIT_C_OVERFLOW:
--	case SLJIT_C_NOT_OVERFLOW:
-+	case SLJIT_OVERFLOW:
-+	case SLJIT_NOT_OVERFLOW:
- 		dst_ar = OVERFLOW_FLAG;
- 		break;
--	case SLJIT_C_MUL_OVERFLOW:
--	case SLJIT_C_MUL_NOT_OVERFLOW:
-+	case SLJIT_MUL_OVERFLOW:
-+	case SLJIT_MUL_NOT_OVERFLOW:
- 		FAIL_IF(CMPLTUI(sugg_dst_ar, OVERFLOW_FLAG, 1));
- 		dst_ar = sugg_dst_ar;
- 		type ^= 0x1; /* Flip type bit for the XORI below. */
- 		break;
--	case SLJIT_C_FLOAT_EQUAL:
--	case SLJIT_C_FLOAT_NOT_EQUAL:
--		dst_ar = EQUAL_FLAG;
--		break;
- 
- 	default:
- 		SLJIT_ASSERT_STOP();
-@@ -2180,11 +2156,11 @@
- 	if (op >= SLJIT_ADD) {
- 		if (TMP_REG2_mapped != dst_ar)
- 			FAIL_IF(ADD(TMP_REG2_mapped, dst_ar, ZERO));
--		return emit_op(compiler, op | flags, CUMULATIVE_OP | LOGICAL_OP | IMM_OP | ALT_KEEP_CACHE, dst, dstw, src, srcw, TMP_REG2, 0);
-+		return emit_op(compiler, op | flags, mem_type | CUMULATIVE_OP | LOGICAL_OP | IMM_OP | ALT_KEEP_CACHE, dst, dstw, src, srcw, TMP_REG2, 0);
- 	}
- 
- 	if (dst & SLJIT_MEM)
--		return emit_op_mem(compiler, WORD_DATA, dst_ar, dst, dstw);
-+		return emit_op_mem(compiler, mem_type, dst_ar, dst, dstw);
- 
- 	if (sugg_dst_ar != dst_ar)
- 		return ADD(sugg_dst_ar, dst_ar, ZERO);
-@@ -2194,7 +2170,7 @@
- 
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) {
- 	CHECK_ERROR();
--	check_sljit_emit_op0(compiler, op);
-+	CHECK(check_sljit_emit_op0(compiler, op));
- 
- 	op = GET_OPCODE(op);
- 	switch (op) {
-@@ -2204,10 +2180,10 @@
- 	case SLJIT_BREAKPOINT:
- 		return PI(BPT);
- 
--	case SLJIT_UMUL:
--	case SLJIT_SMUL:
--	case SLJIT_UDIV:
--	case SLJIT_SDIV:
-+	case SLJIT_LUMUL:
-+	case SLJIT_LSMUL:
-+	case SLJIT_UDIVI:
-+	case SLJIT_SDIVI:
- 		SLJIT_ASSERT_STOP();
- 	}
- 
-@@ -2217,7 +2193,7 @@
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, sljit_si dst, sljit_sw dstw, sljit_si src, sljit_sw srcw)
- {
- 	CHECK_ERROR();
--	check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
-+	CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
- 	ADJUST_LOCAL_OFFSET(dst, dstw);
- 	ADJUST_LOCAL_OFFSET(src, srcw);
- 
-@@ -2273,7 +2249,7 @@
- 		return emit_op(compiler, SLJIT_SUB | GET_ALL_FLAGS(op), IMM_OP, dst, dstw, SLJIT_IMM, 0, src, srcw);
- 
- 	case SLJIT_CLZ:
--		return emit_op(compiler, op, 0, dst, dstw, TMP_REG1, 0, src, srcw);
-+		return emit_op(compiler, op, (op & SLJIT_INT_OP) ? INT_DATA : WORD_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
- 	}
- 
- 	return SLJIT_SUCCESS;
-@@ -2282,7 +2258,7 @@
- SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, sljit_si dst, sljit_sw dstw, sljit_si src1, sljit_sw src1w, sljit_si src2, sljit_sw src2w)
- {
- 	CHECK_ERROR();
--	check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
-+	CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- 	ADJUST_LOCAL_OFFSET(dst, dstw);
- 	ADJUST_LOCAL_OFFSET(src1, src1w);
- 	ADJUST_LOCAL_OFFSET(src2, src2w);
-@@ -2325,7 +2301,7 @@
- 	flush_buffer(compiler);
- 
- 	CHECK_ERROR_PTR();
--	check_sljit_emit_label(compiler);
-+	CHECK_PTR(check_sljit_emit_label(compiler));
- 
- 	if (compiler->last_label && compiler->last_label->size == compiler->size)
- 		return compiler->last_label;
-@@ -2344,7 +2320,7 @@
- 	flush_buffer(compiler);
- 
- 	CHECK_ERROR();
--	check_sljit_emit_ijump(compiler, type, src, srcw);
-+	CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
- 	ADJUST_LOCAL_OFFSET(src, srcw);
- 
- 	if (FAST_IS_REG(src)) {
-@@ -2404,8 +2380,10 @@
- 
- 		return SLJIT_SUCCESS;
- 
--	} else if (src & SLJIT_MEM)
-+	} else if (src & SLJIT_MEM) {
- 		FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw));
-+		flush_buffer(compiler);
-+	}
- 
- 	FAIL_IF(JR_SOLO(reg_map[src_r]));
- 
-@@ -2432,7 +2410,7 @@
- 	flush_buffer(compiler);
- 
- 	CHECK_ERROR_PTR();
--	check_sljit_emit_jump(compiler, type);
-+	CHECK_PTR(check_sljit_emit_jump(compiler, type));
- 
- 	jump = (struct sljit_jump *)ensure_abuf(compiler, sizeof(struct sljit_jump));
- 	PTR_FAIL_IF(!jump);
-@@ -2440,48 +2418,42 @@
- 	type &= 0xff;
- 
- 	switch (type) {
--	case SLJIT_C_EQUAL:
--	case SLJIT_C_FLOAT_NOT_EQUAL:
-+	case SLJIT_EQUAL:
- 		BR_NZ(EQUAL_FLAG);
- 		break;
--	case SLJIT_C_NOT_EQUAL:
--	case SLJIT_C_FLOAT_EQUAL:
-+	case SLJIT_NOT_EQUAL:
- 		BR_Z(EQUAL_FLAG);
- 		break;
--	case SLJIT_C_LESS:
--	case SLJIT_C_FLOAT_LESS:
-+	case SLJIT_LESS:
- 		BR_Z(ULESS_FLAG);
- 		break;
--	case SLJIT_C_GREATER_EQUAL:
--	case SLJIT_C_FLOAT_GREATER_EQUAL:
-+	case SLJIT_GREATER_EQUAL:
- 		BR_NZ(ULESS_FLAG);
- 		break;
--	case SLJIT_C_GREATER:
--	case SLJIT_C_FLOAT_GREATER:
-+	case SLJIT_GREATER:
- 		BR_Z(UGREATER_FLAG);
- 		break;
--	case SLJIT_C_LESS_EQUAL:
--	case SLJIT_C_FLOAT_LESS_EQUAL:
-+	case SLJIT_LESS_EQUAL:
- 		BR_NZ(UGREATER_FLAG);
- 		break;
--	case SLJIT_C_SIG_LESS:
-+	case SLJIT_SIG_LESS:
- 		BR_Z(LESS_FLAG);
- 		break;
--	case SLJIT_C_SIG_GREATER_EQUAL:
-+	case SLJIT_SIG_GREATER_EQUAL:
- 		BR_NZ(LESS_FLAG);
- 		break;
--	case SLJIT_C_SIG_GREATER:
-+	case SLJIT_SIG_GREATER:
- 		BR_Z(GREATER_FLAG);
- 		break;
--	case SLJIT_C_SIG_LESS_EQUAL:
-+	case SLJIT_SIG_LESS_EQUAL:
- 		BR_NZ(GREATER_FLAG);
- 		break;
--	case SLJIT_C_OVERFLOW:
--	case SLJIT_C_MUL_OVERFLOW:
-+	case SLJIT_OVERFLOW:
-+	case SLJIT_MUL_OVERFLOW:
- 		BR_Z(OVERFLOW_FLAG);
- 		break;
--	case SLJIT_C_NOT_OVERFLOW:
--	case SLJIT_C_MUL_NOT_OVERFLOW:
-+	case SLJIT_NOT_OVERFLOW:
-+	case SLJIT_MUL_NOT_OVERFLOW:
- 		BR_NZ(OVERFLOW_FLAG);
- 		break;
- 	default:
-@@ -2536,7 +2508,7 @@
- 	flush_buffer(compiler);
- 
- 	CHECK_ERROR_PTR();
--	check_sljit_emit_const(compiler, dst, dstw, init_value);
-+	CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
- 	ADJUST_LOCAL_OFFSET(dst, dstw);
- 
- 	const_ = (struct sljit_const *)ensure_abuf(compiler, sizeof(struct sljit_const));
-@@ -2572,3 +2544,18 @@
- 	inst[3] = (inst[3] & ~(0xFFFFL << 43)) | ((new_constant & 0xFFFFL) << 43);
- 	SLJIT_CACHE_FLUSH(inst, inst + 4);
- }
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
-+{
-+	CHECK_REG_INDEX(check_sljit_get_register_index(reg));
-+	return reg_map[reg];
-+}
-+
-+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
-+	void *instruction, sljit_si size)
-+{
-+	CHECK_ERROR();
-+	CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
-+	return SLJIT_ERR_UNSUPPORTED;
-+}
-+
-Index: pcregrep.c
-===================================================================
---- pcregrep.c	(revision 1554)
-+++ pcregrep.c	(working copy)
-@@ -1692,9 +1692,13 @@
- 
-     if (filenames == FN_NOMATCH_ONLY) return 1;
- 
-+    /* If all we want is a yes/no answer, stop now. */
-+
-+    if (quiet) return 0;
-+
-     /* Just count if just counting is wanted. */
- 
--    if (count_only) count++;
-+    else if (count_only) count++;
- 
-     /* When handling a binary file and binary-files==binary, the "binary"
-     variable will be set true (it's false in all other cases). In this
-@@ -1715,10 +1719,6 @@
-       return 0;
-       }
- 
--    /* Likewise, if all we want is a yes/no answer. */
--
--    else if (quiet) return 0;
--
-     /* The --only-matching option prints just the substring that matched,
-     and/or one or more captured portions of it, as long as these strings are
-     not empty. The --file-offsets and --line-offsets options output offsets for
-@@ -2089,7 +2089,7 @@
- 
- /* Print the match count if wanted */
- 
--if (count_only)
-+if (count_only && !quiet)
-   {
-   if (count > 0 || !omit_zero_count)
-     {
-Index: pcre_study.c
-===================================================================
---- pcre_study.c	(revision 1554)
-+++ pcre_study.c	(working copy)
-@@ -71,6 +71,7 @@
-   startcode       pointer to start of the whole pattern's code
-   options         the compiling options
-   recurses        chain of recurse_check to catch mutual recursion
-+  countptr        pointer to call count (to catch over complexity) 
- 
- Returns:   the minimum length
-            -1 if \C in UTF-8 mode or (*ACCEPT) was encountered
-@@ -80,7 +81,8 @@
- 
- static int
- find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
--  const pcre_uchar *startcode, int options, recurse_check *recurses)
-+  const pcre_uchar *startcode, int options, recurse_check *recurses,
-+  int *countptr)
- {
- int length = -1;
- /* PCRE_UTF16 has the same value as PCRE_UTF8. */
-@@ -90,6 +92,8 @@
- register int branchlength = 0;
- register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
- 
-+if ((*countptr)++ > 1000) return -1;   /* too complex */
-+
- if (*code == OP_CBRA || *code == OP_SCBRA ||
-     *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;
- 
-@@ -131,7 +135,7 @@
-     case OP_SBRAPOS:
-     case OP_ONCE:
-     case OP_ONCE_NC:
--    d = find_minlength(re, cc, startcode, options, recurses);
-+    d = find_minlength(re, cc, startcode, options, recurses, countptr);
-     if (d < 0) return d;
-     branchlength += d;
-     do cc += GET(cc, 1); while (*cc == OP_ALT);
-@@ -415,7 +419,8 @@
-             int dd;
-             this_recurse.prev = recurses;
-             this_recurse.group = cs;
--            dd = find_minlength(re, cs, startcode, options, &this_recurse);
-+            dd = find_minlength(re, cs, startcode, options, &this_recurse,
-+              countptr);
-             if (dd < d) d = dd;
-             }
-           }
-@@ -451,7 +456,8 @@
-           {
-           this_recurse.prev = recurses;
-           this_recurse.group = cs;
--          d = find_minlength(re, cs, startcode, options, &this_recurse);
-+          d = find_minlength(re, cs, startcode, options, &this_recurse,
-+            countptr);
-           }
-         }
-       }
-@@ -514,7 +520,7 @@
-         this_recurse.prev = recurses;
-         this_recurse.group = cs;
-         branchlength += find_minlength(re, cs, startcode, options,
--          &this_recurse);
-+          &this_recurse, countptr);
-         }
-       }
-     cc += 1 + LINK_SIZE;
-@@ -1453,6 +1459,7 @@
- #endif
- {
- int min;
-+int count = 0;
- BOOL bits_set = FALSE;
- pcre_uint8 start_bits[32];
- PUBL(extra) *extra = NULL;
-@@ -1539,7 +1546,7 @@
- 
- /* Find the minimum length of subject string. */
- 
--switch(min = find_minlength(re, code, code, re->options, NULL))
-+switch(min = find_minlength(re, code, code, re->options, NULL, &count))
-   {
-   case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
-   case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
-Index: pcre_internal.h
-===================================================================
---- pcre_internal.h	(revision 1554)
-+++ pcre_internal.h	(working copy)
-@@ -984,7 +984,7 @@
- #ifndef EBCDIC
- 
- #define HSPACE_LIST \
--  CHAR_HT, CHAR_SPACE, 0xa0, \
-+  CHAR_HT, CHAR_SPACE, CHAR_NBSP, \
-   0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \
-   0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \
-   NOTACHAR
-@@ -1010,7 +1010,7 @@
- #define HSPACE_BYTE_CASES \
-   case CHAR_HT: \
-   case CHAR_SPACE: \
--  case 0xa0     /* NBSP */
-+  case CHAR_NBSP
- 
- #define HSPACE_CASES \
-   HSPACE_BYTE_CASES: \
-@@ -1037,11 +1037,12 @@
- /* ------ EBCDIC environments ------ */
- 
- #else
--#define HSPACE_LIST CHAR_HT, CHAR_SPACE
-+#define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR
- 
- #define HSPACE_BYTE_CASES \
-   case CHAR_HT: \
--  case CHAR_SPACE
-+  case CHAR_SPACE: \
-+  case CHAR_NBSP
- 
- #define HSPACE_CASES HSPACE_BYTE_CASES
- 
-@@ -1215,6 +1216,7 @@
- 
- #define CHAR_ESC                    '\047'
- #define CHAR_DEL                    '\007'
-+#define CHAR_NBSP                   '\x41'
- #define STR_ESC                     "\047"
- #define STR_DEL                     "\007"
- 
-@@ -1229,6 +1231,7 @@
- #define CHAR_NEL                    ((unsigned char)'\x85')
- #define CHAR_ESC                    '\033'
- #define CHAR_DEL                    '\177'
-+#define CHAR_NBSP                   ((unsigned char)'\xa0')
- 
- #define STR_LF                      "\n"
- #define STR_NL                      STR_LF
-@@ -1606,6 +1609,7 @@
- #define CHAR_VERTICAL_LINE          '\174'
- #define CHAR_RIGHT_CURLY_BRACKET    '\175'
- #define CHAR_TILDE                  '\176'
-+#define CHAR_NBSP                   ((unsigned char)'\xa0')
- 
- #define STR_HT                      "\011"
- #define STR_VT                      "\013"
-@@ -1762,6 +1766,10 @@
- 
- /* Escape items that are just an encoding of a particular data value. */
- 
-+#ifndef ESC_a
-+#define ESC_a CHAR_BEL
-+#endif
-+
- #ifndef ESC_e
- #define ESC_e CHAR_ESC
- #endif
-@@ -2446,6 +2454,7 @@
-   BOOL had_pruneorskip;             /* (*PRUNE) or (*SKIP) encountered */
-   BOOL check_lookbehind;            /* Lookbehinds need later checking */
-   BOOL dupnames;                    /* Duplicate names exist */
-+  BOOL dupgroups;                   /* Duplicate groups exist: (?| found */ 
-   BOOL iscondassert;                /* Next assert is a condition */
-   int  nltype;                      /* Newline type */
-   int  nllen;                       /* Newline string length */
-Index: pcre_exec.c
-===================================================================
---- pcre_exec.c	(revision 1554)
-+++ pcre_exec.c	(working copy)
-@@ -6685,7 +6685,8 @@
-   register int *iend = iptr - re->top_bracket;
-   if (iend < md->offset_vector + 2) iend = md->offset_vector + 2;
-   while (--iptr >= iend) *iptr = -1;
--  md->offset_vector[0] = md->offset_vector[1] = -1;
-+  if (offsetcount > 0) md->offset_vector[0] = -1;
-+  if (offsetcount > 1) md->offset_vector[1] = -1;
-   }
- 
- /* Set up the first character to match, if available. The first_char value is
-Index: pcre_jit_test.c
-===================================================================
---- pcre_jit_test.c	(revision 1554)
-+++ pcre_jit_test.c	(working copy)
-@@ -182,6 +182,7 @@
- 	{ CMUAP, 0, "\xf0\x90\x90\x80{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
- 	{ CMUAP, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" },
- 	{ CMUAP, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" },
-+	{ MA, 0, "[3-57-9]", "5" },
- 
- 	/* Assertions. */
- 	{ MUA, 0, "\\b[^A]", "A_B#" },
-Index: configure.ac
-===================================================================
---- configure.ac	(revision 1554)
-+++ configure.ac	(working copy)
-@@ -9,9 +9,9 @@
- dnl be defined as -RC2, for example. For real releases, it should be empty.
- 
- m4_define(pcre_major, [8])
--m4_define(pcre_minor, [37])
--m4_define(pcre_prerelease, [])
--m4_define(pcre_date, [2015-04-28])
-+m4_define(pcre_minor, [38])
-+m4_define(pcre_prerelease, [-RC1])
-+m4_define(pcre_date, [2015-05-03])
- 
- # NOTE: The CMakeLists.txt file searches for the above variables in the first
- # 50 lines of this file. Please update that if the variables above are moved.
-Index: doc/pcrepattern.3
-===================================================================
---- doc/pcrepattern.3	(revision 1554)
-+++ doc/pcrepattern.3	(working copy)
-@@ -1,4 +1,4 @@
--.TH PCREPATTERN 3 "08 January 2014" "PCRE 8.35"
-+.TH PCREPATTERN 3 "14 June 2015" "PCRE 8.38"
- .SH NAME
- PCRE - Perl-compatible regular expressions
- .SH "PCRE REGULAR EXPRESSION DETAILS"
-@@ -308,7 +308,8 @@
- in patterns in a visible manner. There is no restriction on the appearance of
- non-printing characters, apart from the binary zero that terminates a pattern,
- but when a pattern is being prepared by text editing, it is often easier to use
--one of the following escape sequences than the binary character it represents:
-+one of the following escape sequences than the binary character it represents.
-+In an ASCII or Unicode environment, these escapes are as follows:
- .sp
-   \ea        alarm, that is, the BEL character (hex 07)
-   \ecx       "control-x", where x is any ASCII character
-@@ -330,19 +331,31 @@
- but \ec{ becomes hex 3B ({ is 7B), and \ec; becomes hex 7B (; is 3B). If the
- data item (byte or 16-bit value) following \ec has a value greater than 127, a
- compile-time error occurs. This locks out non-ASCII characters in all modes.
-+.P                                                    
-+When PCRE is compiled in EBCDIC mode, \ea, \ee, \ef, \en, \er, and \et
-+generate the appropriate EBCDIC code values. The \ec escape is processed
-+as specified for Perl in the \fBperlebcdic\fP document. The only characters
-+that are allowed after \ec are A-Z, a-z, or one of @, [, \e, ], ^, _, or ?. Any
-+other character provokes a compile-time error. The sequence \e@ encodes
-+character code 0; the letters (in either case) encode characters 1-26 (hex 01
-+to hex 1A); [, \e, ], ^, and _ encode characters 27-31 (hex 1B to hex 1F), and
-+\e? becomes either 255 (hex FF) or 95 (hex 5F).
- .P
--The \ec facility was designed for use with ASCII characters, but with the
--extension to Unicode it is even less useful than it once was. It is, however,
--recognized when PCRE is compiled in EBCDIC mode, where data items are always
--bytes. In this mode, all values are valid after \ec. If the next character is a
--lower case letter, it is converted to upper case. Then the 0xc0 bits of the
--byte are inverted. Thus \ecA becomes hex 01, as in ASCII (A is C1), but because
--the EBCDIC letters are disjoint, \ecZ becomes hex 29 (Z is E9), and other
--characters also generate different values.
-+Thus, apart from \e?, these escapes generate the same character code values as
-+they do in an ASCII environment, though the meanings of the values mostly 
-+differ. For example, \eG always generates code value 7, which is BEL in ASCII
-+but DEL in EBCDIC.
- .P
-+The sequence \e? generates DEL (127, hex 7F) in an ASCII environment, but
-+because 127 is not a control character in EBCDIC, Perl makes it generate the 
-+APC character. Unfortunately, there are several variants of EBCDIC. In most of 
-+them the APC character has the value 255 (hex FF), but in the one Perl calls 
-+POSIX-BC its value is 95 (hex 5F). If certain other characters have POSIX-BC 
-+values, PCRE makes \e? generate 95; otherwise it generates 255.
-+.P
- After \e0 up to two further octal digits are read. If there are fewer than two
--digits, just those that are present are used. Thus the sequence \e0\ex\e07
--specifies two binary zeros followed by a BEL character (code value 7). Make
-+digits, just those that are present are used. Thus the sequence \e0\ex\e015
-+specifies two binary zeros followed by a CR character (code value 13). Make
- sure you supply two digits after the initial zero if the pattern character that
- follows is itself an octal digit.
- .P
-@@ -3283,6 +3296,6 @@
- .rs
- .sp
- .nf
--Last updated: 08 January 2014
--Copyright (c) 1997-2014 University of Cambridge.
-+Last updated: 14 June 2015
-+Copyright (c) 1997-2015 University of Cambridge.
- .fi
-Index: testdata/testoutput11-32
-===================================================================
---- testdata/testoutput11-32	(revision 1554)
-+++ testdata/testoutput11-32	(working copy)
-@@ -231,7 +231,7 @@
- ------------------------------------------------------------------
- 
- /(?P<a>a)...(?P=a)bbb(?P>a)d/BM
--Memory allocation (code space): 125
-+Memory allocation (code space): 157
- ------------------------------------------------------------------
-   0  24 Bra
-   2   5 CBra 1
-@@ -748,4 +748,21 @@
-  22     End
- ------------------------------------------------------------------
- 
-+/.((?2)(?R)\1)()/B
-+------------------------------------------------------------------
-+  0  23 Bra
-+  2     Any
-+  3  13 Once
-+  5   9 CBra 1
-+  8  18 Recurse
-+ 10   0 Recurse
-+ 12     \1
-+ 14   9 Ket
-+ 16  13 Ket
-+ 18   3 CBra 2
-+ 21   3 Ket
-+ 23  23 Ket
-+ 25     End
-+------------------------------------------------------------------
-+
- /-- End of testinput11 --/
-Index: testdata/testinputEBC
-===================================================================
---- testdata/testinputEBC	(revision 1554)
-+++ testdata/testinputEBC	(working copy)
-@@ -29,13 +29,16 @@
- 
- /^A\ˆ/
-     A B
-+    A\x41B
- 
- /-- Test \H --/
- 
- /^A\È/
-     AB
-+    A\x42B
-     ** Fail
-     A B
-+    A\x41B
- 
- /-- Test \R --/
- 
-Index: testdata/testoutput1
-===================================================================
---- testdata/testoutput1	(revision 1554)
-+++ testdata/testoutput1	(working copy)
-@@ -9429,4 +9429,9 @@
-  0: aaaaaaaaa
-  1: a
- 
-+"(?|(\k'Pm')|(?'Pm'))"
-+    abcd
-+ 0: 
-+ 1: 
-+
- /-- End of testinput1 --/
-Index: testdata/testoutput2
-===================================================================
---- testdata/testoutput2	(revision 1554)
-+++ testdata/testoutput2	(working copy)
-@@ -5614,9 +5614,9 @@
-     123456\P
- No match
- 
--//KF>/dev/null
--Compiled pattern written to /dev/null
--Study data written to /dev/null
-+//KF>testsavedregex
-+Compiled pattern written to testsavedregex
-+Study data written to testsavedregex
- 
- /abc/IS>testsavedregex
- Capturing subpattern count = 0
-@@ -9135,10 +9135,10 @@
- Failed: subpattern name expected at offset 3
- 
- /\k/
--Failed: \k is not followed by a braced, angle-bracketed, or quoted name at offset 2
-+Failed: \k is not followed by a braced, angle-bracketed, or quoted name at offset 1
- 
- /\kabc/
--Failed: \k is not followed by a braced, angle-bracketed, or quoted name at offset 5
-+Failed: \k is not followed by a braced, angle-bracketed, or quoted name at offset 1
- 
- /(?P=)/
- Failed: subpattern name expected at offset 4
-@@ -9186,7 +9186,7 @@
- Failed: unknown POSIX class name at offset 3
- 
- /(^(a|b\g<-1'c))/
--Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 15
-+Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 8
- 
- /^(?+1)(?<a>x|y){0}z/
-     xzxx
-@@ -14098,10 +14098,10 @@
- Failed: group name must start with a non-digit at offset 4
- 
- /\g'3gh'/
--Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 7
-+Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 2
- 
- /\g<5fg>/
--Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 7
-+Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 2
- 
- /(?(<4gh>)abc)/
- Failed: group name must start with a non-digit at offset 4
-@@ -14423,4 +14423,146 @@
- 
- /((?2){73}(?2))((?1))/
- 
-+/.((?2)(?R)\1)()/BZ
-+------------------------------------------------------------------
-+        Bra
-+        Any
-+        Once
-+        CBra 1
-+        Recurse
-+        Recurse
-+        \1
-+        Ket
-+        Ket
-+        CBra 2
-+        Ket
-+        Ket
-+        End
-+------------------------------------------------------------------
-+
-+/(?1)()((((((\1++))\x85)+)|))/
-+
-+/(\9*+(?2);\3++()2|)++{/
-+Failed: reference to non-existent subpattern at offset 22
-+
-+/\V\x85\9*+((?2)\3++()2)*:2/
-+Failed: reference to non-existent subpattern at offset 26
-+
-+/(((?(R)){0,2}) (?''((?'R')((?'R')))))/J
-+
-+/(((?(X)){0,2}) (?''((?'X')((?'X')))))/J
-+
-+/(((?(R)){0,2}) (?''((?'X')((?'R')))))/
-+
-+"(?J)(?'d'(?'d'\g{d}))"
-+
-+".*?\h.+.\.+\R*?\xd(?i)(?=!(?=b`b`b`\`b\xa9b!)`\a`bbbbbbbbbbbbb`bbbbbbbbbbbb*R\x85bbbbbbb\C?{((?2)(?))((
-+\H){8(?<=(?1){29}\xa8bbbb\x16\xd\xc6^($(?<! )(\xa9H4){4}h}1)B))\x15')"
-+
-+"(?J:(?|(?'R')(\k'R')|((?'R'))))"
-+
-+/(?<=|(\,\$(?73591620449005828816)\xa8.{7}){6}\x09)/
-+Failed: number is too big at offset 32
-+
-+//
-+\O1
-+Matched, but too many substrings
-+
-+/^(?:(?(1)x|)+)+$()/BZ
-+------------------------------------------------------------------
-+        Bra
-+        ^
-+        SBra
-+        SCond
-+      1 Cond ref
-+        x
-+        Alt
-+        KetRmax
-+        KetRmax
-+        $
-+        CBra 1
-+        Ket
-+        Ket
-+        End
-+------------------------------------------------------------------
-+
-+/(?=di(?<=(?1))|(?=(.))))/
-+Failed: unmatched parentheses at offset 23
-+
-+/(?(R))*+/BZ
-+------------------------------------------------------------------
-+        Bra
-+        Braposzero
-+        SBraPos
-+        SCond
-+        Cond recurse any
-+        Ket
-+        KetRpos
-+        Ket
-+        End
-+------------------------------------------------------------------
-+
-+/[[:\\](?'abc')[a:]/
-+
-+"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
-+Failed: missing terminating ] for character class at offset 353
-+
-+/()(?(R)0)*+/BZ
-+------------------------------------------------------------------
-+        Bra
-+        CBra 1
-+        Ket
-+        Braposzero
-+        SBraPos
-+        SCond
-+        Cond recurse any
-+        0
-+        Ket
-+        KetRpos
-+        Ket
-+        End
-+------------------------------------------------------------------
-+
-+/(?R-:(?</
-+Failed: (?R or (?[+-]digits must be followed by ) at offset 3
-+
-+/(?1){3918}(((((0(\k'R'))))(?J)(?'R'(?'R'\3){99})))/I
-+Capturing subpattern count = 8
-+Max back reference = 8
-+Named capturing subpatterns:
-+  R   7
-+  R   8
-+No options
-+Duplicate name status changes
-+No first char
-+Need char = '0'
-+
-+/(?J:(?|(:(?|(?'R')(\k'R')|((?'R')))H'Rk'Rf)|s(?'R')))/
-+
-+/0(?0)|(1)(*THEN)(*SKIP:0)(*FAIL)/
-+    01
-+No match
-+
-+/((?(R8000000000)))/ 
-+Failed: number is too big at offset 16
-+
-+/(?(8000000000/
-+Failed: number is too big at offset 13
-+
-+/(?:ab)?(?:ab)(?:ab)/
-+    abab
-+ 0: abab
-+    ababab
-+ 0: ababab
-+    aba
-+No match
-+
-+/((*MARK:A))++a(*SKIP:B)b/
-+    aacb
-+No match
-+
-+/(?J:(?|(:(?|(?'R')(\z(?|(?'R')(\k'R')|((?'R')))k'R')|((?'R')))H'Ak'Rf)|s(?'R')))/
-+
-+/(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&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)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?<a>1)/
-+
- /-- End of testinput2 --/
-Index: testdata/testoutput11-16
-===================================================================
---- testdata/testoutput11-16	(revision 1554)
-+++ testdata/testoutput11-16	(working copy)
-@@ -231,7 +231,7 @@
- ------------------------------------------------------------------
- 
- /(?P<a>a)...(?P=a)bbb(?P>a)d/BM
--Memory allocation (code space): 61
-+Memory allocation (code space): 77
- ------------------------------------------------------------------
-   0  24 Bra
-   2   5 CBra 1
-@@ -748,4 +748,21 @@
-  22     End
- ------------------------------------------------------------------
- 
-+/.((?2)(?R)\1)()/B
-+------------------------------------------------------------------
-+  0  23 Bra
-+  2     Any
-+  3  13 Once
-+  5   9 CBra 1
-+  8  18 Recurse
-+ 10   0 Recurse
-+ 12     \1
-+ 14   9 Ket
-+ 16  13 Ket
-+ 18   3 CBra 2
-+ 21   3 Ket
-+ 23  23 Ket
-+ 25     End
-+------------------------------------------------------------------
-+
- /-- End of testinput11 --/
-Index: testdata/testoutput6
-===================================================================
---- testdata/testoutput6	(revision 1554)
-+++ testdata/testoutput6	(working copy)
-@@ -2469,4 +2469,8 @@
-     Ó…\x0aT
- No match
- 
-+/[\pS#moq]/
-+    =
-+ 0: =
-+
- /-- End of testinput6 --/
-Index: testdata/testinput11
-===================================================================
---- testdata/testinput11	(revision 1554)
-+++ testdata/testinput11	(working copy)
-@@ -136,4 +136,6 @@
- 
- /((?+1)(\1))/B
- 
-+/.((?2)(?R)\1)()/B
-+
- /-- End of testinput11 --/
-Index: testdata/testinput12
-===================================================================
---- testdata/testinput12	(revision 1554)
-+++ testdata/testinput12	(working copy)
-@@ -8,6 +8,8 @@
- 
- /(?(?C1)(?=a)a)/S!+I
- 
-+/b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b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a|){100}x/S++
-+
-+/(x(?1)){4}/S++
-+
-+/(.|.)*?bx/
-+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax
-+
- /-- End of testinput12 --/
-Index: testdata/testoutput12
-===================================================================
---- testdata/testoutput12	(revision 1554)
-+++ testdata/testoutput12	(working copy)
-@@ -30,6 +30,15 @@
- No starting char list
- JIT study was not successful
- 
-+/b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b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*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*b*/S+I
-+Capturing subpattern count = 0
-+May match empty string
-+No options
-+No first char
-+No need char
-+Study returned NULL
-+JIT study was not successful
-+
- /abc/S+I>testsavedregex
- Capturing subpattern count = 0
- No options
-@@ -184,4 +193,12 @@
- 
- /(a(?:a|b|c|d|e)b){8,16}/S++
- 
-+/(?:|a|){100}x/S++
-+
-+/(x(?1)){4}/S++
-+
-+/(.|.)*?bx/
-+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabax
-+Error -8 (match limit exceeded)
-+
- /-- End of testinput12 --/
-Index: testdata/testoutput11-8
-===================================================================
---- testdata/testoutput11-8	(revision 1554)
-+++ testdata/testoutput11-8	(working copy)
-@@ -231,7 +231,7 @@
- ------------------------------------------------------------------
- 
- /(?P<a>a)...(?P=a)bbb(?P>a)d/BM
--Memory allocation (code space): 38
-+Memory allocation (code space): 50
- ------------------------------------------------------------------
-   0  30 Bra
-   3   7 CBra 1
-@@ -748,4 +748,21 @@
-  34     End
- ------------------------------------------------------------------
- 
-+/.((?2)(?R)\1)()/B
-+------------------------------------------------------------------
-+  0  35 Bra
-+  3     Any
-+  4  20 Once
-+  7  14 CBra 1
-+ 12  27 Recurse
-+ 15   0 Recurse
-+ 18     \1
-+ 21  14 Ket
-+ 24  20 Ket
-+ 27   5 CBra 2
-+ 32   5 Ket
-+ 35  35 Ket
-+ 38     End
-+------------------------------------------------------------------
-+
- /-- End of testinput11 --/
-Index: testdata/testoutputEBC
-===================================================================
---- testdata/testoutputEBC	(revision 1554)
-+++ testdata/testoutputEBC	(working copy)
-@@ -41,6 +41,8 @@
- /^A\ˆ/
-     A B
-  0: A\x20
-+    A\x41B
-+ 0: AA
- 
- /-- Test \H --/
- 
-@@ -47,10 +49,14 @@
- /^A\È/
-     AB
-  0: AB
-+    A\x42B
-+ 0: AB
-     ** Fail
- No match
-     A B
- No match
-+    A\x41B
-+No match
- 
- /-- Test \R --/
- 
-Index: testdata/grepoutput
-===================================================================
---- testdata/grepoutput	(revision 1554)
-+++ testdata/grepoutput	(working copy)
-@@ -751,3 +751,7 @@
- 2:3,1
- 2:4,1
- RC=0
-+---------------------------- Test 108 ------------------------------
-+RC=0
-+---------------------------- Test 109 -----------------------------
-+RC=0
-Index: testdata/testinput1
-===================================================================
---- testdata/testinput1	(revision 1554)
-+++ testdata/testinput1	(working copy)
-@@ -5730,4 +5730,7 @@
- "(?1)(?#?'){8}(a)"
-     baaaaaaaaac
- 
-+"(?|(\k'Pm')|(?'Pm'))"
-+    abcd
-+
- /-- End of testinput1 --/
-Index: testdata/testinput2
-===================================================================
---- testdata/testinput2	(revision 1554)
-+++ testdata/testinput2	(working copy)
-@@ -1380,7 +1380,7 @@
-     1X
-     123456\P
- 
--//KF>/dev/null
-+//KF>testsavedregex
- 
- /abc/IS>testsavedregex
- <testsavedregex
-@@ -4152,4 +4152,67 @@
- 
- /((?2){73}(?2))((?1))/
- 
-+/.((?2)(?R)\1)()/BZ
-+
-+/(?1)()((((((\1++))\x85)+)|))/
-+
-+/(\9*+(?2);\3++()2|)++{/
-+
-+/\V\x85\9*+((?2)\3++()2)*:2/
-+
-+/(((?(R)){0,2}) (?''((?'R')((?'R')))))/J
-+
-+/(((?(X)){0,2}) (?''((?'X')((?'X')))))/J
-+
-+/(((?(R)){0,2}) (?''((?'X')((?'R')))))/
-+
-+"(?J)(?'d'(?'d'\g{d}))"
-+
-+".*?\h.+.\.+\R*?\xd(?i)(?=!(?=b`b`b`\`b\xa9b!)`\a`bbbbbbbbbbbbb`bbbbbbbbbbbb*R\x85bbbbbbb\C?{((?2)(?))((
-+\H){8(?<=(?1){29}\xa8bbbb\x16\xd\xc6^($(?<! )(\xa9H4){4}h}1)B))\x15')"
-+
-+"(?J:(?|(?'R')(\k'R')|((?'R'))))"
-+
-+/(?<=|(\,\$(?73591620449005828816)\xa8.{7}){6}\x09)/
-+
-+//
-+\O1
-+
-+/^(?:(?(1)x|)+)+$()/BZ
-+
-+/(?=di(?<=(?1))|(?=(.))))/
-+
-+/(?(R))*+/BZ
-+
-+/[[:\\](?'abc')[a:]/
-+
-+"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[: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a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?&a)(?<a>1)/
-+
- /-- End of testinput2 --/
-Index: testdata/testinput6
-===================================================================
---- testdata/testinput6	(revision 1554)
-+++ testdata/testinput6	(working copy)
-@@ -1502,4 +1502,7 @@
- /\C\X*QT/8
-     Ó…\x0aT
- 
-+/[\pS#moq]/
-+    =
-+
- /-- End of testinput6 --/
-Index: NON-AUTOTOOLS-BUILD
-===================================================================
---- NON-AUTOTOOLS-BUILD	(revision 1554)
-+++ NON-AUTOTOOLS-BUILD	(working copy)
-@@ -764,9 +764,9 @@
- 
-   http://www.zaconsultants.net
- 
--There is also a mirror here:
-+You may download PCRE from WWW.CBTTAPE.ORG, file 882.  Everything, source and
-+executable, is in EBCDIC and native z/OS file formats and this is the
-+recommended download site.
- 
--  http://www.vsoft-software.com/downloads.html
--
- ==========================
--Last Updated: 10 February 2015
-+Last Updated: 25 June 2015
diff --git a/pkgs/development/libraries/pixman/default.nix b/pkgs/development/libraries/pixman/default.nix
index ce027a0a269..30cceb59c00 100644
--- a/pkgs/development/libraries/pixman/default.nix
+++ b/pkgs/development/libraries/pixman/default.nix
@@ -1,26 +1,28 @@
-{ fetchurl, stdenv, pkgconfig, perl, libpng, glib /*just passthru*/ }:
+{ fetchurl, stdenv, pkgconfig, libpng, glib /*just passthru*/ }:
 
 stdenv.mkDerivation rec {
-  name = "pixman-0.32.6";
+  name = "pixman-0.32.8";
 
   src = fetchurl {
-    url = "http://cairographics.org/releases/${name}.tar.gz";
-    sha256 = "0129g4zdrw5hif5783li7rzcr4vpbc2cfia91azxmsk0h0xx3zix";
+    url = "mirror://xorg/individual/lib/${name}.tar.bz2";
+    sha1 = "5c57045622265b877c9bf02d531973eadf942140";
   };
 
-  nativeBuildInputs = [ pkgconfig perl ];
+  patches = stdenv.lib.optional stdenv.isDarwin ./fix-clang36.patch;
 
-  buildInputs = [ libpng ]; # NOT in closure anyway
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = stdenv.lib.optional doCheck libpng;
 
-  postInstall = glib.flattenInclude;
+  configureFlags = stdenv.lib.optional stdenv.isArm "--disable-arm-iwmmxt";
 
-  patches = stdenv.lib.optional stdenv.isDarwin ./fix-clang36.patch;
+  doCheck = true;
 
-  configureFlags = if stdenv.isArm then ["--disable-arm-iwmmxt"] else null;
+  postInstall = glib.flattenInclude;
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://pixman.org;
     description = "A low-level library for pixel manipulation";
-    license = stdenv.lib.licenses.mit;
+    license = licenses.mit;
+    platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/poppler/default.nix b/pkgs/development/libraries/poppler/default.nix
index b15142dc673..92777f00169 100644
--- a/pkgs/development/libraries/poppler/default.nix
+++ b/pkgs/development/libraries/poppler/default.nix
@@ -5,8 +5,8 @@
 }:
 
 let # beware: updates often break cups_filters build
-  version = "0.34.0"; # even major numbers are stable
-  sha256 = "1c2wa4pfzqmvzq1jpp3ps5nmzz745gcg8dnpwqpfdccy5ydbm90v";
+  version = "0.36.0"; # even major numbers are stable
+  sha256 = "13i440kv873wgmw50rs4d1v05cj0r7bqnghd70hp9vy44dxhdk4k";
 in
 stdenv.mkDerivation rec {
   name = "poppler-${suffix}-${version}";
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index f043a37033a..d9fbde9aa09 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -3,11 +3,11 @@
 assert interactive -> readline != null && ncurses != null;
 
 stdenv.mkDerivation {
-  name = "sqlite-3.8.11.1";
+  name = "sqlite-3.9.2";
 
   src = fetchurl {
-    url = "http://sqlite.org/2015/sqlite-autoconf-3081101.tar.gz";
-    sha1 = "d0e22d7e361b6f50830a3cdeafe35311443f8f9a";
+    url = "http://sqlite.org/2015/sqlite-autoconf-3090200.tar.gz";
+    sha1 = "dae1ae5297fece9671ae0c434a7ecd0cda09c76a";
   };
 
   buildInputs = lib.optionals interactive [ readline ncurses ];
@@ -17,6 +17,7 @@ stdenv.mkDerivation {
   NIX_CFLAGS_COMPILE = [
     "-DSQLITE_ENABLE_COLUMN_METADATA"
     "-DSQLITE_ENABLE_DBSTAT_VTAB"
+    "-DSQLITE_ENABLE_JSON1"
     "-DSQLITE_ENABLE_FTS3"
     "-DSQLITE_ENABLE_FTS3_PARENTHESIS"
     "-DSQLITE_ENABLE_FTS4"
diff --git a/pkgs/development/libraries/wayland/default.nix b/pkgs/development/libraries/wayland/default.nix
index 9736d651404..0510fde811c 100644
--- a/pkgs/development/libraries/wayland/default.nix
+++ b/pkgs/development/libraries/wayland/default.nix
@@ -8,11 +8,11 @@ assert expat != null;
 
 stdenv.mkDerivation rec {
   name = "wayland-${version}";
-  version = "1.8.1";
+  version = "1.9.0";
 
   src = fetchurl {
     url = "http://wayland.freedesktop.org/releases/${name}.tar.xz";
-    sha256 = "1j3gfzn8i0xhk3j34mwb2srrscjxfyi279jhyq80mz943j6r6z7i";
+    sha256 = "1yhy62vkbq8j8c9zaa6yzvn75cd99kfa8n2zfdwl80x019r711ww";
   };
 
   configureFlags = "--with-scanner --disable-documentation";
diff --git a/pkgs/development/libraries/webkitgtk/default.nix b/pkgs/development/libraries/webkitgtk/default.nix
index 0e67f5d3d1a..d60fbca6141 100644
--- a/pkgs/development/libraries/webkitgtk/default.nix
+++ b/pkgs/development/libraries/webkitgtk/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, perl, python, ruby, bison, gperf, cmake
-, pkgconfig, gettext, gobjectIntrospection
+, pkgconfig, gettext, gobjectIntrospection, libnotify
 , gtk2, gtk3, wayland, libwebp, enchant
 , libxml2, libsoup, libsecret, libxslt, harfbuzz, libpthreadstubs
 , enableGeoLocation ? true, geoclue2, sqlite
@@ -11,7 +11,7 @@ assert enableGeoLocation -> geoclue2 != null;
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "webkitgtk-${version}";
-  version = "2.8.5";
+  version = "2.10.0";
 
   meta = {
     description = "Web content rendering engine, GTK+ port";
@@ -25,12 +25,12 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "http://webkitgtk.org/releases/${name}.tar.xz";
-    sha256 = "082dw0d8jxvsapx30ypmy5h2srzfzi42c3zr9pbkzx1m959hq7rx";
+    sha256 = "0vb8ca6dd9hxb5ycp54bdyykp10blbq5b6qkbak4yf9mxwi5ccj2";
   };
 
   patches = [ ./finding-harfbuzz-icu.patch ];
 
-  cmakeFlags = [ "-DPORT=GTK" ];
+  cmakeFlags = [ "-DPORT=GTK" "-DUSE_LIBHYPHEN=0" ];
 
   # XXX: WebKit2 missing include path for gst-plugins-base.
   # Filled: https://bugs.webkit.org/show_bug.cgi?id=148894
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    gtk2 wayland libwebp enchant
+    gtk2 wayland libwebp enchant libnotify
     libxml2 libsecret libxslt harfbuzz libpthreadstubs
     gst-plugins-base
   ] ++ optional enableGeoLocation geoclue2;
@@ -51,5 +51,5 @@ stdenv.mkDerivation rec {
     libsoup gtk3
   ];
 
-  enableParallelBuilding = true; # build problems on Hydra
+  enableParallelBuilding = true;
 }
diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix
index 45073ba2fa6..55a8c14cd26 100644
--- a/pkgs/development/python-modules/generic/default.nix
+++ b/pkgs/development/python-modules/generic/default.nix
@@ -118,6 +118,7 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
     ${python}/bin/${python.executable} setup.py install \
       --install-lib=$out/lib/${python.libPrefix}/site-packages \
       --old-and-unmanageable \
+      --skip-build \
       --prefix="$out" ${lib.concatStringsSep " " setupPyInstallFlags}
 
     # --install-lib:
diff --git a/pkgs/development/tools/misc/pkgconfig/default.nix b/pkgs/development/tools/misc/pkgconfig/default.nix
index f1471d51e1f..6eea0a6d5d6 100644
--- a/pkgs/development/tools/misc/pkgconfig/default.nix
+++ b/pkgs/development/tools/misc/pkgconfig/default.nix
@@ -1,13 +1,13 @@
 {stdenv, fetchurl, automake, libiconv, vanilla ? false}:
 
 stdenv.mkDerivation (rec {
-  name = "pkg-config-0.28";
+  name = "pkg-config-0.29";
   
   setupHook = ./setup-hook.sh;
   
   src = fetchurl {
     url = "http://pkgconfig.freedesktop.org/releases/${name}.tar.gz";
-    sha256 = "0igqq5m204w71m11y0nipbdf5apx87hwfll6axs12hn4dqfb6vkb";
+    sha256 = "0sq09a39wj4cxf8l2jvkq067g08ywfma4v6nhprnf351s82pfl68";
   };
 
   buildInputs = stdenv.lib.optional (stdenv.isCygwin || stdenv.isDarwin) libiconv;
diff --git a/pkgs/development/tools/misc/texinfo/6.0.nix b/pkgs/development/tools/misc/texinfo/6.0.nix
index ffeae17eb57..5099676f32b 100644
--- a/pkgs/development/tools/misc/texinfo/6.0.nix
+++ b/pkgs/development/tools/misc/texinfo/6.0.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     installTargets="install install-tex";
   '';
 
-  doCheck = !stdenv.isDarwin;
+  doCheck = !stdenv.isDarwin && !interactive;
 
   meta = {
     homepage = "http://www.gnu.org/software/texinfo/";
diff --git a/pkgs/development/web/nodejs/default-arch.patch b/pkgs/development/web/nodejs/default-arch.patch
deleted file mode 100644
index 3c7eb1014de..00000000000
--- a/pkgs/development/web/nodejs/default-arch.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -Naur a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py
---- a/tools/gyp/pylib/gyp/xcode_emulation.py	2014-01-23 06:05:51.000000000 +0100
-+++ b/tools/gyp/pylib/gyp/xcode_emulation.py	2014-02-04 17:49:48.000000000 +0100
-@@ -1018,12 +1033,16 @@
-     # Since the value returned by this function is only used when ARCHS is not
-     # set, then on iOS we return "i386", as the default xcode project generator
-     # does not set ARCHS if it is not set in the .gyp file.
--    if self.isIOS:
-+    
-+    try:
-+      if self.isIOS:
-+        return 'i386'
-+      version, build = self._XcodeVersion()
-+      if version >= '0500':
-+        return 'x86_64'
-       return 'i386'
--    version, build = self._XcodeVersion()
--    if version >= '0500':
-+    except:
-       return 'x86_64'
--    return 'i386'
- 
- class MacPrefixHeader(object):
-   """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature.
diff --git a/pkgs/development/web/nodejs/default.nix b/pkgs/development/web/nodejs/default.nix
index 2a4a7244d4d..1bd8dbec1e6 100644
--- a/pkgs/development/web/nodejs/default.nix
+++ b/pkgs/development/web/nodejs/default.nix
@@ -38,13 +38,12 @@ in stdenv.mkDerivation {
   dontDisableStatic = true;
   prePatch = ''
     patchShebangs .
-    sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' tools/gyp/pylib/gyp/xcode_emulation.py
   '';
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [ ./no-xcode.patch ./pkg-libpath.patch ];
+  patches = stdenv.lib.optional stdenv.isDarwin ./no-xcode.patch;
 
-  buildInputs = [ python which zlib libuv openssl python ]
-    ++ optionals stdenv.isLinux [ utillinux http-parser ]
+  buildInputs = [ python which http-parser zlib libuv openssl python ]
+    ++ (optional stdenv.isLinux utillinux)
     ++ optionals stdenv.isDarwin [ pkgconfig openssl libtool ];
   setupHook = ./setup-hook.sh;
 
diff --git a/pkgs/development/web/nodejs/no-xcode-4.1.0.patch b/pkgs/development/web/nodejs/no-xcode-4.1.0.patch
new file mode 100644
index 00000000000..137158b01b7
--- /dev/null
+++ b/pkgs/development/web/nodejs/no-xcode-4.1.0.patch
@@ -0,0 +1,95 @@
+diff --git a/configure b/configure
+index d199975..66d903b 100755
+--- a/configure
++++ b/configure
+@@ -734,7 +734,7 @@ def configure_library(lib, output):
+     # libpath needs to be provided ahead libraries
+     if pkg_libpath:
+       output['libraries'] += (
+-          filter(None, map(str.strip, pkg_cflags.split('-L'))))
++          pkg_libpath.split())
+ 
+     default_libs = getattr(options, shared_lib + '_libname')
+     default_libs = map('-l{0}'.format, default_libs.split(','))
+diff --git a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py
+index c002b11..fefb765 100644
+--- a/tools/gyp/pylib/gyp/xcode_emulation.py
++++ b/tools/gyp/pylib/gyp/xcode_emulation.py
+@@ -446,10 +446,17 @@ class XcodeSettings(object):
+ 
+   def _XcodeSdkPath(self, sdk_root):
+     if sdk_root not in XcodeSettings._sdk_path_cache:
+-      sdk_path = self._GetSdkVersionInfoItem(sdk_root, 'Path')
+-      XcodeSettings._sdk_path_cache[sdk_root] = sdk_path
+-      if sdk_root:
+-        XcodeSettings._sdk_root_cache[sdk_path] = sdk_root
++      try:
++        sdk_path = self._GetSdkVersionInfoItem(sdk_root, 'Path')
++        XcodeSettings._sdk_path_cache[sdk_root] = sdk_path
++        if sdk_root:
++          XcodeSettings._sdk_root_cache[sdk_path] = sdk_root
++      except:
++        # if this fails it's because xcodebuild failed, which means
++        # the user is probably on a CLT-only system, where there
++        # is no valid SDK root
++        XcodeSettings._sdk_path_cache[sdk_root] = None
++        
+     return XcodeSettings._sdk_path_cache[sdk_root]
+ 
+   def _AppendPlatformVersionMinFlags(self, lst):
+@@ -572,10 +579,12 @@ class XcodeSettings(object):
+       framework_root = sdk_root
+     else:
+       framework_root = ''
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
++    
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
+ 
+     self.configname = None
+     return cflags
+@@ -826,10 +835,12 @@ class XcodeSettings(object):
+     sdk_root = self._SdkPath()
+     if not sdk_root:
+       sdk_root = ''
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
++    
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
+ 
+     is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
+     if sdk_root and is_extension:
+@@ -1032,7 +1043,11 @@ class XcodeSettings(object):
+     sdk_root = self._SdkPath(config_name)
+     if not sdk_root:
+       sdk_root = ''
+-    return l.replace('$(SDKROOT)', sdk_root)
++    
++    if self._SdkPath():
++      return l.replace('$(SDKROOT)', sdk_root)
++    else:
++      return l
+ 
+   def AdjustLibraries(self, libraries, config_name=None):
+     """Transforms entries like 'Cocoa.framework' in libraries into entries like
+@@ -1248,7 +1263,7 @@ def XcodeVersion():
+     if version:
+       version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
+     else:
+-      raise GypError("No Xcode or CLT version detected!")
++      version = "7.0.0"
+     # The CLT has no build information, so we return an empty string.
+     version_list = [version, '']
+   version = version_list[0]
diff --git a/pkgs/development/web/nodejs/no-xcode.patch b/pkgs/development/web/nodejs/no-xcode.patch
index 244a55e9aeb..e88168b68a7 100644
--- a/pkgs/development/web/nodejs/no-xcode.patch
+++ b/pkgs/development/web/nodejs/no-xcode.patch
@@ -70,3 +70,24 @@ diff -Naur a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_
  
    def AdjustLibraries(self, libraries, config_name=None):
      """Transforms entries like 'Cocoa.framework' in libraries into entries like
+@@ -1018,12 +1033,16 @@
+     # Since the value returned by this function is only used when ARCHS is not
+     # set, then on iOS we return "i386", as the default xcode project generator
+     # does not set ARCHS if it is not set in the .gyp file.
+-    if self.isIOS:
++    
++    try:
++      if self.isIOS:
++        return 'i386'
++      version, build = self._XcodeVersion()
++      if version >= '0500':
++        return 'x86_64'
+       return 'i386'
+-    version, build = self._XcodeVersion()
+-    if version >= '0500':
++    except:
+       return 'x86_64'
+-    return 'i386'
+ 
+ class MacPrefixHeader(object):
+   """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature.
diff --git a/pkgs/development/web/nodejs/pkg-libpath.patch b/pkgs/development/web/nodejs/pkg-libpath.patch
deleted file mode 100644
index 8ad94c0e3e2..00000000000
--- a/pkgs/development/web/nodejs/pkg-libpath.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/configure b/configure
-index d199975..66d903b 100755
---- a/configure
-+++ b/configure
-@@ -734,7 +734,7 @@ def configure_library(lib, output):
-     # libpath needs to be provided ahead libraries
-     if pkg_libpath:
-       output['libraries'] += (
--          filter(None, map(str.strip, pkg_cflags.split('-L'))))
-+          pkg_libpath.split())
- 
-     default_libs = getattr(options, shared_lib + '_libname')
-     default_libs = map('-l{0}'.format, default_libs.split(','))
diff --git a/pkgs/development/web/nodejs/v0_10.nix b/pkgs/development/web/nodejs/v0_10.nix
index a5ee621de34..838f1419f2c 100644
--- a/pkgs/development/web/nodejs/v0_10.nix
+++ b/pkgs/development/web/nodejs/v0_10.nix
@@ -42,7 +42,7 @@ in stdenv.mkDerivation {
     patchShebangs .
   '';
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [ ./default-arch.patch ./no-xcode.patch ];
+  patches = stdenv.lib.optional stdenv.isDarwin ./no-xcode.patch;
 
   postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
     (cd tools/gyp; patch -Np1 -i ${../../python-modules/gyp/no-darwin-cflags.patch})
diff --git a/pkgs/development/web/nodejs/v4_1_0.nix b/pkgs/development/web/nodejs/v4_1_0.nix
new file mode 100644
index 00000000000..de8fa5f6bd3
--- /dev/null
+++ b/pkgs/development/web/nodejs/v4_1_0.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl, openssl, python, zlib, libuv, v8, utillinux, http-parser
+, pkgconfig, runCommand, which, libtool
+}:
+
+let
+  version = "4.1.0";
+
+  deps = {
+    inherit openssl zlib libuv;
+
+    # disabled system v8 because v8 3.14 no longer receives security fixes
+    # we fall back to nodejs' internal v8 copy which receives backports for now
+    # inherit v8
+  } // (stdenv.lib.optionalAttrs (!stdenv.isDarwin) {
+    inherit http-parser;
+  });
+
+  inherit (stdenv.lib) concatMap optional optionals maintainers licenses platforms;
+in stdenv.mkDerivation {
+  name = "nodejs-${version}";
+
+  src = fetchurl {
+    url = "http://nodejs.org/dist/v${version}/node-v${version}.tar.gz";
+    sha256 = "025lqmhvl7xpx1ip97jwkz21a97sw9zb4zi3y7fgfag59vv0ac25";
+  };
+
+  configureFlags = map (name: "--shared-${name}") (builtins.attrNames deps) ++ [ "--without-dtrace" ];
+
+  dontDisableStatic = true;
+
+  prePatch = ''
+    patchShebangs .
+  '';
+
+  patches = stdenv.lib.optional stdenv.isDarwin ./no-xcode-4.1.0.patch;
+
+  buildInputs = [ python which ] ++ (builtins.attrValues deps)
+    ++ optional stdenv.isLinux utillinux
+    ++ optionals stdenv.isDarwin [ openssl libtool ];
+  setupHook = ./setup-hook.sh;
+
+  enableParallelBuilding = true;
+
+  passthru.interpreterName = "nodejs";
+
+  meta = {
+    description = "Event-driven I/O framework for the V8 JavaScript engine";
+    homepage = http://nodejs.org;
+    license = licenses.mit;
+    maintainers = [ maintainers.goibhniu maintainers.havvy ];
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/pkgs/misc/jackaudio/jack1.nix b/pkgs/misc/jackaudio/jack1.nix
index 4250efcb6a2..1c5c78548f5 100644
--- a/pkgs/misc/jackaudio/jack1.nix
+++ b/pkgs/misc/jackaudio/jack1.nix
@@ -27,8 +27,7 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ optAlsaLib optDb optLibffado optCelt ];
-  propagatedBuildInputs = [ optLibuuid ];
+  buildInputs = [ optAlsaLib optDb optLibuuid optLibffado optCelt ];
   
   meta = with stdenv.lib; {
     description = "JACK audio connection kit";
diff --git a/pkgs/misc/urbit/default.nix b/pkgs/misc/urbit/default.nix
deleted file mode 100644
index e4049f07897..00000000000
--- a/pkgs/misc/urbit/default.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{ stdenv, fetchgit, gcc, gmp, libsigsegv, openssl, automake, autoconf, ragel,
-  cmake, re2c, libtool, ncurses, perl, zlib, python }:
-
-stdenv.mkDerivation rec {
-
-  name = "urbit-${version}";
-  version = "2015.09.26";
-
-  src = fetchgit {
-    url = "https://github.com/urbit/urbit.git";
-    rev = "c9592664c797b2dd74f26886528656f8a7058640";
-    sha256 = "0sgrxnmpqh54mgar81wlb6gff8c0pc24p53xwxr448g5shvnzjx9";
-  };
-
-  buildInputs = with stdenv.lib; [
-    gcc gmp libsigsegv openssl automake autoconf ragel cmake re2c libtool
-    ncurses perl zlib python
-  ];
-
-  configurePhase = ''
-    :
-  '';
-
-  buildPhase = ''
-    sed -i 's/-lcurses/-lncurses/' Makefile
-    mkdir -p $out
-    cp -r . $out/
-    cd $out
-    make
-  '';
-
-  installPhase = ''
-    :
-  '';
-
-  meta = with stdenv.lib; {
-    description = "an operating function";
-    homepage = http://urbit.org/preview/~2015.9.25/materials;
-    license = licenses.mit;
-    maintainers = with maintainers; [ mudri ];
-  };
-}
diff --git a/pkgs/os-specific/linux/kernel-headers/3.14.nix b/pkgs/os-specific/linux/kernel-headers/3.14.nix
deleted file mode 100644
index d9d0ce7e3b3..00000000000
--- a/pkgs/os-specific/linux/kernel-headers/3.14.nix
+++ /dev/null
@@ -1,71 +0,0 @@
-{ stdenv, fetchurl, perl, cross ? null }:
-
-assert cross == null -> stdenv.isLinux;
-
-let
-
-  version = "3.14.1";
-
-  kernelHeadersBaseConfig =
-    if cross == null
-    then stdenv.platform.kernelHeadersBaseConfig
-    else cross.platform.kernelHeadersBaseConfig;
-
-in
-
-stdenv.mkDerivation {
-  name = "linux-headers-${version}";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1njm8gvlj7cq0m1051yxszl4f63383a7sv1na13hkqkv36kipgqx";
-  };
-
-  targetConfig = if cross != null then cross.config else null;
-
-  platform =
-    if cross != null then cross.platform.kernelArch else
-    if stdenv.system == "i686-linux" then "i386" else
-    if stdenv.system == "x86_64-linux" then "x86_64" else
-    if stdenv.system == "powerpc-linux" then "powerpc" else
-    if stdenv.isArm then "arm" else
-    if stdenv.platform ? kernelArch then stdenv.platform.kernelArch else
-    abort "don't know what the kernel include directory is called for this platform";
-
-  buildInputs = [perl];
-
-  extraIncludeDirs =
-    if cross != null then
-        (if cross.arch == "powerpc" then ["ppc"] else [])
-    else if stdenv.system == "powerpc-linux" then ["ppc"] else [];
-
-  buildPhase = ''
-    if test -n "$targetConfig"; then
-       export ARCH=$platform
-    fi
-    make ${kernelHeadersBaseConfig} SHELL=bash
-    make mrproper headers_check SHELL=bash
-  '';
-
-  installPhase = ''
-    make INSTALL_HDR_PATH=$out headers_install
-
-    # Some builds (e.g. KVM) want a kernel.release.
-    mkdir -p $out/include/config
-    echo "${version}-default" > $out/include/config/kernel.release
-  '';
-
-  # !!! hacky
-  fixupPhase = ''
-    ln -s asm $out/include/asm-$platform
-    if test "$platform" = "i386" -o "$platform" = "x86_64"; then
-      ln -s asm $out/include/asm-x86
-    fi
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Header files and scripts for Linux kernel";
-    license = licenses.gpl2;
-    platforms = platforms.linux;
-  };
-}
diff --git a/pkgs/os-specific/linux/kernel-headers/3.12.nix b/pkgs/os-specific/linux/kernel-headers/3.18.nix
index 2fd34c68edc..0cc38a0548c 100644
--- a/pkgs/os-specific/linux/kernel-headers/3.12.nix
+++ b/pkgs/os-specific/linux/kernel-headers/3.18.nix
@@ -4,7 +4,7 @@ assert cross == null -> stdenv.isLinux;
 
 let
 
-  version = "3.12.32";
+  version = "3.18.14";
 
   kernelHeadersBaseConfig =
     if cross == null
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1hzws2bf267hfk81ywqcxspkyi1lg56x63izdc0pv1338xcfas53";
+    sha256 = "1xh0vvn1l2g1kkg54f0mg0inbpsiqs24ybgsakksmcpcadjgqk1i";
   };
 
   targetConfig = if cross != null then cross.config else null;
diff --git a/pkgs/os-specific/linux/kernel/linux-3.10.nix b/pkgs/os-specific/linux/kernel/linux-3.10.nix
deleted file mode 100644
index a231b551dc0..00000000000
--- a/pkgs/os-specific/linux/kernel/linux-3.10.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "3.10.92";
-  extraMeta.branch = "3.10";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "0z0jdix1mfpnnc8cxw7rzpnhxdayckpnrasvxi1qf0dwhcqgk92d";
-  };
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-})
diff --git a/pkgs/os-specific/linux/kernel/linux-3.12.nix b/pkgs/os-specific/linux/kernel/linux-3.12.nix
deleted file mode 100644
index 7ed6cd142d1..00000000000
--- a/pkgs/os-specific/linux/kernel/linux-3.12.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "3.12.50";
-  extraMeta.branch = "3.12";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1bn07wsrcbg4qgqd4v2810c3qc0ifbcza0fyj8s54yd78g9qj4lj";
-  };
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-})
diff --git a/pkgs/os-specific/linux/kernel/linux-3.14.nix b/pkgs/os-specific/linux/kernel/linux-3.14.nix
deleted file mode 100644
index afb4437459b..00000000000
--- a/pkgs/os-specific/linux/kernel/linux-3.14.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "3.14.56";
-  # Remember to update grsecurity!
-  extraMeta.branch = "3.14";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1ggvjrz51nfhj7amn3v2nd0b0x8dnz68k9cldzl729cqp9gsc3hf";
-  };
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-} // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/libcap-ng/default.nix b/pkgs/os-specific/linux/libcap-ng/default.nix
index 3670f06e543..ea54f1a39fd 100644
--- a/pkgs/os-specific/linux/libcap-ng/default.nix
+++ b/pkgs/os-specific/linux/libcap-ng/default.nix
@@ -1,22 +1,40 @@
-{ stdenv, fetchurl, python }:
+{ stdenv, fetchurl, swig ? null, python2 ? null, python3 ? null }:
 
-assert stdenv.isLinux;
+assert python2 != null || python3 != null -> swig != null;
 
 stdenv.mkDerivation rec {
   name = "libcap-ng-${version}";
-  version = "0.7.3";
+  # When updating make sure to test that the version with
+  # all of the python bindings still works
+  version = "0.7.7";
 
   src = fetchurl {
     url = "${meta.homepage}/${name}.tar.gz";
-    sha256 = "1cavlcrpqi4imkmagjhw65br8rv2fsbhf68mm3lczr51sg44392w";
+    sha256 = "0syhyrixk7fqvwis3k7iddn75g0qxysc1q5fifvzccxk7774jmb1";
   };
 
-  buildInputs = [ python ]; # ToDo? optional swig for python bindings
+  nativeBuildInputs = [ swig ];
+  buildInputs = [ python2 python3 ];
 
-  meta = {
+  postPatch = ''
+    function get_header() {
+      echo -e "#include <$1>" | gcc -M -xc - | tr ' ' '\n' | grep "$1" | head -n 1
+    }
+
+    # Fix some hardcoding of header paths
+    sed -i "s,/usr/include/linux/capability.h,$(get_header linux/capability.h),g" bindings/python{,3}/Makefile.in
+  '';
+
+  configureFlags = [
+    (if python2 != null then "--with-python" else "--without-python")
+    (if python3 != null then "--with-python3" else "--without-python3")
+  ];
+
+  meta = let inherit (stdenv.lib) platforms licenses maintainers; in {
     description = "Library for working with POSIX capabilities";
     homepage = http://people.redhat.com/sgrubb/libcap-ng/;
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.lgpl21;
+    platforms = platforms.linux;
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ wkennington ];
   };
 }
diff --git a/pkgs/os-specific/linux/miraclecast/default.nix b/pkgs/os-specific/linux/miraclecast/default.nix
deleted file mode 100644
index 3d5a76144af..00000000000
--- a/pkgs/os-specific/linux/miraclecast/default.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, udev, systemd, glib, readline }:
-
-with stdenv.lib;
-stdenv.mkDerivation rec {
-  name = "miraclecast-0.0-git-20151002";
-
-  src = fetchFromGitHub {
-    owner = "albfan";
-    repo = "miraclecast";
-    rev = "30b8c2d22391423f76ba582aaaa1e0936869103a";
-    sha256 = "0i076n76kq64fayc7v06gr1853pk5r6ms86m57vd1xsjd0r9wyxd";
-  };
-
-  # INFO: It is important to list 'systemd' first as for now miraclecast
-  # links against a customized systemd. Otherwise, a systemd package from
-  # a propagatedBuildInput could take precedence.
-  buildInputs = [ systemd autoreconfHook pkgconfig udev glib readline ];
-
-  meta = {
-    homepage = https://github.com/albfan/miraclecast;
-    description = "Connect external monitors via Wi-Fi";
-    license = licenses.lgpl21Plus;
-    maintainers = with maintainers; [ tstrobel ];
-    platforms = platforms.linux;
-  };
-}
diff --git a/pkgs/os-specific/linux/nvidiabl/default.nix b/pkgs/os-specific/linux/nvidiabl/default.nix
index a6797608664..a5a43926e04 100644
--- a/pkgs/os-specific/linux/nvidiabl/default.nix
+++ b/pkgs/os-specific/linux/nvidiabl/default.nix
@@ -8,8 +8,6 @@ stdenv.mkDerivation {
     sha256 = "1c7ar39wc8jpqh67sw03lwnyp0m9l6dad469ybqrgcywdiwxspwj";
   };
 
-  patches = [ ./linux4compat.patch ];
-
   preConfigure = ''
     sed -i 's|/sbin/depmod|#/sbin/depmod|' Makefile
   '';
diff --git a/pkgs/os-specific/linux/nvidiabl/linux4compat.patch b/pkgs/os-specific/linux/nvidiabl/linux4compat.patch
deleted file mode 100644
index ad8236a2b63..00000000000
--- a/pkgs/os-specific/linux/nvidiabl/linux4compat.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 2bf6f08b2492cc04a2c39fdcb22a2d0c18963d1c Mon Sep 17 00:00:00 2001
-From: sonic414 <sonic414@gmail.com>
-Date: Tue, 28 Apr 2015 19:30:15 +0530
-Subject: [PATCH] strnicmp to strncasecmp in Linux 4.0.0
-
----
- nvidiabl-module.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/nvidiabl-module.c b/nvidiabl-module.c
-index b789ea4..b306579 100644
---- a/nvidiabl-module.c
-+++ b/nvidiabl-module.c
-@@ -214,7 +214,7 @@ static int __init nvidiabl_init(void)
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- 	
- 	for (iii = 0 ; iii < sizeof(backlight_type_ids) ; iii++) {
--		if (strnicmp(bl_type, backlight_type_ids[iii].id, sizeof(bl_type)) == 0) {
-+		if (strncasecmp(bl_type, backlight_type_ids[iii].id, sizeof(bl_type)) == 0) {
- 			props.type = backlight_type_ids[iii].type;
- 			printk(KERN_INFO "nvidiabl: backlight type is %s\n", backlight_type_ids[iii].id);
- 		}
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index 5e458693799..b4588e3d17f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -1,9 +1,9 @@
-{ stdenv, fetchurl, pkgconfig, intltool, gperf, libcap, dbus, kmod
+{ stdenv, fetchFromGitHub, pkgconfig, intltool, gperf, libcap, dbus, kmod
 , xz, pam, acl, cryptsetup, libuuid, m4, utillinux
 , glib, kbd, libxslt, coreutils, libgcrypt
-, kexectools, libmicrohttpd, linuxHeaders
+, kexectools, libmicrohttpd, linuxHeaders, libseccomp
+, autoreconfHook, gettext, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45
 , pythonPackages ? null, pythonSupport ? false
-, enableKDbus ? false
 }:
 
 assert stdenv.isLinux;
@@ -11,24 +11,26 @@ assert stdenv.isLinux;
 assert pythonSupport -> pythonPackages != null;
 
 stdenv.mkDerivation rec {
-  version = "217";
+  version = "227";
   name = "systemd-${version}";
 
-  src = fetchurl {
-    url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz";
-    sha256 = "163l1y4p2a564d4ynfq3k3xf53j2v5s81blb6cvpn1y7rpxyccd0";
+  src = fetchFromGitHub {
+    owner = "NixOS";
+    repo = "systemd";
+    rev = "7d94d27801d20278103d8c146633fe81e06697d6";
+    sha256 = "0cvzsrazqgbia3zajb0z4ik8myfil4bdy2c29qs6w93d6yvrjfkj";
   };
 
-  patches =
-    [ # These are all changes between upstream and
-      # https://github.com/NixOS/systemd/tree/nixos-v217.
-      ./fixes.patch
-    ];
+  outputs = [ "out" "man" "doc" ];
 
   buildInputs =
-    [ pkgconfig intltool gperf libcap kmod xz pam acl
+    [ linuxHeaders pkgconfig intltool gperf libcap kmod xz pam acl
       /* cryptsetup */ libuuid m4 glib libxslt libgcrypt
-      libmicrohttpd linuxHeaders
+      libmicrohttpd kexectools libseccomp
+      /* FIXME: we may be able to prevent the following dependencies
+         by generating an autoconf'd tarball, but that's probably not
+         worth it. */
+      autoreconfHook gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
     ] ++ stdenv.lib.optionals pythonSupport [pythonPackages.python pythonPackages.lxml];
 
   configureFlags =
@@ -38,7 +40,6 @@ stdenv.mkDerivation rec {
       "--with-kbd-loadkeys=${kbd}/bin/loadkeys"
       "--with-kbd-setfont=${kbd}/bin/setfont"
       "--with-rootprefix=$(out)"
-      "--with-dbusinterfacedir=$(out)/share/dbus-1/interfaces"
       "--with-dbuspolicydir=$(out)/etc/dbus-1/system.d"
       "--with-dbussystemservicedir=$(out)/share/dbus-1/system-services"
       "--with-dbussessionservicedir=$(out)/share/dbus-1/services"
@@ -51,22 +52,27 @@ stdenv.mkDerivation rec {
       "--disable-sysusers"
       "--disable-timedated"
       "--enable-timesyncd"
-      "--disable-readahead"
       "--disable-firstboot"
       "--disable-localed"
       "--enable-resolved"
       "--disable-split-usr"
+      "--disable-libcurl"
+      "--disable-libidn"
+      "--disable-quotacheck"
+      "--disable-ldconfig"
+      "--disable-smack"
 
       "--with-sysvinit-path="
       "--with-sysvrcnd-path="
       "--with-rc-local-script-path-stop=/etc/halt.local"
-    ] ++ stdenv.lib.optional enableKDbus "--enable-kdbus";
+    ];
 
   preConfigure =
     ''
+      ./autogen.sh
+
       # FIXME: patch this in systemd properly (and send upstream).
-      # FIXME: use sulogin from util-linux once updated.
-      for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/core/shutdown.c src/nspawn/nspawn.c; do
+      for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/core/shutdown.c src/nspawn/nspawn.c src/shared/generator.c; do
         test -e $i
         substituteInPlace $i \
           --replace /usr/bin/getent ${stdenv.glibc}/bin/getent \
@@ -77,7 +83,7 @@ stdenv.mkDerivation rec {
           --replace /bin/echo ${coreutils}/bin/echo \
           --replace /bin/cat ${coreutils}/bin/cat \
           --replace /sbin/sulogin ${utillinux}/sbin/sulogin \
-          --replace /sbin/kexec ${kexectools}/sbin/kexec
+          --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck
       done
 
       substituteInPlace src/journal/catalog.c \
@@ -86,10 +92,6 @@ stdenv.mkDerivation rec {
       configureFlagsArray+=("--with-ntp-servers=0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org")
     '';
 
-  # This is needed because systemd uses the gold linker, which doesn't
-  # yet have the wrapper script to add rpath flags automatically.
-  NIX_LDFLAGS = "-rpath ${pam}/lib -rpath ${libcap}/lib -rpath ${acl}/lib -rpath ${stdenv.cc.cc}/lib";
-
   PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python
 
   NIX_CFLAGS_COMPILE =
@@ -147,6 +149,11 @@ stdenv.mkDerivation rec {
       done
 
       rm -rf $out/etc/rpm
+
+      rm $out/lib/*.la
+
+      # "kernel-install" shouldn't be used on NixOS.
+      find $out -name "*kernel-install*" -exec rm {} \;
     ''; # */
 
   enableParallelBuilding = true;
diff --git a/pkgs/os-specific/linux/systemd/fixes.patch b/pkgs/os-specific/linux/systemd/fixes.patch
deleted file mode 100644
index 2997c02d26d..00000000000
--- a/pkgs/os-specific/linux/systemd/fixes.patch
+++ /dev/null
@@ -1,2569 +0,0 @@
-diff --git a/rules/99-systemd.rules.in b/rules/99-systemd.rules.in
-index e30d9a8..a3d399b 100644
---- a/rules/99-systemd.rules.in
-+++ b/rules/99-systemd.rules.in
-@@ -14,10 +14,6 @@ KERNEL=="vport*", TAG+="systemd"
- SUBSYSTEM=="block", KERNEL!="ram*", TAG+="systemd"
- SUBSYSTEM=="block", KERNEL!="ram*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", ENV{SYSTEMD_READY}="0"
- 
--# Ignore encrypted devices with no identified superblock on it, since
--# we are probably still calling mke2fs or mkswap on it.
--SUBSYSTEM=="block", KERNEL!="ram*", ENV{DM_UUID}=="CRYPT-*", ENV{ID_PART_TABLE_TYPE}=="", ENV{ID_FS_USAGE}=="", ENV{SYSTEMD_READY}="0"
--
- # Ignore raid devices that are not yet assembled and started
- SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", TEST!="md/array_state", ENV{SYSTEMD_READY}="0"
- SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0"
-diff --git a/src/core/job.c b/src/core/job.c
-index eaa4bb1..db44fee 100644
---- a/src/core/job.c
-+++ b/src/core/job.c
-@@ -352,6 +352,9 @@ bool job_type_is_redundant(JobType a, UnitActiveState b) {
-                 return
-                         b == UNIT_ACTIVATING;
- 
-+        case JOB_NOP:
-+                return true;
-+
-         default:
-                 assert_not_reached("Invalid job type");
-         }
-diff --git a/src/core/job.h b/src/core/job.h
-index 1e7c61b..ee8e54a 100644
---- a/src/core/job.h
-+++ b/src/core/job.h
-@@ -49,9 +49,11 @@ enum JobType {
-         _JOB_TYPE_MAX_MERGING,
- 
-         /* JOB_NOP can enter into a transaction, but as it won't pull in
--         * any dependencies, it won't have to merge with anything.
--         * job_install() avoids the problem of merging JOB_NOP too (it's
--         * special-cased, only merges with other JOB_NOPs). */
-+         * any dependencies and it uses the special 'nop_job' slot in Unit,
-+         * it won't have to merge with anything (except possibly into another
-+         * JOB_NOP, previously installed). JOB_NOP is special-cased in
-+         * job_type_is_*() functions so that the transaction can be
-+         * activated. */
-         JOB_NOP = _JOB_TYPE_MAX_MERGING, /* do nothing */
- 
-         _JOB_TYPE_MAX_IN_TRANSACTION,
-@@ -190,11 +192,15 @@ _pure_ static inline bool job_type_is_mergeable(JobType a, JobType b) {
- }
- 
- _pure_ static inline bool job_type_is_conflicting(JobType a, JobType b) {
--        return !job_type_is_mergeable(a, b);
-+        return a != JOB_NOP && b != JOB_NOP && !job_type_is_mergeable(a, b);
- }
- 
- _pure_ static inline bool job_type_is_superset(JobType a, JobType b) {
-         /* Checks whether operation a is a "superset" of b in its actions */
-+        if (b == JOB_NOP)
-+                return true;
-+        if (a == JOB_NOP)
-+                return false;
-         return a == job_type_lookup_merge(a, b);
- }
- 
-diff --git a/src/core/manager.c b/src/core/manager.c
-index d427d88..256d6f7 100644
---- a/src/core/manager.c
-+++ b/src/core/manager.c
-@@ -662,9 +662,11 @@ static int manager_setup_notify(Manager *m) {
-                         return -errno;
-                 }
- 
--                if (m->running_as == SYSTEMD_SYSTEM)
-+                if (m->running_as == SYSTEMD_SYSTEM) {
-                         m->notify_socket = strdup("/run/systemd/notify");
--                else {
-+                        if (!m->notify_socket)
-+                                return log_oom();
-+                } else {
-                         const char *e;
- 
-                         e = getenv("XDG_RUNTIME_DIR");
-@@ -674,9 +676,11 @@ static int manager_setup_notify(Manager *m) {
-                         }
- 
-                         m->notify_socket = strappend(e, "/systemd/notify");
-+                        if (!m->notify_socket)
-+                                return log_oom();
-+
-+                        mkdir_parents_label(m->notify_socket, 0755);
-                 }
--                if (!m->notify_socket)
--                        return log_oom();
- 
-                 strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
-                 r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
-diff --git a/src/core/shutdown.c b/src/core/shutdown.c
-index 20cf526..03cfddc 100644
---- a/src/core/shutdown.c
-+++ b/src/core/shutdown.c
-@@ -75,7 +75,9 @@ static int parse_argv(int argc, char *argv[]) {
-         assert(argc >= 1);
-         assert(argv);
- 
--        while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0)
-+        /* "-" prevents getopt from permuting argv[] and moving the verb away
-+         * from argv[1]. Our interface to initrd promises it'll be there. */
-+        while ((c = getopt_long(argc, argv, "-", options, NULL)) >= 0)
-                 switch (c) {
- 
-                 case ARG_LOG_LEVEL:
-@@ -113,6 +115,13 @@ static int parse_argv(int argc, char *argv[]) {
- 
-                         break;
- 
-+                case '\001':
-+                        if (!arg_verb)
-+                                arg_verb = optarg;
-+                        else
-+                                log_error("Excess arguments, ignoring");
-+                        break;
-+
-                 case '?':
-                         return -EINVAL;
- 
-@@ -120,15 +129,11 @@ static int parse_argv(int argc, char *argv[]) {
-                         assert_not_reached("Unhandled option code.");
-                 }
- 
--        if (optind >= argc) {
-+        if (!arg_verb) {
-                 log_error("Verb argument missing.");
-                 return -EINVAL;
-         }
- 
--        arg_verb = argv[optind];
--
--        if (optind + 1 < argc)
--                log_error("Excess arguments, ignoring");
-         return 0;
- }
- 
-diff --git a/src/core/snapshot.c b/src/core/snapshot.c
-index 5eed615..c2678cb 100644
---- a/src/core/snapshot.c
-+++ b/src/core/snapshot.c
-@@ -208,7 +208,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e,
-                         return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s lacks snapshot suffix.", name);
- 
-                 if (manager_get_unit(m, name))
--                        sd_bus_error_setf(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name);
-+                        return sd_bus_error_setf(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name);
- 
-         } else {
- 
-diff --git a/src/core/systemd.pc.in b/src/core/systemd.pc.in
-index d5b86bf..9c66e7b 100644
---- a/src/core/systemd.pc.in
-+++ b/src/core/systemd.pc.in
-@@ -14,8 +14,8 @@ systemduserunitdir=@userunitdir@
- systemduserpresetdir=@userpresetdir@
- systemdsystemconfdir=@pkgsysconfdir@/system
- systemduserconfdir=@pkgsysconfdir@/user
--systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:${systemdsystemunitdir}:/usr/lib/systemd/system:/lib/systemd/system
--systemduserunitpath=${systemduserconfdir}:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:${systemduserunitdir}:/usr/lib/systemd/user:/usr/share/systemd/user
-+systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:/etc/systemd-mutable/system:/nix/var/nix/profiles/default/lib/systemd/user:/run/systemd/system:${systemdsystemunitdir}
-+systemduserunitpath=${systemduserconfdir}:/etc/systemd/user:/etc/systemd-mutable/user:/nix/var/nix/profiles/default/lib/systemd/system:/run/systemd/user:${systemduserunitdir}
- systemdsystemgeneratordir=@systemgeneratordir@
- systemdusergeneratordir=@usergeneratordir@
- systemdsleepdir=@systemsleepdir@
-diff --git a/src/core/timer.c b/src/core/timer.c
-index a3713e2..5c4e9f9 100644
---- a/src/core/timer.c
-+++ b/src/core/timer.c
-@@ -521,6 +521,7 @@ fail:
- 
- static int timer_start(Unit *u) {
-         Timer *t = TIMER(u);
-+        TimerValue *v;
- 
-         assert(t);
-         assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
-@@ -530,6 +531,11 @@ static int timer_start(Unit *u) {
- 
-         t->last_trigger = DUAL_TIMESTAMP_NULL;
- 
-+        /* Reenable all timers that depend on unit activation time */
-+        LIST_FOREACH(value, v, t->values)
-+                if (v->base == TIMER_ACTIVE)
-+                        v->disabled = false;
-+
-         if (t->stamp_path) {
-                 struct stat st;
- 
-diff --git a/src/core/umount.c b/src/core/umount.c
-index cffa453..4d1a9ff 100644
---- a/src/core/umount.c
-+++ b/src/core/umount.c
-@@ -385,6 +385,8 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e
-                  * anyway, since we are running from it. They have
-                  * already been remounted ro. */
-                 if (path_equal(m->path, "/")
-+                    || path_equal(m->path, "/nix")
-+                    || path_equal(m->path, "/nix/store")
- #ifndef HAVE_SPLIT_USR
-                     || path_equal(m->path, "/usr")
- #endif
-diff --git a/src/delta/delta.c b/src/delta/delta.c
-index 25c4a0b..e1f2d6d 100644
---- a/src/delta/delta.c
-+++ b/src/delta/delta.c
-@@ -487,7 +487,7 @@ static int parse_flags(const char *flag_str, int flags) {
-         const char *word, *state;
-         size_t l;
- 
--        FOREACH_WORD(word, l, flag_str, state) {
-+        FOREACH_WORD_SEPARATOR(word, l, flag_str, ",", state) {
-                 if (strneq("masked", word, l))
-                         flags |= SHOW_MASKED;
-                 else if (strneq ("equivalent", word, l))
-diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
-index 70a5918..a5661e8 100644
---- a/src/fsck/fsck.c
-+++ b/src/fsck/fsck.c
-@@ -315,8 +315,7 @@ int main(int argc, char *argv[]) {
-                         return EXIT_FAILURE;
-                 }
- 
--        cmdline[i++] = "/sbin/fsck";
--        cmdline[i++] =  arg_repair;
-+        cmdline[i++] = "/run/current-system/sw/bin/fsck";
-         cmdline[i++] = "-T";
- 
-         /*
-diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
-index e257c12..1e04553 100644
---- a/src/fstab-generator/fstab-generator.c
-+++ b/src/fstab-generator/fstab-generator.c
-@@ -485,7 +485,7 @@ static int add_usr_mount(void) {
-                         return log_oom();
-         }
- 
--        if (!arg_usr_what || !arg_usr_options)
-+        if (!arg_usr_what)
-                 return 0;
- 
-         what = fstab_node_to_udev_node(arg_usr_what);
-@@ -494,7 +494,13 @@ static int add_usr_mount(void) {
-                 return -1;
-         }
- 
--        opts = arg_usr_options;
-+        if (!arg_usr_options)
-+                opts = arg_root_rw > 0 ? "rw" : "ro";
-+        else if (!mount_test_option(arg_usr_options, "ro") &&
-+                 !mount_test_option(arg_usr_options, "rw"))
-+                opts = strappenda(arg_usr_options, ",", arg_root_rw > 0 ? "rw" : "ro");
-+        else
-+                opts = arg_usr_options;
- 
-         log_debug("Found entry what=%s where=/sysroot/usr type=%s", what, strna(arg_usr_fstype));
-         return add_mount(what,
-diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
-index e487369..ff4e9c9 100644
---- a/src/hostname/hostnamectl.c
-+++ b/src/hostname/hostnamectl.c
-@@ -536,5 +536,5 @@ int main(int argc, char *argv[]) {
-         r = hostnamectl_main(bus, argc, argv);
- 
- finish:
--        return r < 0 ? EXIT_FAILURE : r;
-+        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
- }
-diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
-index 7dd8878..70a9a13 100644
---- a/src/journal-remote/journal-remote-parse.c
-+++ b/src/journal-remote/journal-remote-parse.c
-@@ -344,22 +344,25 @@ int process_data(RemoteSource *source) {
-                    LLLLLLLL0011223344...\n
-                 */
-                 sep = memchr(line, '=', n);
--                if (sep)
-+                if (sep) {
-                         /* chomp newline */
-                         n--;
--                else
-+
-+                        r = iovw_put(&source->iovw, line, n);
-+                        if (r < 0)
-+                                return r;
-+                } else {
-                         /* replace \n with = */
-                         line[n-1] = '=';
--                log_trace("Received: %.*s", (int) n, line);
- 
--                r = iovw_put(&source->iovw, line, n);
--                if (r < 0) {
--                        log_error("Failed to put line in iovect");
--                        return r;
-+                        source->field_len = n;
-+                        source->state = STATE_DATA_START;
-+
-+                        /* we cannot put the field in iovec until we have all data */
-                 }
- 
--                if (!sep)
--                        source->state = STATE_DATA_START;
-+                log_trace("Received: %.*s (%s)", (int) n, line, sep ? "text" : "binary");
-+
-                 return 0; /* continue */
-         }
- 
-@@ -382,6 +385,7 @@ int process_data(RemoteSource *source) {
- 
-         case STATE_DATA: {
-                 void *data;
-+                char *field;
- 
-                 assert(source->data_size > 0);
- 
-@@ -396,11 +400,12 @@ int process_data(RemoteSource *source) {
- 
-                 assert(data);
- 
--                r = iovw_put(&source->iovw, data, source->data_size);
--                if (r < 0) {
--                        log_error("failed to put binary buffer in iovect");
-+                field = (char*) data - sizeof(uint64_t) - source->field_len;
-+                memmove(field + sizeof(uint64_t), field, source->field_len);
-+
-+                r = iovw_put(&source->iovw, field + sizeof(uint64_t), source->field_len + source->data_size);
-+                if (r < 0)
-                         return r;
--                }
- 
-                 source->state = STATE_DATA_FINISH;
- 
-diff --git a/src/journal-remote/journal-remote-parse.h b/src/journal-remote/journal-remote-parse.h
-index 8499f4e..22db550 100644
---- a/src/journal-remote/journal-remote-parse.h
-+++ b/src/journal-remote/journal-remote-parse.h
-@@ -42,7 +42,9 @@ typedef struct RemoteSource {
-         size_t offset;     /* offset to the beginning of live data in the buffer */
-         size_t scanned;    /* number of bytes since the beginning of data without a newline */
-         size_t filled;     /* total number of bytes in the buffer */
--        size_t data_size;  /* size of the binary data chunk being processed */
-+
-+        size_t field_len;  /* used for binary fields: the field name length */
-+        size_t data_size;  /* and the size of the binary data chunk being processed */
- 
-         struct iovec_wrapper iovw;
- 
-diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c
-index 5ab1982..1f980ee 100644
---- a/src/journal/journal-authenticate.c
-+++ b/src/journal/journal-authenticate.c
-@@ -229,7 +229,7 @@ int journal_file_maybe_append_tag(JournalFile *f, uint64_t realtime) {
-         return 0;
- }
- 
--int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p) {
-+int journal_file_hmac_put_object(JournalFile *f, ObjectType type, Object *o, uint64_t p) {
-         int r;
- 
-         assert(f);
-@@ -246,7 +246,7 @@ int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p
-                 if (r < 0)
-                         return r;
-         } else {
--                if (type >= 0 && o->object.type != type)
-+                if (type > OBJECT_UNUSED && o->object.type != type)
-                         return -EBADMSG;
-         }
- 
-diff --git a/src/journal/journal-authenticate.h b/src/journal/journal-authenticate.h
-index 0aaf836..565fe84 100644
---- a/src/journal/journal-authenticate.h
-+++ b/src/journal/journal-authenticate.h
-@@ -33,7 +33,7 @@ int journal_file_append_first_tag(JournalFile *f);
- int journal_file_hmac_setup(JournalFile *f);
- int journal_file_hmac_start(JournalFile *f);
- int journal_file_hmac_put_header(JournalFile *f);
--int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p);
-+int journal_file_hmac_put_object(JournalFile *f, ObjectType type, Object *o, uint64_t p);
- 
- int journal_file_fss_load(JournalFile *f);
- int journal_file_parse_verification_key(JournalFile *f, const char *key);
-diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
-index e55fa19..ab089cb 100644
---- a/src/journal/journal-def.h
-+++ b/src/journal/journal-def.h
-@@ -52,8 +52,8 @@ typedef struct HashItem HashItem;
- typedef struct FSSHeader FSSHeader;
- 
- /* Object types */
--enum {
--        OBJECT_UNUSED,
-+typedef enum ObjectType {
-+        OBJECT_UNUSED, /* also serves as "any type" or "additional context" */
-         OBJECT_DATA,
-         OBJECT_FIELD,
-         OBJECT_ENTRY,
-@@ -62,7 +62,7 @@ enum {
-         OBJECT_ENTRY_ARRAY,
-         OBJECT_TAG,
-         _OBJECT_TYPE_MAX
--};
-+} ObjectType;
- 
- /* Object flags */
- enum {
-diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
-index 8a2c0fc..c55a4dc 100644
---- a/src/journal/journal-file.c
-+++ b/src/journal/journal-file.c
-@@ -374,7 +374,13 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
-         return 0;
- }
- 
--static int journal_file_move_to(JournalFile *f, int context, bool keep_always, uint64_t offset, uint64_t size, void **ret) {
-+static unsigned type_to_context(ObjectType type) {
-+        /* One context for each type, plus one catch-all for the rest */
-+        assert_cc(_OBJECT_TYPE_MAX <= MMAP_CACHE_MAX_CONTEXTS);
-+        return type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX ? type : 0;
-+}
-+
-+static int journal_file_move_to(JournalFile *f, ObjectType type, bool keep_always, uint64_t offset, uint64_t size, void **ret) {
-         assert(f);
-         assert(ret);
- 
-@@ -391,7 +397,7 @@ static int journal_file_move_to(JournalFile *f, int context, bool keep_always, u
-                         return -EADDRNOTAVAIL;
-         }
- 
--        return mmap_cache_get(f->mmap, f->fd, f->prot, context, keep_always, offset, size, &f->last_stat, ret, NULL);
-+        return mmap_cache_get(f->mmap, f->fd, f->prot, type_to_context(type), keep_always, offset, size, &f->last_stat, ret);
- }
- 
- static uint64_t minimum_header_size(Object *o) {
-@@ -412,7 +418,7 @@ static uint64_t minimum_header_size(Object *o) {
-         return table[o->object.type];
- }
- 
--int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret) {
-+int journal_file_move_to_object(JournalFile *f, ObjectType type, uint64_t offset, Object **ret) {
-         int r;
-         void *t;
-         Object *o;
-@@ -425,7 +431,7 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec
-         if (!VALID64(offset))
-                 return -EFAULT;
- 
--        r = journal_file_move_to(f, type_to_context(type), false, offset, sizeof(ObjectHeader), &t);
-+        r = journal_file_move_to(f, type, false, offset, sizeof(ObjectHeader), &t);
-         if (r < 0)
-                 return r;
- 
-@@ -441,11 +447,11 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec
-         if (s < minimum_header_size(o))
-                 return -EBADMSG;
- 
--        if (type > 0 && o->object.type != type)
-+        if (type > OBJECT_UNUSED && o->object.type != type)
-                 return -EBADMSG;
- 
-         if (s > sizeof(ObjectHeader)) {
--                r = journal_file_move_to(f, o->object.type, false, offset, s, &t);
-+                r = journal_file_move_to(f, type, false, offset, s, &t);
-                 if (r < 0)
-                         return r;
- 
-@@ -482,14 +488,14 @@ static uint64_t journal_file_entry_seqnum(JournalFile *f, uint64_t *seqnum) {
-         return r;
- }
- 
--int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object **ret, uint64_t *offset) {
-+int journal_file_append_object(JournalFile *f, ObjectType type, uint64_t size, Object **ret, uint64_t *offset) {
-         int r;
-         uint64_t p;
-         Object *tail, *o;
-         void *t;
- 
-         assert(f);
--        assert(type > 0 && type < _OBJECT_TYPE_MAX);
-+        assert(type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX);
-         assert(size >= sizeof(ObjectHeader));
-         assert(offset);
-         assert(ret);
-@@ -502,7 +508,7 @@ int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object *
-         if (p == 0)
-                 p = le64toh(f->header->header_size);
-         else {
--                r = journal_file_move_to_object(f, -1, p, &tail);
-+                r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &tail);
-                 if (r < 0)
-                         return r;
- 
-@@ -1657,7 +1663,7 @@ static int generic_array_bisect(
-                         }
-                 }
- 
--                if (k > n) {
-+                if (k >= n) {
-                         if (direction == DIRECTION_UP) {
-                                 i = n;
-                                 subtract_one = true;
-@@ -1793,23 +1799,6 @@ _pure_ static int test_object_offset(JournalFile *f, uint64_t p, uint64_t needle
-                 return TEST_RIGHT;
- }
- 
--int journal_file_move_to_entry_by_offset(
--                JournalFile *f,
--                uint64_t p,
--                direction_t direction,
--                Object **ret,
--                uint64_t *offset) {
--
--        return generic_array_bisect(f,
--                                    le64toh(f->header->entry_array_offset),
--                                    le64toh(f->header->n_entries),
--                                    p,
--                                    test_object_offset,
--                                    direction,
--                                    ret, offset, NULL);
--}
--
--
- static int test_object_seqnum(JournalFile *f, uint64_t p, uint64_t needle) {
-         Object *o;
-         int r;
-@@ -1939,9 +1928,81 @@ int journal_file_move_to_entry_by_monotonic(
-                                              ret, offset, NULL);
- }
- 
-+void journal_file_reset_location(JournalFile *f) {
-+        f->location_type = LOCATION_HEAD;
-+        f->current_offset = 0;
-+        f->current_seqnum = 0;
-+        f->current_realtime = 0;
-+        f->current_monotonic = 0;
-+        zero(f->current_boot_id);
-+        f->current_xor_hash = 0;
-+}
-+
-+void journal_file_save_location(JournalFile *f, Object *o, uint64_t offset) {
-+        f->location_type = LOCATION_SEEK;
-+        f->current_offset = offset;
-+        f->current_seqnum = le64toh(o->entry.seqnum);
-+        f->current_realtime = le64toh(o->entry.realtime);
-+        f->current_monotonic = le64toh(o->entry.monotonic);
-+        f->current_boot_id = o->entry.boot_id;
-+        f->current_xor_hash = le64toh(o->entry.xor_hash);
-+}
-+
-+int journal_file_compare_locations(JournalFile *af, JournalFile *bf) {
-+        assert(af);
-+        assert(bf);
-+        assert(af->location_type == LOCATION_SEEK);
-+        assert(bf->location_type == LOCATION_SEEK);
-+
-+        /* If contents and timestamps match, these entries are
-+         * identical, even if the seqnum does not match */
-+        if (sd_id128_equal(af->current_boot_id, bf->current_boot_id) &&
-+            af->current_monotonic == bf->current_monotonic &&
-+            af->current_realtime == bf->current_realtime &&
-+            af->current_xor_hash == bf->current_xor_hash)
-+                return 0;
-+
-+        if (sd_id128_equal(af->header->seqnum_id, bf->header->seqnum_id)) {
-+
-+                /* If this is from the same seqnum source, compare
-+                 * seqnums */
-+                if (af->current_seqnum < bf->current_seqnum)
-+                        return -1;
-+                if (af->current_seqnum > bf->current_seqnum)
-+                        return 1;
-+
-+                /* Wow! This is weird, different data but the same
-+                 * seqnums? Something is borked, but let's make the
-+                 * best of it and compare by time. */
-+        }
-+
-+        if (sd_id128_equal(af->current_boot_id, bf->current_boot_id)) {
-+
-+                /* If the boot id matches, compare monotonic time */
-+                if (af->current_monotonic < bf->current_monotonic)
-+                        return -1;
-+                if (af->current_monotonic > bf->current_monotonic)
-+                        return 1;
-+        }
-+
-+        /* Otherwise, compare UTC time */
-+        if (af->current_realtime < bf->current_realtime)
-+                return -1;
-+        if (af->current_realtime > bf->current_realtime)
-+                return 1;
-+
-+        /* Finally, compare by contents */
-+        if (af->current_xor_hash < bf->current_xor_hash)
-+                return -1;
-+        if (af->current_xor_hash > bf->current_xor_hash)
-+                return 1;
-+
-+        return 0;
-+}
-+
- int journal_file_next_entry(
-                 JournalFile *f,
--                Object *o, uint64_t p,
-+                uint64_t p,
-                 direction_t direction,
-                 Object **ret, uint64_t *offset) {
- 
-@@ -1949,18 +2010,14 @@ int journal_file_next_entry(
-         int r;
- 
-         assert(f);
--        assert(p > 0 || !o);
- 
-         n = le64toh(f->header->n_entries);
-         if (n <= 0)
-                 return 0;
- 
--        if (!o)
-+        if (p == 0)
-                 i = direction == DIRECTION_DOWN ? 0 : n - 1;
-         else {
--                if (o->object.type != OBJECT_ENTRY)
--                        return -EINVAL;
--
-                 r = generic_array_bisect(f,
-                                          le64toh(f->header->entry_array_offset),
-                                          le64toh(f->header->n_entries),
-@@ -2006,55 +2063,6 @@ int journal_file_next_entry(
-         return 1;
- }
- 
--int journal_file_skip_entry(
--                JournalFile *f,
--                Object *o, uint64_t p,
--                int64_t skip,
--                Object **ret, uint64_t *offset) {
--
--        uint64_t i, n;
--        int r;
--
--        assert(f);
--        assert(o);
--        assert(p > 0);
--
--        if (o->object.type != OBJECT_ENTRY)
--                return -EINVAL;
--
--        r = generic_array_bisect(f,
--                                 le64toh(f->header->entry_array_offset),
--                                 le64toh(f->header->n_entries),
--                                 p,
--                                 test_object_offset,
--                                 DIRECTION_DOWN,
--                                 NULL, NULL,
--                                 &i);
--        if (r <= 0)
--                return r;
--
--        /* Calculate new index */
--        if (skip < 0) {
--                if ((uint64_t) -skip >= i)
--                        i = 0;
--                else
--                        i = i - (uint64_t) -skip;
--        } else
--                i  += (uint64_t) skip;
--
--        n = le64toh(f->header->n_entries);
--        if (n <= 0)
--                return -EBADMSG;
--
--        if (i >= n)
--                i = n-1;
--
--        return generic_array_get(f,
--                                 le64toh(f->header->entry_array_offset),
--                                 i,
--                                 ret, offset);
--}
--
- int journal_file_next_entry_for_data(
-                 JournalFile *f,
-                 Object *o, uint64_t p,
-@@ -2289,7 +2297,7 @@ void journal_file_dump(JournalFile *f) {
- 
-         p = le64toh(f->header->header_size);
-         while (p != 0) {
--                r = journal_file_move_to_object(f, -1, p, &o);
-+                r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
-                 if (r < 0)
-                         goto fail;
- 
-diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
-index 211e121..ca17c97 100644
---- a/src/journal/journal-file.h
-+++ b/src/journal/journal-file.h
-@@ -48,6 +48,20 @@ typedef enum direction {
-         DIRECTION_DOWN
- } direction_t;
- 
-+typedef enum LocationType {
-+        /* The first and last entries, resp. */
-+        LOCATION_HEAD,
-+        LOCATION_TAIL,
-+
-+        /* We already read the entry we currently point to, and the
-+         * next one to read should probably not be this one again. */
-+        LOCATION_DISCRETE,
-+
-+        /* We should seek to the precise location specified, and
-+         * return it, as we haven't read it yet. */
-+        LOCATION_SEEK
-+} LocationType;
-+
- typedef struct JournalFile {
-         int fd;
- 
-@@ -63,6 +77,8 @@ typedef struct JournalFile {
-         bool tail_entry_monotonic_valid:1;
- 
-         direction_t last_direction;
-+        LocationType location_type;
-+        uint64_t last_n_entries;
- 
-         char *path;
-         struct stat last_stat;
-@@ -72,6 +88,11 @@ typedef struct JournalFile {
-         HashItem *field_hash_table;
- 
-         uint64_t current_offset;
-+        uint64_t current_seqnum;
-+        uint64_t current_realtime;
-+        uint64_t current_monotonic;
-+        sd_id128_t current_boot_id;
-+        uint64_t current_xor_hash;
- 
-         JournalMetrics metrics;
-         MMapCache *mmap;
-@@ -160,13 +181,13 @@ static inline bool VALID_EPOCH(uint64_t u) {
- #define JOURNAL_HEADER_COMPRESSED_LZ4(h) \
-         (!!(le32toh((h)->incompatible_flags) & HEADER_INCOMPATIBLE_COMPRESSED_LZ4))
- 
--int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret);
-+int journal_file_move_to_object(JournalFile *f, ObjectType type, uint64_t offset, Object **ret);
- 
- uint64_t journal_file_entry_n_items(Object *o) _pure_;
- uint64_t journal_file_entry_array_n_items(Object *o) _pure_;
- uint64_t journal_file_hash_table_n_items(Object *o) _pure_;
- 
--int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object **ret, uint64_t *offset);
-+int journal_file_append_object(JournalFile *f, ObjectType type, uint64_t size, Object **ret, uint64_t *offset);
- int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqno, Object **ret, uint64_t *offset);
- 
- int journal_file_find_data_object(JournalFile *f, const void *data, uint64_t size, Object **ret, uint64_t *offset);
-@@ -175,12 +196,13 @@ int journal_file_find_data_object_with_hash(JournalFile *f, const void *data, ui
- int journal_file_find_field_object(JournalFile *f, const void *field, uint64_t size, Object **ret, uint64_t *offset);
- int journal_file_find_field_object_with_hash(JournalFile *f, const void *field, uint64_t size, uint64_t hash, Object **ret, uint64_t *offset);
- 
--int journal_file_next_entry(JournalFile *f, Object *o, uint64_t p, direction_t direction, Object **ret, uint64_t *offset);
--int journal_file_skip_entry(JournalFile *f, Object *o, uint64_t p, int64_t skip, Object **ret, uint64_t *offset);
-+void journal_file_reset_location(JournalFile *f);
-+void journal_file_save_location(JournalFile *f, Object *o, uint64_t offset);
-+int journal_file_compare_locations(JournalFile *af, JournalFile *bf);
-+int journal_file_next_entry(JournalFile *f, uint64_t p, direction_t direction, Object **ret, uint64_t *offset);
- 
- int journal_file_next_entry_for_data(JournalFile *f, Object *o, uint64_t p, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *offset);
- 
--int journal_file_move_to_entry_by_offset(JournalFile *f, uint64_t seqnum, direction_t direction, Object **ret, uint64_t *offset);
- int journal_file_move_to_entry_by_seqnum(JournalFile *f, uint64_t seqnum, direction_t direction, Object **ret, uint64_t *offset);
- int journal_file_move_to_entry_by_realtime(JournalFile *f, uint64_t realtime, direction_t direction, Object **ret, uint64_t *offset);
- int journal_file_move_to_entry_by_monotonic(JournalFile *f, sd_id128_t boot_id, uint64_t monotonic, direction_t direction, Object **ret, uint64_t *offset);
-@@ -205,21 +227,3 @@ int journal_file_get_cutoff_realtime_usec(JournalFile *f, usec_t *from, usec_t *
- int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot, usec_t *from, usec_t *to);
- 
- bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec);
--
--
--static unsigned type_to_context(int type) {
--        /* One context for each type, plus one catch-all for the rest */
--        return type > 0 && type < _OBJECT_TYPE_MAX ? type : 0;
--}
--
--static inline int journal_file_object_keep(JournalFile *f, Object *o, uint64_t offset, void **release_cookie) {
--        unsigned context = type_to_context(o->object.type);
--        uint64_t s = le64toh(o->object.size);
--
--        return mmap_cache_get(f->mmap, f->fd, f->prot, context, true,
--                              offset, s, &f->last_stat, NULL, release_cookie);
--}
--
--static inline int journal_file_object_release(JournalFile *f, void *release_cookie) {
--        return mmap_cache_release(f->mmap, f->fd, release_cookie);
--}
-diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
-index 70847db..e99050c 100644
---- a/src/journal/journal-internal.h
-+++ b/src/journal/journal-internal.h
-@@ -57,20 +57,6 @@ struct Match {
-         LIST_HEAD(Match, matches);
- };
- 
--typedef enum LocationType {
--        /* The first and last entries, resp. */
--        LOCATION_HEAD,
--        LOCATION_TAIL,
--
--        /* We already read the entry we currently point to, and the
--         * next one to read should probably not be this one again. */
--        LOCATION_DISCRETE,
--
--        /* We should seek to the precise location specified, and
--         * return it, as we haven't read it yet. */
--        LOCATION_SEEK
--} LocationType;
--
- struct Location {
-         LocationType type;
- 
-diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
-index f74adcb..5baa22d 100644
---- a/src/journal/journal-verify.c
-+++ b/src/journal/journal-verify.c
-@@ -368,7 +368,7 @@ static int contains_uint64(MMapCache *m, int fd, uint64_t n, uint64_t p) {
- 
-                 c = (a + b) / 2;
- 
--                r = mmap_cache_get(m, fd, PROT_READ|PROT_WRITE, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z, NULL);
-+                r = mmap_cache_get(m, fd, PROT_READ|PROT_WRITE, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z);
-                 if (r < 0)
-                         return r;
- 
-@@ -865,7 +865,7 @@ int journal_file_verify(
-                 if (show_progress)
-                         draw_progress(0x7FFF * p / le64toh(f->header->tail_object_offset), &last_usec);
- 
--                r = journal_file_move_to_object(f, -1, p, &o);
-+                r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
-                 if (r < 0) {
-                         error(p, "invalid object");
-                         goto fail;
-@@ -1085,11 +1085,11 @@ int journal_file_verify(
-                                         q = last_tag;
- 
-                                 while (q <= p) {
--                                        r = journal_file_move_to_object(f, -1, q, &o);
-+                                        r = journal_file_move_to_object(f, OBJECT_UNUSED, q, &o);
-                                         if (r < 0)
-                                                 goto fail;
- 
--                                        r = journal_file_hmac_put_object(f, -1, o, q);
-+                                        r = journal_file_hmac_put_object(f, OBJECT_UNUSED, o, q);
-                                         if (r < 0)
-                                                 goto fail;
- 
-@@ -1097,7 +1097,7 @@ int journal_file_verify(
-                                 }
- 
-                                 /* Position might have changed, let's reposition things */
--                                r = journal_file_move_to_object(f, -1, p, &o);
-+                                r = journal_file_move_to_object(f, OBJECT_UNUSED, p, &o);
-                                 if (r < 0)
-                                         goto fail;
- 
-diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
-index f50faf4..03579fd 100644
---- a/src/journal/journalctl.c
-+++ b/src/journal/journalctl.c
-@@ -682,7 +682,7 @@ static int parse_argv(int argc, char *argv[]) {
-                         assert_not_reached("Unhandled option");
-                 }
- 
--        if (arg_follow && !arg_no_tail && arg_lines == ARG_LINES_DEFAULT)
-+        if (arg_follow && !arg_no_tail && !arg_since && arg_lines == ARG_LINES_DEFAULT)
-                 arg_lines = 10;
- 
-         if (!!arg_directory + !!arg_file + !!arg_machine > 1) {
-diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
-index a635202..655e2dd 100644
---- a/src/journal/journald-native.c
-+++ b/src/journal/journald-native.c
-@@ -132,8 +132,8 @@ void server_process_native_message(
- 
-                 /* A property follows */
- 
--                /* n received properties, +1 for _TRANSPORT */
--                if (!GREEDY_REALLOC(iovec, m, n + 1 + N_IOVEC_META_FIELDS + !!object_pid * N_IOVEC_OBJECT_FIELDS)) {
-+                /* n existing properties, 1 new, +1 for _TRANSPORT */
-+                if (!GREEDY_REALLOC(iovec, m, n + 2 + N_IOVEC_META_FIELDS + N_IOVEC_OBJECT_FIELDS)) {
-                         log_oom();
-                         break;
-                 }
-diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
-index 12735c4..08b143b 100644
---- a/src/journal/journald-server.c
-+++ b/src/journal/journald-server.c
-@@ -1655,6 +1655,7 @@ void server_done(Server *s) {
-         free(s->buffer);
-         free(s->tty_path);
-         free(s->cgroup_root);
-+        free(s->hostname_field);
- 
-         if (s->mmap)
-                 mmap_cache_unref(s->mmap);
-diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
-index b7db6f1..f6f669d 100644
---- a/src/journal/mmap-cache.c
-+++ b/src/journal/mmap-cache.c
-@@ -38,7 +38,7 @@ typedef struct FileDescriptor FileDescriptor;
- struct Window {
-         MMapCache *cache;
- 
--        unsigned keep_always;
-+        bool keep_always;
-         bool in_unused;
- 
-         int prot;
-@@ -76,7 +76,7 @@ struct MMapCache {
- 
- 
-         Hashmap *fds;
--        Hashmap *contexts;
-+        Context *contexts[MMAP_CACHE_MAX_CONTEXTS];
- 
-         LIST_HEAD(Window, unused);
-         Window *last_unused;
-@@ -185,7 +185,7 @@ static void context_detach_window(Context *c) {
-         c->window = NULL;
-         LIST_REMOVE(by_window, w->contexts, c);
- 
--        if (!w->contexts && w->keep_always == 0) {
-+        if (!w->contexts && !w->keep_always) {
-                 /* Not used anymore? */
-                 LIST_PREPEND(unused, c->cache->unused, w);
-                 if (!c->cache->last_unused)
-@@ -219,18 +219,13 @@ static void context_attach_window(Context *c, Window *w) {
- 
- static Context *context_add(MMapCache *m, unsigned id) {
-         Context *c;
--        int r;
- 
-         assert(m);
- 
--        c = hashmap_get(m->contexts, UINT_TO_PTR(id + 1));
-+        c = m->contexts[id];
-         if (c)
-                 return c;
- 
--        r = hashmap_ensure_allocated(&m->contexts, NULL);
--        if (r < 0)
--                return NULL;
--
-         c = new0(Context, 1);
-         if (!c)
-                 return NULL;
-@@ -238,11 +233,8 @@ static Context *context_add(MMapCache *m, unsigned id) {
-         c->cache = m;
-         c->id = id;
- 
--        r = hashmap_put(m->contexts, UINT_TO_PTR(id + 1), c);
--        if (r < 0) {
--                free(c);
--                return NULL;
--        }
-+        assert(!m->contexts[id]);
-+        m->contexts[id] = c;
- 
-         return c;
- }
-@@ -252,8 +244,10 @@ static void context_free(Context *c) {
- 
-         context_detach_window(c);
- 
--        if (c->cache)
--                assert_se(hashmap_remove(c->cache->contexts, UINT_TO_PTR(c->id + 1)));
-+        if (c->cache) {
-+                assert(c->cache->contexts[c->id] == c);
-+                c->cache->contexts[c->id] = NULL;
-+        }
- 
-         free(c);
- }
-@@ -302,15 +296,14 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
- }
- 
- static void mmap_cache_free(MMapCache *m) {
--        Context *c;
-         FileDescriptor *f;
-+        int i;
- 
-         assert(m);
- 
--        while ((c = hashmap_first(m->contexts)))
--                context_free(c);
--
--        hashmap_free(m->contexts);
-+        for (i = 0; i < MMAP_CACHE_MAX_CONTEXTS; i++)
-+                if (m->contexts[i])
-+                        context_free(m->contexts[i]);
- 
-         while ((f = hashmap_first(m->fds)))
-                 fd_free(f);
-@@ -352,8 +345,7 @@ static int try_context(
-                 bool keep_always,
-                 uint64_t offset,
-                 size_t size,
--                void **ret,
--                void **release_cookie) {
-+                void **ret) {
- 
-         Context *c;
- 
-@@ -361,8 +353,9 @@ static int try_context(
-         assert(m->n_ref > 0);
-         assert(fd >= 0);
-         assert(size > 0);
-+        assert(ret);
- 
--        c = hashmap_get(m->contexts, UINT_TO_PTR(context+1));
-+        c = m->contexts[context];
-         if (!c)
-                 return 0;
- 
-@@ -378,12 +371,9 @@ static int try_context(
-                 return 0;
-         }
- 
--        c->window->keep_always += keep_always;
-+        c->window->keep_always |= keep_always;
- 
--        if (ret)
--                *ret = (uint8_t*) c->window->ptr + (offset - c->window->offset);
--        if (keep_always && release_cookie)
--                *release_cookie = c->window;
-+        *ret = (uint8_t*) c->window->ptr + (offset - c->window->offset);
-         return 1;
- }
- 
-@@ -395,8 +385,7 @@ static int find_mmap(
-                 bool keep_always,
-                 uint64_t offset,
-                 size_t size,
--                void **ret,
--                void **release_cookie) {
-+                void **ret) {
- 
-         FileDescriptor *f;
-         Window *w;
-@@ -427,10 +416,7 @@ static int find_mmap(
-         context_attach_window(c, w);
-         w->keep_always += keep_always;
- 
--        if (ret)
--                *ret = (uint8_t*) w->ptr + (offset - w->offset);
--        if (keep_always && release_cookie)
--                *release_cookie = c->window;
-+        *ret = (uint8_t*) w->ptr + (offset - w->offset);
-         return 1;
- }
- 
-@@ -443,8 +429,7 @@ static int add_mmap(
-                 uint64_t offset,
-                 size_t size,
-                 struct stat *st,
--                void **ret,
--                void **release_cookie) {
-+                void **ret) {
- 
-         uint64_t woffset, wsize;
-         Context *c;
-@@ -457,6 +442,7 @@ static int add_mmap(
-         assert(m->n_ref > 0);
-         assert(fd >= 0);
-         assert(size > 0);
-+        assert(ret);
- 
-         woffset = offset & ~((uint64_t) page_size() - 1ULL);
-         wsize = size + (offset - woffset);
-@@ -526,10 +512,7 @@ static int add_mmap(
-         c->window = w;
-         LIST_PREPEND(by_window, w->contexts, c);
- 
--        if (ret)
--                *ret = (uint8_t*) w->ptr + (offset - w->offset);
--        if (keep_always && release_cookie)
--                *release_cookie = c->window;
-+        *ret = (uint8_t*) w->ptr + (offset - w->offset);
-         return 1;
- 
- outofmem:
-@@ -546,8 +529,7 @@ int mmap_cache_get(
-                 uint64_t offset,
-                 size_t size,
-                 struct stat *st,
--                void **ret,
--                void **release_cookie) {
-+                void **ret) {
- 
-         int r;
- 
-@@ -555,16 +537,18 @@ int mmap_cache_get(
-         assert(m->n_ref > 0);
-         assert(fd >= 0);
-         assert(size > 0);
-+        assert(ret);
-+        assert(context < MMAP_CACHE_MAX_CONTEXTS);
- 
-         /* Check whether the current context is the right one already */
--        r = try_context(m, fd, prot, context, keep_always, offset, size, ret, release_cookie);
-+        r = try_context(m, fd, prot, context, keep_always, offset, size, ret);
-         if (r != 0) {
-                 m->n_hit ++;
-                 return r;
-         }
- 
-         /* Search for a matching mmap */
--        r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret, release_cookie);
-+        r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret);
-         if (r != 0) {
-                 m->n_hit ++;
-                 return r;
-@@ -573,39 +557,7 @@ int mmap_cache_get(
-         m->n_missed++;
- 
-         /* Create a new mmap */
--        return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret, release_cookie);
--}
--
--int mmap_cache_release(
--                MMapCache *m,
--                int fd,
--                void *release_cookie) {
--
--        FileDescriptor *f;
--        Window *w;
--
--        assert(m);
--        assert(m->n_ref > 0);
--        assert(fd >= 0);
--
--        f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
--        if (!f)
--                return -EBADF;
--
--        assert(f->fd == fd);
--
--        LIST_FOREACH(by_fd, w, f->windows)
--                if (w == release_cookie)
--                        break;
--
--        if (!w)
--                return -ENOENT;
--
--        if (w->keep_always == 0)
--                return -ENOLCK;
--
--        w->keep_always -= 1;
--        return 0;
-+        return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret);
- }
- 
- void mmap_cache_close_fd(MMapCache *m, int fd) {
-@@ -621,18 +573,6 @@ void mmap_cache_close_fd(MMapCache *m, int fd) {
-         fd_free(f);
- }
- 
--void mmap_cache_close_context(MMapCache *m, unsigned context) {
--        Context *c;
--
--        assert(m);
--
--        c = hashmap_get(m->contexts, UINT_TO_PTR(context + 1));
--        if (!c)
--                return;
--
--        context_free(c);
--}
--
- unsigned mmap_cache_get_hit(MMapCache *m) {
-         assert(m);
- 
-diff --git a/src/journal/mmap-cache.h b/src/journal/mmap-cache.h
-index 76e5316..fe2c83d 100644
---- a/src/journal/mmap-cache.h
-+++ b/src/journal/mmap-cache.h
-@@ -25,6 +25,8 @@
- #include <stdbool.h>
- #include <sys/stat.h>
- 
-+#define MMAP_CACHE_MAX_CONTEXTS 8
-+
- typedef struct MMapCache MMapCache;
- 
- MMapCache* mmap_cache_new(void);
-@@ -40,14 +42,8 @@ int mmap_cache_get(
-         uint64_t offset,
-         size_t size,
-         struct stat *st,
--        void **ret,
--        void **release_cookie);
--int mmap_cache_release(
--        MMapCache *m,
--        int fd,
--        void *release_cookie);
-+        void **ret);
- void mmap_cache_close_fd(MMapCache *m, int fd);
--void mmap_cache_close_context(MMapCache *m, unsigned context);
- 
- unsigned mmap_cache_get_hit(MMapCache *m);
- unsigned mmap_cache_get_missed(MMapCache *m);
-diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
-index cf21c4d..cb7fc32 100644
---- a/src/journal/sd-journal.c
-+++ b/src/journal/sd-journal.c
-@@ -87,7 +87,7 @@ static void detach_location(sd_journal *j) {
-         j->current_field = 0;
- 
-         ORDERED_HASHMAP_FOREACH(f, j->files, i)
--                f->current_offset = 0;
-+                journal_file_reset_location(f);
- }
- 
- static void reset_location(sd_journal *j) {
-@@ -114,20 +114,19 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object
-         l->seqnum_set = l->realtime_set = l->monotonic_set = l->xor_hash_set = true;
- }
- 
--static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o,
--                         direction_t direction, uint64_t offset) {
-+static void set_location(sd_journal *j, JournalFile *f, Object *o) {
-         assert(j);
--        assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
-         assert(f);
-         assert(o);
- 
--        init_location(&j->current_location, type, f, o);
-+        init_location(&j->current_location, LOCATION_DISCRETE, f, o);
- 
-         j->current_file = f;
-         j->current_field = 0;
- 
--        f->last_direction = direction;
--        f->current_offset = offset;
-+        /* Let f know its candidate entry was picked. */
-+        assert(f->location_type == LOCATION_SEEK);
-+        f->location_type = LOCATION_DISCRETE;
- }
- 
- static int match_is_valid(const void *data, size_t size) {
-@@ -413,144 +412,51 @@ _public_ void sd_journal_flush_matches(sd_journal *j) {
-         detach_location(j);
- }
- 
--static int compare_entry_order(JournalFile *af, Object *_ao,
--                               JournalFile *bf, uint64_t bp) {
--
--        uint64_t a, b;
--        Object *ao, *bo;
--        int r;
--
--        assert(af);
--        assert(bf);
--        assert(_ao);
--
--        /* The mmap cache might invalidate the object from the first
--         * file if we look at the one from the second file. Hence
--         * temporarily copy the header of the first one, and look at
--         * that only. */
--        ao = alloca(offsetof(EntryObject, items));
--        memcpy(ao, _ao, offsetof(EntryObject, items));
--
--        r = journal_file_move_to_object(bf, OBJECT_ENTRY, bp, &bo);
--        if (r < 0)
--                return strcmp(af->path, bf->path);
--
--        /* We operate on two different files here, hence we can access
--         * two objects at the same time, which we normally can't.
--         *
--         * If contents and timestamps match, these entries are
--         * identical, even if the seqnum does not match */
--
--        if (sd_id128_equal(ao->entry.boot_id, bo->entry.boot_id) &&
--            ao->entry.monotonic == bo->entry.monotonic &&
--            ao->entry.realtime == bo->entry.realtime &&
--            ao->entry.xor_hash == bo->entry.xor_hash)
--                return 0;
--
--        if (sd_id128_equal(af->header->seqnum_id, bf->header->seqnum_id)) {
--
--                /* If this is from the same seqnum source, compare
--                 * seqnums */
--                a = le64toh(ao->entry.seqnum);
--                b = le64toh(bo->entry.seqnum);
--
--                if (a < b)
--                        return -1;
--                if (a > b)
--                        return 1;
--
--                /* Wow! This is weird, different data but the same
--                 * seqnums? Something is borked, but let's make the
--                 * best of it and compare by time. */
--        }
--
--        if (sd_id128_equal(ao->entry.boot_id, bo->entry.boot_id)) {
--
--                /* If the boot id matches, compare monotonic time */
--                a = le64toh(ao->entry.monotonic);
--                b = le64toh(bo->entry.monotonic);
--
--                if (a < b)
--                        return -1;
--                if (a > b)
--                        return 1;
--        }
--
--        /* Otherwise, compare UTC time */
--        a = le64toh(ao->entry.realtime);
--        b = le64toh(bo->entry.realtime);
--
--        if (a < b)
--                return -1;
--        if (a > b)
--                return 1;
--
--        /* Finally, compare by contents */
--        a = le64toh(ao->entry.xor_hash);
--        b = le64toh(bo->entry.xor_hash);
--
--        if (a < b)
--                return -1;
--        if (a > b)
--                return 1;
--
--        return 0;
--}
--
--_pure_ static int compare_with_location(JournalFile *af, Object *ao, Location *l) {
--        uint64_t a;
--
--        assert(af);
--        assert(ao);
-+_pure_ static int compare_with_location(JournalFile *f, Location *l) {
-+        assert(f);
-         assert(l);
-+        assert(f->location_type == LOCATION_SEEK);
-         assert(l->type == LOCATION_DISCRETE || l->type == LOCATION_SEEK);
- 
-         if (l->monotonic_set &&
--            sd_id128_equal(ao->entry.boot_id, l->boot_id) &&
-+            sd_id128_equal(f->current_boot_id, l->boot_id) &&
-             l->realtime_set &&
--            le64toh(ao->entry.realtime) == l->realtime &&
-+            f->current_realtime == l->realtime &&
-             l->xor_hash_set &&
--            le64toh(ao->entry.xor_hash) == l->xor_hash)
-+            f->current_xor_hash == l->xor_hash)
-                 return 0;
- 
-         if (l->seqnum_set &&
--            sd_id128_equal(af->header->seqnum_id, l->seqnum_id)) {
--
--                a = le64toh(ao->entry.seqnum);
-+            sd_id128_equal(f->header->seqnum_id, l->seqnum_id)) {
- 
--                if (a < l->seqnum)
-+                if (f->current_seqnum < l->seqnum)
-                         return -1;
--                if (a > l->seqnum)
-+                if (f->current_seqnum > l->seqnum)
-                         return 1;
-         }
- 
-         if (l->monotonic_set &&
--            sd_id128_equal(ao->entry.boot_id, l->boot_id)) {
-+            sd_id128_equal(f->current_boot_id, l->boot_id)) {
- 
--                a = le64toh(ao->entry.monotonic);
--
--                if (a < l->monotonic)
-+                if (f->current_monotonic < l->monotonic)
-                         return -1;
--                if (a > l->monotonic)
-+                if (f->current_monotonic > l->monotonic)
-                         return 1;
-         }
- 
-         if (l->realtime_set) {
- 
--                a = le64toh(ao->entry.realtime);
--
--                if (a < l->realtime)
-+                if (f->current_realtime < l->realtime)
-                         return -1;
--                if (a > l->realtime)
-+                if (f->current_realtime > l->realtime)
-                         return 1;
-         }
- 
-         if (l->xor_hash_set) {
--                a = le64toh(ao->entry.xor_hash);
- 
--                if (a < l->xor_hash)
-+                if (f->current_xor_hash < l->xor_hash)
-                         return -1;
--                if (a > l->xor_hash)
-+                if (f->current_xor_hash > l->xor_hash)
-                         return 1;
-         }
- 
-@@ -766,9 +672,9 @@ static int find_location_with_matches(
-                 /* No matches is simple */
- 
-                 if (j->current_location.type == LOCATION_HEAD)
--                        return journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, ret, offset);
-+                        return journal_file_next_entry(f, 0, DIRECTION_DOWN, ret, offset);
-                 if (j->current_location.type == LOCATION_TAIL)
--                        return journal_file_next_entry(f, NULL, 0, DIRECTION_UP, ret, offset);
-+                        return journal_file_next_entry(f, 0, DIRECTION_UP, ret, offset);
-                 if (j->current_location.seqnum_set && sd_id128_equal(j->current_location.seqnum_id, f->header->seqnum_id))
-                         return journal_file_move_to_entry_by_seqnum(f, j->current_location.seqnum, direction, ret, offset);
-                 if (j->current_location.monotonic_set) {
-@@ -779,7 +685,7 @@ static int find_location_with_matches(
-                 if (j->current_location.realtime_set)
-                         return journal_file_move_to_entry_by_realtime(f, j->current_location.realtime, direction, ret, offset);
- 
--                return journal_file_next_entry(f, NULL, 0, direction, ret, offset);
-+                return journal_file_next_entry(f, 0, direction, ret, offset);
-         } else
-                 return find_location_for_match(j, j->level0, f, direction, ret, offset);
- }
-@@ -791,49 +697,61 @@ static int next_with_matches(
-                 Object **ret,
-                 uint64_t *offset) {
- 
--        Object *c;
--        uint64_t cp;
--
-         assert(j);
-         assert(f);
-         assert(ret);
-         assert(offset);
- 
--        c = *ret;
--        cp = *offset;
--
-         /* No matches is easy. We simple advance the file
-          * pointer by one. */
-         if (!j->level0)
--                return journal_file_next_entry(f, c, cp, direction, ret, offset);
-+                return journal_file_next_entry(f, f->current_offset, direction, ret, offset);
- 
-         /* If we have a match then we look for the next matching entry
-          * with an offset at least one step larger */
--        return next_for_match(j, j->level0, f, direction == DIRECTION_DOWN ? cp+1 : cp-1, direction, ret, offset);
-+        return next_for_match(j, j->level0, f,
-+                              direction == DIRECTION_DOWN ? f->current_offset + 1
-+                                                          : f->current_offset - 1,
-+                              direction, ret, offset);
- }
- 
--static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direction, Object **ret, uint64_t *offset) {
-+static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direction) {
-         Object *c;
--        uint64_t cp;
-+        uint64_t cp, n_entries;
-         int r;
- 
-         assert(j);
-         assert(f);
- 
--        if (f->last_direction == direction && f->current_offset > 0) {
--                cp = f->current_offset;
-+        n_entries = le64toh(f->header->n_entries);
- 
--                r = journal_file_move_to_object(f, OBJECT_ENTRY, cp, &c);
--                if (r < 0)
--                        return r;
-+        /* If we hit EOF before, we don't need to look into this file again
-+         * unless direction changed or new entries appeared. */
-+        if (f->last_direction == direction && f->location_type == LOCATION_TAIL &&
-+            n_entries == f->last_n_entries)
-+                return 0;
- 
--                r = next_with_matches(j, f, direction, &c, &cp);
--                if (r <= 0)
--                        return r;
-+        f->last_n_entries = n_entries;
-+
-+        if (f->last_direction == direction && f->current_offset > 0) {
-+                /* LOCATION_SEEK here means we did the work in a previous
-+                 * iteration and the current location already points to a
-+                 * candidate entry. */
-+                if (f->location_type != LOCATION_SEEK) {
-+                        r = next_with_matches(j, f, direction, &c, &cp);
-+                        if (r <= 0)
-+                                return r;
-+
-+                        journal_file_save_location(f, c, cp);
-+                }
-         } else {
-+                f->last_direction = direction;
-+
-                 r = find_location_with_matches(j, f, direction, &c, &cp);
-                 if (r <= 0)
-                         return r;
-+
-+                journal_file_save_location(f, c, cp);
-         }
- 
-         /* OK, we found the spot, now let's advance until an entry
-@@ -848,30 +766,25 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
-                 if (j->current_location.type == LOCATION_DISCRETE) {
-                         int k;
- 
--                        k = compare_with_location(f, c, &j->current_location);
-+                        k = compare_with_location(f, &j->current_location);
- 
-                         found = direction == DIRECTION_DOWN ? k > 0 : k < 0;
-                 } else
-                         found = true;
- 
--                if (found) {
--                        if (ret)
--                                *ret = c;
--                        if (offset)
--                                *offset = cp;
-+                if (found)
-                         return 1;
--                }
- 
-                 r = next_with_matches(j, f, direction, &c, &cp);
-                 if (r <= 0)
-                         return r;
-+
-+                journal_file_save_location(f, c, cp);
-         }
- }
- 
- static int real_journal_next(sd_journal *j, direction_t direction) {
-         JournalFile *f, *new_file = NULL;
--        uint64_t new_offset = 0;
--        uint64_t p = 0;
-         Iterator i;
-         Object *o;
-         int r;
-@@ -882,38 +795,38 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
-         ORDERED_HASHMAP_FOREACH(f, j->files, i) {
-                 bool found;
- 
--                r = next_beyond_location(j, f, direction, &o, &p);
-+                r = next_beyond_location(j, f, direction);
-                 if (r < 0) {
-                         log_debug("Can't iterate through %s, ignoring: %s", f->path, strerror(-r));
-                         remove_file_real(j, f);
-                         continue;
--                } else if (r == 0)
-+                } else if (r == 0) {
-+                        f->location_type = LOCATION_TAIL;
-                         continue;
-+                }
- 
-                 if (!new_file)
-                         found = true;
-                 else {
-                         int k;
- 
--                        k = compare_entry_order(f, o, new_file, new_offset);
-+                        k = journal_file_compare_locations(f, new_file);
- 
-                         found = direction == DIRECTION_DOWN ? k < 0 : k > 0;
-                 }
- 
--                if (found) {
-+                if (found)
-                         new_file = f;
--                        new_offset = p;
--                }
-         }
- 
-         if (!new_file)
-                 return 0;
- 
--        r = journal_file_move_to_object(new_file, OBJECT_ENTRY, new_offset, &o);
-+        r = journal_file_move_to_object(new_file, OBJECT_ENTRY, new_file->current_offset, &o);
-         if (r < 0)
-                 return r;
- 
--        set_location(j, LOCATION_DISCRETE, new_file, o, direction, new_offset);
-+        set_location(j, new_file, o);
- 
-         return 1;
- }
-@@ -2526,7 +2439,6 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
-                 size_t ol;
-                 bool found;
-                 int r;
--                void *release_cookie;
- 
-                 /* Proceed to next data object in the field's linked list */
-                 if (j->unique_offset == 0) {
-@@ -2552,10 +2464,10 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
-                         continue;
-                 }
- 
--                /* We do not use the type context here, but 0 instead,
--                 * so that we can look at this data object at the same
-+                /* We do not use OBJECT_DATA context here, but OBJECT_UNUSED
-+                 * instead, so that we can look at this data object at the same
-                  * time as one on another file */
--                r = journal_file_move_to_object(j->unique_file, 0, j->unique_offset, &o);
-+                r = journal_file_move_to_object(j->unique_file, OBJECT_UNUSED, j->unique_offset, &o);
-                 if (r < 0)
-                         return r;
- 
-@@ -2567,10 +2479,6 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
-                         return -EBADMSG;
-                 }
- 
--                r = journal_file_object_keep(j->unique_file, o, j->unique_offset, &release_cookie);
--                if (r < 0)
--                        return r;
--
-                 r = return_data(j, j->unique_file, o, &odata, &ol);
-                 if (r < 0)
-                         return r;
-@@ -2615,10 +2523,6 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
-                                 found = true;
-                 }
- 
--                r = journal_file_object_release(j->unique_file, release_cookie);
--                if (r < 0)
--                        return r;
--
-                 if (found)
-                         continue;
- 
-diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
-index 372f3ed..d56ee51 100644
---- a/src/libsystemd-network/network-internal.c
-+++ b/src/libsystemd-network/network-internal.c
-@@ -392,10 +392,12 @@ void serialize_dhcp_routes(FILE *f, const char *key, struct sd_dhcp_route *route
- 
-         fprintf(f, "%s=", key);
- 
--        for (i = 0; i < size; i++)
--                fprintf(f, "%s/%" PRIu8 ",%s%s", inet_ntoa(routes[i].dst_addr),
--                        routes[i].dst_prefixlen, inet_ntoa(routes[i].gw_addr),
-+        for (i = 0; i < size; i++) {
-+                fprintf(f, "%s/%" PRIu8, inet_ntoa(routes[i].dst_addr),
-+                        routes[i].dst_prefixlen);
-+                fprintf(f, ",%s%s", inet_ntoa(routes[i].gw_addr),
-                         (i < (size - 1)) ? " ": "");
-+        }
- 
-         fputs("\n", f);
- }
-diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
-index 0eba4c3..9986b52 100644
---- a/src/libsystemd-network/sd-dhcp-client.c
-+++ b/src/libsystemd-network/sd-dhcp-client.c
-@@ -68,7 +68,6 @@ struct sd_dhcp_client {
-         uint32_t mtu;
-         uint32_t xid;
-         usec_t start_time;
--        uint16_t secs;
-         unsigned int attempt;
-         usec_t request_sent;
-         sd_event_source *timeout_t1;
-@@ -321,10 +320,12 @@ static int client_message_init(sd_dhcp_client *client, DHCPPacket **ret,
-         _cleanup_free_ DHCPPacket *packet;
-         size_t optlen, optoffset, size;
-         be16_t max_size;
-+        usec_t time_now;
-+        uint16_t secs;
-         int r;
- 
-         assert(client);
--        assert(client->secs);
-+        assert(client->start_time);
-         assert(ret);
-         assert(_optlen);
-         assert(_optoffset);
-@@ -344,7 +345,15 @@ static int client_message_init(sd_dhcp_client *client, DHCPPacket **ret,
- 
-         /* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP servers
-            refuse to issue an DHCP lease if 'secs' is set to zero */
--        packet->dhcp.secs = htobe16(client->secs);
-+        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
-+        if (r < 0)
-+                return r;
-+        assert(time_now >= client->start_time);
-+
-+        /* seconds between sending first and last DISCOVER
-+         * must always be strictly positive to deal with broken servers */
-+        secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1;
-+        packet->dhcp.secs = htobe16(secs);
- 
-         /* RFC2132 section 4.1
-            A client that cannot receive unicast IP datagrams until its protocol
-@@ -441,24 +450,12 @@ static int dhcp_client_send_raw(sd_dhcp_client *client, DHCPPacket *packet,
- static int client_send_discover(sd_dhcp_client *client) {
-         _cleanup_free_ DHCPPacket *discover = NULL;
-         size_t optoffset, optlen;
--        usec_t time_now;
-         int r;
- 
-         assert(client);
-         assert(client->state == DHCP_STATE_INIT ||
-                client->state == DHCP_STATE_SELECTING);
- 
--        /* See RFC2131 section 4.4.1 */
--
--        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
--        if (r < 0)
--                return r;
--        assert(time_now >= client->start_time);
--
--        /* seconds between sending first and last DISCOVER
--         * must always be strictly positive to deal with broken servers */
--        client->secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1;
--
-         r = client_message_init(client, &discover, DHCP_DISCOVER,
-                                 &optlen, &optoffset);
-         if (r < 0)
-@@ -875,10 +872,8 @@ static int client_start(sd_dhcp_client *client) {
-         }
-         client->fd = r;
- 
--        if (client->state == DHCP_STATE_INIT) {
-+        if (client->state == DHCP_STATE_INIT || client->state == DHCP_STATE_INIT_REBOOT)
-                 client->start_time = now(clock_boottime_or_monotonic());
--                client->secs = 0;
--        }
- 
-         return client_initialize_events(client, client_receive_message_raw);
- }
-@@ -1269,6 +1264,9 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
-                 if (r >= 0) {
-                         client->timeout_resend =
-                                 sd_event_source_unref(client->timeout_resend);
-+                        client->receive_message =
-+                                sd_event_source_unref(client->receive_message);
-+                        client->fd = asynchronous_close(client->fd);
- 
-                         if (IN_SET(client->state, DHCP_STATE_REQUESTING,
-                                    DHCP_STATE_REBOOTING))
-diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
-index 4fb01c0..b7c9a07 100644
---- a/src/libsystemd-network/sd-dhcp-lease.c
-+++ b/src/libsystemd-network/sd-dhcp-lease.c
-@@ -50,7 +50,7 @@ int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) {
- 
- int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime) {
-         assert_return(lease, -EINVAL);
--        assert_return(lease, -EINVAL);
-+        assert_return(lifetime, -EINVAL);
- 
-         *lifetime = lease->lifetime;
- 
-diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
-index fa4f9b5..dbec1a2 100644
---- a/src/libsystemd-network/sd-dhcp6-client.c
-+++ b/src/libsystemd-network/sd-dhcp6-client.c
-@@ -200,19 +200,19 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *du
- 
-         switch (type) {
-         case DHCP6_DUID_LLT:
--                if (duid_len <= sizeof(client->duid.llt))
-+                if (duid_len <= sizeof(client->duid.llt) - 2)
-                         return -EINVAL;
-                 break;
-         case DHCP6_DUID_EN:
--                if (duid_len != sizeof(client->duid.en))
-+                if (duid_len != sizeof(client->duid.en) - 2)
-                         return -EINVAL;
-                 break;
-         case DHCP6_DUID_LL:
--                if (duid_len <= sizeof(client->duid.ll))
-+                if (duid_len <= sizeof(client->duid.ll) - 2)
-                         return -EINVAL;
-                 break;
-         case DHCP6_DUID_UUID:
--                if (duid_len != sizeof(client->duid.uuid))
-+                if (duid_len != sizeof(client->duid.uuid) - 2)
-                         return -EINVAL;
-                 break;
-         default:
-@@ -222,7 +222,7 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *du
- 
-         client->duid.raw.type = htobe16(type);
-         memcpy(&client->duid.raw.data, duid, duid_len);
--        client->duid_len = duid_len;
-+        client->duid_len = duid_len + 2;  /* +2 for sizeof(type) */
- 
-         return 0;
- }
-diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
-index 18afe0f..5658c61 100644
---- a/src/libsystemd/sd-bus/bus-match.c
-+++ b/src/libsystemd/sd-bus/bus-match.c
-@@ -537,7 +537,7 @@ static int bus_match_find_compare_value(
-         else if (BUS_MATCH_CAN_HASH(t))
-                 n = hashmap_get(c->compare.children, value_str);
-         else {
--                for (n = c->child; !value_node_same(n, t, value_u8, value_str); n = n->next)
-+                for (n = c->child; n && !value_node_same(n, t, value_u8, value_str); n = n->next)
-                         ;
-         }
- 
-diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
-index 0ab1119..6c3230a 100644
---- a/src/libsystemd/sd-bus/bus-objects.c
-+++ b/src/libsystemd/sd-bus/bus-objects.c
-@@ -617,6 +617,9 @@ static int property_get_set_callbacks_run(
-                         return r;
- 
-         } else {
-+                const char *signature = NULL;
-+                char type = 0;
-+
-                 if (c->vtable->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
-                         return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_PROPERTY_READ_ONLY, "Property '%s' is not writable.", c->member);
- 
-@@ -628,6 +631,13 @@ static int property_get_set_callbacks_run(
- 
-                 c->last_iteration = bus->iteration_counter;
- 
-+                r = sd_bus_message_peek_type(m, &type, &signature);
-+                if (r < 0)
-+                        return r;
-+
-+                if (type != 'v' || !streq(strempty(signature), strempty(c->vtable->x.property.signature)))
-+                        return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Incorrect parameters for property '%s', expected '%s', got '%s'.", c->member, strempty(c->vtable->x.property.signature), strempty(signature));
-+
-                 r = sd_bus_message_enter_container(m, 'v', c->vtable->x.property.signature);
-                 if (r < 0)
-                         return r;
-diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
-index b501a52..740133a 100644
---- a/src/libsystemd/sd-rtnl/rtnl-message.c
-+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
-@@ -36,6 +36,8 @@
- #define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offsets[i]) : NULL)
- #define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers ++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr;
- 
-+#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)
-+
- static int message_new_empty(sd_rtnl *rtnl, sd_rtnl_message **ret) {
-         sd_rtnl_message *m;
- 
-@@ -566,8 +568,8 @@ int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const
-                 size = (size_t)r;
- 
-         if (size) {
--                length = strnlen(data, size);
--                if (length >= size)
-+                length = strnlen(data, size+1);
-+                if (length > size)
-                         return -EINVAL;
-         } else
-                 length = strlen(data);
-@@ -1066,7 +1068,7 @@ int rtnl_message_parse(sd_rtnl_message *m,
-         *rta_tb_size = max + 1;
- 
-         for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
--                type = rta->rta_type;
-+                type = RTA_TYPE(rta);
- 
-                 /* if the kernel is newer than the headers we used
-                    when building, we ignore out-of-range attributes
-@@ -1222,7 +1224,7 @@ int socket_read_message(sd_rtnl *rtnl) {
-                 }
-         }
- 
--        for (new_msg = rtnl->rbuffer; NLMSG_OK(new_msg, len); new_msg = NLMSG_NEXT(new_msg, len)) {
-+        for (new_msg = rtnl->rbuffer; NLMSG_OK(new_msg, len) && !done; new_msg = NLMSG_NEXT(new_msg, len)) {
-                 _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
-                 const NLType *nl_type;
- 
-@@ -1237,7 +1239,8 @@ int socket_read_message(sd_rtnl *rtnl) {
-                 if (new_msg->nlmsg_type == NLMSG_DONE) {
-                         /* finished reading multi-part message */
-                         done = true;
--                        break;
-+
-+                        continue;
-                 }
- 
-                 /* check that we support this message type */
-diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
-index 2699374..e2afcb8 100644
---- a/src/libudev/libudev-device.c
-+++ b/src/libudev/libudev-device.c
-@@ -730,8 +730,13 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con
-                         return NULL;
-         } else {
-                 /* everything else just needs to be a directory */
--                if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
-+                if (stat(path, &statbuf) != 0)
-                         return NULL;
-+
-+                if (!S_ISDIR(statbuf.st_mode)) {
-+                        errno = EISDIR;
-+                        return NULL;
-+                }
-         }
- 
-         udev_device = udev_device_new(udev);
-diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
-index b6d9bc6..759794f 100644
---- a/src/nspawn/nspawn.c
-+++ b/src/nspawn/nspawn.c
-@@ -758,7 +758,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
-                  * and char devices. */
-                 if (S_ISDIR(source_st.st_mode)) {
-                         r = mkdir_label(where, 0755);
--                        if (r < 0) {
-+                        if (r < 0 && errno != EEXIST) {
-                                 log_error("Failed to create mount point %s: %s", where, strerror(-r));
- 
-                                 return r;
-@@ -818,7 +818,7 @@ static int mount_tmpfs(const char *dest) {
-                         return log_oom();
- 
-                 r = mkdir_label(where, 0755);
--                if (r < 0) {
-+                if (r < 0 && errno != EEXIST) {
-                         log_error("creating mount point for tmpfs %s failed: %s", where, strerror(-r));
- 
-                         return r;
-@@ -3073,6 +3073,7 @@ int main(int argc, char *argv[]) {
-                                 goto finish;
-                         }
-                 } else {
-+#if 0
-                         const char *p;
- 
-                         p = strappenda(arg_directory,
-@@ -3082,6 +3083,7 @@ int main(int argc, char *argv[]) {
-                                 goto finish;
- 
-                         }
-+#endif
-                 }
-         } else {
-                 char template[] = "/tmp/nspawn-root-XXXXXX";
-diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
-index 7375f77..ec8efcc 100644
---- a/src/resolve/resolved-dns-packet.c
-+++ b/src/resolve/resolved-dns-packet.c
-@@ -866,7 +866,7 @@ fail:
- 
- int dns_packet_read_name(DnsPacket *p, char **_ret,
-                          bool allow_compression, size_t *start) {
--        size_t saved_rindex, after_rindex = 0;
-+        size_t saved_rindex, after_rindex = 0, jump_barrier;
-         _cleanup_free_ char *ret = NULL;
-         size_t n = 0, allocated = 0;
-         bool first = true;
-@@ -876,6 +876,7 @@ int dns_packet_read_name(DnsPacket *p, char **_ret,
-         assert(_ret);
- 
-         saved_rindex = p->rindex;
-+        jump_barrier = p->rindex;
- 
-         for (;;) {
-                 uint8_t c, d;
-@@ -922,7 +923,7 @@ int dns_packet_read_name(DnsPacket *p, char **_ret,
-                                 goto fail;
- 
-                         ptr = (uint16_t) (c & ~0xc0) << 8 | (uint16_t) d;
--                        if (ptr < DNS_PACKET_HEADER_SIZE || ptr >= saved_rindex) {
-+                        if (ptr < DNS_PACKET_HEADER_SIZE || ptr >= jump_barrier) {
-                                 r = -EBADMSG;
-                                 goto fail;
-                         }
-@@ -930,9 +931,13 @@ int dns_packet_read_name(DnsPacket *p, char **_ret,
-                         if (after_rindex == 0)
-                                 after_rindex = p->rindex;
- 
-+                        /* Jumps are limited to a "prior occurence" (RFC-1035 4.1.4) */
-+                        jump_barrier = ptr;
-                         p->rindex = ptr;
--                } else
-+                } else {
-+                        r = -EBADMSG;
-                         goto fail;
-+                }
-         }
- 
-         if (!GREEDY_REALLOC(ret, allocated, n + 1)) {
-diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
-index 7d258c9..6dd4cad 100644
---- a/src/resolve/resolved.c
-+++ b/src/resolve/resolved.c
-@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) {
- 
- finish:
-         sd_notify(false,
--                  "STOPPIN=1\n"
-+                  "STOPPING=1\n"
-                   "STATUS=Shutting down...");
- 
-         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-diff --git a/src/run/run.c b/src/run/run.c
-index e3b6293..dcefb5c 100644
---- a/src/run/run.c
-+++ b/src/run/run.c
-@@ -573,9 +573,12 @@ int main(int argc, char* argv[]) {
-         if (r <= 0)
-                 goto finish;
- 
--        r = find_binary(argv[optind], &command);
-+        r = find_binary(argv[optind], arg_transport == BUS_TRANSPORT_LOCAL, &command);
-         if (r < 0) {
--                log_error("Failed to find executable %s: %s", argv[optind], strerror(-r));
-+                log_error("Failed to find executable %s%s: %s",
-+                          argv[optind],
-+                          arg_transport == BUS_TRANSPORT_LOCAL ? "" : " on local system",
-+                          strerror(-r));
-                 goto finish;
-         }
-         argv[optind] = command;
-diff --git a/src/shared/install.c b/src/shared/install.c
-index 035b44c..cab93e8 100644
---- a/src/shared/install.c
-+++ b/src/shared/install.c
-@@ -1620,12 +1620,10 @@ int unit_file_enable(
-         STRV_FOREACH(i, files) {
-                 UnitFileState state;
- 
-+                /* We only want to know if this unit is masked, so we ignore
-+                 * errors from unit_file_get_state, deferring other checks.
-+                 * This allows templated units to be enabled on the fly. */
-                 state = unit_file_get_state(scope, root_dir, *i);
--                if (state < 0) {
--                        log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
--                        return state;
--                }
--
-                 if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) {
-                         log_error("Failed to enable unit: Unit %s is masked", *i);
-                         return -ENOTSUP;
-diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
-index 8f75a8e..c800e01 100644
---- a/src/shared/path-lookup.c
-+++ b/src/shared/path-lookup.c
-@@ -86,17 +86,14 @@ static char** user_dirs(
-         const char * const config_unit_paths[] = {
-                 USER_CONFIG_UNIT_PATH,
-                 "/etc/systemd/user",
-+                "/etc/systemd-mutable/user",
-                 NULL
-         };
- 
-         const char * const runtime_unit_path = "/run/systemd/user";
- 
-         const char * const data_unit_paths[] = {
--                "/usr/local/lib/systemd/user",
--                "/usr/local/share/systemd/user",
-                 USER_DATA_UNIT_PATH,
--                "/usr/lib/systemd/user",
--                "/usr/share/systemd/user",
-                 NULL
-         };
- 
-@@ -260,13 +257,11 @@ int lookup_paths_init(
-                                         STRV_IFNOTNULL(generator_early),
-                                         USER_CONFIG_UNIT_PATH,
-                                         "/etc/systemd/user",
-+                                        "/etc/systemd-mutable/user",
-+                                        "/nix/var/nix/profiles/default/lib/systemd/user",
-                                         "/run/systemd/user",
-                                         STRV_IFNOTNULL(generator),
--                                        "/usr/local/lib/systemd/user",
--                                        "/usr/local/share/systemd/user",
-                                         USER_DATA_UNIT_PATH,
--                                        "/usr/lib/systemd/user",
--                                        "/usr/share/systemd/user",
-                                         STRV_IFNOTNULL(generator_late),
-                                         NULL);
-                 } else
-@@ -276,14 +271,11 @@ int lookup_paths_init(
-                                 STRV_IFNOTNULL(generator_early),
-                                 SYSTEM_CONFIG_UNIT_PATH,
-                                 "/etc/systemd/system",
-+                                "/etc/systemd-mutable/system",
-+                                "/nix/var/nix/profiles/default/lib/systemd/system",
-                                 "/run/systemd/system",
-                                 STRV_IFNOTNULL(generator),
--                                "/usr/local/lib/systemd/system",
-                                 SYSTEM_DATA_UNIT_PATH,
--                                "/usr/lib/systemd/system",
--#ifdef HAVE_SPLIT_USR
--                                "/lib/systemd/system",
--#endif
-                                 STRV_IFNOTNULL(generator_late),
-                                 NULL);
- 
-diff --git a/src/shared/path-util.c b/src/shared/path-util.c
-index 67566bc..be03695 100644
---- a/src/shared/path-util.c
-+++ b/src/shared/path-util.c
-@@ -563,11 +563,11 @@ int path_is_os_tree(const char *path) {
-         return r >= 0;
- }
- 
--int find_binary(const char *name, char **filename) {
-+int find_binary(const char *name, bool local, char **filename) {
-         assert(name);
- 
-         if (is_path(name)) {
--                if (access(name, X_OK) < 0)
-+                if (local && access(name, X_OK) < 0)
-                         return -errno;
- 
-                 if (filename) {
-@@ -657,7 +657,7 @@ int fsck_exists(const char *fstype) {
- 
-         checker = strappenda("fsck.", fstype);
- 
--        r = find_binary(checker, &p);
-+        r = find_binary(checker, true, &p);
-         if (r < 0)
-                 return r;
- 
-diff --git a/src/shared/path-util.h b/src/shared/path-util.h
-index 8d171a5..bd0d324 100644
---- a/src/shared/path-util.h
-+++ b/src/shared/path-util.h
-@@ -55,7 +55,7 @@ int path_is_mount_point(const char *path, bool allow_symlink);
- int path_is_read_only_fs(const char *path);
- int path_is_os_tree(const char *path);
- 
--int find_binary(const char *name, char **filename);
-+int find_binary(const char *name, bool local, char **filename);
- 
- bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
- 
-diff --git a/src/shared/virt.c b/src/shared/virt.c
-index f9c4e67..f3104d5 100644
---- a/src/shared/virt.c
-+++ b/src/shared/virt.c
-@@ -151,7 +151,7 @@ int detect_vm(const char **id) {
-         _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL;
-         static thread_local int cached_found = -1;
-         static thread_local const char *cached_id = NULL;
--        const char *_id = NULL;
-+        const char *_id = NULL, *_id_cpuid = NULL;
-         int r;
- 
-         if (_likely_(cached_found >= 0)) {
-@@ -197,10 +197,26 @@ int detect_vm(const char **id) {
- 
-         /* this will set _id to "other" and return 0 for unknown hypervisors */
-         r = detect_vm_cpuid(&_id);
--        if (r != 0)
-+
-+        /* finish when found a known hypervisor other than kvm */
-+        if (r < 0 || (r > 0 && !streq(_id, "kvm")))
-                 goto finish;
- 
-+        _id_cpuid = _id;
-+
-         r = detect_vm_dmi(&_id);
-+
-+        /* kvm with and without Virtualbox */
-+        if (streq_ptr(_id_cpuid, "kvm")) {
-+                if (r > 0 && streq(_id, "oracle"))
-+                        goto finish;
-+
-+                _id = _id_cpuid;
-+                r = 1;
-+                goto finish;
-+        }
-+
-+        /* information from dmi */
-         if (r != 0)
-                 goto finish;
- 
-@@ -293,8 +309,26 @@ int detect_container(const char **id) {
- 
-                 r = read_one_line_file("/run/systemd/container", &m);
-                 if (r == -ENOENT) {
--                        r = 0;
--                        goto finish;
-+
-+                        /* Fallback for cases where PID 1 was not
-+                         * systemd (for example, cases where
-+                         * init=/bin/sh is used. */
-+
-+                        r = getenv_for_pid(1, "container", &m);
-+                        if (r <= 0) {
-+
-+                                /* If that didn't work, give up,
-+                                 * assume no container manager.
-+                                 *
-+                                 * Note: This means we still cannot
-+                                 * detect containers if init=/bin/sh
-+                                 * is passed but privileges dropped,
-+                                 * as /proc/1/environ is only readable
-+                                 * with privileges. */
-+
-+                                r = 0;
-+                                goto finish;
-+                        }
-                 }
-                 if (r < 0)
-                         return r;
-diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
-index 28eaa6a..3866308 100644
---- a/src/systemctl/systemctl.c
-+++ b/src/systemctl/systemctl.c
-@@ -2651,7 +2651,7 @@ static int start_unit_one(
- 
-                 log_debug("Adding %s to the set", p);
-                 r = set_consume(s, p);
--                if (r < 0)
-+                if (r < 0 && r != -EEXIST)
-                         return log_oom();
-         }
- 
-@@ -6917,8 +6917,13 @@ done:
- 
- static int halt_now(enum action a) {
- 
--/* Make sure C-A-D is handled by the kernel from this
--         * point on... */
-+        /* The kernel will automaticall flush ATA disks and suchlike
-+         * on reboot(), but the file systems need to be synce'd
-+         * explicitly in advance. */
-+        sync();
-+
-+        /* Make sure C-A-D is handled by the kernel from this point
-+         * on... */
-         reboot(RB_ENABLE_CAD);
- 
-         switch (a) {
-diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h
-index eb24372..00237a2 100644
---- a/src/systemd/sd-journal.h
-+++ b/src/systemd/sd-journal.h
-@@ -138,13 +138,15 @@ int sd_journal_reliable_fd(sd_journal *j);
- int sd_journal_get_catalog(sd_journal *j, char **text);
- int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **text);
- 
-+/* the inverse condition avoids ambiguity of danling 'else' after the macro */
- #define SD_JOURNAL_FOREACH(j)                                           \
--        if (sd_journal_seek_head(j) >= 0)                               \
--                while (sd_journal_next(j) > 0)
-+        if (sd_journal_seek_head(j) < 0) { }                            \
-+        else while (sd_journal_next(j) > 0)
- 
-+/* the inverse condition avoids ambiguity of danling 'else' after the macro */
- #define SD_JOURNAL_FOREACH_BACKWARDS(j)                                 \
--        if (sd_journal_seek_tail(j) >= 0)                               \
--                while (sd_journal_previous(j) > 0)
-+        if (sd_journal_seek_tail(j) < 0) { }                            \
-+        else while (sd_journal_previous(j) > 0)
- 
- #define SD_JOURNAL_FOREACH_DATA(j, data, l)                             \
-         for (sd_journal_restart_data(j); sd_journal_enumerate_data((j), &(data), &(l)) > 0; )
-diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
-index 63d64b2..57264de 100644
---- a/src/test/test-path-util.c
-+++ b/src/test/test-path-util.c
-@@ -85,29 +85,30 @@ static void test_path(void) {
-         }
- }
- 
--static void test_find_binary(const char *self) {
-+static void test_find_binary(const char *self, bool local) {
-         char *p;
- 
--        assert_se(find_binary("/bin/sh", &p) == 0);
-+        assert_se(find_binary("/bin/sh", local, &p) == 0);
-         puts(p);
-         assert_se(streq(p, "/bin/sh"));
-         free(p);
- 
--        assert_se(find_binary(self, &p) == 0);
-+        assert_se(find_binary(self, local, &p) == 0);
-         puts(p);
-         assert_se(endswith(p, "/test-path-util"));
-         assert_se(path_is_absolute(p));
-         free(p);
- 
--        assert_se(find_binary("sh", &p) == 0);
-+        assert_se(find_binary("sh", local, &p) == 0);
-         puts(p);
-         assert_se(endswith(p, "/sh"));
-         assert_se(path_is_absolute(p));
-         free(p);
- 
--        assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
-+        assert_se(find_binary("xxxx-xxxx", local, &p) == -ENOENT);
- 
--        assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
-+        assert_se(find_binary("/some/dir/xxxx-xxxx", local, &p) ==
-+                  (local ? -ENOENT : 0));
- }
- 
- static void test_prefixes(void) {
-@@ -244,7 +245,8 @@ static void test_strv_resolve(void) {
- 
- int main(int argc, char **argv) {
-         test_path();
--        test_find_binary(argv[0]);
-+        test_find_binary(argv[0], true);
-+        test_find_binary(argv[0], false);
-         test_prefixes();
-         test_path_join();
-         test_fsck_exists();
-diff --git a/src/udev/udevd.c b/src/udev/udevd.c
-index 2e6c713..193702c 100644
---- a/src/udev/udevd.c
-+++ b/src/udev/udevd.c
-@@ -994,9 +994,9 @@ static void kernel_cmdline_options(struct udev *udev) {
-                         if (r < 0)
-                                 log_warning("Invalid udev.exec-delay ignored: %s", opt + 16);
-                 } else if (startswith(opt, "udev.event-timeout=")) {
--                        r = safe_atou64(opt + 16, &arg_event_timeout_usec);
-+                        r = safe_atou64(opt + 19, &arg_event_timeout_usec);
-                         if (r < 0) {
--                                log_warning("Invalid udev.event-timeout ignored: %s", opt + 16);
-+                                log_warning("Invalid udev.event-timeout ignored: %s", opt + 19);
-                                 break;
-                         }
-                         arg_event_timeout_usec *= USEC_PER_SEC;
-diff --git a/units/console-getty.service.m4.in b/units/console-getty.service.m4.in
-index 8ac51a4..cae9fb5 100644
---- a/units/console-getty.service.m4.in
-+++ b/units/console-getty.service.m4.in
-@@ -15,7 +15,6 @@ After=rc-local.service
- Before=getty.target
- 
- [Service]
--ExecStart=-/sbin/agetty --noclear --keep-baud console 115200,38400,9600 $TERM
- Type=idle
- Restart=always
- RestartSec=0
-diff --git a/units/container-getty@.service.m4.in b/units/container-getty@.service.m4.in
-index 4f7794b..6dfc2e9 100644
---- a/units/container-getty@.service.m4.in
-+++ b/units/container-getty@.service.m4.in
-@@ -14,9 +14,9 @@ After=rc-local.service
- )m4_dnl
- Before=getty.target
- IgnoreOnIsolate=yes
-+ConditionPathExists=/dev/pts/%I
- 
- [Service]
--ExecStart=-/sbin/agetty --noclear --keep-baud pts/%I 115200,38400,9600 $TERM
- Type=idle
- Restart=always
- RestartSec=0
-diff --git a/units/emergency.service.in b/units/emergency.service.in
-index 18973e7..3a99660 100644
---- a/units/emergency.service.in
-+++ b/units/emergency.service.in
-@@ -16,7 +16,6 @@ Before=shutdown.target
- [Service]
- Environment=HOME=/root
- WorkingDirectory=/root
--ExecStartPre=-/bin/plymouth quit
- ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" or ^D to\\ntry again to boot into default mode.'
- ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
- Type=idle
-diff --git a/units/getty@.service.m4 b/units/getty@.service.m4
-index 46164ab..f194a31 100644
---- a/units/getty@.service.m4
-+++ b/units/getty@.service.m4
-@@ -23,11 +23,12 @@ IgnoreOnIsolate=yes
- # On systems without virtual consoles, don't start any getty. Note
- # that serial gettys are covered by serial-getty@.service, not this
- # unit.
--ConditionPathExists=/dev/tty0
-+ConditionPathExists=|/dev/tty0
-+ConditionVirtualization=|lxc
-+ConditionVirtualization=|lxc-libvirt
- 
- [Service]
- # the VT is cleared by TTYVTDisallocate
--ExecStart=-/sbin/agetty --noclear %I $TERM
- Type=idle
- Restart=always
- RestartSec=0
-diff --git a/units/kmod-static-nodes.service.in b/units/kmod-static-nodes.service.in
-index 0934a87..7e30c9e 100644
---- a/units/kmod-static-nodes.service.in
-+++ b/units/kmod-static-nodes.service.in
-@@ -10,7 +10,6 @@ Description=Create list of required static device nodes for the current kernel
- DefaultDependencies=no
- Before=sysinit.target systemd-tmpfiles-setup-dev.service
- ConditionCapability=CAP_SYS_MODULE
--ConditionPathExists=/lib/modules/%v/modules.devname
- 
- [Service]
- Type=oneshot
-diff --git a/units/local-fs.target b/units/local-fs.target
-index d2e5429..d26984b 100644
---- a/units/local-fs.target
-+++ b/units/local-fs.target
-@@ -13,3 +13,5 @@ Conflicts=shutdown.target
- After=local-fs-pre.target
- OnFailure=emergency.target
- OnFailureJobMode=replace-irreversibly
-+
-+X-StopOnReconfiguration=yes
-diff --git a/units/remote-fs.target b/units/remote-fs.target
-index 43ffa5c..156a681 100644
---- a/units/remote-fs.target
-+++ b/units/remote-fs.target
-@@ -12,5 +12,7 @@ After=remote-fs-pre.target
- DefaultDependencies=no
- Conflicts=shutdown.target
- 
-+X-StopOnReconfiguration=yes
-+
- [Install]
- WantedBy=multi-user.target
-diff --git a/units/rescue.service.in b/units/rescue.service.in
-index fc93f1e..3c87cf8 100644
---- a/units/rescue.service.in
-+++ b/units/rescue.service.in
-@@ -16,7 +16,6 @@ Before=shutdown.target
- [Service]
- Environment=HOME=/root
- WorkingDirectory=/root
--ExecStartPre=-/bin/plymouth quit
- ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" or ^D to\\nboot into default mode.'
- ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
- Type=idle
-diff --git a/units/serial-getty@.service.m4 b/units/serial-getty@.service.m4
-index 4522d0d..96daa5c 100644
---- a/units/serial-getty@.service.m4
-+++ b/units/serial-getty@.service.m4
-@@ -22,7 +22,6 @@ Before=getty.target
- IgnoreOnIsolate=yes
- 
- [Service]
--ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM
- Type=idle
- Restart=always
- UtmpIdentifier=%I
-diff --git a/units/sysinit.target b/units/sysinit.target
-index ec33503..4ac47b9 100644
---- a/units/sysinit.target
-+++ b/units/sysinit.target
-@@ -9,5 +9,4 @@
- Description=System Initialization
- Documentation=man:systemd.special(7)
- Conflicts=emergency.service emergency.target
--Wants=local-fs.target swap.target
--After=local-fs.target swap.target emergency.service emergency.target
-+After=emergency.service emergency.target
-diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in
-index ecf3de4..7e83446 100644
---- a/units/systemd-backlight@.service.in
-+++ b/units/systemd-backlight@.service.in
-@@ -19,3 +19,4 @@ Type=oneshot
- RemainAfterExit=yes
- ExecStart=@rootlibexecdir@/systemd-backlight load %i
- ExecStop=@rootlibexecdir@/systemd-backlight save %i
-+X-RestartIfChanged=false
-diff --git a/units/systemd-journal-flush.service.in b/units/systemd-journal-flush.service.in
-index 699670b..ba22c6d 100644
---- a/units/systemd-journal-flush.service.in
-+++ b/units/systemd-journal-flush.service.in
-@@ -10,8 +10,10 @@ Description=Trigger Flushing of Journal to Persistent Storage
- Documentation=man:systemd-journald.service(8) man:journald.conf(5)
- DefaultDependencies=no
- Requires=systemd-journald.service
--After=systemd-journald.service local-fs.target remote-fs.target
-+After=systemd-journald.service
-+After=systemd-remount-fs.service
- Before=systemd-user-sessions.service systemd-tmpfiles-setup.service
-+RequiresMountsFor=/var/log/journal
- 
- [Service]
- ExecStart=@rootbindir@/journalctl --flush
-diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in
-index 4de38fa..2f23c13 100644
---- a/units/systemd-journald.service.in
-+++ b/units/systemd-journald.service.in
-@@ -14,6 +14,7 @@ After=systemd-journald.socket systemd-journald-dev-log.socket syslog.socket
- Before=sysinit.target
- 
- [Service]
-+Type=notify
- Sockets=systemd-journald.socket systemd-journald-dev-log.socket
- ExecStart=@rootlibexecdir@/systemd-journald
- Restart=always
-@@ -26,3 +27,8 @@ WatchdogSec=1min
- # Increase the default a bit in order to allow many simultaneous
- # services being run since we keep one fd open per service.
- LimitNOFILE=16384
-+
-+# Don't restart journald, since that causes services connected to
-+# journald to stop logging (see
-+# https://bugs.freedesktop.org/show_bug.cgi?id=56043).
-+X-RestartIfChanged=no
-diff --git a/units/systemd-random-seed.service.in b/units/systemd-random-seed.service.in
-index b55844b..3ef9fc6 100644
---- a/units/systemd-random-seed.service.in
-+++ b/units/systemd-random-seed.service.in
-@@ -19,3 +19,4 @@ Type=oneshot
- RemainAfterExit=yes
- ExecStart=@rootlibexecdir@/systemd-random-seed load
- ExecStop=@rootlibexecdir@/systemd-random-seed save
-+X-RestartIfChanged=false
-diff --git a/units/systemd-rfkill@.service.in b/units/systemd-rfkill@.service.in
-index 0e9851b..9f8fa0d 100644
---- a/units/systemd-rfkill@.service.in
-+++ b/units/systemd-rfkill@.service.in
-@@ -19,3 +19,4 @@ Type=oneshot
- RemainAfterExit=yes
- ExecStart=@rootlibexecdir@/systemd-rfkill load %I
- ExecStop=@rootlibexecdir@/systemd-rfkill save %I
-+X-RestartIfChanged=false
-diff --git a/units/systemd-tmpfiles-setup.service.in b/units/systemd-tmpfiles-setup.service.in
-index e895cda..194146f 100644
---- a/units/systemd-tmpfiles-setup.service.in
-+++ b/units/systemd-tmpfiles-setup.service.in
-@@ -11,7 +11,7 @@ Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
- DefaultDependencies=no
- Conflicts=shutdown.target
- After=local-fs.target systemd-sysusers.service
--Before=sysinit.target shutdown.target
-+Before=shutdown.target
- RefuseManualStop=yes
- 
- [Service]
-diff --git a/units/systemd-update-utmp.service.in b/units/systemd-update-utmp.service.in
-index 163eccd..7357c12 100644
---- a/units/systemd-update-utmp.service.in
-+++ b/units/systemd-update-utmp.service.in
-@@ -11,7 +11,7 @@ Documentation=man:systemd-update-utmp.service(8) man:utmp(5)
- DefaultDependencies=no
- RequiresMountsFor=/var/log/wtmp
- Conflicts=shutdown.target
--After=systemd-remount-fs.service systemd-tmpfiles-setup.service auditd.service
-+After=systemd-remount-fs.service auditd.service
- Before=sysinit.target shutdown.target
- 
- [Service]
-@@ -19,3 +19,4 @@ Type=oneshot
- RemainAfterExit=yes
- ExecStart=@rootlibexecdir@/systemd-update-utmp reboot
- ExecStop=@rootlibexecdir@/systemd-update-utmp shutdown
-+X-RestartIfChanged=false
-diff --git a/units/systemd-user-sessions.service.in b/units/systemd-user-sessions.service.in
-index 0869e73..b6ed958 100644
---- a/units/systemd-user-sessions.service.in
-+++ b/units/systemd-user-sessions.service.in
-@@ -15,3 +15,6 @@ Type=oneshot
- RemainAfterExit=yes
- ExecStart=@rootlibexecdir@/systemd-user-sessions start
- ExecStop=@rootlibexecdir@/systemd-user-sessions stop
-+
-+# Restart kills all active sessions.
-+X-RestartIfChanged=no
diff --git a/pkgs/os-specific/linux/udisks/2-default.nix b/pkgs/os-specific/linux/udisks/2-default.nix
index 76d6caa767c..060d9ad1dd3 100644
--- a/pkgs/os-specific/linux/udisks/2-default.nix
+++ b/pkgs/os-specific/linux/udisks/2-default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, intltool
 , expat, acl, systemd, glib, libatasmart, polkit
-, libxslt, docbook_xsl, utillinux, mdadm
+, libxslt, docbook_xsl, utillinux, mdadm, libgudev
 }:
 
 stdenv.mkDerivation rec {
@@ -26,9 +26,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig intltool ];
 
-  propagatedBuildInputs = [ expat acl systemd glib libatasmart polkit ]; # in closure anyway
-
-  buildInputs = [ libxslt docbook_xsl ];
+  buildInputs = [ libxslt docbook_xsl libgudev expat acl systemd glib libatasmart polkit ];
 
   configureFlags = [
     "--localstatedir=/var"
diff --git a/pkgs/os-specific/linux/upower/default.nix b/pkgs/os-specific/linux/upower/default.nix
index 66b9c34ab51..0f7f93a5741 100644
--- a/pkgs/os-specific/linux/upower/default.nix
+++ b/pkgs/os-specific/linux/upower/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, glib, dbus_glib
-, intltool, libxslt, docbook_xsl, udev, libusb1
+, intltool, libxslt, docbook_xsl, udev, libgudev, libusb1
 , useSystemd ? true, systemd, gobjectIntrospection
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ dbus_glib intltool libxslt docbook_xsl udev libusb1 gobjectIntrospection ]
+    [ dbus_glib intltool libxslt docbook_xsl udev libgudev libusb1 gobjectIntrospection ]
     ++ stdenv.lib.optional useSystemd systemd;
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix
index 7768875ca57..bcd9aa58bcc 100644
--- a/pkgs/os-specific/linux/util-linux/default.nix
+++ b/pkgs/os-specific/linux/util-linux/default.nix
@@ -1,13 +1,15 @@
 { stdenv, fetchurl, zlib, ncurses ? null, perl ? null, pam }:
 
 stdenv.mkDerivation rec {
-  name = "util-linux-2.26.2";
+  name = "util-linux-2.27.1";
 
   src = fetchurl {
-    url = "mirror://kernel/linux/utils/util-linux/v2.26/${name}.tar.xz";
-    sha256 = "0rlnzmiqdannzf81fbh41541lrck63v9zhskm6h4i2jj8ahvsa8f";
+    url = "mirror://kernel/linux/utils/util-linux/v2.27/${name}.tar.xz";
+    sha256 = "1452hz5zx56a3mad8yrg5wb0vy5zi19mpjp6zx1yr6p9xp6qz08a";
   };
 
+  outputs = [ "out" "man" ];
+
   patches = [
     ./rtcwake-search-PATH-for-shutdown.patch
   ];
diff --git a/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch b/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch
index 92cb07d4383..68970c655f1 100644
--- a/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch
+++ b/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch
@@ -4,10 +4,10 @@ distros anyway).
 
   -- nckx <tobias.geerinckx.rice@gmail.com>
 
-diff -Naur a/include/pathnames.h b/include/pathnames.h
---- a/include/pathnames.h	2014-09-16 14:37:06.138551680 +0200
-+++ b/include/pathnames.h	2015-01-01 20:41:02.510948314 +0100
-@@ -43,7 +43,7 @@
+diff -ru util-linux-2.27-orig/include/pathnames.h util-linux-2.27/include/pathnames.h
+--- util-linux-2.27-orig/include/pathnames.h	2015-06-29 13:13:14.669847478 +0200
++++ util-linux-2.27/include/pathnames.h	2015-10-07 20:09:17.401022602 +0200
+@@ -54,7 +54,7 @@
  #define _PATH_INITTAB		"/etc/inittab"
  #define _PATH_RC		"/etc/rc"
  #define _PATH_REBOOT		"/sbin/reboot"
@@ -16,15 +16,15 @@ diff -Naur a/include/pathnames.h b/include/pathnames.h
  #define _PATH_SINGLE		"/etc/singleboot"
  #define _PATH_SHUTDOWN_CONF	"/etc/shutdown.conf"
  
-diff -Naur a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
---- a/sys-utils/rtcwake.c	2014-10-24 11:21:20.447389309 +0200
-+++ b/sys-utils/rtcwake.c	2015-01-01 20:57:59.398911209 +0100
-@@ -582,7 +582,7 @@
+diff -ru util-linux-2.27-orig/sys-utils/rtcwake.c util-linux-2.27/sys-utils/rtcwake.c
+--- util-linux-2.27-orig/sys-utils/rtcwake.c	2015-08-05 11:32:44.453821232 +0200
++++ util-linux-2.27/sys-utils/rtcwake.c	2015-10-07 20:09:37.834032536 +0200
+@@ -576,7 +576,7 @@
+ 		arg[i++] = "now";
  		arg[i]   = NULL;
- 
- 		if (!dryrun) {
+ 		if (!ctl.dryrun) {
 -			execv(arg[0], arg);
 +			execvp(arg[0], arg);
- 
  			warn(_("failed to execute %s"), _PATH_SHUTDOWN);
  			rc = EXIT_FAILURE;
+ 		}
diff --git a/pkgs/servers/mail/opensmtpd/default.nix b/pkgs/servers/mail/opensmtpd/default.nix
index 2fd3f0421b9..a95a5d81ce9 100644
--- a/pkgs/servers/mail/opensmtpd/default.nix
+++ b/pkgs/servers/mail/opensmtpd/default.nix
@@ -4,18 +4,16 @@
 
 stdenv.mkDerivation rec {
   name = "opensmtpd-${version}";
-  version = "5.7.1p1";
+  version = "5.4.5p1";
 
   nativeBuildInputs = [ autoconf automake libtool bison ];
   buildInputs = [ libasr libevent zlib openssl db pam ];
 
   src = fetchurl {
     url = "http://www.opensmtpd.org/archives/${name}.tar.gz";
-    sha256 = "67e9dd9682ca8c181e84e66c76245a4a8f6205834f915a2c021cdfeb22049e3a";
+    sha256 = "15sicrpqsgg72igdckkwpmbgrapcjbfjsdrvm0zl8z13kgp6r4ks";
   };
 
-  patches = [ ./proc_path.diff ];
-
   configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
@@ -26,7 +24,6 @@ stdenv.mkDerivation rec {
     "--with-privsep-user=smtpd"
     "--with-queue-user=smtpq"
     "--with-ca-file=/etc/ssl/certs/ca-certificates.crt"
-    "--with-libevent-dir=${libevent}"
   ];
 
   installFlags = [
diff --git a/pkgs/servers/mail/opensmtpd/extras.nix b/pkgs/servers/mail/opensmtpd/extras.nix
deleted file mode 100644
index 0123d19bf3f..00000000000
--- a/pkgs/servers/mail/opensmtpd/extras.nix
+++ /dev/null
@@ -1,79 +0,0 @@
-{ stdenv, fetchurl, openssl, libevent, libasr,
-  python2, pkgconfig, lua5, perl, mariadb, postgresql, sqlite, hiredis }:
-stdenv.mkDerivation rec {
-  name = "opensmtpd-extras-${version}";
-  version = "5.7.1";
-
-  src = fetchurl {
-    url = "https://www.opensmtpd.org/archives/${name}.tar.gz";
-    sha256 = "1kld4hxgz792s0cb2gl7m2n618ikzqkj88w5dhaxdrxg4x2c4vdm";
-  };
-
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ openssl libevent
-    libasr python2 lua5 perl mariadb postgresql sqlite hiredis ];
-
-  configureFlags = [
-    "--sysconfdir=/etc"
-    "--localstatedir=/var"
-    "--with-privsep-user=smtpd"
-    "--with-libevent-dir=${libevent}"
-
-    "--with-filter-clamav"
-    "--with-filter-dkim-signer"
-    "--with-filter-dnsbl"
-    "--with-filter-monkey"
-    "--with-filter-pause"
-    "--with-filter-regex"
-    "--with-filter-spamassassin"
-    "--with-filter-stub"
-    "--with-filter-trace"
-    "--with-filter-void"
-    "--with-queue-null"
-    "--with-queue-ram"
-    "--with-queue-stub"
-    "--with-table-ldap"
-    "--with-table-socketmap"
-    "--with-table-passwd"
-    "--with-table-stub"
-    "--with-scheduler-ram"
-    "--with-scheduler-stub"
-
-  ] ++ stdenv.lib.optional (python2 != null) [
-    "--with-python=${python2}"
-    "--with-filter-python"
-    "--with-queue-python"
-    "--with-table-python"
-    "--with-scheduler-python"
-
-  ] ++ stdenv.lib.optional (lua5 != null) [
-    "--with-lua=${pkgconfig}"
-    "--with-filter-lua"
-
-  ] ++ stdenv.lib.optional (perl != null) [
-    "--with-perl=${perl}"
-    "--with-filter-perl"
-
-  ] ++ stdenv.lib.optional (mariadb != null) [
-    "--with-table-mysql"
-
-  ] ++ stdenv.lib.optional (postgresql != null) [
-    "--with-table-postgres"
-
-  ] ++ stdenv.lib.optional (sqlite != null) [
-    "--with-table-sqlite"
-
-  ] ++ stdenv.lib.optional (hiredis != null) [
-    "--with-table-redis"
-  ];
-
-  NIX_CFLAGS_COMPILE = stdenv.lib.optional (hiredis != null) [ "-I${hiredis}/include/hiredis" ];
-
-  meta = with stdenv.lib; {
-    homepage = https://www.opensmtpd.org/;
-    description = "Extra plugins for the OpenSMTPD mail server";
-    license = licenses.isc;
-    platforms = platforms.unix;
-    maintainers = with maintainers; [ gebner ];
-  };
-}
diff --git a/pkgs/servers/mail/opensmtpd/proc_path.diff b/pkgs/servers/mail/opensmtpd/proc_path.diff
deleted file mode 100644
index 0e8eac0bb83..00000000000
--- a/pkgs/servers/mail/opensmtpd/proc_path.diff
+++ /dev/null
@@ -1,76 +0,0 @@
-diff -Naur opensmtpd-5.7.1p1/smtpd/parse.y opensmtpd-5.7.1p1.patched/smtpd/parse.y
---- opensmtpd-5.7.1p1/smtpd/parse.y	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/parse.y	2015-09-26 08:41:17.012472516 +0200
-@@ -2519,13 +2519,19 @@
- {
- 	struct filter_conf	*f;
- 	char			*path;
-+        const char              *proc_path;
- 
- 	if (dict_get(&conf->sc_filters, name)) {
- 		yyerror("filter \"%s\" already defined", name);
- 		return (NULL);
- 	}
- 
--	if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) {
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
-+
-+	if (asprintf(&path, "%s/filter-%s", proc_path, prog) == -1) {
- 		yyerror("filter \"%s\" asprintf failed", name);
- 		return (0);
- 	}
-diff -Naur opensmtpd-5.7.1p1/smtpd/smtpd.c opensmtpd-5.7.1p1.patched/smtpd/smtpd.c
---- opensmtpd-5.7.1p1/smtpd/smtpd.c	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/smtpd.c	2015-09-26 08:41:16.998472557 +0200
-@@ -854,6 +854,7 @@
- 	char		path[PATH_MAX];
- 	char		name[PATH_MAX];
- 	char		*arg;
-+        char            *proc_path;
- 
- 	if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
- 		log_warnx("warn: %s-proc: conf too long", key);
-@@ -864,7 +865,12 @@
- 	if (arg)
- 		*arg++ = '\0';
- 
--	if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
-+
-+	if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
- 	    (ssize_t)sizeof(path)) {
- 		log_warn("warn: %s-proc: exec path too long", key);
- 		return (-1);
-diff -Naur opensmtpd-5.7.1p1/smtpd/table.c opensmtpd-5.7.1p1.patched/smtpd/table.c
---- opensmtpd-5.7.1p1/smtpd/table.c	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/table.c	2015-09-26 08:41:17.005472536 +0200
-@@ -201,6 +201,7 @@
- 	struct table_backend	*tb;
- 	char			 buf[LINE_MAX];
- 	char			 path[LINE_MAX];
-+        const char              *proc_path;
- 	size_t			 n;
- 	struct stat		 sb;
- 
-@@ -215,8 +216,14 @@
- 	if (name && table_find(name, NULL))
- 		fatalx("table_create: table \"%s\" already defined", name);
- 
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
-+
- 	if ((tb = table_backend_lookup(backend)) == NULL) {
--		if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC "/table-%s",
-+		if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
-+                    proc_path,
- 		    backend) >= sizeof(path)) {
- 			fatalx("table_create: path too long \""
- 			    PATH_LIBEXEC "/table-%s\"", backend);
diff --git a/pkgs/servers/search/elasticsearch/default.nix b/pkgs/servers/search/elasticsearch/default.nix
index 859f1501bb3..16f01030290 100644
--- a/pkgs/servers/search/elasticsearch/default.nix
+++ b/pkgs/servers/search/elasticsearch/default.nix
@@ -3,11 +3,11 @@
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "elasticsearch-1.5.2";
+  name = "elasticsearch-1.7.2";
 
   src = fetchurl {
     url = "https://download.elastic.co/elasticsearch/elasticsearch/${name}.tar.gz";
-    sha256 = "054s0k0y0g1x6wzbd6gmvrp5n89fqwqssbyhay0gmhvs6sbpibpg";
+    sha256 = "1lix4asvx1lbc227gzsrws3xqbcbqaal7v10w60kch0c4xg970bg";
   };
 
   patches = [ ./es-home.patch ];
diff --git a/pkgs/servers/search/elasticsearch/es-home.patch b/pkgs/servers/search/elasticsearch/es-home.patch
index 2f7a7fe7919..2f2018fd69f 100644
--- a/pkgs/servers/search/elasticsearch/es-home.patch
+++ b/pkgs/servers/search/elasticsearch/es-home.patch
@@ -28,9 +28,10 @@ diff -rupN a/bin/plugin b/bin/plugin
  
  # make ELASTICSEARCH_HOME absolute
  ES_HOME=`cd "$ES_HOME"; pwd`
-@@ -45,4 +48,4 @@ while [ $# -gt 0 ]; do
-   shift
- done
- 
--exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args
-+exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_CLASSPATH/lib/*" org.elasticsearch.plugins.PluginManager $args
+@@ -105,4 +105,4 @@
+
+ export HOSTNAME=`hostname -s`
+
+-eval "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home=\""$ES_HOME"\" $properties -cp \""$ES_HOME/lib/*"\" org.elasticsearch.plugins.PluginManager $args
+\ No newline at end of file
++eval "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_CLASSPATH/lib/*" org.elasticsearch.plugins.PluginManager $args
diff --git a/pkgs/servers/sql/mariadb/default.nix b/pkgs/servers/sql/mariadb/default.nix
index df7721ca81e..c758ef88269 100644
--- a/pkgs/servers/sql/mariadb/default.nix
+++ b/pkgs/servers/sql/mariadb/default.nix
@@ -1,19 +1,25 @@
-{ stdenv, fetchurl, cmake, ncurses, zlib, openssl, pcre, boost, judy, bison, libxml2
-, libaio, libevent, groff, jemalloc, perl, fixDarwinDylibNames, cctools
+{ stdenv, fetchurl, cmake, ncurses, zlib, xz, lzo, lz4, bzip2, snappy
+, openssl, pcre, boost, judy, bison, libxml2
+, libaio, libevent, groff, jemalloc, cracklib, systemd, numactl, perl
+, fixDarwinDylibNames, cctools
 }:
 
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "mariadb-${version}";
-  version = "10.0.22";
+  version = "10.1.8";
 
   src = fetchurl {
     url    = "https://downloads.mariadb.org/interstitial/mariadb-${version}/source/mariadb-${version}.tar.gz";
-    sha256 = "0yzwv99s6smbmhs28pmdy01h23sdjxaa5k2m8n3rl1mprjmg85wy";
+    sha256 = "1yiv0161rkgll1yd9r1cb1wdx55rwynj8i623p6wjvda9536mgvw";
   };
 
-  buildInputs = [ cmake ncurses openssl zlib pcre libxml2 boost judy bison libevent ]
-    ++ stdenv.lib.optionals stdenv.isLinux [ jemalloc libaio ]
+  buildInputs = [
+    cmake ncurses openssl zlib xz lzo lz4 bzip2
+    # temporary due to https://mariadb.atlassian.net/browse/MDEV-9000
+    (if stdenv.is64bit then snappy else null)
+    pcre libxml2 boost judy bison libevent cracklib
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ jemalloc libaio systemd numactl ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ perl fixDarwinDylibNames cctools ];
 
   patches = stdenv.lib.optional stdenv.isDarwin ./my_context_asm.patch;
@@ -49,6 +55,8 @@ stdenv.mkDerivation rec {
     "-DWITH_PARTITION_STORAGE_ENGINE=1"
     "-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1"
     "-DWITHOUT_FEDERATED_STORAGE_ENGINE=1"
+    "-DSECURITY_HARDENED=ON"
+    "-DWITH_WSREP=ON"
   ] ++ stdenv.lib.optionals stdenv.isDarwin [
     "-DWITHOUT_OQGRAPH_STORAGE_ENGINE=1"
     "-DWITHOUT_TOKUDB=1"
@@ -56,7 +64,7 @@ stdenv.mkDerivation rec {
   ];
 
   # fails to find lex_token.h sometimes
-  enableParallelBuilding = stdenv.isDarwin;
+  enableParallelBuilding = true;
 
   outputs = [ "out" "lib" ];
 
diff --git a/pkgs/servers/x11/quartz-wm/default.nix b/pkgs/servers/x11/quartz-wm/default.nix
index 5c9fe74b2ed..45e4df2bb8b 100644
--- a/pkgs/servers/x11/quartz-wm/default.nix
+++ b/pkgs/servers/x11/quartz-wm/default.nix
@@ -21,6 +21,9 @@ in stdenv.mkDerivation {
     pkgconfig
     AppKit Xplugin
   ];
+  NIX_CFLAGS_COMPILE = "-F/System/Library/Frameworks -I/usr/include";
+  NIX_LDFLAGS = stdenv.lib.optional stdenv.isDarwin
+    "/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation";
   meta = with lib; {
     license = licenses.apsl20;
     platforms = platforms.darwin;
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 1ef67a1aa8e..1339e51eb23 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -360,6 +360,9 @@ in
           "--with-bundle-id-prefix=org.nixos.xquartz"
           "--with-sha1=CommonCrypto"
         ];
+        __impureHostDeps = ["/System/Library" "/usr"];
+        NIX_CFLAGS_COMPILE = "-F/System/Library/Frameworks -I/usr/include";
+        NIX_CFLAGS_LINK = "-L/usr/lib";
         preConfigure = ''
           ensureDir $out/Applications
           export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-error"
diff --git a/pkgs/servers/x11/xquartz/default.nix b/pkgs/servers/x11/xquartz/default.nix
index cb84111c2c2..920b66147f2 100644
--- a/pkgs/servers/x11/xquartz/default.nix
+++ b/pkgs/servers/x11/xquartz/default.nix
@@ -109,8 +109,7 @@ in stdenv.mkDerivation {
 
     cp ${installer} $out/bin/xquartz-install
 
-    rm -rf $out/LaunchAgents
-    rm -rf $out/LaunchDaemons
+    rm -rf $out/LaunchAgents $out/LaunchDaemons
 
     fontsConfPath=$out/etc/X11/fonts.conf
     cp ${fontsConf} $fontsConfPath
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 9ad2c8504d1..c5634984532 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -58,6 +58,8 @@ rec {
     export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
     export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib"
     export CMAKE_OSX_ARCHITECTURES=x86_64
+    # Workaround for https://openradar.appspot.com/22671534 on 10.11.
+    export gl_cv_func_getcwd_abort_bug=no
   '';
 
   # A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 57875fa6ada..a01af7db70a 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -450,7 +450,7 @@ substituteAllInPlace() {
 # the environment used for building.
 dumpVars() {
     if [ "$noDumpEnvVars" != 1 ]; then
-        export > "$NIX_BUILD_TOP/env-vars"
+        export > "$NIX_BUILD_TOP/env-vars" || true
     fi
 }
 
diff --git a/pkgs/stdenv/pure-darwin/default.nix b/pkgs/stdenv/pure-darwin/default.nix
index 265d7bf7fc4..d13dc98cd74 100644
--- a/pkgs/stdenv/pure-darwin/default.nix
+++ b/pkgs/stdenv/pure-darwin/default.nix
@@ -220,11 +220,13 @@ in rec {
   persistent3 = orig: with stage3.pkgs; {
     inherit
       gnumake gzip gnused bzip2 gawk ed xz patch bash
-      libcxxabi libcxx ncurses libffi zlib llvm gmp pcre gnugrep
+      libcxxabi libcxx ncurses libffi zlib gmp pcre gnugrep
       coreutils findutils diffutils patchutils;
 
-    llvmPackages = orig.llvmPackages // {
-      inherit (llvmPackages) llvm clang-unwrapped;
+    llvmPackages = let llvmOverride = llvmPackages.llvm.override { inherit libcxxabi; };
+    in orig.llvmPackages // {
+      llvm = llvmOverride;
+      clang-unwrapped = llvmPackages.clang-unwrapped.override { llvm = llvmOverride; };
     };
 
     darwin = orig.darwin // {
diff --git a/pkgs/tools/archivers/unzip/CVE-2015-7696.diff b/pkgs/tools/archivers/unzip/CVE-2015-7696.diff
new file mode 100644
index 00000000000..3aad17bddd7
--- /dev/null
+++ b/pkgs/tools/archivers/unzip/CVE-2015-7696.diff
@@ -0,0 +1,66 @@
+From 68efed87fabddd450c08f3112f62a73f61d493c9 Mon Sep 17 00:00:00 2001
+From: Petr Stodulka <pstodulk@redhat.com>
+Date: Mon, 14 Sep 2015 18:23:17 +0200
+Subject: [PATCH 1/2] upstream fix for heap overflow
+
+https://bugzilla.redhat.com/attachment.cgi?id=1073002
+---
+ crypt.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/crypt.c b/crypt.c
+index 784e411..a8975f2 100644
+--- a/crypt.c
++++ b/crypt.c
+@@ -465,7 +465,17 @@ int decrypt(__G__ passwrd)
+     GLOBAL(pInfo->encrypted) = FALSE;
+     defer_leftover_input(__G);
+     for (n = 0; n < RAND_HEAD_LEN; n++) {
+-        b = NEXTBYTE;
++        /* 2012-11-23 SMS.  (OUSPG report.)
++         * Quit early if compressed size < HEAD_LEN.  The resulting
++         * error message ("unable to get password") could be improved,
++         * but it's better than trying to read nonexistent data, and
++         * then continuing with a negative G.csize.  (See
++         * fileio.c:readbyte()).
++         */
++        if ((b = NEXTBYTE) == (ush)EOF)
++        {
++            return PK_ERR;
++        }
+         h[n] = (uch)b;
+         Trace((stdout, " (%02x)", h[n]));
+     }
+-- 
+2.4.6
+
+
+From bd8a743ee0a77e65ad07ef4196c4cd366add3f26 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Mon, 14 Sep 2015 18:24:56 +0200
+Subject: [PATCH 2/2] fix infinite loop when extracting empty bzip2 data
+
+---
+ extract.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/extract.c b/extract.c
+index 7134bfe..29db027 100644
+--- a/extract.c
++++ b/extract.c
+@@ -2733,6 +2733,12 @@ __GDEF
+     int repeated_buf_err;
+     bz_stream bstrm;
+ 
++    if (G.incnt <= 0 && G.csize <= 0L) {
++        /* avoid an infinite loop */
++        Trace((stderr, "UZbunzip2() got empty input\n"));
++        return 2;
++    }
++
+ #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
+     if (G.redirect_slide)
+         wsize = G.redirect_size, redirSlide = G.redirect_buffer;
+-- 
+2.4.6
+
diff --git a/pkgs/tools/archivers/unzip/CVE-2015-7697.diff b/pkgs/tools/archivers/unzip/CVE-2015-7697.diff
new file mode 100644
index 00000000000..98ebf53c478
--- /dev/null
+++ b/pkgs/tools/archivers/unzip/CVE-2015-7697.diff
@@ -0,0 +1,36 @@
+From bd150334fb4084f5555a6be26b015a0671cb5b74 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Tue, 22 Sep 2015 18:52:23 +0200
+Subject: [PATCH] extract: prevent unsigned overflow on invalid input
+
+Suggested-by: Stefan Cornelius
+---
+ extract.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/extract.c b/extract.c
+index 29db027..b9ae667 100644
+--- a/extract.c
++++ b/extract.c
+@@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk,
+         if (G.lrec.compression_method == STORED) {
+             zusz_t csiz_decrypted = G.lrec.csize;
+ 
+-            if (G.pInfo->encrypted)
++            if (G.pInfo->encrypted) {
++                if (csiz_decrypted <= 12) {
++                    /* handle the error now to prevent unsigned overflow */
++                    Info(slide, 0x401, ((char *)slide,
++                      LoadFarStringSmall(ErrUnzipNoFile),
++                      LoadFarString(InvalidComprData),
++                      LoadFarStringSmall2(Inflate)));
++                    return PK_ERR;
++                }
+                 csiz_decrypted -= 12;
++            }
+             if (G.lrec.ucsize != csiz_decrypted) {
+                 Info(slide, 0x401, ((char *)slide,
+                   LoadFarStringSmall2(WrnStorUCSizCSizDiff),
+-- 
+2.5.2
+
diff --git a/pkgs/tools/archivers/unzip/default.nix b/pkgs/tools/archivers/unzip/default.nix
index c5e06663dc0..b5d03bc18b2 100644
--- a/pkgs/tools/archivers/unzip/default.nix
+++ b/pkgs/tools/archivers/unzip/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
     ./CVE-2014-8140.diff
     ./CVE-2014-8141.diff
     ./CVE-2014-9636.diff
+    ./CVE-2015-7696.diff
+    ./CVE-2015-7697.diff
   ] ++ stdenv.lib.optional enableNLS
     (fetchurl {
       url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1";
diff --git a/pkgs/tools/backup/httrack/default.nix b/pkgs/tools/backup/httrack/default.nix
index 5667bb5e748..8860fbc5dbc 100644
--- a/pkgs/tools/backup/httrack/default.nix
+++ b/pkgs/tools/backup/httrack/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "10p4gf8y9h7mxkqlbs3hqgvmvbgvcbax8jp1whbw4yidwahn06w7";
   };
 
-  buildInputs = [ zlib openssl libiconv ];
+  buildInputs = [ zlib openssl ] ++ stdenv.lib.optional stdenv.isDarwin libiconv;
 
   meta = {
     homepage = "http://www.httrack.com";
diff --git a/pkgs/tools/compression/xz/default.nix b/pkgs/tools/compression/xz/default.nix
index 6a9d4582dff..5f5ee28ca06 100644
--- a/pkgs/tools/compression/xz/default.nix
+++ b/pkgs/tools/compression/xz/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "xz-5.2.1";
+  name = "xz-5.2.2";
 
   src = fetchurl {
     url = "http://tukaani.org/xz/${name}.tar.bz2";
-    sha256 = "101a1kih58s1ysqfncqw69qnwx1zlbjxwhnfmp0z5gz0jzs4i4b7";
+    sha256 = "1da071wyx921pyx3zkxlnbpp14p6km98pnp66mg1arwi9dxgbxbg";
   };
 
   doCheck = true;
diff --git a/pkgs/tools/filesystems/duff/default.nix b/pkgs/tools/filesystems/duff/default.nix
index 1c4d068c4c1..31015334166 100644
--- a/pkgs/tools/filesystems/duff/default.nix
+++ b/pkgs/tools/filesystems/duff/default.nix
@@ -1,14 +1,12 @@
 { stdenv, fetchFromGitHub, autoreconfHook, gettext }:
 
-# The last release (0.5.2) is more than 2 years old and lacks features like -D,
-# limiting its usefulness. Upstream appears comatose if not dead.
-let version = "2014-07-03"; in
+let version = "0.5.2"; in
 stdenv.mkDerivation {
   name = "duff-${version}";
 
   src = fetchFromGitHub {
-    sha256 = "1k2dx38pjzc5d624vw1cs5ipj9fprsm5vqv55agksc29m63lswnx";
-    rev = "f26d4837768b062a3f98fa075c791d9c8a0bb75c";
+    sha256 = "0yfm910wjj6z0f0cg68x59ykf4ql5m49apzy8sra00f8kv4lpn53";
+    rev = version;
     repo = "duff";
     owner = "elmindreda";
   };
@@ -16,6 +14,10 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ autoreconfHook gettext ];
 
   preAutoreconf = ''
+    # duff is currently badly packaged, requiring us to do extra work here that
+    # should be done upstream. If that is ever fixed, this entire phase can be
+    # removed along with all buildInputs.
+
     # gettexttize rightly refuses to run non-interactively:
     cp ${gettext}/bin/gettextize .
     substituteInPlace gettextize \
@@ -28,15 +30,14 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-    inherit version;
     description = "Quickly find duplicate files";
+    homepage = http://duff.dreda.org/;
+    license = licenses.zlib;
     longDescription = ''
       Duff is a Unix command-line utility for quickly finding duplicates in
       a given set of files.
     '';
-    homepage = http://duff.dreda.org/;
-    license = licenses.zlib;
-    platforms = platforms.all;
     maintainers = with maintainers; [ nckx ];
+    platforms = with platforms; all;
   };
 }
diff --git a/pkgs/tools/graphics/enblend-enfuse/default.nix b/pkgs/tools/graphics/enblend-enfuse/default.nix
index c967b73001c..6b65d3df0d3 100644
--- a/pkgs/tools/graphics/enblend-enfuse/default.nix
+++ b/pkgs/tools/graphics/enblend-enfuse/default.nix
@@ -1,24 +1,22 @@
 { stdenv, fetchurl
 , boost, freeglut, glew, gsl, lcms2, libpng, libtiff, libxmi, mesa, vigra
-, help2man, pkgconfig, perl }:
+, pkgconfig, perl }:
 
-let version = "4.1.4"; in
 stdenv.mkDerivation rec {
-  name = "enblend-enfuse-${version}";
+  name = "enblend-enfuse-4.1.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/enblend/${name}.tar.gz";
-    sha256 = "0208x01i129hqylmy6jh3krwdac47mx6fi8xccjm9h35c18c7xl5";
+    sha256 = "1b7r1nnwaind0344ckwggy0ghl0ipbk9jzylsxcjfl05rnasw00w";
   };
 
   buildInputs = [ boost freeglut glew gsl lcms2 libpng libtiff libxmi mesa vigra ];
 
-  nativeBuildInputs = [ help2man perl pkgconfig ];
+  nativeBuildInputs = [ perl pkgconfig ];
 
   enableParallelBuilding = true;
 
   meta = {
-    inherit version;
     homepage = http://enblend.sourceforge.net/;
     description = "Blends away the seams in a panoramic image mosaic using a multiresolution spline";
     license = stdenv.lib.licenses.gpl2;
diff --git a/pkgs/tools/misc/cloc/default.nix b/pkgs/tools/misc/cloc/default.nix
index bb278dbe1b1..0b5796d4ac3 100644
--- a/pkgs/tools/misc/cloc/default.nix
+++ b/pkgs/tools/misc/cloc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl, AlgorithmDiff, RegexpCommon }:
+{ stdenv, fetchurl, fetchpatch, perl, AlgorithmDiff, RegexpCommon }:
 
 stdenv.mkDerivation rec {
 
@@ -11,6 +11,12 @@ stdenv.mkDerivation rec {
     sha256 = "1w3mz69h2i7pscvi9q7yp7wimds8g38c5ph78cj5pvjl5wa035rh";
   };
 
+  patches = [ (fetchpatch {
+    name = "perl-5.22.patch";
+    url = "https://bugs.archlinux.org/task/45494?getfile=13174";
+    sha256 = "1xxwqjy2q2fdza7kfp9ld0yzljkdsrgm8a9pwnmx5q4adigcjjsz";
+  }) ];
+
   buildInputs = [ perl AlgorithmDiff RegexpCommon ];
 
   makeFlags = [ "prefix=" "DESTDIR=$(out)" "INSTALL=install" ];
diff --git a/pkgs/tools/misc/colord/default.nix b/pkgs/tools/misc/colord/default.nix
index 267ed4db67c..40c9ddf8c94 100644
--- a/pkgs/tools/misc/colord/default.nix
+++ b/pkgs/tools/misc/colord/default.nix
@@ -1,6 +1,7 @@
 { stdenv, fetchzip, fetchgit, bashCompletion
 , glib, polkit, pkgconfig, intltool, gusb, libusb1, lcms2, sqlite, systemd, dbus
-, automake, autoconf, libtool, gtk_doc, which, gobjectIntrospection, argyllcms }:
+, automake, autoconf, libtool, gtk_doc, which, gobjectIntrospection, argyllcms
+, libgudev }:
 
 stdenv.mkDerivation rec {
   name = "colord-1.2.12";
@@ -19,7 +20,7 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [ glib polkit pkgconfig intltool gusb libusb1 lcms2 sqlite systemd dbus gobjectIntrospection
-                  bashCompletion argyllcms automake autoconf ];
+                  bashCompletion argyllcms automake autoconf libgudev ];
 
   postInstall = ''
     rm -fr $out/var/lib/colord
@@ -28,7 +29,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    description = "system service that makes it easy to manage, install and generate color profiles to accurately color manage input and output devices";
+    description = "System service to manage, install and generate color profiles to accurately color manage input and output devices";
     homepage = http://www.freedesktop.org/software/colord/intro.html;
     license = stdenv.lib.licenses.lgpl2Plus;
     maintainers = [stdenv.lib.maintainers.marcweber];
diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix
index 7d991a41556..749bf59fde9 100644
--- a/pkgs/tools/misc/file/default.nix
+++ b/pkgs/tools/misc/file/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "file-5.24";
+  name = "file-5.25";
 
   buildInputs = [ zlib ];
 
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
       "ftp://ftp.astron.com/pub/file/${name}.tar.gz"
       "http://distfiles.macports.org/file/${name}.tar.gz"
     ];
-    sha256 = "1kjhqwmi1sjw8jcf6li725c59wm00zajrdfwgkwqxs295vgb6b40";
+    sha256 = "1jhfi5mivdnqvry5la5q919l503ahwdwbf3hjhiv97znccakhd9p";
   };
 
   meta = {
diff --git a/pkgs/tools/misc/heatseeker/default.nix b/pkgs/tools/misc/heatseeker/default.nix
deleted file mode 100644
index 0d85554c347..00000000000
--- a/pkgs/tools/misc/heatseeker/default.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ stdenv, fetchFromGitHub, rustPlatform }:
-
-with rustPlatform;
-
-buildRustPackage rec {
-  name = "heatseeker-${version}";
-  version = "1.3.0";
-
-  depsSha256 = "03jap7myf85xgx9270sws8x57nl04a1wx8szrk9qx24s9vnnjcnh";
-
-  src = fetchFromGitHub {
-    owner = "rschmitt";
-    repo = "heatseeker";
-    rev = "v${version}";
-    sha256 = "1xdvwgmh9lwv82hv1qg82bjv2iplnvva6lzbg7dyhbszhv7rhkbl";
-  };
-  
-  # some tests require a tty, this variable turns them off for Travis CI,
-  # which we can also make use of
-  TRAVIS= "true";
-
-  meta = with stdenv.lib; {
-    description = "A general-purpose fuzzy selector";
-    homepage = https://github.com/rschmitt/heatseeker;
-    license = stdenv.lib.licenses.mit;
-    maintainers = [ maintainers.michaelpj ];
-  };
-}
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index f9f638ec813..14687817835 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -16,11 +16,11 @@ assert scpSupport -> libssh2 != null;
 assert c-aresSupport -> c-ares != null;
 
 stdenv.mkDerivation rec {
-  name = "curl-7.44.0";
+  name = "curl-7.45.0";
 
   src = fetchurl {
     url = "http://curl.haxx.se/download/${name}.tar.bz2";
-    sha256 = "050q6i20lbh7dyyhva2sbp8dbyp6sghlkbpvq2bvcasqwsx4298y";
+    sha256 = "1slq5c0v9wa8hajgimhkxhvsrd07jmih8sa3gjsl597qp5k4w5b5";
   };
 
   # Zlib and OpenSSL must be propagated because `libcurl.la' contains
diff --git a/pkgs/tools/networking/modemmanager/default.nix b/pkgs/tools/networking/modemmanager/default.nix
index b044b526873..77c71f38331 100644
--- a/pkgs/tools/networking/modemmanager/default.nix
+++ b/pkgs/tools/networking/modemmanager/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, udev, polkit, dbus_glib, ppp, intltool, pkgconfig, libmbim, libqmi }:
+{ stdenv, fetchurl, udev, libgudev, polkit, dbus_glib, ppp, intltool, pkgconfig, libmbim, libqmi }:
 
 stdenv.mkDerivation rec {
   name = "ModemManager-${version}";
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ intltool pkgconfig ];
 
-  buildInputs = [ udev polkit dbus_glib ppp libmbim libqmi ];
+  buildInputs = [ udev libgudev polkit dbus_glib ppp libmbim libqmi ];
 
   configureFlags = [
     "--with-polkit"
diff --git a/pkgs/tools/networking/network-manager-applet/default.nix b/pkgs/tools/networking/network-manager-applet/default.nix
index 15ee5859ff4..93ab1266c6b 100644
--- a/pkgs/tools/networking/network-manager-applet/default.nix
+++ b/pkgs/tools/networking/network-manager-applet/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, intltool, pkgconfig, libglade, networkmanager, gnome3
 , libnotify, libsecret, dbus_glib, polkit, isocodes
 , mobile_broadband_provider_info, glib_networking, gsettings_desktop_schemas
-, makeWrapper, udev, hicolor_icon_theme }:
+, makeWrapper, udev, libgudev, hicolor_icon_theme }:
 
 let
   pn = "network-manager-applet";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     gnome3.gtk libglade networkmanager libnotify libsecret dbus_glib gsettings_desktop_schemas
-    polkit isocodes makeWrapper udev gnome3.gconf gnome3.libgnome_keyring
+    polkit isocodes makeWrapper udev libgudev gnome3.gconf gnome3.libgnome_keyring
   ];
 
   nativeBuildInputs = [ intltool pkgconfig ];
diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix
index 60a7444156b..5b2e14d033a 100644
--- a/pkgs/tools/networking/network-manager/default.nix
+++ b/pkgs/tools/networking/network-manager/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, intltool, wirelesstools, pkgconfig, dbus_glib, xz
-, udev, libnl, libuuid, polkit, gnutls, ppp, dhcp, dhcpcd, iptables
+, udev, libgudev, libnl, libuuid, polkit, gnutls, ppp, dhcp, dhcpcd, iptables
 , libgcrypt, dnsmasq, avahi, bind, perl, bluez5, substituteAll, readline
 , gobjectIntrospection, modemmanager, openresolv, libndp, newt, libsoup }:
 
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
     "--with-libsoup=yes"
   ];
 
-  buildInputs = [ wirelesstools udev libnl libuuid polkit ppp libndp
+  buildInputs = [ wirelesstools udev libgudev libnl libuuid polkit ppp libndp
                   xz bluez5 dnsmasq gobjectIntrospection modemmanager readline newt libsoup ];
 
   propagatedBuildInputs = [ dbus_glib gnutls libgcrypt ];
diff --git a/pkgs/tools/text/gnugrep/cve-2015-1345.patch b/pkgs/tools/text/gnugrep/cve-2015-1345.patch
deleted file mode 100644
index 7156f475e7e..00000000000
--- a/pkgs/tools/text/gnugrep/cve-2015-1345.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 83a95bd8c8561875b948cadd417c653dbe7ef2e2 Mon Sep 17 00:00:00 2001
-From: Yuliy Pisetsky <ypisetsky@fb.com>
-Date: Thu, 01 Jan 2015 23:36:55 +0000
-Subject: grep -F: fix a heap buffer (read) overrun
-
-grep's read buffer is often filled to its full size, except when
-reading the final buffer of a file.  In that case, the number of
-bytes read may be far less than the size of the buffer.  However, for
-certain unusual pattern/text combinations, grep -F would mistakenly
-examine bytes in that uninitialized region of memory when searching
-for a match.  With carefully chosen inputs, one can cause grep -F to
-read beyond the end of that buffer altogether.  This problem arose via
-commit v2.18-90-g73893ff with the introduction of a more efficient
-heuristic using what is now the memchr_kwset function. The use of
-that function in bmexec_trans could leave TP much larger than EP,
-and the subsequent call to bm_delta2_search would mistakenly access
-beyond end of the main input read buffer.
-
-* src/kwset.c (bmexec_trans): When TP reaches or exceeds EP,
-do not call bm_delta2_search.
-* tests/kwset-abuse: New file.
-* tests/Makefile.am (TESTS): Add it.
-* THANKS.in: Update.
-* NEWS (Bug fixes): Mention it.
-
-Prior to this patch, this command would trigger a UMR:
-
-  printf %0360db 0 | valgrind src/grep -F $(printf %019dXb 0)
-
-  Use of uninitialised value of size 8
-     at 0x4142BE: bmexec_trans (kwset.c:657)
-     by 0x4143CA: bmexec (kwset.c:678)
-     by 0x414973: kwsexec (kwset.c:848)
-     by 0x414DC4: Fexecute (kwsearch.c:128)
-     by 0x404E2E: grepbuf (grep.c:1238)
-     by 0x4054BF: grep (grep.c:1417)
-     by 0x405CEB: grepdesc (grep.c:1645)
-     by 0x405EC1: grep_command_line_arg (grep.c:1692)
-     by 0x4077D4: main (grep.c:2570)
-
-See the accompanying test for how to trigger the heap buffer overrun.
-
-Thanks to Nima Aghdaii for testing and finding numerous
-ways to break early iterations of this patch.
-
-Nix: @vcunat restricted this to the runtime code only to avoid needing autoreconfiguration.
----
-diff --git a/src/kwset.c b/src/kwset.c
-index 4003c8d..376f7c3 100644
---- a/src/kwset.c
-+++ b/src/kwset.c
-@@ -643,6 +643,8 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
-                     if (! tp)
-                       return -1;
-                     tp++;
-+                    if (ep <= tp)
-+                      break;
-                   }
-               }
-           }
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index d03db13ed42..e8352e318b9 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -1,17 +1,17 @@
-{ stdenv, fetchurl, pcre, libiconv }:
+{ stdenv, fetchurl, pcre, libiconv, perl }:
 
-let version = "2.21"; in
+let version = "2.22"; in
 
 stdenv.mkDerivation {
   name = "gnugrep-${version}";
 
   src = fetchurl {
     url = "mirror://gnu/grep/grep-${version}.tar.xz";
-    sha256 = "1pp5n15qwxrw1pibwjhhgsibyv5cafhamf8lwzjygs6y00fa2i2j";
+    sha256 = "1srn321x7whlhs5ks36zlcrrmj4iahll8fxwsh1vbz3v04px54fa";
   };
 
-  patches = [ ./cve-2015-1345.patch ];
-
+  # Perl is needed for testing
+  nativeBuildInputs = [ perl ];
   buildInputs = [ pcre libiconv ];
 
   # cygwin: FAIL: multibyte-white-space
diff --git a/pkgs/tools/typesetting/tex/texlive-new/combine.nix b/pkgs/tools/typesetting/tex/texlive-new/combine.nix
index 2c9119b934f..e69c6ec425c 100644
--- a/pkgs/tools/typesetting/tex/texlive-new/combine.nix
+++ b/pkgs/tools/typesetting/tex/texlive-new/combine.nix
@@ -82,21 +82,21 @@ in buildEnv {
     # updmap.cfg seems like not needing changes
 
     # now filter hyphenation patterns, in a hacky way ATM
-  ''
+  (let script =
+    writeText "hyphens.sed" (
+      lib.concatMapStrings (pkg: "/^\% from ${pkg.pname}/,/^\%/p;\n") pkgList.splitBin.wrong
+      + "1,/^\% from/p;" );
+  in ''
     (
-      local script='${
-        lib.concatMapStrings (pkg: "/^\% from ${pkg.pname}/,/^\%/p;\n")
-          pkgList.splitBin.wrong
-      } 1,/^\% from/p;'
       cd ./share/texmf/tex/generic/config/
       for fname in language.dat language.def; do
         [ -e $fname ] || continue;
         cnfOrig="$(realpath ./$fname)"
         rm ./$fname
-        cat "$cnfOrig" | sed -n "$script" > ./$fname
+        cat "$cnfOrig" | sed -n -f '${script}' > ./$fname
       done
     )
-  '' +
+  '') +
 
   # function to wrap created executables with required env vars
   ''
diff --git a/pkgs/tools/typesetting/tex/texlive-new/default.nix b/pkgs/tools/typesetting/tex/texlive-new/default.nix
index c8b2a414fa3..a084c973b78 100644
--- a/pkgs/tools/typesetting/tex/texlive-new/default.nix
+++ b/pkgs/tools/typesetting/tex/texlive-new/default.nix
@@ -24,7 +24,7 @@
     * in case of any bugs or feature requests, file a github issue and /cc @vcunat
 */
 
-{ stdenv, lib, fetchurl, runCommand, buildEnv
+{ stdenv, lib, fetchurl, runCommand, writeText, buildEnv
 , callPackage, ghostscriptX, harfbuzz, poppler_min
 , makeWrapper, perl, python, ruby
 , useFixedHashes ? true
@@ -48,7 +48,8 @@ let
 
   # function for creating a working environment from a set of TL packages
   combine = import ./combine.nix {
-    inherit bin combinePkgs buildEnv fastUnique lib makeWrapper perl stdenv python ruby;
+    inherit bin combinePkgs buildEnv fastUnique lib makeWrapper writeText
+      perl stdenv python ruby;
   };
 
   # the set of TeX Live packages, collections, and schemes; using upstream naming
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index b04c4a3f5d6..1b9480a2649 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -628,7 +628,6 @@ let
   aria2 = callPackage ../tools/networking/aria2 {
     inherit (darwin.apple_sdk.frameworks) Security;
   };
-
   aria = aria2;
 
   at = callPackage ../tools/system/at { };
@@ -820,7 +819,7 @@ let
   dtrx = callPackage ../tools/compression/dtrx { };
 
   duperemove = callPackage ../tools/filesystems/duperemove {
-    linuxHeaders = linuxHeaders_3_14;
+    linuxHeaders = linuxHeaders_3_18;
   };
 
   edac-utils = callPackage ../os-specific/linux/edac-utils { };
@@ -849,8 +848,6 @@ let
 
   gmic = callPackage ../tools/graphics/gmic { };
 
-  heatseeker = callPackage ../tools/misc/heatseeker { };
-
   mathics = pythonPackages.mathics;
 
   mcrl = callPackage ../tools/misc/mcrl { };
@@ -1377,7 +1374,7 @@ let
 
   emv = callPackage ../tools/misc/emv { };
 
-  enblend-enfuse = callPackage ../tools/graphics/enblend-enfuse { };
+  enblendenfuse = callPackage ../tools/graphics/enblend-enfuse { };
 
   encfs = callPackage ../tools/filesystems/encfs { };
 
@@ -2048,7 +2045,6 @@ let
 
   nodejs-4_1 = callPackage ../development/web/nodejs {
     libtool = darwin.cctools;
-    openssl = openssl_1_0_2;
   };
 
   nodejs-0_10 = callPackage ../development/web/nodejs/v0_10.nix {
@@ -2061,7 +2057,7 @@ let
   else
     nodejs-4_1;
 
-  nodePackages_4_1 = callPackage ./node-packages.nix { self = nodePackages_4_1; nodejs = nodejs-4_1; };
+  nodePackages_4_1 = recurseIntoAttrs (callPackage ./node-packages.nix { self = nodePackages_4_1; nodejs = nodejs-4_1; });
 
   nodePackages_0_10 = callPackage ./node-packages.nix { self = nodePackages_0_10; nodejs = nodejs-0_10; };
 
@@ -4205,7 +4201,7 @@ let
   llvm_34 = llvmPackages_34.llvm;
   llvm_33 = callPackage ../development/compilers/llvm/3.3/llvm.nix { };
 
-  llvmPackages = recurseIntoAttrs llvmPackages_36;
+  llvmPackages = recurseIntoAttrs llvmPackages_37;
 
   llvmPackagesSelf = llvmPackages_34.override {
     stdenv = libcxxStdenv;
@@ -6106,6 +6102,10 @@ let
     cogl = cogl_1_20;
   };
 
+  clutter_1_24 = callPackage ../development/libraries/clutter/1.24.nix {
+    cogl = cogl_1_22;
+  };
+
   clutter-gst = callPackage ../development/libraries/clutter-gst { };
 
   clutter-gst_3_0 = callPackage ../development/libraries/clutter-gst/3.0.nix {
@@ -6124,6 +6124,8 @@ let
 
   cogl_1_20 = callPackage ../development/libraries/cogl/1.20.nix { };
 
+  cogl_1_22 = callPackage ../development/libraries/cogl/1.22.nix { };
+
   coin3d = callPackage ../development/libraries/coin3d { };
 
   CoinMP = callPackage ../development/libraries/CoinMP { };
@@ -6244,16 +6246,13 @@ let
   ffmpeg_2_2 = callPackage ../development/libraries/ffmpeg/2.2.nix {
     inherit (darwin.apple_sdk.frameworks) Cocoa;
   };
-  ffmpeg_2_6 = callPackage ../development/libraries/ffmpeg/2.6.nix {
-    inherit (darwin.apple_sdk.frameworks) Cocoa;
-  };
-  ffmpeg_2_7 = callPackage ../development/libraries/ffmpeg/2.7.nix {
+  ffmpeg_2_8 = callPackage ../development/libraries/ffmpeg/2.8.nix {
     inherit (darwin.apple_sdk.frameworks) Cocoa;
   };
   # Aliases
   ffmpeg_0 = ffmpeg_0_10;
   ffmpeg_1 = ffmpeg_1_2;
-  ffmpeg_2 = ffmpeg_2_7;
+  ffmpeg_2 = ffmpeg_2_8;
   ffmpeg = ffmpeg_2;
 
   ffmpeg-full = callPackage ../development/libraries/ffmpeg-full {
@@ -7124,6 +7123,8 @@ let
 
   libgsystem = callPackage ../development/libraries/libgsystem { };
 
+  libgudev = callPackage ../development/libraries/libgudev { };
+
   libguestfs = callPackage ../development/libraries/libguestfs {
     inherit (perlPackages) libintlperl GetoptLong SysVirt;
   };
@@ -7260,7 +7261,7 @@ let
 
   libjpeg_original = callPackage ../development/libraries/libjpeg { };
   libjpeg_turbo = callPackage ../development/libraries/libjpeg-turbo { };
-  libjpeg = if (stdenv.isLinux) then libjpeg_turbo else libjpeg_original; # some problems, both on FreeBSD and Darwin
+  libjpeg = if stdenv.isLinux then libjpeg_turbo else libjpeg_original; # some problems, both on FreeBSD and Darwin
 
   libjpeg62 = callPackage ../development/libraries/libjpeg/62.nix {
     libtool = libtool_1_5;
@@ -7533,9 +7534,11 @@ let
   libusbmuxd = callPackage ../development/libraries/libusbmuxd { };
 
   libunwind = if stdenv.isDarwin
-    then darwin.libunwind
+    then libunwindNative
     else callPackage ../development/libraries/libunwind { };
 
+  libunwindNative = callPackage ../development/libraries/libunwind/native.nix {};
+
   libuvVersions = recurseIntoAttrs (callPackage ../development/libraries/libuv {
     automake = automake113x; # fails with 14
     inherit (darwin.apple_sdk.frameworks) ApplicationServices CoreServices;
@@ -7684,7 +7687,6 @@ let
     # makes it slower, but during runtime we link against just mesa_drivers
     # through /run/opengl-driver*, which is overriden according to config.grsecurity
     grsecEnabled = true;
-    llvmPackages = llvmPackages_36;
   });
   mesa_glu =  mesaDarwinOr (callPackage ../development/libraries/mesa-glu { });
   mesa_drivers = mesaDarwinOr (
@@ -8485,6 +8487,8 @@ let
 
   v8_3_16_14 = callPackage ../development/libraries/v8/3.16.14.nix {
     inherit (pythonPackages) gyp;
+    # The build succeeds using gcc5 but it fails to build pkgs.consul-ui
+    stdenv = overrideCC stdenv gcc48;
   };
 
   v8_3_24_10 = callPackage ../development/libraries/v8/3.24.10.nix {
@@ -9221,7 +9225,6 @@ let
   openresty = callPackage ../servers/http/openresty { };
 
   opensmtpd = callPackage ../servers/mail/opensmtpd { };
-  opensmtpd-extras = callPackage ../servers/mail/opensmtpd/extras.nix { };
 
   openxpki = callPackage ../servers/openxpki { };
 
@@ -9845,19 +9848,17 @@ let
 
   # -- Linux kernel expressions ------------------------------------------------
 
-  linuxHeaders = linuxHeaders_3_12;
+  linuxHeaders = linuxHeaders_3_18;
 
   linuxHeaders24Cross = forceNativeDrv (callPackage ../os-specific/linux/kernel-headers/2.4.nix {
     cross = assert crossSystem != null; crossSystem;
   });
 
-  linuxHeaders26Cross = forceNativeDrv (callPackage ../os-specific/linux/kernel-headers/3.12.nix {
+  linuxHeaders26Cross = forceNativeDrv (callPackage ../os-specific/linux/kernel-headers/3.18.nix {
     cross = assert crossSystem != null; crossSystem;
   });
 
-  linuxHeaders_3_12 = callPackage ../os-specific/linux/kernel-headers/3.12.nix { };
-
-  linuxHeaders_3_14 = callPackage ../os-specific/linux/kernel-headers/3.14.nix { };
+  linuxHeaders_3_18 = callPackage ../os-specific/linux/kernel-headers/3.18.nix { };
 
   # We can choose:
   linuxHeadersCrossChooser = ver : if ver == "2.4" then linuxHeaders24Cross
@@ -9873,33 +9874,6 @@ let
     kernelPatches = [ kernelPatches.bridge_stp_helper ];
   };
 
-  linux_3_10 = callPackage ../os-specific/linux/kernel/linux-3.10.nix {
-    kernelPatches = [ kernelPatches.bridge_stp_helper ]
-      ++ lib.optionals ((platform.kernelArch or null) == "mips")
-      [ kernelPatches.mips_fpureg_emu
-        kernelPatches.mips_fpu_sigill
-        kernelPatches.mips_ext3_n32
-      ];
-  };
-
-  linux_3_12 = callPackage ../os-specific/linux/kernel/linux-3.12.nix {
-    kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.crc_regression ]
-      ++ lib.optionals ((platform.kernelArch or null) == "mips")
-      [ kernelPatches.mips_fpureg_emu
-        kernelPatches.mips_fpu_sigill
-        kernelPatches.mips_ext3_n32
-      ];
-  };
-
-  linux_3_14 = callPackage ../os-specific/linux/kernel/linux-3.14.nix {
-    kernelPatches = [ kernelPatches.bridge_stp_helper ]
-      ++ lib.optionals ((platform.kernelArch or null) == "mips")
-      [ kernelPatches.mips_fpureg_emu
-        kernelPatches.mips_fpu_sigill
-        kernelPatches.mips_ext3_n32
-      ];
-  };
-
   linux_3_18 = callPackage ../os-specific/linux/kernel/linux-3.18.nix {
     kernelPatches = [ kernelPatches.bridge_stp_helper ]
       ++ lib.optionals ((platform.kernelArch or null) == "mips")
@@ -10103,10 +10077,6 @@ let
 
   # Build the kernel modules for the some of the kernels.
   linuxPackages_rpi = linuxPackagesFor pkgs.linux_rpi linuxPackages_rpi;
-  linuxPackages_3_10 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_10 linuxPackages_3_10);
-  linuxPackages_3_10_tuxonice = linuxPackagesFor pkgs.linux_3_10_tuxonice linuxPackages_3_10_tuxonice;
-  linuxPackages_3_12 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_12 linuxPackages_3_12);
-  linuxPackages_3_14 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_14 linuxPackages_3_14);
   linuxPackages_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_18 linuxPackages_3_18);
   linuxPackages_4_1 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_1 linuxPackages_4_1);
   linuxPackages_4_2 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_2 linuxPackages_4_2);
@@ -10176,7 +10146,11 @@ let
 
   libcap_manpages = callPackage ../os-specific/linux/libcap/man.nix { };
 
-  libcap_ng = callPackage ../os-specific/linux/libcap-ng { };
+  libcap_ng = callPackage ../os-specific/linux/libcap-ng {
+    swig = null; # Currently not using the python2/3 bindings
+    python2 = null; # Currently not using the python2 bindings
+    python3 = null; # Currently not using the python3 bindings
+  };
 
   libnscd = callPackage ../os-specific/linux/libnscd { };
 
@@ -10362,7 +10336,7 @@ let
   sysstat = callPackage ../os-specific/linux/sysstat { };
 
   systemd = callPackage ../os-specific/linux/systemd {
-    linuxHeaders = linuxHeaders_3_14;
+    linuxHeaders = linuxHeaders_3_18;
   };
 
   systemtap = callPackage ../development/tools/profiling/systemtap {
@@ -12004,8 +11978,6 @@ let
 
   iptraf = callPackage ../applications/networking/iptraf { };
 
-  iptraf-ng = callPackage ../applications/networking/iptraf-ng { };
-
   irssi = callPackage ../applications/networking/irc/irssi { };
 
   irssi_fish = callPackage ../applications/networking/irc/irssi/fish { };
@@ -12026,9 +11998,6 @@ let
 
   jackmeter = callPackage ../applications/audio/jackmeter { };
 
-  jackmix = callPackage ../applications/audio/jackmix { };
-  jackmix_jack1 = jackmix.override { jack = jack1; };
-
   jalv = callPackage ../applications/audio/jalv { };
 
   jedit = callPackage ../applications/editors/jedit { };
@@ -14264,6 +14233,8 @@ let
 
   gnome3_16 = recurseIntoAttrs (callPackage ../desktops/gnome-3/3.16 { });
 
+  gnome3_18 = recurseIntoAttrs (callPackage ../desktops/gnome-3/3.18 { });
+
   gnome3 = gnome3_16;
 
   gnome = recurseIntoAttrs gnome2;
@@ -14281,7 +14252,6 @@ let
         libcanberra = libcanberra_kde;
         boost = boost155;
         kdelibs = kdeApps_15_08.kdelibs;
-        subversionClient = subversionClient.override { branch = "1.8"; };
       }
       ../desktops/kde-4.14;
 
@@ -15322,8 +15292,6 @@ let
 
   tvheadend = callPackage ../servers/tvheadend { };
 
-  urbit = callPackage ../misc/urbit { };
-
   utf8proc = callPackage ../development/libraries/utf8proc { };
 
   vault = goPackages.vault.bin // { outputs = [ "bin" ]; };
@@ -15487,7 +15455,6 @@ aliases = with self; rec {
   clangAnalyzer = clang-analyzer;  # added 2015-02-20
   cool-old-term = cool-retro-term; # added 2015-01-31
   cv = progress; # added 2015-09-06
-  enblendenfuse = enblend-enfuse;	# 2015-09-30
   exfat-utils = exfat;                  # 2015-09-11
   firefoxWrapper = firefox-wrapper;
   fuse_exfat = exfat;                   # 2015-09-11
diff --git a/pkgs/top-level/go-packages.nix b/pkgs/top-level/go-packages.nix
index a69d361db61..db110d3a1ef 100644
--- a/pkgs/top-level/go-packages.nix
+++ b/pkgs/top-level/go-packages.nix
@@ -740,26 +740,6 @@ let
     subPackages = [ "./" ];  # don't try to build test fixtures
   };
 
-  git-lfs = buildFromGitHub {
-    rev = "v1.0.0";
-    owner = "github";
-    repo = "git-lfs";
-    sha256 = "1zlg3rm5yxak6d88brffv1wpj0iq4qgzn6sgg8xn0pbnzxjd1284";
-
-    # Tests fail with 'lfstest-gitserver.go:46: main redeclared in this block'
-    excludedPackages = [ "test" ];
-
-    preBuild = ''
-      pushd go/src/github.com/github/git-lfs
-        go generate ./commands
-      popd
-    '';
-
-    postInstall = ''
-      rm -v $bin/bin/{man,script}
-    '';
-  };
-
   glide = buildFromGitHub {
     rev    = "0.6.1";
     owner  = "Masterminds";
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index 6292fa457f7..ff569f5e520 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -716,15 +716,15 @@ let self = _self // overrides; _self = with self; {
   };
 
   Cairo = buildPerlPackage rec {
-    name = "Cairo-1.106";
+    name = "Cairo-1.105";
     src = fetchurl {
       url = "mirror://cpan/authors/id/X/XA/XAOC/${name}.tar.gz";
-      sha256 = "1i25kks408c54k2zxskvg54l5k3qadzm8n72ffga9jy7ic0h6j76";
+      sha256 = "0im025wy1346w7b7hi6im08bfn6x4ma0cxmjz6xnk8riizm1s84q";
     };
     buildInputs = [ ExtUtilsDepends ExtUtilsPkgConfig pkgs.cairo ];
     meta = {
       homepage = http://gtk2-perl.sourceforge.net/;
-      description = "Perl interface to the cairo 2D vector graphics library";
+      description = "Perl interface to the cairo 2d vector graphics library";
       maintainers = with maintainers; [ nckx ];
       license = stdenv.lib.licenses.lgpl21Plus;
     };
@@ -4944,10 +4944,10 @@ let self = _self // overrides; _self = with self; {
   };
 
   Glib = buildPerlPackage rec {
-    name = "Glib-1.314";
+    name = "Glib-1.313";
     src = fetchurl {
       url = "mirror://cpan/authors/id/X/XA/XAOC/${name}.tar.gz";
-      sha256 = "13lhyksm7fgj6rgrgs06kr0hinbyhiq3lfr6gd2qal1j2w0rwzml";
+      sha256 = "162g342bhzy2ca4xwk63j10q9jycsps0s8l8y8pda70m7zcmr7xj";
     };
     buildInputs = [ ExtUtilsDepends ExtUtilsPkgConfig pkgs.glib ];
     meta = {
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 6a3516ded4e..fb64ae7e02e 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -8957,11 +8957,12 @@ let
 
 
   markupsafe = buildPythonPackage rec {
-    name = "markupsafe-0.15";
+    name = "markupsafe-${version}";
+    version = "0.23";
 
     src = pkgs.fetchurl {
-      url = "http://pypi.python.org/packages/source/M/MarkupSafe/${name}.tar.gz";
-      md5 = "4e7c4d965fe5e033fa2d7bb7746bb186";
+      url = "http://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-${version}.tar.gz";
+      sha256 = "a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3";
     };
 
     meta = {