summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/languages-frameworks/python.section.md3
-rw-r--r--doc/languages-frameworks/rust.section.md8
-rw-r--r--doc/old/cross.txt2
-rw-r--r--maintainers/maintainer-list.nix5
-rw-r--r--nixos/lib/make-system-tarball.nix2
-rw-r--r--nixos/lib/qemu-flags.nix4
-rw-r--r--nixos/modules/installer/cd-dvd/installation-cd-base.nix2
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image-aarch64.nix3
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix3
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix3
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix4
-rw-r--r--nixos/modules/installer/netboot/netboot.nix2
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix2
-rw-r--r--nixos/modules/services/misc/gitea.nix2
-rw-r--r--nixos/modules/services/misc/gitit.nix2
-rw-r--r--nixos/modules/services/monitoring/incron.nix98
-rw-r--r--nixos/modules/services/networking/vsftpd.nix2
-rw-r--r--nixos/modules/services/networking/zeronet.nix102
-rw-r--r--nixos/modules/services/security/usbguard.nix7
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix5
-rw-r--r--nixos/modules/services/web-servers/nginx/vhost-options.nix7
-rw-r--r--nixos/modules/system/boot/luksroot.nix2
-rw-r--r--nixos/modules/virtualisation/azure-agent.nix2
-rw-r--r--nixos/modules/virtualisation/brightbox-image.nix2
-rw-r--r--nixos/modules/virtualisation/google-compute-image.nix2
-rw-r--r--nixos/modules/virtualisation/virtualbox-guest.nix2
-rw-r--r--nixos/modules/virtualisation/virtualbox-image.nix10
-rw-r--r--nixos/modules/virtualisation/vmware-guest.nix2
-rw-r--r--nixos/modules/virtualisation/xen-dom0.nix2
-rw-r--r--nixos/tests/nfs.nix3
-rw-r--r--pkgs/applications/altcoins/mist.nix4
-rw-r--r--pkgs/applications/audio/baudline/default.nix6
-rw-r--r--pkgs/applications/audio/google-musicmanager/default.nix2
-rw-r--r--pkgs/applications/audio/mpg123/default.nix6
-rw-r--r--pkgs/applications/audio/pulseeffects/default.nix4
-rw-r--r--pkgs/applications/audio/renoise/default.nix4
-rw-r--r--pkgs/applications/audio/spotify/default.nix7
-rwxr-xr-x[-rw-r--r--]pkgs/applications/audio/spotify/update.sh0
-rw-r--r--pkgs/applications/audio/transcribe/default.nix4
-rw-r--r--pkgs/applications/display-managers/lightdm/default.nix7
-rw-r--r--pkgs/applications/editors/eclipse/build-eclipse.nix2
-rw-r--r--pkgs/applications/editors/eclipse/default.nix14
-rw-r--r--pkgs/applications/editors/ed/default.nix3
-rw-r--r--pkgs/applications/editors/jetbrains/common.nix2
-rw-r--r--pkgs/applications/editors/kodestudio/default.nix14
-rw-r--r--pkgs/applications/editors/music/tuxguitar/default.nix4
-rw-r--r--pkgs/applications/editors/sublime/2/default.nix2
-rw-r--r--pkgs/applications/editors/sublime/3/common.nix4
-rw-r--r--pkgs/applications/editors/typora/default.nix2
-rw-r--r--pkgs/applications/editors/vim/default.nix5
-rw-r--r--pkgs/applications/editors/vscode/default.nix12
-rw-r--r--pkgs/applications/graphics/ImageMagick/7.0.nix15
-rw-r--r--pkgs/applications/graphics/ImageMagick/default.nix17
-rw-r--r--pkgs/applications/graphics/gcolor2/default.nix4
-rw-r--r--pkgs/applications/graphics/sane/backends/brscan4/default.nix6
-rw-r--r--pkgs/applications/graphics/unigine-valley/default.nix6
-rw-r--r--pkgs/applications/misc/1password/default.nix6
-rw-r--r--pkgs/applications/misc/adobe-reader/default.nix2
-rw-r--r--pkgs/applications/misc/cura/lulzbot.nix6
-rw-r--r--pkgs/applications/misc/googleearth/default.nix6
-rw-r--r--pkgs/applications/misc/icesl/default.nix4
-rw-r--r--pkgs/applications/misc/kdbplus/default.nix2
-rw-r--r--pkgs/applications/misc/kiwix/default.nix2
-rw-r--r--pkgs/applications/misc/notify-osd-customizable/default.nix47
-rw-r--r--pkgs/applications/misc/playonlinux/default.nix8
-rw-r--r--pkgs/applications/misc/rescuetime/default.nix2
-rw-r--r--pkgs/applications/misc/sweethome3d/default.nix2
-rw-r--r--pkgs/applications/misc/sweethome3d/editors.nix2
-rw-r--r--pkgs/applications/misc/xmind/default.nix6
-rw-r--r--pkgs/applications/networking/apache-directory-studio/default.nix6
-rw-r--r--pkgs/applications/networking/bittorrentsync/generic.nix6
-rw-r--r--pkgs/applications/networking/browsers/firefox-bin/default.nix2
-rw-r--r--pkgs/applications/networking/browsers/firefox/wrapper.nix8
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix6
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/google-talk-plugin/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/trezor/default.nix2
-rw-r--r--pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix8
-rw-r--r--pkgs/applications/networking/browsers/tor-browser-bundle/default.nix24
-rw-r--r--pkgs/applications/networking/cluster/minikube/default.nix8
-rw-r--r--pkgs/applications/networking/dropbox/default.nix4
-rw-r--r--pkgs/applications/networking/ids/bro/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/franz/default.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/mattermost-desktop/default.nix6
-rw-r--r--pkgs/applications/networking/instant-messengers/rambox/sencha/bare.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/slack/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/wire-desktop/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/zoom-us/default.nix4
-rw-r--r--pkgs/applications/networking/insync/default.nix4
-rw-r--r--pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix4
-rw-r--r--pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix2
-rw-r--r--pkgs/applications/networking/p2p/frostwire/default.nix2
-rw-r--r--pkgs/applications/networking/p2p/soulseekqt/default.nix2
-rw-r--r--pkgs/applications/networking/p2p/zeronet/default.nix12
-rw-r--r--pkgs/applications/networking/remote/anydesk/default.nix4
-rw-r--r--pkgs/applications/networking/remote/putty/default.nix17
-rw-r--r--pkgs/applications/networking/resilio-sync/default.nix4
-rw-r--r--pkgs/applications/networking/spideroak/default.nix18
-rw-r--r--pkgs/applications/networking/super-productivity/default.nix4
-rw-r--r--pkgs/applications/office/jameica/default.nix8
-rw-r--r--pkgs/applications/office/mendeley/default.nix4
-rw-r--r--pkgs/applications/office/moneyplex/default.nix4
-rw-r--r--pkgs/applications/office/wpsoffice/default.nix2
-rw-r--r--pkgs/applications/science/electronics/eagle/eagle7.nix6
-rw-r--r--pkgs/applications/science/logic/isabelle/default.nix2
-rw-r--r--pkgs/applications/science/logic/saw-tools/default.nix2
-rw-r--r--pkgs/applications/science/math/mathematica/10.nix4
-rw-r--r--pkgs/applications/science/math/mathematica/9.nix4
-rw-r--r--pkgs/applications/science/math/mathematica/default.nix2
-rw-r--r--pkgs/applications/science/math/scilab-bin/default.nix8
-rw-r--r--pkgs/applications/search/catfish/default.nix8
-rw-r--r--pkgs/applications/search/recoll/default.nix2
-rw-r--r--pkgs/applications/version-management/git-and-tools/git-cola/default.nix4
-rw-r--r--pkgs/applications/video/lightworks/default.nix4
-rw-r--r--pkgs/applications/video/mplayer/default.nix6
-rw-r--r--pkgs/applications/video/omxplayer/default.nix7
-rw-r--r--pkgs/applications/video/webtorrent_desktop/default.nix4
-rw-r--r--pkgs/applications/virtualization/qemu/default.nix2
-rw-r--r--pkgs/applications/virtualization/virtualbox/guest-additions/default.nix16
-rw-r--r--pkgs/applications/virtualization/vpcs/default.nix4
-rw-r--r--pkgs/applications/virtualization/xen/4.10.nix3
-rw-r--r--pkgs/applications/virtualization/xen/4.8.nix3
-rw-r--r--pkgs/applications/window-managers/i3/default.nix4
-rw-r--r--pkgs/applications/window-managers/way-cooler/way-cooler.nix4
-rw-r--r--pkgs/applications/window-managers/way-cooler/wc-bg.nix4
-rw-r--r--pkgs/applications/window-managers/way-cooler/wc-grab.nix4
-rw-r--r--pkgs/applications/window-managers/way-cooler/wc-lock.nix4
-rw-r--r--pkgs/build-support/build-fhs-userenv/env.nix4
-rw-r--r--pkgs/build-support/kernel/make-initrd.nix3
-rw-r--r--pkgs/build-support/release/nix-build.nix2
-rw-r--r--pkgs/build-support/rust/build-rust-crate.nix24
-rw-r--r--pkgs/build-support/rust/cargo-vendor/cargo-vendor.nix6
-rw-r--r--pkgs/build-support/rust/carnix.nix6
-rw-r--r--pkgs/build-support/vm/windows/controller/default.nix2
-rw-r--r--pkgs/build-support/vm/windows/cygwin-iso/default.nix2
-rw-r--r--pkgs/development/arduino/arduino-core/default.nix18
-rw-r--r--pkgs/development/compilers/ccl/default.nix2
-rw-r--r--pkgs/development/compilers/clean/default.nix4
-rw-r--r--pkgs/development/compilers/cmucl/binary.nix2
-rw-r--r--pkgs/development/compilers/crystal/default.nix4
-rw-r--r--pkgs/development/compilers/fpc/binary.nix6
-rw-r--r--pkgs/development/compilers/fpc/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/5/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/8/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/snapshot/default.nix14
-rw-r--r--pkgs/development/compilers/ghc/7.10.3.nix9
-rw-r--r--pkgs/development/compilers/ghc/8.0.2.nix9
-rw-r--r--pkgs/development/compilers/ghc/8.2.2.nix9
-rw-r--r--pkgs/development/compilers/ghc/8.4.3.nix13
-rw-r--r--pkgs/development/compilers/ghc/8.6.1.nix13
-rw-r--r--pkgs/development/compilers/ghc/head.nix13
-rw-r--r--pkgs/development/compilers/ghcjs-ng/default.nix2
-rw-r--r--pkgs/development/compilers/go/1.10.nix6
-rw-r--r--pkgs/development/compilers/go/1.11.nix10
-rw-r--r--pkgs/development/compilers/go/1.4.nix6
-rw-r--r--pkgs/development/compilers/go/1.9.nix6
-rw-r--r--pkgs/development/compilers/jetbrains-jdk/default.nix4
-rw-r--r--pkgs/development/compilers/julia/0.7.nix6
-rw-r--r--pkgs/development/compilers/julia/1.0.nix6
-rw-r--r--pkgs/development/compilers/julia/default.nix2
-rw-r--r--pkgs/development/compilers/julia/shared.nix218
-rw-r--r--pkgs/development/compilers/llvm/3.9/llvm.nix8
-rw-r--r--pkgs/development/compilers/mezzo/default.nix4
-rw-r--r--pkgs/development/compilers/mlton/default.nix6
-rw-r--r--pkgs/development/compilers/mozart/binary.nix2
-rw-r--r--pkgs/development/compilers/nvidia-cg-toolkit/default.nix6
-rw-r--r--pkgs/development/compilers/opendylan/bin.nix6
-rw-r--r--pkgs/development/compilers/opendylan/default.nix6
-rw-r--r--pkgs/development/compilers/openjdk/10.nix2
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk-linux-base.nix6
-rw-r--r--pkgs/development/compilers/orc/default.nix2
-rw-r--r--pkgs/development/compilers/picat/default.nix4
-rw-r--r--pkgs/development/compilers/rust/bootstrap.nix14
-rw-r--r--pkgs/development/compilers/rust/rustc.nix1
-rw-r--r--pkgs/development/compilers/sbcl/bootstrap.nix4
-rw-r--r--pkgs/development/compilers/sbcl/default.nix2
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix17
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix6
-rw-r--r--pkgs/development/interpreters/dart/default.nix2
-rw-r--r--pkgs/development/interpreters/guile/1.8.nix3
-rw-r--r--pkgs/development/interpreters/guile/2.0.nix3
-rw-r--r--pkgs/development/interpreters/guile/default.nix3
-rw-r--r--pkgs/development/interpreters/python/cpython/2.7/default.nix22
-rw-r--r--pkgs/development/interpreters/spidermonkey/1.8.5.nix2
-rw-r--r--pkgs/development/libraries/SDL/default.nix5
-rw-r--r--pkgs/development/libraries/apr/default.nix2
-rw-r--r--pkgs/development/libraries/attr/default.nix4
-rw-r--r--pkgs/development/libraries/audio/libbass/default.nix4
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix5
-rw-r--r--pkgs/development/libraries/boost/1.66.nix2
-rw-r--r--pkgs/development/libraries/boost/1.67.nix2
-rw-r--r--pkgs/development/libraries/boost/1.68.nix2
-rw-r--r--pkgs/development/libraries/boost/generic.nix38
-rw-r--r--pkgs/development/libraries/bootil/default.nix2
-rw-r--r--pkgs/development/libraries/c-ares/default.nix6
-rw-r--r--pkgs/development/libraries/crypto++/default.nix7
-rw-r--r--pkgs/development/libraries/ffmpeg-full/default.nix5
-rw-r--r--pkgs/development/libraries/ffmpeg/generic.nix5
-rw-r--r--pkgs/development/libraries/fontconfig/2.10.nix5
-rw-r--r--pkgs/development/libraries/fontconfig/default.nix5
-rw-r--r--pkgs/development/libraries/gbenchmark/default.nix2
-rw-r--r--pkgs/development/libraries/gcc/libgcc/default.nix24
-rw-r--r--pkgs/development/libraries/gdbm/default.nix4
-rw-r--r--pkgs/development/libraries/gettext/default.nix8
-rw-r--r--pkgs/development/libraries/glew/1.10.nix5
-rw-r--r--pkgs/development/libraries/glew/default.nix5
-rw-r--r--pkgs/development/libraries/glibc/common.nix11
-rw-r--r--pkgs/development/libraries/gmp/6.x.nix4
-rw-r--r--pkgs/development/libraries/gpgme/default.nix5
-rw-r--r--pkgs/development/libraries/gsl/default.nix2
-rw-r--r--pkgs/development/libraries/icu/base.nix4
-rw-r--r--pkgs/development/libraries/igraph/default.nix31
-rw-r--r--pkgs/development/libraries/java/jzmq/default.nix2
-rw-r--r--pkgs/development/libraries/java/swt/default.nix2
-rw-r--r--pkgs/development/libraries/libav/default.nix5
-rw-r--r--pkgs/development/libraries/libb2/default.nix4
-rw-r--r--pkgs/development/libraries/libelf/default.nix7
-rw-r--r--pkgs/development/libraries/libffi/default.nix10
-rw-r--r--pkgs/development/libraries/libiconv/default.nix5
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix3
-rw-r--r--pkgs/development/libraries/libnfsidmap/default.nix26
-rw-r--r--pkgs/development/libraries/libpng/12.nix6
-rw-r--r--pkgs/development/libraries/libspotify/default.nix12
-rw-r--r--pkgs/development/libraries/libssh2/default.nix6
-rw-r--r--pkgs/development/libraries/libvpx/default.nix19
-rw-r--r--pkgs/development/libraries/libvpx/git.nix19
-rw-r--r--pkgs/development/libraries/libxml2/default.nix7
-rw-r--r--pkgs/development/libraries/libxslt/default.nix5
-rw-r--r--pkgs/development/libraries/live555/default.nix2
-rw-r--r--pkgs/development/libraries/mesa/default.nix2
-rw-r--r--pkgs/development/libraries/microsoft_gsl/default.nix3
-rw-r--r--pkgs/development/libraries/mpfr/default.nix8
-rw-r--r--pkgs/development/libraries/msgpack/generic.nix3
-rw-r--r--pkgs/development/libraries/ncurses/default.nix7
-rw-r--r--pkgs/development/libraries/nettle/generic.nix4
-rw-r--r--pkgs/development/libraries/nlohmann_json/default.nix3
-rw-r--r--pkgs/development/libraries/opencolorio/default.nix31
-rw-r--r--pkgs/development/libraries/opencv/3.x.nix6
-rw-r--r--pkgs/development/libraries/openssl/default.nix29
-rw-r--r--pkgs/development/libraries/oracle-instantclient/default.nix6
-rw-r--r--pkgs/development/libraries/pcre/default.nix7
-rw-r--r--pkgs/development/libraries/physics/geant4/fetch.nix2
-rw-r--r--pkgs/development/libraries/readline/6.2.nix3
-rw-r--r--pkgs/development/libraries/readline/6.3.nix6
-rw-r--r--pkgs/development/libraries/readline/7.0.nix3
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix6
-rw-r--r--pkgs/development/libraries/scmccid/default.nix4
-rw-r--r--pkgs/development/libraries/skalibs/default.nix2
-rw-r--r--pkgs/development/libraries/tachyon/default.nix18
-rw-r--r--pkgs/development/libraries/v8/3.14.nix2
-rw-r--r--pkgs/development/libraries/vigra/default.nix2
-rw-r--r--pkgs/development/libraries/vxl/default.nix2
-rw-r--r--pkgs/development/libraries/wtk/default.nix2
-rw-r--r--pkgs/development/libraries/zlib/default.nix17
-rw-r--r--pkgs/development/misc/amdapp-sdk/default.nix4
-rw-r--r--pkgs/development/mobile/androidenv/androidndk-pkgs.nix28
-rw-r--r--pkgs/development/mobile/androidenv/androidndk.nix4
-rw-r--r--pkgs/development/mobile/androidenv/androidndk_r8e.nix6
-rw-r--r--pkgs/development/mobile/androidenv/androidsdk.nix18
-rw-r--r--pkgs/development/mobile/androidenv/build-tools.nix8
-rw-r--r--pkgs/development/mobile/androidenv/default.nix6
-rw-r--r--pkgs/development/mobile/androidenv/platform-tools.nix8
-rw-r--r--pkgs/development/mobile/titaniumenv/build-app.nix2
-rw-r--r--pkgs/development/mobile/titaniumenv/default.nix2
-rw-r--r--pkgs/development/mobile/titaniumenv/titaniumsdk-6.3.nix12
-rw-r--r--pkgs/development/mobile/titaniumenv/titaniumsdk-7.1.nix10
-rw-r--r--pkgs/development/node-packages/default-v10.nix5
-rw-r--r--pkgs/development/node-packages/default-v6.nix5
-rw-r--r--pkgs/development/node-packages/default-v8.nix5
-rw-r--r--pkgs/development/ocaml-modules/bin_prot/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/bolt/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/camlimages/4.1.nix4
-rw-r--r--pkgs/development/ocaml-modules/cil/default.nix5
-rw-r--r--pkgs/development/ocaml-modules/cryptgps/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/dypgen/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/enumerate/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/erm_xml/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/faillib/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/fieldslib/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/frontc/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/gtktop/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/lwt/legacy.nix1
-rw-r--r--pkgs/development/ocaml-modules/magick/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ocaml-cairo/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ocamlsdl/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/odn/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ojquery/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/pa_ounit/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/sqlite3EZ/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ulex/0.8/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/variantslib/default.nix6
-rw-r--r--pkgs/development/python-modules/cozy/default.nix38
-rw-r--r--pkgs/development/python-modules/dictionaries/default.nix19
-rw-r--r--pkgs/development/python-modules/ecpy/default.nix13
-rw-r--r--pkgs/development/python-modules/folium/default.nix2
-rw-r--r--pkgs/development/python-modules/httpsig/default.nix32
-rw-r--r--pkgs/development/python-modules/numpy/default.nix4
-rw-r--r--pkgs/development/python-modules/ordered-set/default.nix26
-rw-r--r--pkgs/development/python-modules/pyserial/default.nix4
-rw-r--r--pkgs/development/python-modules/python-igraph/default.nix22
-rw-r--r--pkgs/development/ruby-modules/testing/stubs.nix2
-rw-r--r--pkgs/development/tools/analysis/cov-build/default.nix2
-rw-r--r--pkgs/development/tools/analysis/valgrind/default.nix2
-rw-r--r--pkgs/development/tools/build-managers/cmake/2.8.nix3
-rw-r--r--pkgs/development/tools/build-managers/meson/default.nix10
-rw-r--r--pkgs/development/tools/electron/default.nix4
-rw-r--r--pkgs/development/tools/github/github-release/default.nix6
-rw-r--r--pkgs/development/tools/google-app-engine-go-sdk/default.nix2
-rw-r--r--pkgs/development/tools/minizinc/default.nix4
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix13
-rw-r--r--pkgs/development/tools/misc/cflow/default.nix2
-rw-r--r--pkgs/development/tools/misc/gdb/default.nix10
-rw-r--r--pkgs/development/tools/misc/gnum4/default.nix4
-rw-r--r--pkgs/development/tools/misc/help2man/default.nix6
-rw-r--r--pkgs/development/tools/misc/iozone/default.nix10
-rw-r--r--pkgs/development/tools/misc/kibana/5.x.nix4
-rw-r--r--pkgs/development/tools/misc/kibana/default.nix4
-rw-r--r--pkgs/development/tools/misc/libtool/libtool2.nix3
-rw-r--r--pkgs/development/tools/misc/lsof/default.nix2
-rw-r--r--pkgs/development/tools/misc/saleae-logic/default.nix4
-rw-r--r--pkgs/development/tools/neoload/default.nix2
-rw-r--r--pkgs/development/tools/node-webkit/nw12.nix2
-rw-r--r--pkgs/development/tools/nwjs/default.nix2
-rw-r--r--pkgs/development/tools/ocaml/omake/0.9.8.6-rc1.nix5
-rw-r--r--pkgs/development/tools/phantomjs/default.nix4
-rw-r--r--pkgs/development/tools/sauce-connect/default.nix4
-rw-r--r--pkgs/development/tools/selenium/chromedriver/default.nix4
-rw-r--r--pkgs/development/tools/xcbuild/wrapper.nix7
-rw-r--r--pkgs/development/web/remarkjs/default.nix2
-rw-r--r--pkgs/games/andyetitmoves/default.nix8
-rw-r--r--pkgs/games/dwarf-fortress/dfhack/default.nix4
-rw-r--r--pkgs/games/dwarf-fortress/game.nix6
-rw-r--r--pkgs/games/eduke32/default.nix2
-rw-r--r--pkgs/games/ezquake/default.nix4
-rw-r--r--pkgs/games/factorio/default.nix2
-rw-r--r--pkgs/games/nethack/default.nix2
-rw-r--r--pkgs/games/oilrush/default.nix4
-rw-r--r--pkgs/games/openarena/default.nix2
-rw-r--r--pkgs/games/racer/default.nix4
-rw-r--r--pkgs/games/scummvm/default.nix1
-rw-r--r--pkgs/games/sdlmame/default.nix2
-rw-r--r--pkgs/games/steam/default.nix6
-rw-r--r--pkgs/games/ut2004/demo.nix4
-rw-r--r--pkgs/games/vessel/default.nix2
-rw-r--r--pkgs/games/worldofgoo/default.nix2
-rw-r--r--pkgs/games/xjump/default.nix4
-rw-r--r--pkgs/games/zandronum/fmod.nix2
-rw-r--r--pkgs/misc/base16-builder/default.nix2
-rw-r--r--pkgs/misc/cups/drivers/cnijfilter_4_00/default.nix6
-rw-r--r--pkgs/misc/cups/drivers/kyocera/default.nix6
-rw-r--r--pkgs/misc/cups/drivers/kyodialog3/default.nix6
-rw-r--r--pkgs/misc/cups/drivers/samsung/4.01.17.nix4
-rw-r--r--pkgs/misc/cups/drivers/samsung/default.nix2
-rw-r--r--pkgs/misc/drivers/gutenprint/bin.nix2
-rw-r--r--pkgs/misc/drivers/hplip/3.16.11.nix6
-rw-r--r--pkgs/misc/drivers/hplip/default.nix6
-rw-r--r--pkgs/misc/emulators/retroarch/cores.nix4
-rw-r--r--pkgs/misc/emulators/retroarch/default.nix4
-rw-r--r--pkgs/misc/emulators/wine/default.nix4
-rw-r--r--pkgs/os-specific/bsd/netbsd/default.nix8
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix6
-rw-r--r--pkgs/os-specific/darwin/cctools/port.nix13
-rw-r--r--pkgs/os-specific/darwin/xcode/default.nix4
-rw-r--r--pkgs/os-specific/linux/alsa-plugins/wrapper.nix2
-rw-r--r--pkgs/os-specific/linux/amdgpu-pro/default.nix4
-rw-r--r--pkgs/os-specific/linux/ati-drivers/default.nix4
-rw-r--r--pkgs/os-specific/linux/broadcom-sta/default.nix4
-rw-r--r--pkgs/os-specific/linux/busybox/sandbox-shell.nix4
-rw-r--r--pkgs/os-specific/linux/displaylink/default.nix4
-rw-r--r--pkgs/os-specific/linux/fusionio/util.nix2
-rw-r--r--pkgs/os-specific/linux/fusionio/vsl.nix2
-rw-r--r--pkgs/os-specific/linux/jool/cli.nix1
-rw-r--r--pkgs/os-specific/linux/kernel-headers/default.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix23
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.14.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.17.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.18.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.4.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.9.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-beagleboard.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-copperhead-lts.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-hardkernel-4.14.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-mptcp-93.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-mptcp.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-riscv.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-rpi.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-samus-4.12.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-testing.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix10
-rw-r--r--pkgs/os-specific/linux/klibc/default.nix12
-rw-r--r--pkgs/os-specific/linux/kmod/default.nix5
-rw-r--r--pkgs/os-specific/linux/libatasmart/default.nix7
-rw-r--r--pkgs/os-specific/linux/lksctp-tools/default.nix5
-rw-r--r--pkgs/os-specific/linux/lm-sensors/default.nix5
-rw-r--r--pkgs/os-specific/linux/mdadm/default.nix3
-rw-r--r--pkgs/os-specific/linux/multipath-tools/default.nix5
-rw-r--r--pkgs/os-specific/linux/musl/default.nix4
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix19
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/generic.nix8
-rw-r--r--pkgs/os-specific/linux/pam/default.nix6
-rw-r--r--pkgs/os-specific/linux/pam_ccreds/default.nix8
-rw-r--r--pkgs/os-specific/linux/pam_mount/default.nix7
-rw-r--r--pkgs/os-specific/linux/perf-tools/default.nix7
-rw-r--r--pkgs/os-specific/linux/prl-tools/default.nix4
-rw-r--r--pkgs/os-specific/linux/rfkill/default.nix7
-rw-r--r--pkgs/os-specific/linux/rtkit/default.nix5
-rw-r--r--pkgs/os-specific/linux/shadow/default.nix9
-rw-r--r--pkgs/os-specific/linux/sssd/default.nix4
-rw-r--r--pkgs/os-specific/linux/systemd/default.nix3
-rw-r--r--pkgs/os-specific/linux/uclibc/default.nix7
-rw-r--r--pkgs/os-specific/linux/udisks/1-default.nix5
-rw-r--r--pkgs/os-specific/linux/usbutils/default.nix5
-rw-r--r--pkgs/os-specific/linux/wpa_supplicant/gui.nix6
-rw-r--r--pkgs/os-specific/windows/pthread-w32/default.nix4
-rw-r--r--pkgs/os-specific/windows/wxMSW-2.8/default.nix4
-rw-r--r--pkgs/servers/fingerd/bsd-fingerd/default.nix5
-rw-r--r--pkgs/servers/http/nginx/mainline.nix4
-rw-r--r--pkgs/servers/matrix-synapse/default.nix4
-rw-r--r--pkgs/servers/web-apps/wallabag/default.nix4
-rw-r--r--pkgs/shells/bash/4.4.nix19
-rw-r--r--pkgs/stdenv/cross/default.nix5
-rw-r--r--pkgs/stdenv/darwin/default.nix4
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix2
-rw-r--r--pkgs/stdenv/linux/default.nix2
-rw-r--r--pkgs/tools/X11/xwinwrap/default.nix6
-rw-r--r--pkgs/tools/admin/bluemix-cli/default.nix2
-rw-r--r--pkgs/tools/admin/google-cloud-sdk/default.nix2
-rw-r--r--pkgs/tools/archivers/gnutar/default.nix2
-rw-r--r--pkgs/tools/archivers/zpaq/zpaqd.nix12
-rw-r--r--pkgs/tools/bootloaders/refind/default.nix2
-rw-r--r--pkgs/tools/compression/bzip2/default.nix2
-rw-r--r--pkgs/tools/filesystems/sshfs-fuse/default.nix2
-rw-r--r--pkgs/tools/graphics/optipng/default.nix5
-rw-r--r--pkgs/tools/graphics/pngout/default.nix10
-rw-r--r--pkgs/tools/misc/bandwidth/default.nix10
-rw-r--r--pkgs/tools/misc/coreutils/default.nix25
-rw-r--r--pkgs/tools/misc/execline/default.nix2
-rw-r--r--pkgs/tools/misc/findutils/default.nix9
-rw-r--r--pkgs/tools/misc/grub/2.0x.nix12
-rw-r--r--pkgs/tools/misc/grub/pvgrub_image/default.nix8
-rw-r--r--pkgs/tools/misc/grub/trusted.nix4
-rw-r--r--pkgs/tools/misc/mongodb-compass/default.nix4
-rw-r--r--pkgs/tools/misc/mprime/default.nix14
-rw-r--r--pkgs/tools/misc/ocz-ssd-guru/default.nix2
-rw-r--r--pkgs/tools/misc/os-prober/default.nix2
-rw-r--r--pkgs/tools/misc/otfcc/default.nix4
-rw-r--r--pkgs/tools/misc/pspg/default.nix4
-rw-r--r--pkgs/tools/misc/s6-portable-utils/default.nix2
-rw-r--r--pkgs/tools/misc/staruml/default.nix2
-rw-r--r--pkgs/tools/misc/ttyrec/default.nix4
-rw-r--r--pkgs/tools/misc/youtube-dl/default.nix4
-rw-r--r--pkgs/tools/networking/airfield/default.nix2
-rw-r--r--pkgs/tools/networking/filegive/default.nix2
-rw-r--r--pkgs/tools/networking/logmein-hamachi/default.nix10
-rw-r--r--pkgs/tools/networking/ngrok-2/default.nix2
-rw-r--r--pkgs/tools/networking/s6-dns/default.nix2
-rw-r--r--pkgs/tools/networking/s6-networking/default.nix2
-rw-r--r--pkgs/tools/networking/strongswan/default.nix2
-rw-r--r--pkgs/tools/package-management/cargo-edit/cargo-edit.nix2
-rw-r--r--pkgs/tools/package-management/cargo-update/cargo-update.nix6
-rw-r--r--pkgs/tools/package-management/checkinstall/default.nix2
-rw-r--r--pkgs/tools/package-management/nix/default.nix5
-rw-r--r--pkgs/tools/package-management/nixui/default.nix2
-rw-r--r--pkgs/tools/security/afl/default.nix6
-rw-r--r--pkgs/tools/security/afl/qemu.nix8
-rw-r--r--pkgs/tools/security/encryptr/default.nix12
-rw-r--r--pkgs/tools/security/enpass/default.nix7
-rw-r--r--pkgs/tools/security/pcsc-scm-scl011/default.nix6
-rw-r--r--pkgs/tools/security/sshuttle/default.nix2
-rw-r--r--pkgs/tools/system/at/default.nix4
-rw-r--r--pkgs/tools/system/incron/default.nix36
-rw-r--r--pkgs/tools/system/incron/default_path.patch36
-rw-r--r--pkgs/tools/system/s6-rc/default.nix2
-rw-r--r--pkgs/tools/system/s6/default.nix2
-rw-r--r--pkgs/tools/system/storebrowse/default.nix2
-rw-r--r--pkgs/tools/text/gawk/default.nix2
-rw-r--r--pkgs/tools/text/gnupatch/default.nix5
-rw-r--r--pkgs/tools/text/html-tidy/default.nix6
-rw-r--r--pkgs/tools/text/xidel/default.nix6
-rw-r--r--pkgs/tools/typesetting/kindlegen/default.nix4
-rw-r--r--pkgs/top-level/aliases.nix3
-rw-r--r--pkgs/top-level/all-packages.nix192
-rw-r--r--pkgs/top-level/coq-packages.nix3
-rw-r--r--pkgs/top-level/darwin-packages.nix2
-rw-r--r--pkgs/top-level/haskell-packages.nix2
-rw-r--r--pkgs/top-level/ocaml-packages.nix14
-rw-r--r--pkgs/top-level/perl-packages.nix4
-rw-r--r--pkgs/top-level/python-packages.nix19
-rw-r--r--pkgs/top-level/splice.nix8
-rw-r--r--pkgs/top-level/unix-tools.nix8
497 files changed, 2235 insertions, 1360 deletions
diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md
index d825823d01a2..5eabb866654e 100644
--- a/doc/languages-frameworks/python.section.md
+++ b/doc/languages-frameworks/python.section.md
@@ -1074,4 +1074,5 @@ Following rules are desired to be respected:
 * Make sure libraries build for all Python interpreters.
 * By default we enable tests. Make sure the tests are found and, in the case of libraries, are passing for all interpreters. If certain tests fail they can be disabled individually. Try to avoid disabling the tests altogether. In any case, when you disable tests, leave a comment explaining why.
 * Commit names of Python libraries should reflect that they are Python libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
-
+* Attribute names in `python-packages.nix` should be normalized according to [PEP 0503](https://www.python.org/dev/peps/pep-0503/#normalized-names).
+  This means that characters should be converted to lowercase and `.` and `_` should be replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz )
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index eec982d4c90a..6588281878a0 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -93,8 +93,8 @@ Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
 
 ```
 # Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.buildPlatform.parsed.kernel.name;
     # ... (content skipped)
 in
 rec {
@@ -122,8 +122,8 @@ following nix file:
 
 ```
 # Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.buildPlatform.parsed.kernel.name;
     # ... (content skipped)
 in
 rec {
diff --git a/doc/old/cross.txt b/doc/old/cross.txt
index c0885c08176e..ff9fefb04a86 100644
--- a/doc/old/cross.txt
+++ b/doc/old/cross.txt
@@ -78,7 +78,7 @@ Step 2: build kernel headers for the target architecture
 ---
 {stdenv, fetchurl}:
 
-assert stdenv.system == "i686-linux";
+assert stdenv.buildPlatform.system == "i686-linux";
 
 stdenv.mkDerivation {
   name = "linux-headers-2.6.13.1-arm";
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 1d6d772e7e95..1800c6d8f49a 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -23,6 +23,11 @@
     github = "a1russell";
     name = "Adam Russell";
   };
+  aanderse = {
+    email = "aaron@fosslib.net";
+    github = "aanderse";
+    name = "Aaron Andersen";
+  };
   aaronschif = {
     email = "aaronschif@gmail.com";
     github = "aaronschif";
diff --git a/nixos/lib/make-system-tarball.nix b/nixos/lib/make-system-tarball.nix
index 92539235be75..846013b02d14 100644
--- a/nixos/lib/make-system-tarball.nix
+++ b/nixos/lib/make-system-tarball.nix
@@ -1,7 +1,7 @@
 { stdenv, perl, pixz, pathsFromGraph
 
 , # The file name of the resulting tarball
-  fileName ? "nixos-system-${stdenv.system}"
+  fileName ? "nixos-system-${stdenv.hostPlatform.system}"
 
 , # The files and directories to be placed in the tarball.
   # This is a list of attribute sets {source, target} where `source'
diff --git a/nixos/lib/qemu-flags.nix b/nixos/lib/qemu-flags.nix
index f115ca5ac000..779f0377a512 100644
--- a/nixos/lib/qemu-flags.nix
+++ b/nixos/lib/qemu-flags.nix
@@ -14,12 +14,12 @@ in
 
   qemuSerialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
         else if pkgs.stdenv.isAarch32 || pkgs.stdenv.isAarch64 then "ttyAMA0"
-        else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
+        else throw "Unknown QEMU serial device for system '${pkgs.stdenv.hostPlatform.system}'";
 
   qemuBinary = qemuPkg: {
     "x86_64-linux" = "${qemuPkg}/bin/qemu-kvm -cpu kvm64";
     "armv7l-linux" = "${qemuPkg}/bin/qemu-system-arm -enable-kvm -machine virt -cpu host";
     "aarch64-linux" = "${qemuPkg}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
     "x86_64-darwin" = "${qemuPkg}/bin/qemu-kvm -cpu kvm64";
-  }.${pkgs.stdenv.system} or "${qemuPkg}/bin/qemu-kvm";
+  }.${pkgs.stdenv.hostPlatform.system} or "${qemuPkg}/bin/qemu-kvm";
 }
diff --git a/nixos/modules/installer/cd-dvd/installation-cd-base.nix b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
index 1453e8082b0d..24070a786945 100644
--- a/nixos/modules/installer/cd-dvd/installation-cd-base.nix
+++ b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
@@ -16,7 +16,7 @@ with lib;
     ];
 
   # ISO naming.
-  isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.system}.iso";
+  isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.iso";
 
   isoImage.volumeID = substring 0 11 "NIXOS_ISO";
 
diff --git a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
index bd6cf029967c..86e19f3da562 100644
--- a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
@@ -16,7 +16,8 @@ in
   ];
 
   assertions = lib.singleton {
-    assertion = pkgs.stdenv.system == "aarch64-linux";
+    assertion = pkgs.stdenv.hostPlatform.system == "aarch64-linux"
+      && pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system;
     message = "sd-image-aarch64.nix can be only built natively on Aarch64 / ARM64; " +
       "it cannot be cross compiled";
   };
diff --git a/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix b/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix
index 0c89eb533359..695c79ca1707 100644
--- a/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix
@@ -16,7 +16,8 @@ in
   ];
 
   assertions = lib.singleton {
-    assertion = pkgs.stdenv.system == "armv7l-linux";
+    assertion = pkgs.stdenv.hostPlatform.system == "armv7l-linux"
+      && pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system;
     message = "sd-image-armv7l-multiplatform.nix can be only built natively on ARMv7; " +
       "it cannot be cross compiled";
   };
diff --git a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix
index 78ea3f1a205c..e395b265d15e 100644
--- a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix
@@ -16,7 +16,8 @@ in
   ];
 
   assertions = lib.singleton {
-    assertion = pkgs.stdenv.system == "armv6l-linux";
+    assertion = pkgs.stdenv.hostPlatform.system == "armv6l-linux"
+      && pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system;
     message = "sd-image-raspberrypi.nix can be only built natively on ARMv6; " +
       "it cannot be cross compiled";
   };
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index 2371be9d89a1..b6e1d11c2b54 100644
--- a/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -22,7 +22,7 @@ in
 {
   options.sdImage = {
     imageName = mkOption {
-      default = "${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.system}.img";
+      default = "${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img";
       description = ''
         Name of the generated image file.
       '';
@@ -102,7 +102,7 @@ in
         mkdir -p $out/nix-support $out/sd-image
         export img=$out/sd-image/${config.sdImage.imageName}
 
-        echo "${pkgs.stdenv.system}" > $out/nix-support/system
+        echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
         echo "file sd-image $img" >> $out/nix-support/hydra-build-products
 
         # Create the image file sized to fit /boot and /, plus 20M of slack
diff --git a/nixos/modules/installer/netboot/netboot.nix b/nixos/modules/installer/netboot/netboot.nix
index ea640173c6dd..303d9fce3f9a 100644
--- a/nixos/modules/installer/netboot/netboot.nix
+++ b/nixos/modules/installer/netboot/netboot.nix
@@ -25,7 +25,7 @@ with lib;
 
     # !!! Hack - attributes expected by other modules.
     environment.systemPackages = [ pkgs.grub2_efi ]
-      ++ (if pkgs.stdenv.system == "aarch64-linux"
+      ++ (if pkgs.stdenv.hostPlatform.system == "aarch64-linux"
           then []
           else [ pkgs.grub2 pkgs.syslinux ]);
 
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 0928e368d80f..8292cdc995e0 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -328,6 +328,7 @@
       qemu-libvirtd = 301;
       # kvm = 302; # unused
       # render = 303; # unused
+      zeronet = 304;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -616,6 +617,7 @@
       qemu-libvirtd = 301;
       kvm = 302; # default udev rules from systemd requires these
       render = 303; # default udev rules from systemd requires these
+      zeronet = 304;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 6bad54d6d433..4795922abcfb 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -421,6 +421,7 @@
   ./services/monitoring/graphite.nix
   ./services/monitoring/hdaps.nix
   ./services/monitoring/heapster.nix
+  ./services/monitoring/incron.nix
   ./services/monitoring/longview.nix
   ./services/monitoring/monit.nix
   ./services/monitoring/munin.nix
@@ -619,6 +620,7 @@
   ./services/networking/xl2tpd.nix
   ./services/networking/xrdp.nix
   ./services/networking/zerobin.nix
+  ./services/networking/zeronet.nix
   ./services/networking/zerotierone.nix
   ./services/networking/znc.nix
   ./services/printing/cupsd.nix
diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix
index dc63f1a6c052..a222325579fe 100644
--- a/nixos/modules/services/misc/gitea.nix
+++ b/nixos/modules/services/misc/gitea.nix
@@ -283,7 +283,7 @@ in
 
         mkdir -p ${cfg.repositoryRoot}
         # update all hooks' binary paths
-        HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 5 -type f -wholename "*git/hooks/*")
+        HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 6 -type f -wholename "*git/hooks/*")
         if [ "$HOOKS" ]
         then
           sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gitea,${gitea.bin}/bin/gitea,g' $HOOKS
diff --git a/nixos/modules/services/misc/gitit.nix b/nixos/modules/services/misc/gitit.nix
index 0025d96bd37b..1ec030549f98 100644
--- a/nixos/modules/services/misc/gitit.nix
+++ b/nixos/modules/services/misc/gitit.nix
@@ -10,7 +10,7 @@ let
 
   toYesNo = b: if b then "yes" else "no";
 
-  gititShared = with cfg.haskellPackages; gitit + "/share/" + pkgs.stdenv.system + "-" + ghc.name + "/" + gitit.pname + "-" + gitit.version;
+  gititShared = with cfg.haskellPackages; gitit + "/share/" + pkgs.stdenv.hostPlatform.system + "-" + ghc.name + "/" + gitit.pname + "-" + gitit.version;
 
   gititWithPkgs = hsPkgs: extras: hsPkgs.ghcWithPackages (self: with self; [ gitit ] ++ (extras self));
 
diff --git a/nixos/modules/services/monitoring/incron.nix b/nixos/modules/services/monitoring/incron.nix
new file mode 100644
index 000000000000..1789fd9f2051
--- /dev/null
+++ b/nixos/modules/services/monitoring/incron.nix
@@ -0,0 +1,98 @@
+
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.services.incron;
+
+in
+
+{
+  options = {
+
+    services.incron = {
+
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Whether to enable the incron daemon.
+
+          Note that commands run under incrontab only support common Nix profiles for the <envar>PATH</envar> provided variable.
+        '';
+      };
+
+      allow = mkOption {
+        type = types.nullOr (types.listOf types.str);
+        default = null;
+        description = ''
+          Users allowed to use incrontab.
+
+          If empty then no user will be allowed to have their own incrontab.
+          If <literal>null</literal> then will defer to <option>deny</option>.
+          If both <option>allow</option> and <option>deny</option> are null
+          then all users will be allowed to have their own incrontab.
+        '';
+      };
+
+      deny = mkOption {
+        type = types.nullOr (types.listOf types.str);
+        default = null;
+        description = "Users forbidden from using incrontab.";
+      };
+
+      systab = mkOption {
+        type = types.lines;
+        default = "";
+        description = "The system incrontab contents.";
+        example = ''
+          /var/mail IN_CLOSE_WRITE abc $@/$#
+          /tmp IN_ALL_EVENTS efg $@/$# $&
+        '';
+      };
+
+      extraPackages = mkOption {
+        type = types.listOf types.package;
+        default = [];
+        example = literalExample "[ pkgs.rsync ]";
+        description = "Extra packages available to the system incrontab.";
+      };
+
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+
+    warnings = optional (cfg.allow != null && cfg.deny != null)
+      ''If `services.incron.allow` is set then `services.incron.deny` will be ignored.'';
+
+    environment.systemPackages = [ pkgs.incron ];
+
+    security.wrappers.incrontab.source = "${pkgs.incron}/bin/incrontab";
+
+    # incron won't read symlinks
+    environment.etc."incron.d/system" = {
+      mode = "0444";
+      text = cfg.systab;
+    };
+    environment.etc."incron.allow" = mkIf (cfg.allow != null) {
+      text = concatStringsSep "\n" cfg.allow;
+    };
+    environment.etc."incron.deny" = mkIf (cfg.deny != null) {
+      text = concatStringsSep "\n" cfg.deny;
+    };
+
+    systemd.services.incron = {
+      description = "File System Events Scheduler";
+      wantedBy = [ "multi-user.target" ];
+      path = cfg.extraPackages;
+      serviceConfig.PIDFile = "/run/incrond.pid";
+      serviceConfig.ExecStartPre = "${pkgs.coreutils}/bin/mkdir -m 710 -p /var/spool/incron";
+      serviceConfig.ExecStart = "${pkgs.incron}/bin/incrond --foreground";
+    };
+  };
+
+}
diff --git a/nixos/modules/services/networking/vsftpd.nix b/nixos/modules/services/networking/vsftpd.nix
index 1f9107c3ce9c..31e1e65fa9ca 100644
--- a/nixos/modules/services/networking/vsftpd.nix
+++ b/nixos/modules/services/networking/vsftpd.nix
@@ -99,7 +99,7 @@ let
       nopriv_user=vsftpd
       secure_chroot_dir=/var/empty
       syslog_enable=YES
-      ${optionalString (pkgs.stdenv.system == "x86_64-linux") ''
+      ${optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
         seccomp_sandbox=NO
       ''}
       anon_umask=${cfg.anonymousUmask}
diff --git a/nixos/modules/services/networking/zeronet.nix b/nixos/modules/services/networking/zeronet.nix
new file mode 100644
index 000000000000..2377cb2c8f11
--- /dev/null
+++ b/nixos/modules/services/networking/zeronet.nix
@@ -0,0 +1,102 @@
+{ config, lib, pkgs, ... }:
+
+let
+  cfg = config.services.zeronet;
+
+  zConfFile = pkgs.writeTextFile {
+    name = "zeronet.conf";
+    
+    text = ''
+      [global]
+      data_dir = ${cfg.dataDir}
+      log_dir = ${cfg.logDir}
+    '' + lib.optionalString (cfg.port != null) ''
+      ui_port = ${toString cfg.port}
+    '' + cfg.extraConfig;
+  };
+in with lib; {
+  options.services.zeronet = {
+    enable = mkEnableOption "zeronet";
+
+    dataDir = mkOption {
+      type = types.path;
+      default = "/var/lib/zeronet";
+      example = "/home/okina/zeronet";
+      description = "Path to the zeronet data directory.";
+    };
+
+    logDir = mkOption {
+      type = types.path;
+      default = "/var/log/zeronet";
+      example = "/home/okina/zeronet/log";
+      description = "Path to the zeronet log directory.";
+    };
+
+    port = mkOption {
+      type = types.nullOr types.int;
+      default = null;
+      example = 15441;
+      description = "Optional zeronet port.";
+    };
+
+    tor = mkOption {
+      type = types.bool;
+      default = false;
+      description = "Use TOR for all zeronet traffic.";
+    };
+
+    extraConfig = mkOption {
+      type = types.lines;
+      default = "";
+
+      description = ''
+        Extra configuration. Contents will be added verbatim to the
+        configuration file at the end.
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+    services.tor = mkIf cfg.tor {
+      enable = true;
+      controlPort = 9051;
+      extraConfig = "CookieAuthentication 1";
+    };
+    
+    systemd.services.zeronet = {
+      description = "zeronet";
+      after = [ "network.target" (optionalString cfg.tor "tor.service") ];
+      wantedBy = [ "multi-user.target" ];
+
+      preStart = ''
+        # Ensure folder exists or create it and permissions are correct
+        mkdir -p ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir}
+        chmod 750 ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir}
+        chown zeronet:zeronet ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir}
+      '';
+
+      serviceConfig = {
+        PermissionsStartOnly = true;
+        PrivateTmp = "yes";
+        User = "zeronet";
+        Group = "zeronet";
+        ExecStart = "${pkgs.zeronet}/bin/zeronet --config_file ${zConfFile}";
+      };
+    };
+
+    users = {
+      groups.zeronet.gid = config.ids.gids.zeronet;
+
+      users.zeronet = {
+        description = "zeronet service user";
+        home = cfg.dataDir;
+        createHome = true;
+        group = "zeronet";
+        extraGroups = mkIf cfg.tor [ "tor" ];
+        uid = config.ids.uids.zeronet;
+      };
+    };
+  };
+
+  meta.maintainers = with maintainers; [ chiiruno ];
+}
diff --git a/nixos/modules/services/security/usbguard.nix b/nixos/modules/services/security/usbguard.nix
index 5d469cabe2cb..88d2f69db572 100644
--- a/nixos/modules/services/security/usbguard.nix
+++ b/nixos/modules/services/security/usbguard.nix
@@ -188,11 +188,14 @@ in {
       wants = [ "systemd-udevd.service" "local-fs.target" ];
 
       # make sure an empty rule file and required directories exist
-      preStart = ''mkdir -p $(dirname "${cfg.ruleFile}") "${cfg.IPCAccessControlFiles}" && ([ -f "${cfg.ruleFile}" ] || touch ${cfg.ruleFile})'';
+      preStart = ''
+        mkdir -p $(dirname "${cfg.ruleFile}") $(dirname "${cfg.auditFilePath}") "${cfg.IPCAccessControlFiles}" \
+          && ([ -f "${cfg.ruleFile}" ] || touch ${cfg.ruleFile})
+      '';
 
       serviceConfig = {
         Type = "simple";
-        ExecStart = ''${pkgs.usbguard}/bin/usbguard-daemon -P -d -k -c ${daemonConfFile}'';
+        ExecStart = ''${pkgs.usbguard}/bin/usbguard-daemon -P -k -c ${daemonConfFile}'';
         Restart = "on-failure";
       };
     };
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix
index 17b169f7c696..b231ee5a3f01 100644
--- a/nixos/modules/services/web-servers/nginx/default.nix
+++ b/nixos/modules/services/web-servers/nginx/default.nix
@@ -16,9 +16,11 @@ let
     } // (optionalAttrs vhostConfig.enableACME {
       sslCertificate = "${acmeDirectory}/${serverName}/fullchain.pem";
       sslCertificateKey = "${acmeDirectory}/${serverName}/key.pem";
+      sslTrustedCertificate = "${acmeDirectory}/${serverName}/full.pem";
     }) // (optionalAttrs (vhostConfig.useACMEHost != null) {
       sslCertificate = "${acmeDirectory}/${vhostConfig.useACMEHost}/fullchain.pem";
       sslCertificateKey = "${acmeDirectory}/${vhostConfig.useACMEHost}/key.pem";
+      sslTrustedCertificate = "${acmeDirectory}/${vhostConfig.useACMEHost}/full.pem";
     })
   ) cfg.virtualHosts;
   enableIPv6 = config.networking.enableIPv6;
@@ -228,6 +230,9 @@ let
             ssl_certificate ${vhost.sslCertificate};
             ssl_certificate_key ${vhost.sslCertificateKey};
           ''}
+          ${optionalString (hasSSL && vhost.sslTrustedCertificate != null) ''
+            ssl_trusted_certificate ${vhost.sslTrustedCertificate};
+          ''}
 
           ${optionalString (vhost.basicAuthFile != null || vhost.basicAuth != {}) ''
             auth_basic secured;
diff --git a/nixos/modules/services/web-servers/nginx/vhost-options.nix b/nixos/modules/services/web-servers/nginx/vhost-options.nix
index 1075b00768fd..6954d932eed4 100644
--- a/nixos/modules/services/web-servers/nginx/vhost-options.nix
+++ b/nixos/modules/services/web-servers/nginx/vhost-options.nix
@@ -129,6 +129,13 @@ with lib;
       description = "Path to server SSL certificate key.";
     };
 
+    sslTrustedCertificate = mkOption {
+      type = types.path;
+      default = null;
+      example = "/var/root.cert";
+      description = "Path to root SSL certificate for stapling and client certificates.";
+    };
+
     http2 = mkOption {
       type = types.bool;
       default = true;
diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix
index 27c1f891f485..ed8b9f01e275 100644
--- a/nixos/modules/system/boot/luksroot.nix
+++ b/nixos/modules/system/boot/luksroot.nix
@@ -324,7 +324,7 @@ in
         [ "aes" "aes_generic" "blowfish" "twofish"
           "serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512"
 
-          (if pkgs.stdenv.system == "x86_64-linux" then "aes_x86_64" else "aes_i586")
+          (if pkgs.stdenv.hostPlatform.system == "x86_64-linux" then "aes_x86_64" else "aes_i586")
         ];
       description = ''
         A list of cryptographic kernel modules needed to decrypt the root device(s).
diff --git a/nixos/modules/virtualisation/azure-agent.nix b/nixos/modules/virtualisation/azure-agent.nix
index b7ab54aab7ec..770cefbcd511 100644
--- a/nixos/modules/virtualisation/azure-agent.nix
+++ b/nixos/modules/virtualisation/azure-agent.nix
@@ -77,7 +77,7 @@ in
   config = mkIf cfg.enable {
     assertions = [ {
       assertion = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64;
-      message = "Azure not currently supported on ${pkgs.stdenv.system}";
+      message = "Azure not currently supported on ${pkgs.stdenv.hostPlatform.system}";
     } {
       assertion = config.networking.networkmanager.enable == false;
       message = "Windows Azure Linux Agent is not compatible with NetworkManager";
diff --git a/nixos/modules/virtualisation/brightbox-image.nix b/nixos/modules/virtualisation/brightbox-image.nix
index 39a655b4c104..e716982c510a 100644
--- a/nixos/modules/virtualisation/brightbox-image.nix
+++ b/nixos/modules/virtualisation/brightbox-image.nix
@@ -26,7 +26,7 @@ in
               rm $diskImageBase
               popd
             '';
-          diskImageBase = "nixos-image-${config.system.nixos.label}-${pkgs.stdenv.system}.raw";
+          diskImageBase = "nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.raw";
           buildInputs = [ pkgs.utillinux pkgs.perl ];
           exportReferencesGraph =
             [ "closure" config.system.build.toplevel ];
diff --git a/nixos/modules/virtualisation/google-compute-image.nix b/nixos/modules/virtualisation/google-compute-image.nix
index de2c43b8a40a..4c7cffcf4557 100644
--- a/nixos/modules/virtualisation/google-compute-image.nix
+++ b/nixos/modules/virtualisation/google-compute-image.nix
@@ -14,7 +14,7 @@ in
       PATH=$PATH:${pkgs.stdenv.lib.makeBinPath [ pkgs.gnutar pkgs.gzip ]}
       pushd $out
       mv $diskImage disk.raw
-      tar -Szcf nixos-image-${config.system.nixos.label}-${pkgs.stdenv.system}.raw.tar.gz disk.raw
+      tar -Szcf nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.raw.tar.gz disk.raw
       rm $out/disk.raw
       popd
     '';
diff --git a/nixos/modules/virtualisation/virtualbox-guest.nix b/nixos/modules/virtualisation/virtualbox-guest.nix
index 78c6f740788e..834b994e92d2 100644
--- a/nixos/modules/virtualisation/virtualbox-guest.nix
+++ b/nixos/modules/virtualisation/virtualbox-guest.nix
@@ -34,7 +34,7 @@ in
   config = mkIf cfg.enable (mkMerge [{
     assertions = [{
       assertion = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64;
-      message = "Virtualbox not currently supported on ${pkgs.stdenv.system}";
+      message = "Virtualbox not currently supported on ${pkgs.stdenv.hostPlatform.system}";
     }];
 
     environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
diff --git a/nixos/modules/virtualisation/virtualbox-image.nix b/nixos/modules/virtualisation/virtualbox-image.nix
index 475852d1546c..60048911658c 100644
--- a/nixos/modules/virtualisation/virtualbox-image.nix
+++ b/nixos/modules/virtualisation/virtualbox-image.nix
@@ -26,21 +26,21 @@ in {
       };
       vmDerivationName = mkOption {
         type = types.str;
-        default = "nixos-ova-${config.system.nixos.label}-${pkgs.stdenv.system}";
+        default = "nixos-ova-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}";
         description = ''
           The name of the derivation for the VirtualBox appliance.
         '';
       };
       vmName = mkOption {
         type = types.str;
-        default = "NixOS ${config.system.nixos.label} (${pkgs.stdenv.system})";
+        default = "NixOS ${config.system.nixos.label} (${pkgs.stdenv.hostPlatform.system})";
         description = ''
           The name of the VirtualBox appliance.
         '';
       };
       vmFileName = mkOption {
         type = types.str;
-        default = "nixos-${config.system.nixos.label}-${pkgs.stdenv.system}.ova";
+        default = "nixos-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.ova";
         description = ''
           The file name of the VirtualBox appliance.
         '';
@@ -67,10 +67,10 @@ in {
           echo "creating VirtualBox VM..."
           vmName="${cfg.vmName}";
           VBoxManage createvm --name "$vmName" --register \
-            --ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"}
+            --ostype ${if pkgs.stdenv.hostPlatform.system == "x86_64-linux" then "Linux26_64" else "Linux26"}
           VBoxManage modifyvm "$vmName" \
             --memory ${toString cfg.memorySize} --acpi on --vram 32 \
-            ${optionalString (pkgs.stdenv.system == "i686-linux") "--pae on"} \
+            ${optionalString (pkgs.stdenv.hostPlatform.system == "i686-linux") "--pae on"} \
             --nictype1 virtio --nic1 nat \
             --audiocontroller ac97 --audio alsa \
             --rtcuseutc on \
diff --git a/nixos/modules/virtualisation/vmware-guest.nix b/nixos/modules/virtualisation/vmware-guest.nix
index 68930a0e3254..15c78f14c524 100644
--- a/nixos/modules/virtualisation/vmware-guest.nix
+++ b/nixos/modules/virtualisation/vmware-guest.nix
@@ -22,7 +22,7 @@ in
   config = mkIf cfg.enable {
     assertions = [ {
       assertion = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64;
-      message = "VMWare guest is not currently supported on ${pkgs.stdenv.system}";
+      message = "VMWare guest is not currently supported on ${pkgs.stdenv.hostPlatform.system}";
     } ];
 
     environment.systemPackages = [ open-vm-tools ];
diff --git a/nixos/modules/virtualisation/xen-dom0.nix b/nixos/modules/virtualisation/xen-dom0.nix
index cf57868acef9..70e575b6c0d2 100644
--- a/nixos/modules/virtualisation/xen-dom0.nix
+++ b/nixos/modules/virtualisation/xen-dom0.nix
@@ -146,7 +146,7 @@ in
   config = mkIf cfg.enable {
     assertions = [ {
       assertion = pkgs.stdenv.isx86_64;
-      message = "Xen currently not supported on ${pkgs.stdenv.system}";
+      message = "Xen currently not supported on ${pkgs.stdenv.hostPlatform.system}";
     } {
       assertion = config.boot.loader.grub.enable && (config.boot.loader.grub.efiSupport == false);
       message = "Xen currently does not support EFI boot";
diff --git a/nixos/tests/nfs.nix b/nixos/tests/nfs.nix
index 1992f240e7b0..0ef44f1a4890 100644
--- a/nixos/tests/nfs.nix
+++ b/nixos/tests/nfs.nix
@@ -6,7 +6,8 @@ let
     { pkgs, ... }:
     { fileSystems = pkgs.lib.mkVMOverride
         [ { mountPoint = "/data";
-            device = "server:/data";
+            # nfs4 exports the export with fsid=0 as a virtual root directory
+            device = if (version == 4) then "server:/" else "server:/data";
             fsType = "nfs";
             options = [ "vers=${toString version}" ];
           }
diff --git a/pkgs/applications/altcoins/mist.nix b/pkgs/applications/altcoins/mist.nix
index 5f89b0a0c173..194c004f9c7f 100644
--- a/pkgs/applications/altcoins/mist.nix
+++ b/pkgs/applications/altcoins/mist.nix
@@ -4,7 +4,7 @@ let
   version = "0.11.1";
   name = "mist";
 
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   meta = with stdenv.lib; {
     description = "Browse and use Ðapps on the Ethereum network";
@@ -37,7 +37,7 @@ let
         url = "https://github.com/ethereum/mist/releases/download/v${version}/Mist-linux64-${urlVersion}.zip";
         sha256 = "0yx4x72l8gk68yh9saki48zgqx8k92xnkm79dc651wdpd5c25cz3";
       };
-    }.${stdenv.system} or throwSystem;
+    }.${stdenv.hostPlatform.system} or throwSystem;
 
     buildInputs = [ unzip makeWrapper ];
 
diff --git a/pkgs/applications/audio/baudline/default.nix b/pkgs/applications/audio/baudline/default.nix
index deaa3f98e52e..6827d12b3217 100644
--- a/pkgs/applications/audio/baudline/default.nix
+++ b/pkgs/applications/audio/baudline/default.nix
@@ -11,18 +11,18 @@ stdenv.mkDerivation rec {
   version = "1.08";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "http://www.baudline.com/baudline_${version}_linux_x86_64.tar.gz";
         sha256 = "09fn0046i69in1jpizkzbaq5ggij0mpflcsparyskm3wh71mbzvr";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "http://www.baudline.com/baudline_${version}_linux_i686.tar.gz";
         sha256 = "1waip5pmcf5ffcfvn8lf1rvsaq2ab66imrbfqs777scz7k8fhhjb";
       }
     else
-      throw "baudline isn't supported (yet?) on ${stdenv.system}";
+      throw "baudline isn't supported (yet?) on ${stdenv.hostPlatform.system}";
 
   buildInputs = [ makeWrapper ];
 
diff --git a/pkgs/applications/audio/google-musicmanager/default.nix b/pkgs/applications/audio/google-musicmanager/default.nix
index 4cd3010ec3d3..b4fe78dcbfcd 100644
--- a/pkgs/applications/audio/google-musicmanager/default.nix
+++ b/pkgs/applications/audio/google-musicmanager/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 , flac, expat, libidn, qtbase, qtwebkit, libvorbis }:
-assert stdenv.system == "x86_64-linux";
+assert stdenv.hostPlatform.system == "x86_64-linux";
 
 stdenv.mkDerivation rec {
   version = "beta_1.0.467.4929-r0"; # friendly to nix-env version sorting algo
diff --git a/pkgs/applications/audio/mpg123/default.nix b/pkgs/applications/audio/mpg123/default.nix
index 3aef2e35943d..44f1c681ec1a 100644
--- a/pkgs/applications/audio/mpg123/default.nix
+++ b/pkgs/applications/audio/mpg123/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchurl, alsaLib
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -13,8 +12,9 @@ stdenv.mkDerivation rec {
 
   buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
 
-  configureFlags =
-    stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";
+  configureFlags = stdenv.lib.optional
+    (stdenv.hostPlatform ? mpg123)
+    "--with-cpu=${stdenv.hostPlatform.mpg123.cpu}";
 
   meta = {
     description = "Fast console MPEG Audio Player and decoder library";
diff --git a/pkgs/applications/audio/pulseeffects/default.nix b/pkgs/applications/audio/pulseeffects/default.nix
index 313f737cd422..37729868e6f7 100644
--- a/pkgs/applications/audio/pulseeffects/default.nix
+++ b/pkgs/applications/audio/pulseeffects/default.nix
@@ -43,13 +43,13 @@ let
   ];
 in stdenv.mkDerivation rec {
   name = "pulseeffects-${version}";
-  version = "4.2.8";
+  version = "4.3.3";
 
   src = fetchFromGitHub {
     owner = "wwmm";
     repo = "pulseeffects";
     rev = "v${version}";
-    sha256 = "0ckl0640n6lhk0gcmnmwngajkf46rrd8bxfh7xy5sq6qmm01dhdd";
+    sha256 = "1krfxvwqimfcsv7f2l722ivzz0qdf5h0pmb702mg65qb160zn065";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/applications/audio/renoise/default.nix b/pkgs/applications/audio/renoise/default.nix
index 24a2f1a8a601..cd06fa80f5aa 100644
--- a/pkgs/applications/audio/renoise/default.nix
+++ b/pkgs/applications/audio/renoise/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   version = "3.1.0";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
         if builtins.isNull releasePath then
         fetchurl {
           url = "https://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_x86_64.tar.bz2";
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
         }
         else
         releasePath
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
         if builtins.isNull releasePath then
         fetchurl {
           url = "http://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_x86.tar.bz2";
diff --git a/pkgs/applications/audio/spotify/default.nix b/pkgs/applications/audio/spotify/default.nix
index 04bdff3c8135..1639ab34b6cf 100644
--- a/pkgs/applications/audio/spotify/default.nix
+++ b/pkgs/applications/audio/spotify/default.nix
@@ -3,15 +3,16 @@
 , libgcrypt, systemd, fontconfig, dbus, expat, ffmpeg_0_10, curl, zlib, gnome3 }:
 
 let
+  # TO UPDATE: just execute the ./update.sh script (won't do anything if there is no update)
   # "rev" decides what is actually being downloaded
-  version = "1.0.80.474.gef6b503e-7";
+  version = "1.0.88.353.g15c26ea1-14";
   # To get the latest stable revision:
   # curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=stable' | jq '.download_url,.version,.last_updated'
   # To get general information:
   # curl -H 'Snap-Device-Series: 16' 'https://api.snapcraft.io/v2/snaps/info/spotify' | jq '.'
   # More exapmles of api usage:
   # https://github.com/canonical-websites/snapcraft.io/blob/master/webapp/publisher/snaps/views.py
-  rev = "16";
+  rev = "19";
 
 
   deps = [
@@ -64,7 +65,7 @@ stdenv.mkDerivation {
   # https://community.spotify.com/t5/Desktop-Linux/Redistribute-Spotify-on-Linux-Distributions/td-p/1695334
   src = fetchurl {
     url = "https://api.snapcraft.io/api/v1/snaps/download/pOBIoZ2LrCB3rDohMxoYGnbN14EHOgD7_${rev}.snap";
-    sha512 = "45b7ab574b30fb368e0b6f4dd60addbfd1ddc02173b4f98b31c524eed49073432352a361e75959ce8e2f752231e93c79ca1b538c4bd295c935d1e2e0585d147f";
+    sha512 = "3a068cbe3c1fca84ae67e28830216f993aa459947517956897c3b3f63063005c9db646960e85185b149747ffc302060c208a7f9968ea69d50a3496067089f3db";
   };
 
   buildInputs = [ squashfsTools makeWrapper ];
diff --git a/pkgs/applications/audio/spotify/update.sh b/pkgs/applications/audio/spotify/update.sh
index 114245f6d46c..114245f6d46c 100644..100755
--- a/pkgs/applications/audio/spotify/update.sh
+++ b/pkgs/applications/audio/spotify/update.sh
diff --git a/pkgs/applications/audio/transcribe/default.nix b/pkgs/applications/audio/transcribe/default.nix
index 5ec5087b9f26..c6d5ebc1627f 100644
--- a/pkgs/applications/audio/transcribe/default.nix
+++ b/pkgs/applications/audio/transcribe/default.nix
@@ -7,12 +7,12 @@ stdenv.mkDerivation rec {
   name = "transcribe-${version}";
   version = "8.40";
 
-  src = if stdenv.system == "i686-linux" then
+  src = if stdenv.hostPlatform.system == "i686-linux" then
     fetchzip {
       url = "https://www.seventhstring.com/xscribe/downlinux32_old/xscsetup.tar.gz";
       sha256 = "1ngidmj9zz8bmv754s5xfsjv7v6xr03vck4kigzq4bpc9b1fdhjq";
     }
-  else if stdenv.system == "x86_64-linux" then
+  else if stdenv.hostPlatform.system == "x86_64-linux" then
     fetchzip {
       url = "https://www.seventhstring.com/xscribe/downlinux64_old/xsc64setup.tar.gz";
       sha256 = "0svzi8svj6zn06gj0hr8mpnhq4416dvb4g5al0gpb1g3paywdaf9";
diff --git a/pkgs/applications/display-managers/lightdm/default.nix b/pkgs/applications/display-managers/lightdm/default.nix
index 4bf81dcdd26a..bec07ac2d506 100644
--- a/pkgs/applications/display-managers/lightdm/default.nix
+++ b/pkgs/applications/display-managers/lightdm/default.nix
@@ -9,15 +9,17 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   pname = "lightdm";
-  version = "1.26.0";
+  version = "1.28.0";
 
   name = "${pname}-${version}";
 
+  outputs = [ "out" "dev" ];
+
   src = fetchFromGitHub {
     owner = "CanonicalLtd";
     repo = pname;
     rev = version;
-    sha256 = "1mhj6l025cnf2dzxnbzlk0qa9fm4gj2aw58qh5fl4ky87dp4wdyb";
+    sha256 = "1mmqy1jdvgc0h0h9gli7n4vdv5p8m5019qjr5ni4h73iz6mjdj2b";
   };
 
   nativeBuildInputs = [
@@ -73,6 +75,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     homepage = https://github.com/CanonicalLtd/lightdm;
+    description = "A cross-desktop display manager.";
     platforms = platforms.linux;
     license = licenses.gpl3;
     maintainers = with maintainers; [ ocharles wkennington worldofpeace ];
diff --git a/pkgs/applications/editors/eclipse/build-eclipse.nix b/pkgs/applications/editors/eclipse/build-eclipse.nix
index a26d380ec1df..389608ad8249 100644
--- a/pkgs/applications/editors/eclipse/build-eclipse.nix
+++ b/pkgs/applications/editors/eclipse/build-eclipse.nix
@@ -2,7 +2,7 @@
 , zlib, jdk, glib, gtk3, libXtst, gsettings-desktop-schemas, webkitgtk
 , makeWrapper, ... }:
 
-{ name, src ? builtins.getAttr stdenv.system sources, sources ? null, description }:
+{ name, src ? builtins.getAttr stdenv.hostPlatform.system sources, sources ? null, description }:
 
 stdenv.mkDerivation rec {
   inherit name src;
diff --git a/pkgs/applications/editors/eclipse/default.nix b/pkgs/applications/editors/eclipse/default.nix
index c719c7b2da1a..8d47a551c93e 100644
--- a/pkgs/applications/editors/eclipse/default.nix
+++ b/pkgs/applications/editors/eclipse/default.nix
@@ -27,24 +27,24 @@ rec {
     name = "eclipse-cpp-4.7.0";
     description = "Eclipse IDE for C/C++ Developers, Oxygen release";
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/oxygen/R/eclipse-cpp-oxygen-R-linux-gtk-x86_64.tar.gz;
           sha512 = "813c791e739d7d0e2ab242a5bacadca135bbeee20ef97aa830353cd90f63fa6e9c89cfcc6aadf635c742befe035bd6e3f15103013f63c419f6144e86ebde3ed1";
         }
-      else if stdenv.system == "i686-linux" then
+      else if stdenv.hostPlatform.system == "i686-linux" then
         fetchurl {
           url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/oxygen/R/eclipse-cpp-oxygen-R-linux-gtk.tar.gz;
           sha512 = "2b50f4a00306a89cda1aaaa606e62285cacbf93464a9dd3f3319dca3e2c578b802e685de6f78e5e617d269e21271188effe73d41f491a6de946e28795d82db8a";
         }
-      else throw "Unsupported system: ${stdenv.system}";
+      else throw "Unsupported system: ${stdenv.hostPlatform.system}";
   };
 
   eclipse-cpp-37 = buildEclipse {
     name = "eclipse-cpp-3.7";
     description = "Eclipse IDE for C/C++ Developers";
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/indigo/R/eclipse-cpp-indigo-incubation-linux-gtk-x86_64.tar.gz;
           sha256 = "14ppc9g9igzvj1pq7jl01vwhzb66nmzbl9wsdl1sf3xnwa9wnqk3";
@@ -65,7 +65,7 @@ rec {
     name = "eclipse-modeling-4.7";
     description = "Eclipse Modeling Tools";
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/oxygen/R/eclipse-modeling-oxygen-R-linux-gtk-x86_64.tar.gz;
           sha512 = "3b9a7ad4b5d6b77fbdd64e8d323e0adb6c2904763ad042b374b4d87cef8607408cb407e395870fc755d58c0c800e20818adcf456ebe193d76cede16c5fe12271";
@@ -81,7 +81,7 @@ rec {
     name = "eclipse-modeling-3.6.2";
     description = "Eclipse Modeling Tools (includes Incubating components)";
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/helios/SR2/eclipse-modeling-helios-SR2-incubation-linux-gtk-x86_64.tar.gz;
           sha1 = "e96f5f006298f68476f4a15a2be8589158d5cc61";
@@ -151,7 +151,7 @@ rec {
     name = "eclipse-scala-sdk-4.4.1";
     description = "Eclipse IDE for Scala Developers";
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl { # tested
           url = https://downloads.typesafe.com/scalaide-pack/4.4.1-vfinal-luna-211-20160504/scala-SDK-4.4.1-vfinal-2.11-linux.gtk.x86_64.tar.gz;
           sha256  = "4c2d1ac68384e12a11a851cf0fc7757aea087eba69329b21d539382a65340d27";
diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
index 832dc3c0e799..536b319cab04 100644
--- a/pkgs/applications/editors/ed/default.nix
+++ b/pkgs/applications/editors/ed/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, lzip
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation (rec {
@@ -36,7 +35,7 @@ stdenv.mkDerivation (rec {
     maintainers = [ ];
     platforms = stdenv.lib.platforms.unix;
   };
-} // stdenv.lib.optionalAttrs (hostPlatform != buildPlatform) {
+} // stdenv.lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
   # This may be moved above during a stdenv rebuild.
   preConfigure = ''
     configureFlagsArray+=("CC=$CC")
diff --git a/pkgs/applications/editors/jetbrains/common.nix b/pkgs/applications/editors/jetbrains/common.nix
index 04de4f564c33..2bb84bce0b12 100644
--- a/pkgs/applications/editors/jetbrains/common.nix
+++ b/pkgs/applications/editors/jetbrains/common.nix
@@ -42,7 +42,7 @@ with stdenv; lib.makeOverridable mkDerivation rec {
       }
 
       interpreter=$(echo ${stdenv.glibc.out}/lib/ld-linux*.so.2)
-      if [ "${stdenv.system}" == "x86_64-linux" ]; then
+      if [ "${stdenv.hostPlatform.system}" == "x86_64-linux" ]; then
         target_size=$(get_file_size bin/fsnotifier64)
         patchelf --set-interpreter "$interpreter" bin/fsnotifier64
         munge_size_hack bin/fsnotifier64 $target_size
diff --git a/pkgs/applications/editors/kodestudio/default.nix b/pkgs/applications/editors/kodestudio/default.nix
index 4e22e032e357..b212773712c2 100644
--- a/pkgs/applications/editors/kodestudio/default.nix
+++ b/pkgs/applications/editors/kodestudio/default.nix
@@ -8,15 +8,15 @@ let
 
   version = "17.1";
 
-  sha256 = if stdenv.system == "x86_64-linux"  then "1kddisnvlk48jip6k59mw3wlkrl7rkck2lxpaghn0gfx02cvms5f"
-      else if stdenv.system == "i686-cygwin"   then "1izp42afrlh4yd322ax9w85ki388gnkqfqbw8dwnn4k3j7r5487z"
-      else throw "Unsupported system: ${stdenv.system}";
+  sha256 = if stdenv.hostPlatform.system == "x86_64-linux"  then "1kddisnvlk48jip6k59mw3wlkrl7rkck2lxpaghn0gfx02cvms5f"
+      else if stdenv.hostPlatform.system == "i686-cygwin"   then "1izp42afrlh4yd322ax9w85ki388gnkqfqbw8dwnn4k3j7r5487z"
+      else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   urlBase = "https://github.com/Kode/KodeStudio/releases/download/v${version}/KodeStudio-";
 
-  urlStr = if stdenv.system == "x86_64-linux"  then urlBase + "linux64.tar.gz"
-      else if stdenv.system == "i686-cygwin"   then urlBase + "win32.zip"
-      else throw "Unsupported system: ${stdenv.system}";
+  urlStr = if stdenv.hostPlatform.system == "x86_64-linux"  then urlBase + "linux64.tar.gz"
+      else if stdenv.hostPlatform.system == "i686-cygwin"   then urlBase + "win32.zip"
+      else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
 in
 
@@ -47,7 +47,7 @@ in
       cp -r ./* $out
     '';
 
-    postFixup = lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") ''
+    postFixup = lib.optionalString (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux") ''
       # Patch Binaries
       patchelf \
           --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
diff --git a/pkgs/applications/editors/music/tuxguitar/default.nix b/pkgs/applications/editors/music/tuxguitar/default.nix
index f305db1abb8f..1b1c6eaf9e54 100644
--- a/pkgs/applications/editors/music/tuxguitar/default.nix
+++ b/pkgs/applications/editors/music/tuxguitar/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, swt, jdk, makeWrapper, alsaLib }:
 
-let metadata = assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
-  if stdenv.system == "i686-linux" then
+let metadata = assert stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux";
+  if stdenv.hostPlatform.system == "i686-linux" then
     { arch = "x86"; sha256 = "1qmb51k0538pn7gv4nsvhfv33xik4l4af0qmpllkzrikmj8wvzlb"; }
   else
     { arch = "x86_64"; sha256 = "12af47jhlrh9aq5b3d13l7cdhlndgnfpy61gz002hajbq7i00ixh"; };
diff --git a/pkgs/applications/editors/sublime/2/default.nix b/pkgs/applications/editors/sublime/2/default.nix
index 78c2d9aaa0c4..11724d9802a5 100644
--- a/pkgs/applications/editors/sublime/2/default.nix
+++ b/pkgs/applications/editors/sublime/2/default.nix
@@ -6,7 +6,7 @@ in
 stdenv.mkDerivation rec {
   name = "sublimetext-2.0.2";
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         name = "sublimetext-2.0.2.tar.bz2";
         url = http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.2.tar.bz2;
diff --git a/pkgs/applications/editors/sublime/3/common.nix b/pkgs/applications/editors/sublime/3/common.nix
index 628993dbf5be..eb282b1be3a8 100644
--- a/pkgs/applications/editors/sublime/3/common.nix
+++ b/pkgs/applications/editors/sublime/3/common.nix
@@ -13,13 +13,13 @@ let
     ++ stdenv.lib.optional gksuSupport "/usr/bin/gksudo=${gksu}/bin/gksudo";
 in let
   archSha256 =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       x32sha256
     else
       x64sha256;
 
   arch =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       "x32"
     else
       "x64";
diff --git a/pkgs/applications/editors/typora/default.nix b/pkgs/applications/editors/typora/default.nix
index 93ee70e4148b..0bff4864c612 100644
--- a/pkgs/applications/editors/typora/default.nix
+++ b/pkgs/applications/editors/typora/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation rec {
   version = "0.9.53";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://www.typora.io/linux/typora_${version}_amd64.deb";
         sha256 = "02k6x30l4mbjragqbq5rn663xbw3h4bxzgppfxqf5lwydswldklb";
diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix
index 067179974b1e..26cd61d182bd 100644
--- a/pkgs/applications/editors/vim/default.nix
+++ b/pkgs/applications/editors/vim/default.nix
@@ -7,7 +7,6 @@
   }
 # apple frameworks
 , Carbon, Cocoa
-, buildPlatform, hostPlatform
 }:
 
 let
@@ -20,12 +19,12 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ gettext pkgconfig ];
   buildInputs = [ ncurses ]
-    ++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ];
+    ++ stdenv.lib.optionals stdenv.hostPlatform.isDarwin [ Carbon Cocoa ];
 
   configureFlags = [
     "--enable-multibyte"
     "--enable-nls"
-  ] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "vim_cv_toupper_broken=no"
     "--with-tlib=ncurses"
     "vim_cv_terminfo=yes"
diff --git a/pkgs/applications/editors/vscode/default.nix b/pkgs/applications/editors/vscode/default.nix
index a775fb3bd79a..0cf0c7bcbc69 100644
--- a/pkgs/applications/editors/vscode/default.nix
+++ b/pkgs/applications/editors/vscode/default.nix
@@ -9,15 +9,15 @@ let
     "i686-linux" = "linux-ia32";
     "x86_64-linux" = "linux-x64";
     "x86_64-darwin" = "darwin";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
   sha256 = {
     "i686-linux" = "1g7kqbz6mrf8ngx2bnwpi9fifq5rjznxgsgwjb532z3nh92ypa8n";
     "x86_64-linux" = "02yldycakn5zxj1ji4nmhdyazqlkjqpzdj3g8j501c3j28pgiwjy";
     "x86_64-darwin" = "0pnsfkh20mj7pzqw7wlfd98jqc6a1mnsq1iira15n7fafqgj8zpl";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
-  archive_fmt = if stdenv.system == "x86_64-darwin" then "zip" else "tar.gz";
+  archive_fmt = if stdenv.hostPlatform.system == "x86_64-darwin" then "zip" else "tar.gz";
 
   rpath = lib.concatStringsSep ":" [
     atomEnv.libPath
@@ -48,12 +48,12 @@ in
       categories = "GNOME;GTK;Utility;TextEditor;Development;";
     };
 
-    buildInputs = if stdenv.system == "x86_64-darwin"
+    buildInputs = if stdenv.hostPlatform.system == "x86_64-darwin"
       then [ unzip libXScrnSaver libsecret ]
       else [ wrapGAppsHook libXScrnSaver libxkbfile libsecret ];
 
     installPhase =
-      if stdenv.system == "x86_64-darwin" then ''
+      if stdenv.hostPlatform.system == "x86_64-darwin" then ''
         mkdir -p $out/lib/vscode $out/bin
         cp -r ./* $out/lib/vscode
         ln -s $out/lib/vscode/Contents/Resources/app/bin/code $out/bin
@@ -72,7 +72,7 @@ in
         cp $out/lib/vscode/resources/app/resources/linux/code.png $out/share/pixmaps/code.png
       '';
 
-    postFixup = lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") ''
+    postFixup = lib.optionalString (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux") ''
       patchelf \
         --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
         --set-rpath "${rpath}" \
diff --git a/pkgs/applications/graphics/ImageMagick/7.0.nix b/pkgs/applications/graphics/ImageMagick/7.0.nix
index c4afd6b3bed3..7881741a1cbb 100644
--- a/pkgs/applications/graphics/ImageMagick/7.0.nix
+++ b/pkgs/applications/graphics/ImageMagick/7.0.nix
@@ -2,15 +2,14 @@
 , bzip2, zlib, libX11, libXext, libXt, fontconfig, freetype, ghostscript, libjpeg
 , lcms2, openexr, libpng, librsvg, libtiff, libxml2, openjpeg, libwebp, libheif
 , ApplicationServices
-, hostPlatform
 }:
 
 let
   arch =
-    if stdenv.system == "i686-linux" then "i686"
-    else if stdenv.system == "x86_64-linux" || stdenv.system == "x86_64-darwin" then "x86-64"
-    else if stdenv.system == "armv7l-linux" then "armv7l"
-    else if stdenv.system == "aarch64-linux" then "aarch64"
+    if stdenv.hostPlatform.system == "i686-linux" then "i686"
+    else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
+    else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
+    else if stdenv.hostPlatform.system == "aarch64-linux" then "aarch64"
     else throw "ImageMagick is not supported on this platform.";
 
   cfg = {
@@ -46,7 +45,7 @@ stdenv.mkDerivation rec {
       [ "--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
         "--with-gslib"
       ]
-    ++ lib.optionals hostPlatform.isMinGW
+    ++ lib.optionals stdenv.hostPlatform.isMinGW
       [ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
     ;
 
@@ -56,13 +55,13 @@ stdenv.mkDerivation rec {
     [ zlib fontconfig freetype ghostscript
       libpng libtiff libxml2 libheif
     ]
-    ++ lib.optionals (!hostPlatform.isMinGW)
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
       [ openexr librsvg openjpeg ]
     ++ lib.optional stdenv.isDarwin ApplicationServices;
 
   propagatedBuildInputs =
     [ bzip2 freetype libjpeg lcms2 ]
-    ++ lib.optionals (!hostPlatform.isMinGW)
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
       [ libX11 libXext libXt libwebp ]
     ;
 
diff --git a/pkgs/applications/graphics/ImageMagick/default.nix b/pkgs/applications/graphics/ImageMagick/default.nix
index 94a4aeaa9337..5220fdf89813 100644
--- a/pkgs/applications/graphics/ImageMagick/default.nix
+++ b/pkgs/applications/graphics/ImageMagick/default.nix
@@ -2,15 +2,14 @@
 , bzip2, zlib, libX11, libXext, libXt, fontconfig, freetype, ghostscript, libjpeg
 , lcms2, openexr, libpng, librsvg, libtiff, libxml2, openjpeg, libwebp, fftw, libheif, libde265
 , ApplicationServices
-, hostPlatform
 }:
 
 let
   arch =
-    if stdenv.system == "i686-linux" then "i686"
-    else if stdenv.system == "x86_64-linux" || stdenv.system == "x86_64-darwin" then "x86-64"
-    else if stdenv.system == "armv7l-linux" then "armv7l"
-    else if stdenv.system == "aarch64-linux" then "aarch64"
+    if stdenv.hostPlatform.system == "i686-linux" then "i686"
+    else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
+    else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
+    else if stdenv.hostPlatform.system == "aarch64-linux" then "aarch64"
     else throw "ImageMagick is not supported on this platform.";
 
   cfg = {
@@ -20,7 +19,7 @@ let
   }
     # Freeze version on mingw so we don't need to port the patch too often.
     # FIXME: This version has multiple security vulnerabilities
-    // lib.optionalAttrs (hostPlatform.isMinGW) {
+    // lib.optionalAttrs (stdenv.hostPlatform.isMinGW) {
         version = "6.9.2-0";
         sha256 = "17ir8bw1j7g7srqmsz3rx780sgnc21zfn0kwyj78iazrywldx8h7";
         patches = [(fetchpatch {
@@ -58,7 +57,7 @@ stdenv.mkDerivation rec {
       [ "--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
         "--with-gslib"
       ]
-    ++ lib.optionals (hostPlatform.isMinGW)
+    ++ lib.optionals (stdenv.hostPlatform.isMinGW)
       [ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
     ;
 
@@ -68,13 +67,13 @@ stdenv.mkDerivation rec {
     [ zlib fontconfig freetype ghostscript
       libpng libtiff libxml2 libheif libde265
     ]
-    ++ lib.optionals (!hostPlatform.isMinGW)
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
       [ openexr librsvg openjpeg ]
     ++ lib.optional stdenv.isDarwin ApplicationServices;
 
   propagatedBuildInputs =
     [ bzip2 freetype libjpeg lcms2 fftw ]
-    ++ lib.optionals (!hostPlatform.isMinGW)
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
       [ libX11 libXext libXt libwebp ]
     ;
 
diff --git a/pkgs/applications/graphics/gcolor2/default.nix b/pkgs/applications/graphics/gcolor2/default.nix
index 3747b802e231..27ca6e26e9f9 100644
--- a/pkgs/applications/graphics/gcolor2/default.nix
+++ b/pkgs/applications/graphics/gcolor2/default.nix
@@ -3,7 +3,7 @@
 let version = "0.4"; in
 stdenv.mkDerivation {
   name = "gcolor2-${version}";
-  arch = if stdenv.system == "x86_64-linux" then "amd64" else "386";
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" else "386";
 
   src = fetchurl {
     url = "mirror://sourceforge/project/gcolor2/gcolor2/${version}/gcolor2-${version}.tar.bz2";
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
   '';
 
   # from https://github.com/PhantomX/slackbuilds/tree/master/gcolor2/patches
-  patches = if stdenv.system == "x86_64-linux" then
+  patches = if stdenv.hostPlatform.system == "x86_64-linux" then
         [ ./gcolor2-amd64.patch ] else
         [ ];
 
diff --git a/pkgs/applications/graphics/sane/backends/brscan4/default.nix b/pkgs/applications/graphics/sane/backends/brscan4/default.nix
index df44c132ed96..b431cf51b019 100644
--- a/pkgs/applications/graphics/sane/backends/brscan4/default.nix
+++ b/pkgs/applications/graphics/sane/backends/brscan4/default.nix
@@ -12,17 +12,17 @@ let
 in stdenv.mkDerivation rec {
   name = "brscan4-0.4.4-4";
   src = 
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "http://download.brother.com/welcome/dlf006646/${name}.i386.deb";
         sha256 = "13mhjbzf9nvpdzrc2s98684r7likg76zxs1wlz2h8w59fsqgx4k2";
       }
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://download.brother.com/welcome/dlf006645/${name}.amd64.deb";
         sha256 = "0xy5px96y1saq9l80vwvfn6anr2q42qlxdhm6ci2a0diwib5q9fd";
       }
-    else throw "${name} is not supported on ${stdenv.system} (only i686-linux and x86_64 linux are supported)";
+    else throw "${name} is not supported on ${stdenv.hostPlatform.system} (only i686-linux and x86_64 linux are supported)";
 
   unpackPhase = ''
     ar x $src
diff --git a/pkgs/applications/graphics/unigine-valley/default.nix b/pkgs/applications/graphics/unigine-valley/default.nix
index f1adc6bd10ea..d29c9cd82598 100644
--- a/pkgs/applications/graphics/unigine-valley/default.nix
+++ b/pkgs/applications/graphics/unigine-valley/default.nix
@@ -17,12 +17,12 @@
 let
   version = "1.0";
 
-  arch = if stdenv.system == "x86_64-linux" then
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then
     "x64"
-  else if stdenv.system == "i686-linux" then
+  else if stdenv.hostPlatform.system == "i686-linux" then
     "x86"
   else
-    throw "Unsupported platform ${stdenv.system}";
+    throw "Unsupported platform ${stdenv.hostPlatform.system}";
 
 in
   stdenv.mkDerivation rec {
diff --git a/pkgs/applications/misc/1password/default.nix b/pkgs/applications/misc/1password/default.nix
index 94dfc68fb59b..331f516c88ce 100644
--- a/pkgs/applications/misc/1password/default.nix
+++ b/pkgs/applications/misc/1password/default.nix
@@ -4,19 +4,19 @@ stdenv.mkDerivation rec {
   name = "1password-${version}";
   version = "0.5.3";
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchzip {
         url = "https://cache.agilebits.com/dist/1P/op/pkg/v${version}/op_linux_386_v${version}.zip";
         sha256 = "05s223h1yps4k9kmignl0r5sbh6w7m1hnlmafnf1kiwv7gacvxjc";
         stripRoot = false;
       }
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchzip {
         url = "https://cache.agilebits.com/dist/1P/op/pkg/v${version}/op_linux_amd64_v${version}.zip";
         sha256 = "0p9x1fx0309v8dxxaf88m8x8q15zzqywfmjn6v5wb9v3scp9396v";
         stripRoot = false;
       }
-    else if stdenv.system == "x86_64-darwin" then
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then
       fetchzip {
         url = "https://cache.agilebits.com/dist/1P/op/pkg/v${version}/op_darwin_amd64_v${version}.zip";
         sha256 = "1z2xp9bn93gr4ha6zx65va1fb58a2xlnnmpv583y96gq3vbnqdcj";
diff --git a/pkgs/applications/misc/adobe-reader/default.nix b/pkgs/applications/misc/adobe-reader/default.nix
index 88bf87b0a84f..0ca12a0096ed 100644
--- a/pkgs/applications/misc/adobe-reader/default.nix
+++ b/pkgs/applications/misc/adobe-reader/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, libX11, cups, zlib, libxml2, pango, atk, gtk2, glib
 , gdk_pixbuf }:
 
-assert stdenv.system == "i686-linux";
+assert stdenv.hostPlatform.system == "i686-linux";
 
 let version = "9.5.5"; in
 
diff --git a/pkgs/applications/misc/cura/lulzbot.nix b/pkgs/applications/misc/cura/lulzbot.nix
index 6a36e42eaa3d..f3f1972f6e6e 100644
--- a/pkgs/applications/misc/cura/lulzbot.nix
+++ b/pkgs/applications/misc/cura/lulzbot.nix
@@ -8,17 +8,17 @@ stdenv.mkDerivation rec {
   version = "15.02.1-1.03-5064";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://download.alephobjects.com/ao/aodeb/dists/jessie/main/binary-amd64/cura_${version}_amd64.deb";
         sha256 = "1gsfidg3gim5pjbl82vkh0cw4ya253m4p7nirm8nr6yjrsirkzxg";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "http://download.alephobjects.com/ao/aodeb/dists/jessie/main/binary-i386/cura_${version}_i386.deb";
         sha256 = "0xd3df6bxq4rijgvsqvps454jkc1nzhxbdzzj6j2w317ppsbhyc1";
       }
-    else throw "${name} is not supported on ${stdenv.system}";
+    else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
 
   python_deps = with py; [ pyopengl pyserial numpy wxPython30 power setuptools ];
   pythonPath = python_deps;
diff --git a/pkgs/applications/misc/googleearth/default.nix b/pkgs/applications/misc/googleearth/default.nix
index 9c1b457c299d..96f8cb116143 100644
--- a/pkgs/applications/misc/googleearth/default.nix
+++ b/pkgs/applications/misc/googleearth/default.nix
@@ -4,9 +4,9 @@
 
 let
   arch =
-    if stdenv.system == "x86_64-linux" then "amd64"
-    else if stdenv.system == "i686-linux" then "i386"
-    else throw "Unsupported system ${stdenv.system}";
+    if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "i386"
+    else throw "Unsupported system ${stdenv.hostPlatform.system}";
   sha256 =
     if arch == "amd64"
     then "0dwnppn5snl5bwkdrgj4cyylnhngi0g66fn2k41j3dvis83x24k6"
diff --git a/pkgs/applications/misc/icesl/default.nix b/pkgs/applications/misc/icesl/default.nix
index 49b1741fd5af..c0c1faef09d2 100644
--- a/pkgs/applications/misc/icesl/default.nix
+++ b/pkgs/applications/misc/icesl/default.nix
@@ -6,10 +6,10 @@ stdenv.mkDerivation rec {
   name = "iceSL-${version}";
   version = "2.1.10";
 
-  src =  if stdenv.system == "x86_64-linux" then fetchzip {
+  src =  if stdenv.hostPlatform.system == "x86_64-linux" then fetchzip {
     url = "https://gforge.inria.fr/frs/download.php/file/37268/icesl${version}-amd64.zip";
     sha256 = "0dv3mq6wy46xk9blzzmgbdxpsjdaxid3zadfrysxlhmgl7zb2cn2";
-  } else if stdenv.system == "i686-linux" then fetchzip {
+  } else if stdenv.hostPlatform.system == "i686-linux" then fetchzip {
     url = "https://gforge.inria.fr/frs/download.php/file/37267/icesl${version}-i386.zip";
     sha256 = "0sl54fsb2gz6dy0bwdscpdq1ab6ph5b7zald3bwzgkqsvna7p1jr";
   } else throw "Unsupported architecture";
diff --git a/pkgs/applications/misc/kdbplus/default.nix b/pkgs/applications/misc/kdbplus/default.nix
index ba048761367c..b518481e29ad 100644
--- a/pkgs/applications/misc/kdbplus/default.nix
+++ b/pkgs/applications/misc/kdbplus/default.nix
@@ -1,6 +1,6 @@
 { stdenv, requireFile, unzip, rlwrap, bash }:
 
-assert (stdenv.system == "i686-linux");
+assert (stdenv.hostPlatform.system == "i686-linux");
 
 let
   libPath = stdenv.lib.makeLibraryPath
diff --git a/pkgs/applications/misc/kiwix/default.nix b/pkgs/applications/misc/kiwix/default.nix
index c37d26f3dbcc..8d095b78cdbf 100644
--- a/pkgs/applications/misc/kiwix/default.nix
+++ b/pkgs/applications/misc/kiwix/default.nix
@@ -25,7 +25,7 @@ let
     sha256 = "1h9vcbvf8wgds6i2z20y7krpys0mqsqhv1ijyfljanp6vyll9fvi";
   };
 
-  xulrunner = if stdenv.system == "x86_64-linux"
+  xulrunner = if stdenv.hostPlatform.system == "x86_64-linux"
               then { tar = xulrunner64_tar; sdk = xulrunnersdk64_tar; }
               else { tar = xulrunner32_tar; sdk = xulrunnersdk32_tar; };
 
diff --git a/pkgs/applications/misc/notify-osd-customizable/default.nix b/pkgs/applications/misc/notify-osd-customizable/default.nix
new file mode 100644
index 000000000000..828c39d5ed87
--- /dev/null
+++ b/pkgs/applications/misc/notify-osd-customizable/default.nix
@@ -0,0 +1,47 @@
+{ stdenv
+, dbus-glib
+, fetchurl
+, glib
+, gnome3
+, libnotify
+, libtool
+, libwnck3
+, makeWrapper
+, pkgconfig
+}:
+
+let baseURI = "https://launchpad.net/~leolik/+archive/leolik";
+in stdenv.mkDerivation rec {
+  name = "notify-osd-${version}";
+  version = "0.9.35+16.04.20160415";
+
+  src = fetchurl {
+    url = "${baseURI}/+files/notify-osd_${version}-0ubuntu1-leolik~ppa0.tar.gz";
+    sha256 = "026dr46jh3xc4103wnslzy7pxbxkkpflh52c59j8vzwaa7bvvzkv";
+    name = "notify-osd-customizable.tar.gz";
+  };
+
+  preConfigure = "./autogen.sh --libexecdir=$(out)/bin";
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    glib libwnck3 libnotify dbus-glib makeWrapper
+    gnome3.gsettings-desktop-schemas gnome3.gnome-common
+    libtool
+  ];
+
+  configureFlags = "--libexecdir=$(out)/bin";
+
+  preFixup = ''
+    wrapProgram "$out/bin/notify-osd" \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Daemon that displays passive pop-up notifications";
+    homepage = https://launchpad.net/notify-osd;
+    license = licenses.gpl3;
+    maintainers = [ maintainers.imalison ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/applications/misc/playonlinux/default.nix b/pkgs/applications/misc/playonlinux/default.nix
index 2ad6321d5191..8c9f13ce92c7 100644
--- a/pkgs/applications/misc/playonlinux/default.nix
+++ b/pkgs/applications/misc/playonlinux/default.nix
@@ -44,9 +44,9 @@ let
     ];
 
   ld32 =
-    if stdenv.system == "x86_64-linux" then "${stdenv.cc}/nix-support/dynamic-linker-m32"
-    else if stdenv.system == "i686-linux" then "${stdenv.cc}/nix-support/dynamic-linker"
-    else throw "Unsupported platform for PlayOnLinux: ${stdenv.system}";
+    if stdenv.hostPlatform.system == "x86_64-linux" then "${stdenv.cc}/nix-support/dynamic-linker-m32"
+    else if stdenv.hostPlatform.system == "i686-linux" then "${stdenv.cc}/nix-support/dynamic-linker"
+    else throw "Unsupported platform for PlayOnLinux: ${stdenv.hostPlatform.system}";
   ld64 = "${stdenv.cc}/nix-support/dynamic-linker";
   libs = pkgs: stdenv.lib.makeLibraryPath [ pkgs.xorg.libX11 ];
 
@@ -83,7 +83,7 @@ in stdenv.mkDerivation {
 
     bunzip2 $out/share/playonlinux/bin/check_dd_x86.bz2
     patchelf --set-interpreter $(cat ${ld32}) --set-rpath ${libs pkgsi686Linux} $out/share/playonlinux/bin/check_dd_x86
-    ${if stdenv.system == "x86_64-linux" then ''
+    ${if stdenv.hostPlatform.system == "x86_64-linux" then ''
       bunzip2 $out/share/playonlinux/bin/check_dd_amd64.bz2
       patchelf --set-interpreter $(cat ${ld64}) --set-rpath ${libs pkgs} $out/share/playonlinux/bin/check_dd_amd64
     '' else ''
diff --git a/pkgs/applications/misc/rescuetime/default.nix b/pkgs/applications/misc/rescuetime/default.nix
index 57cdfd08d5b0..d9cd85d5098a 100644
--- a/pkgs/applications/misc/rescuetime/default.nix
+++ b/pkgs/applications/misc/rescuetime/default.nix
@@ -2,7 +2,7 @@
 
 let
   src =
-    if stdenv.system == "i686-linux" then fetchurl {
+    if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
       name = "rescuetime-installer.deb";
       url = "https://www.rescuetime.com/installers/rescuetime_current_i386.deb";
       sha256 = "06q1jwqsrjvlj820dd4vl80jznwafsqshsg0p6si8qx4721blryz";
diff --git a/pkgs/applications/misc/sweethome3d/default.nix b/pkgs/applications/misc/sweethome3d/default.nix
index 68a192d78b84..3c56a6a046fb 100644
--- a/pkgs/applications/misc/sweethome3d/default.nix
+++ b/pkgs/applications/misc/sweethome3d/default.nix
@@ -55,7 +55,7 @@ let
 
       makeWrapper ${jre}/bin/java $out/bin/$exec \
         --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3.out}/share:${gsettings-desktop-schemas}/share:$out/share:$GSETTINGS_SCHEMAS_PATH" \
-        --add-flags "-jar $out/share/java/${module}-${version}.jar -cp $out/share/java/Furniture.jar:$out/share/java/Textures.jar:$out/share/java/Help.jar ${if stdenv.system == "x86_64-linux" then "-d64" else "-d32"}"
+        --add-flags "-jar $out/share/java/${module}-${version}.jar -cp $out/share/java/Furniture.jar:$out/share/java/Textures.jar:$out/share/java/Help.jar -d${toString stdenv.hostPlatform.parsed.cpu.bits}"
     '';
 
     dontStrip = true;
diff --git a/pkgs/applications/misc/sweethome3d/editors.nix b/pkgs/applications/misc/sweethome3d/editors.nix
index 14285a52e27c..eef5185aaeed 100644
--- a/pkgs/applications/misc/sweethome3d/editors.nix
+++ b/pkgs/applications/misc/sweethome3d/editors.nix
@@ -44,7 +44,7 @@ let
       cp "${editorItem}/share/applications/"* $out/share/applications
       makeWrapper ${jre}/bin/java $out/bin/$exec \
         --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3.out}/share:${gsettings-desktop-schemas}/share:$out/share:$GSETTINGS_SCHEMAS_PATH" \
-        --add-flags "-jar $out/share/java/${module}-${version}.jar ${if stdenv.system == "x86_64-linux" then "-d64" else "-d32"}"
+        --add-flags "-jar $out/share/java/${module}-${version}.jar -d${toString stdenv.hostPlatform.parsed.cpu.bits}"
     '';
 
     dontStrip = true;
diff --git a/pkgs/applications/misc/xmind/default.nix b/pkgs/applications/misc/xmind/default.nix
index a578c53f0e7c..a12f3dc304ba 100644
--- a/pkgs/applications/misc/xmind/default.nix
+++ b/pkgs/applications/misc/xmind/default.nix
@@ -4,13 +4,13 @@ stdenv.mkDerivation rec {
   name = "xmind-${version}";
   version = "7.5-update1";
 
-  src = if stdenv.system == "i686-linux" then fetchurl {
+  src = if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
     url = "http://dl2.xmind.net/xmind-downloads/${name}-linux_i386.deb";
     sha256 = "04kr6pw0kwy715bp9wcnqnw1k5wl65xa87lhljrskm291p402jy1";
-  } else if stdenv.system == "x86_64-linux" then fetchurl {
+  } else if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
     url = "http://dl2.xmind.net/xmind-downloads/${name}-linux_amd64.deb";
     sha256 = "1j2ynhk7p3m3vd6c4mjwpnlzqgfj5c4q3zydab3nfwncwx6gaqj9";
-  } else throw "platform ${stdenv.system} not supported!";
+  } else throw "platform ${stdenv.hostPlatform.system} not supported!";
 
   nativeBuildInputs = [ dpkg makeWrapper ];
 
diff --git a/pkgs/applications/networking/apache-directory-studio/default.nix b/pkgs/applications/networking/apache-directory-studio/default.nix
index d593947f3e62..05dee5b6154c 100644
--- a/pkgs/applications/networking/apache-directory-studio/default.nix
+++ b/pkgs/applications/networking/apache-directory-studio/default.nix
@@ -21,17 +21,17 @@ stdenv.mkDerivation rec {
   version = "2.0.0.v20170904-M13";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "mirror://apache/directory/studio/${version}/ApacheDirectoryStudio-${version}-linux.gtk.x86_64.tar.gz";
         sha256 = "1jfnm6m0ijk31r30hhrxxnizk742dm317iny041p29v897rma7aq";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "mirror://apache/directory/studio/${version}/ApacheDirectoryStudio-${version}-linux.gtk.x86.tar.gz";
         sha256 = "1bxmgram42qyhrqkgp5k8770f5mjjdd4c6xl4gj09smiycm1qa4n";
       }
-    else throw "Unsupported system: ${stdenv.system}";
+    else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   buildInputs = [ makeWrapper ];
 
diff --git a/pkgs/applications/networking/bittorrentsync/generic.nix b/pkgs/applications/networking/bittorrentsync/generic.nix
index dae540ba4260..1075aea8db3a 100644
--- a/pkgs/applications/networking/bittorrentsync/generic.nix
+++ b/pkgs/applications/networking/bittorrentsync/generic.nix
@@ -4,9 +4,9 @@ let
   arch = {
     "x86_64-linux" = "x64";
     "i686-linux" = "i386";
-  }.${stdenv.system} or throwSystem;
+  }.${stdenv.hostPlatform.system} or throwSystem;
   libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
 in
 
 stdenv.mkDerivation rec {
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
       "https://download-cdn.getsync.com/${version}/linux-${arch}/BitTorrent-Sync_${arch}.tar.gz"
       "http://syncapp.bittorrent.com/${version}/btsync_${arch}-${version}.tar.gz"
     ];
-    sha256 = sha256s.${stdenv.system} or throwSystem;
+    sha256 = sha256s.${stdenv.hostPlatform.system} or throwSystem;
   };
 
   dontStrip = true; # Don't strip, otherwise patching the rpaths breaks
diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix
index 1fbcb3d97143..7e92df163afc 100644
--- a/pkgs/applications/networking/browsers/firefox-bin/default.nix
+++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix
@@ -59,7 +59,7 @@ let
     "x86_64-linux" = "linux-x86_64";
   };
 
-  arch = mozillaPlatforms.${stdenv.system};
+  arch = mozillaPlatforms.${stdenv.hostPlatform.system};
 
   isPrefixOf = prefix: string:
     builtins.substring 0 (builtins.stringLength prefix) string == prefix;
diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix
index b64a6cf7ad98..8b06c35fe005 100644
--- a/pkgs/applications/networking/browsers/firefox/wrapper.nix
+++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix
@@ -36,10 +36,10 @@ let
       jre = cfg.jre or false;
       icedtea = cfg.icedtea or false;
       supportsJDK =
-        stdenv.system == "i686-linux" ||
-        stdenv.system == "x86_64-linux" ||
-        stdenv.system == "armv7l-linux" ||
-        stdenv.system == "aarch64-linux";
+        stdenv.hostPlatform.system == "i686-linux" ||
+        stdenv.hostPlatform.system == "x86_64-linux" ||
+        stdenv.hostPlatform.system == "armv7l-linux" ||
+        stdenv.hostPlatform.system == "aarch64-linux";
 
       plugins =
         assert !(jre && icedtea);
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
index 94d0e9e5badd..72e1a08f40b3 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer/default.nix
@@ -60,13 +60,13 @@
 
 let
   arch =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       "x86_64"
-    else if stdenv.system == "i686-linux"   then
+    else if stdenv.hostPlatform.system == "i686-linux"   then
       "i386"
     else throw "Flash Player is not supported on this platform";
   lib_suffix =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
       "64"
     else
       "";
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/google-talk-plugin/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/google-talk-plugin/default.nix
index a172e0e8d5d9..71b5161c1e39 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/google-talk-plugin/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/google-talk-plugin/default.nix
@@ -54,12 +54,12 @@ stdenv.mkDerivation rec {
   version = "5.41.3.0";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "${baseURL}/google-talkplugin_${version}-1_amd64.deb";
         sha1 = "0bbc3d6997ba22ce712d93e5bc336c894b54fc81";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "${baseURL}/google-talkplugin_${version}-1_i386.deb";
         sha1 = "6eae0544858f85c68b0cc46d7786e990bd94f139";
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/trezor/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/trezor/default.nix
index 3d4e0fc00225..5f7f601b3545 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/trezor/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/trezor/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
   };
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url    = https://mytrezor.com/data/plugin/1.0.5/browser-plugin-trezor_1.0.5_amd64.deb;
         sha256 = "0097h4v88yca4aayzprrh4pk03xvvj7ncz2mi83chm81gsr2v67z";
diff --git a/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix b/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix
index de6766709131..ffa5d4472527 100644
--- a/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix
+++ b/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix
@@ -51,6 +51,9 @@
 
 # Extra preferences
 , extraPrefs ? ""
+
+# For meta
+, tor-browser-bundle
 }:
 
 with stdenv.lib;
@@ -125,7 +128,7 @@ stdenv.mkDerivation rec {
   name = "tor-browser-bundle-bin-${version}";
   inherit version;
 
-  src = srcs."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}");
+  src = srcs."${stdenv.hostPlatform.system}" or (throw "unsupported system: ${stdenv.hostPlatform.system}");
 
   preferLocalBuild = true;
   allowSubstitutes = false;
@@ -397,7 +400,8 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    description = "Tor Browser Bundle";
+    description = "Tor Browser Bundle built by torproject.org";
+    longDescription = tor-browser-bundle.meta.longDescription;
     homepage = https://www.torproject.org/;
     platforms = attrNames srcs;
     maintainers = with maintainers; [ offline matejc doublec thoughtpolice joachifm ];
diff --git a/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix b/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix
index 50b992253cea..6ce22e164155 100644
--- a/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix
+++ b/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix
@@ -339,7 +339,29 @@ stdenv.mkDerivation rec {
 
   passthru.execdir = "/bin";
   meta = with stdenv.lib; {
-    description = "An unofficial version of the tor browser bundle, built from source";
+    description = "An unofficial version of the Tor Browser Bundle, built from source";
+    longDescription = ''
+      Tor Browser Bundle is a bundle of the Tor daemon, Tor Browser (heavily patched version of
+      Firefox), several essential extensions for Tor Browser, and some tools that glue those
+      together with a convenient UI.
+
+      `tor-browser-bundle-bin` package is the official version built by torproject.org patched with
+      `patchelf` to work under nix and with bundled scripts adapted to the read-only nature of
+      the `/nix/store`.
+
+      `tor-browser-bundle` package is the version built completely from source. It reuses the `tor`
+      package for the tor daemon, `firefoxPackages.tor-browser` package for the tor-browser, and
+      builds all the extensions from source.
+
+      Note that `tor-browser-bundle` package is not only built from source, but also bundles Tor
+      Browser differently from the official `tor-browser-bundle-bin` implementation. The official
+      Tor Browser is not a normal UNIX program and is heavily patched for its use in the Tor Browser
+      Bundle (which `tor-browser-bundle-bin` package then has to work around for the read-only
+      /nix/store). Meanwhile, `firefoxPackages.tor-browser` reverts all those patches, allowing
+      `firefoxPackages.tor-browser` to be used independently of the bundle, and then implements what
+      `tor-browser-bundle` needs for the bundling using a much simpler patch. See the
+      longDescription and expression of the `firefoxPackages.tor-browser` package for more info.
+    '';
     homepage = https://torproject.org/;
     license = licenses.free;
     platforms = [ "x86_64-linux" ];
diff --git a/pkgs/applications/networking/cluster/minikube/default.nix b/pkgs/applications/networking/cluster/minikube/default.nix
index b674f1f64580..37431b0fbc44 100644
--- a/pkgs/applications/networking/cluster/minikube/default.nix
+++ b/pkgs/applications/networking/cluster/minikube/default.nix
@@ -1,5 +1,5 @@
 { stdenv, buildGoPackage, fetchFromGitHub, go-bindata, libvirt, qemu
-, gpgme, makeWrapper, hostPlatform, vmnet, python
+, gpgme, makeWrapper, vmnet, python
 , docker-machine-kvm, docker-machine-kvm2
 , extraDrivers ? []
 }:
@@ -25,8 +25,8 @@ in buildGoPackage rec {
     sha256 = "0c36rzsdzxf9q6l4hl506bsd4qwmw033i0k1xhqszv9agg7qjlmm";
   };
 
-  buildInputs = [ go-bindata makeWrapper gpgme ] ++ stdenv.lib.optional hostPlatform.isDarwin vmnet;
-  subPackages = [ "cmd/minikube" ] ++ stdenv.lib.optional hostPlatform.isDarwin "cmd/drivers/hyperkit";
+  buildInputs = [ go-bindata makeWrapper gpgme ] ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin vmnet;
+  subPackages = [ "cmd/minikube" ] ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin "cmd/drivers/hyperkit";
 
   preBuild = ''
     pushd go/src/${goPackagePath} >/dev/null
@@ -56,7 +56,7 @@ in buildGoPackage rec {
 
   postFixup = ''
     wrapProgram $bin/bin/${pname} --prefix PATH : $bin/bin:${stdenv.lib.makeBinPath binPath}
-  '' + stdenv.lib.optionalString hostPlatform.isDarwin ''
+  '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
     mv $bin/bin/hyperkit $bin/bin/docker-machine-driver-hyperkit
   '';
 
diff --git a/pkgs/applications/networking/dropbox/default.nix b/pkgs/applications/networking/dropbox/default.nix
index 3450ad720486..047ad734bd40 100644
--- a/pkgs/applications/networking/dropbox/default.nix
+++ b/pkgs/applications/networking/dropbox/default.nix
@@ -2,7 +2,7 @@
 
 let platforms = [ "i686-linux" "x86_64-linux" ]; in
 
-assert lib.elem stdenv.system platforms;
+assert lib.elem stdenv.hostPlatform.system platforms;
 
 # Dropbox client to bootstrap installation.
 # The client is self-updating, so the actual version may be newer.
@@ -12,7 +12,7 @@ let
   arch = {
     "x86_64-linux" = "x86_64";
     "i686-linux"   = "x86";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
   installer = "https://clientupdates.dropboxstatic.com/dbx-releng/client/dropbox-lnx.${arch}-${version}.tar.gz";
 in
diff --git a/pkgs/applications/networking/ids/bro/default.nix b/pkgs/applications/networking/ids/bro/default.nix
index 5e79517a5512..f90457ba9379 100644
--- a/pkgs/applications/networking/ids/bro/default.nix
+++ b/pkgs/applications/networking/ids/bro/default.nix
@@ -2,11 +2,11 @@
 , geoip, gperftools, python, swig }:
 
 stdenv.mkDerivation rec {
-  name = "bro-2.5.4";
+  name = "bro-2.5.5";
 
   src = fetchurl {
     url = "https://www.bro.org/downloads/${name}.tar.gz";
-    sha256 = "07sz1i4ly30257677b8vfrbsvxhz2awijyzn5ihg4m567x1ymnl0";
+    sha256 = "1kvkiq8jjsqryry9jd4vw45pbfb46jly988mq62mv4sd1fqsxwhq";
   };
 
   nativeBuildInputs = [ cmake flex bison file ];
diff --git a/pkgs/applications/networking/instant-messengers/franz/default.nix b/pkgs/applications/networking/instant-messengers/franz/default.nix
index b253e41ae7d8..2f3870d78994 100644
--- a/pkgs/applications/networking/instant-messengers/franz/default.nix
+++ b/pkgs/applications/networking/instant-messengers/franz/default.nix
@@ -3,7 +3,7 @@
 , gnome2, dbus, nss, nspr, alsaLib, cups, expat, udev, libnotify, xdg_utils }:
 
 let
-  bits = if stdenv.system == "x86_64-linux" then "x64"
+  bits = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
          else "ia32";
 
   version = "4.0.4";
diff --git a/pkgs/applications/networking/instant-messengers/mattermost-desktop/default.nix b/pkgs/applications/networking/instant-messengers/mattermost-desktop/default.nix
index a9ce8a96f970..109893850de1 100644
--- a/pkgs/applications/networking/instant-messengers/mattermost-desktop/default.nix
+++ b/pkgs/applications/networking/instant-messengers/mattermost-desktop/default.nix
@@ -41,18 +41,18 @@ in
     version = "4.1.2";
 
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = "https://releases.mattermost.com/desktop/${version}/${name}-linux-x64.tar.gz";
           sha256 = "16dn6870bs1nfl2082ym9gwvmqb3i5sli48qprap80p7riph6k9s";
         }
-      else if stdenv.system == "i686-linux" then
+      else if stdenv.hostPlatform.system == "i686-linux" then
         fetchurl {
           url = "https://releases.mattermost.com/desktop/${version}/${name}-linux-ia32.tar.gz";
           sha256 = "145zb1l37fa2slfrrlprlwzcc5km3plxs374yhgix25mlg2afkqr";
         }
       else
-        throw "Mattermost-Desktop is not currently supported on ${stdenv.system}";
+        throw "Mattermost-Desktop is not currently supported on ${stdenv.hostPlatform.system}";
 
     phases = [ "unpackPhase" "installPhase" ];
     installPhase = ''
diff --git a/pkgs/applications/networking/instant-messengers/rambox/sencha/bare.nix b/pkgs/applications/networking/instant-messengers/rambox/sencha/bare.nix
index ca82f30e2d1f..af92462a2a49 100644
--- a/pkgs/applications/networking/instant-messengers/rambox/sencha/bare.nix
+++ b/pkgs/applications/networking/instant-messengers/rambox/sencha/bare.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   inherit version;
 
   name = "sencha-bare-${version}";
-  src = srcs.${stdenv.system};
+  src = srcs.${stdenv.hostPlatform.system};
 
   nativeBuildInputs = [ gzip which unzip ];
   buildInputs = [ jdk ];
diff --git a/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix b/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix
index d728c8d95cca..eaa9103a7b64 100644
--- a/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix
+++ b/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix
@@ -53,13 +53,13 @@ let
   ] + ":${stdenv.cc.cc.lib}/lib64";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://repo.skype.com/deb/pool/main/s/skypeforlinux/skypeforlinux_${version}_amd64.deb";
         sha256 = "1kydf71qbz35dx4674h3nxfx8a88k620217906i54ic4qq2mgy2x";
       }
     else
-      throw "Skype for linux is not supported on ${stdenv.system}";
+      throw "Skype for linux is not supported on ${stdenv.hostPlatform.system}";
 
 in stdenv.mkDerivation {
   name = "skypeforlinux-${version}";
diff --git a/pkgs/applications/networking/instant-messengers/slack/default.nix b/pkgs/applications/networking/instant-messengers/slack/default.nix
index bcf887808750..af2030a20b8a 100644
--- a/pkgs/applications/networking/instant-messengers/slack/default.nix
+++ b/pkgs/applications/networking/instant-messengers/slack/default.nix
@@ -44,13 +44,13 @@ let
   ] + ":${stdenv.cc.cc.lib}/lib64";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://downloads.slack-edge.com/linux_releases/slack-desktop-${version}-amd64.deb";
         sha256 = "095dpkwvvnwlxsglyg6wi9126wpalzi736b6g6j3bd6d93z9afah";
       }
     else
-      throw "Slack is not supported on ${stdenv.system}";
+      throw "Slack is not supported on ${stdenv.hostPlatform.system}";
 
 in stdenv.mkDerivation {
   name = "slack-${version}";
diff --git a/pkgs/applications/networking/instant-messengers/wire-desktop/default.nix b/pkgs/applications/networking/instant-messengers/wire-desktop/default.nix
index 0745836271ae..0985f139238e 100644
--- a/pkgs/applications/networking/instant-messengers/wire-desktop/default.nix
+++ b/pkgs/applications/networking/instant-messengers/wire-desktop/default.nix
@@ -44,12 +44,12 @@ let
   plat = {
     "i686-linux" = "i386";
     "x86_64-linux" = "amd64";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
   sha256 = {
     "i686-linux" = "071ddh2d8wmiybwafwyb97962zj358l0fq7g2r44231653sgybvq";
     "x86_64-linux" = "0qp9ms94smnm7k47b0n0jdzvnm1b7gj25hyinsfc6lghrb6jqw3r";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
 in
   stdenv.mkDerivation rec {
diff --git a/pkgs/applications/networking/instant-messengers/zoom-us/default.nix b/pkgs/applications/networking/instant-messengers/zoom-us/default.nix
index afc6f03edb4a..882215c50c5c 100644
--- a/pkgs/applications/networking/instant-messengers/zoom-us/default.nix
+++ b/pkgs/applications/networking/instant-messengers/zoom-us/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, system, makeWrapper, makeDesktopItem, autoPatchelfHook, env
+{ stdenv, fetchurl, makeWrapper, makeDesktopItem, autoPatchelfHook, env
 # Dynamic libraries
 , dbus, glib, libGL, libX11, libXfixes, libuuid, libxcb, qtbase, qtdeclarative
 , qtimageformats, qtlocation, qtquickcontrols, qtquickcontrols2, qtscript, qtsvg
@@ -31,7 +31,7 @@ let
 in stdenv.mkDerivation {
   name = "zoom-us-${version}";
 
-  src = srcs.${system};
+  src = srcs.${stdenv.hostPlatform.system};
 
   nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
 
diff --git a/pkgs/applications/networking/insync/default.nix b/pkgs/applications/networking/insync/default.nix
index e718dc6562fb..fee19de0e8d7 100644
--- a/pkgs/applications/networking/insync/default.nix
+++ b/pkgs/applications/networking/insync/default.nix
@@ -4,13 +4,13 @@ stdenv.mkDerivation rec {
   name = "insync-${version}";
   version = "1.4.5.37069";
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "http://s.insynchq.com/builds/insync-portable_${version}_amd64.tar.bz2";
         sha256 = "0mkqgpq4isngkj20c0ygmxf4cj975d446svhwvl3cqdrjkjm1ybd";
       }
     else
-      throw "${name} is not supported on ${stdenv.system}";
+      throw "${name} is not supported on ${stdenv.hostPlatform.system}";
 
   buildInputs = [ makeWrapper ];
 
diff --git a/pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix b/pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix
index 3376eebe5dc9..3d8673a87a1b 100644
--- a/pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix
+++ b/pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix
@@ -33,13 +33,13 @@ stdenv.mkDerivation rec {
   subVersion = "fec7941";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://edgehill.s3.amazonaws.com/${version}-${subVersion}/linux-deb/x64/NylasMail.deb";
         sha256 = "40060aa1dc3b5187b8ed4a07b9de3427e3c5a291df98c2c82395647fa2aa4ada";
       }
     else
-      throw "NylasMail is not supported on ${stdenv.system}";
+      throw "NylasMail is not supported on ${stdenv.hostPlatform.system}";
 
   propagatedBuildInputs = [
     alsaLib
diff --git a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix
index b9b553f94472..cf68a2686194 100644
--- a/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix
+++ b/pkgs/applications/networking/mailreaders/thunderbird-bin/default.nix
@@ -47,7 +47,7 @@
 with (import ./release_sources.nix);
 
 let
-  arch = if stdenv.system == "i686-linux"
+  arch = if stdenv.hostPlatform.system == "i686-linux"
     then "linux-i686"
     else "linux-x86_64";
 
diff --git a/pkgs/applications/networking/p2p/frostwire/default.nix b/pkgs/applications/networking/p2p/frostwire/default.nix
index 7b854fce6c55..40ff91e792b4 100644
--- a/pkgs/applications/networking/p2p/frostwire/default.nix
+++ b/pkgs/applications/networking/p2p/frostwire/default.nix
@@ -75,7 +75,7 @@ in stdenv.mkDerivation {
     cp ${ { x86_64-darwin = "desktop/lib/native/*.dylib";
             x86_64-linux  = "desktop/lib/native/lib{jlibtorrent,SystemUtilities}.so";
             i686-linux    = "desktop/lib/native/lib{jlibtorrent,SystemUtilities}X86.so";
-          }.${stdenv.system} or (throw "unsupported system ${stdenv.system}")
+          }.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")
         } $out/lib
 
     cp -dpR ${desktopItem}/share $out
diff --git a/pkgs/applications/networking/p2p/soulseekqt/default.nix b/pkgs/applications/networking/p2p/soulseekqt/default.nix
index 44e434aa8ee9..12ed680482f6 100644
--- a/pkgs/applications/networking/p2p/soulseekqt/default.nix
+++ b/pkgs/applications/networking/p2p/soulseekqt/default.nix
@@ -37,7 +37,7 @@ in stdenv.mkDerivation rec {
 
   name = "soulseekqt-${version}";
   inherit version;
-  src = srcs."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}");
+  src = srcs."${stdenv.hostPlatform.system}" or (throw "unsupported system: ${stdenv.hostPlatform.system}");
 
   dontBuild = true;
 
diff --git a/pkgs/applications/networking/p2p/zeronet/default.nix b/pkgs/applications/networking/p2p/zeronet/default.nix
index 8a8d1b33ca73..33acd103d8b4 100644
--- a/pkgs/applications/networking/p2p/zeronet/default.nix
+++ b/pkgs/applications/networking/p2p/zeronet/default.nix
@@ -3,6 +3,7 @@
 python2Packages.buildPythonApplication rec {
   pname = "zeronet";
   version = "0.6.2";
+  format = "other";
 
   src = fetchFromGitHub {
     owner = "HelloZeroNet";
@@ -12,9 +13,6 @@ python2Packages.buildPythonApplication rec {
   };
 
   propagatedBuildInputs = with python2Packages; [ msgpack gevent ];
-
-  format = "other";
-
   buildPhase = "${python2Packages.python.interpreter} -O -m compileall .";
 
   installPhase = ''
@@ -22,14 +20,10 @@ python2Packages.buildPythonApplication rec {
     cp -r plugins src tools *.py $out/share/
   '';
 
-  # Wrap the main executable and set the log and data dir to something out of
-  # the store
   postFixup = ''
     makeWrapper "$out/share/zeronet.py" "$out/bin/zeronet" \
-        --set PYTHONPATH "$PYTHONPATH" \
-        --set PATH ${python2Packages.python}/bin \
-        --add-flags "--log_dir \$HOME/.local/share/zeronet/logs" \
-        --add-flags "--data_dir \$HOME/.local/share/zeronet"
+      --set PYTHONPATH "$PYTHONPATH" \
+      --set PATH ${python2Packages.python}/bin
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/applications/networking/remote/anydesk/default.nix b/pkgs/applications/networking/remote/anydesk/default.nix
index 0f107936be6f..cb3814b55f19 100644
--- a/pkgs/applications/networking/remote/anydesk/default.nix
+++ b/pkgs/applications/networking/remote/anydesk/default.nix
@@ -6,12 +6,12 @@ let
   sha256 = {
     "x86_64-linux" = "0g19sac4j3m1nf400vn6qcww7prqg2p4k4zsj74i109kk1396aa2";
     "i686-linux"   = "1dd4ai2pclav9g872xil3x67bxy32gvz9pb3w76383pcsdh5zh45";
-  }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
+  }."${stdenv.hostPlatform.system}" or (throw "system ${stdenv.hostPlatform.system} not supported");
 
   arch = {
     "x86_64-linux" = "amd64";
     "i686-linux"   = "i686";
-  }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
+  }."${stdenv.hostPlatform.system}" or (throw "system ${stdenv.hostPlatform.system} not supported");
 
   description = "Desktop sharing application, providing remote support and online meetings";
 
diff --git a/pkgs/applications/networking/remote/putty/default.nix b/pkgs/applications/networking/remote/putty/default.nix
index e07bf7958f3f..13613774b7c2 100644
--- a/pkgs/applications/networking/remote/putty/default.nix
+++ b/pkgs/applications/networking/remote/putty/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, autoconf, automake, pkgconfig, libtool
+{ stdenv, lib, fetchurl, autoconf, automake, pkgconfig, libtool
 , gtk2, halibut, ncurses, perl
-, hostPlatform, lib }:
+}:
 
 stdenv.mkDerivation rec {
   version = "0.70";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
     sha256 = "1gmhwwj1y7b5hgkrkxpf4jddjpk9l5832zq5ibhsiicndsfs92mv";
   };
 
-  preConfigure = lib.optionalString hostPlatform.isUnix ''
+  preConfigure = lib.optionalString stdenv.hostPlatform.isUnix ''
     perl mkfiles.pl
     ( cd doc ; make );
     sed -e '/AM_PATH_GTK(/d' \
@@ -22,22 +22,23 @@ stdenv.mkDerivation rec {
         -e '/AC_OUTPUT/iAM_PROG_AR' -i configure.ac
     ./mkauto.sh
     cd unix
-  '' + lib.optionalString hostPlatform.isWindows ''
+  '' + lib.optionalString stdenv.hostPlatform.isWindows ''
     cd windows
   '';
 
   TOOLPATH = stdenv.cc.targetPrefix;
-  makefile = if hostPlatform.isWindows then "Makefile.mgw" else null;
+  makefile = if stdenv.hostPlatform.isWindows then "Makefile.mgw" else null;
 
-  installPhase = if hostPlatform.isWindows then ''
+  installPhase = if stdenv.hostPlatform.isWindows then ''
     for exe in *.exe; do
        install -D $exe $out/bin/$exe
     done
   '' else null;
 
   nativeBuildInputs = [ autoconf automake halibut libtool perl pkgconfig ];
-  buildInputs = []
-              ++ lib.optionals hostPlatform.isUnix [ gtk2 ncurses ];
+  buildInputs = lib.optionals stdenv.hostPlatform.isUnix [
+    gtk2 ncurses
+  ];
   enableParallelBuilding = true;
 
   meta = with lib; {
diff --git a/pkgs/applications/networking/resilio-sync/default.nix b/pkgs/applications/networking/resilio-sync/default.nix
index 0db18e77bfa6..b59219d99366 100644
--- a/pkgs/applications/networking/resilio-sync/default.nix
+++ b/pkgs/applications/networking/resilio-sync/default.nix
@@ -4,7 +4,7 @@ let
   arch = {
     "x86_64-linux" = "x64";
     "i686-linux" = "i386";
-  }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
+  }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
   libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
 
 in stdenv.mkDerivation rec {
@@ -16,7 +16,7 @@ in stdenv.mkDerivation rec {
     sha256 = {
       "x86_64-linux" = "0041axi9carspkfaxvyirfvsa29zz55al01x90nh93nzxvpvywsz";
       "i686-linux"   = "1ar36lp4f6a1z9i82g3gpak4q4ny09faqxdd59q1pvfzq25ypdhs";
-    }.${stdenv.system};
+    }.${stdenv.hostPlatform.system};
   };
 
   dontStrip = true; # Don't strip, otherwise patching the rpaths breaks
diff --git a/pkgs/applications/networking/spideroak/default.nix b/pkgs/applications/networking/spideroak/default.nix
index c1f3d62af737..c07ad715afd2 100644
--- a/pkgs/applications/networking/spideroak/default.nix
+++ b/pkgs/applications/networking/spideroak/default.nix
@@ -4,17 +4,17 @@
 }:
 
 let
-  arch = if stdenv.system == "x86_64-linux" then "x64"
-    else if stdenv.system == "i686-linux" then "x86"
-    else throw "Spideroak client for: ${stdenv.system} not supported!";
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "x86"
+    else throw "Spideroak client for: ${stdenv.hostPlatform.system} not supported!";
 
-  interpreter = if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2"
-    else if stdenv.system == "i686-linux" then "ld-linux.so.2"
-    else throw "Spideroak client for: ${stdenv.system} not supported!";
+  interpreter = if stdenv.hostPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2"
+    else if stdenv.hostPlatform.system == "i686-linux" then "ld-linux.so.2"
+    else throw "Spideroak client for: ${stdenv.hostPlatform.system} not supported!";
 
-  sha256 = if stdenv.system == "x86_64-linux" then "a88e5a8fe4a565ac500668bd53cf5784752d7c9253304ddce39ee7b01d078533"
-    else if stdenv.system == "i686-linux" then "668f3b83a974a3877d16c8743c233a427ea0a44ab84b7f9aec19a2995db66c16"
-    else throw "Spideroak client for: ${stdenv.system} not supported!";
+  sha256 = if stdenv.hostPlatform.system == "x86_64-linux" then "a88e5a8fe4a565ac500668bd53cf5784752d7c9253304ddce39ee7b01d078533"
+    else if stdenv.hostPlatform.system == "i686-linux" then "668f3b83a974a3877d16c8743c233a427ea0a44ab84b7f9aec19a2995db66c16"
+    else throw "Spideroak client for: ${stdenv.hostPlatform.system} not supported!";
 
   ldpath = stdenv.lib.makeLibraryPath [
     fontconfig freetype glib libICE libSM
diff --git a/pkgs/applications/networking/super-productivity/default.nix b/pkgs/applications/networking/super-productivity/default.nix
index 59872afaad93..9bb4254c64a2 100644
--- a/pkgs/applications/networking/super-productivity/default.nix
+++ b/pkgs/applications/networking/super-productivity/default.nix
@@ -44,13 +44,13 @@ let
   ] + ":${stdenv.cc.cc.lib}/lib64";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://github.com/johannesjo/super-productivity/releases/download/v${version}/superProductivity_${version}_amd64.deb";
         sha256 = "0jfi0lfijnhij9jvkhxgyvq8m1jzaym8n1c7707fv3hjh1h0vxn1";
       }
     else
-      throw "super-productivity is not supported on ${stdenv.system}";
+      throw "super-productivity is not supported on ${stdenv.hostPlatform.system}";
 
 in stdenv.mkDerivation {
   name = "super-productivity-${version}";
diff --git a/pkgs/applications/office/jameica/default.nix b/pkgs/applications/office/jameica/default.nix
index fdc6c58213a1..8d17ef2acaa4 100644
--- a/pkgs/applications/office/jameica/default.nix
+++ b/pkgs/applications/office/jameica/default.nix
@@ -6,10 +6,10 @@ let
   version = "${_version}-${_build}";
   name = "jameica-${version}";
 
-  swtSystem = if stdenv.system == "i686-linux" then "linux"
-  else if stdenv.system == "x86_64-linux" then "linux64"
-  else if stdenv.system == "x86_64-darwin" then "macos64"
-  else throw "Unsupported system: ${stdenv.system}";
+  swtSystem = if stdenv.hostPlatform.system == "i686-linux" then "linux"
+  else if stdenv.hostPlatform.system == "x86_64-linux" then "linux64"
+  else if stdenv.hostPlatform.system == "x86_64-darwin" then "macos64"
+  else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   desktopItem = makeDesktopItem {
     name = "jameica";
diff --git a/pkgs/applications/office/mendeley/default.nix b/pkgs/applications/office/mendeley/default.nix
index 693fa63661b5..5b6271db83bd 100644
--- a/pkgs/applications/office/mendeley/default.nix
+++ b/pkgs/applications/office/mendeley/default.nix
@@ -37,7 +37,7 @@
 let
   arch32 = "i686-linux";
 
-  arch = if stdenv.system == arch32
+  arch = if stdenv.hostPlatform.system == arch32
     then "i386"
     else "amd64";
 
@@ -46,7 +46,7 @@ let
   version = "${shortVersion}_${arch}";
 
   url = "http://desktop-download.mendeley.com/download/apt/pool/main/m/mendeleydesktop/mendeleydesktop_${version}.deb";
-  sha256 = if stdenv.system == arch32
+  sha256 = if stdenv.hostPlatform.system == arch32
     then "0fcyl5i8xdgb5j0x1643qc0j74d8p11jczvqmgqkqh0wgid1y1ad"
     else "1dzwa2cnn9xakrhhq159fhh71gw5wlbf017rrikdlia694m8akq6";
 
diff --git a/pkgs/applications/office/moneyplex/default.nix b/pkgs/applications/office/moneyplex/default.nix
index 47d2ecc81ea3..9f4ed80e6d80 100644
--- a/pkgs/applications/office/moneyplex/default.nix
+++ b/pkgs/applications/office/moneyplex/default.nix
@@ -21,8 +21,8 @@ stdenv.mkDerivation rec {
   name = "moneyplex-${version}";
   version = "16.0.22424";
 
-  src = fetchurl (if stdenv.system == "i686-linux" then src_i686
-                  else if stdenv.system == "x86_64-linux" then src_x86_64
+  src = fetchurl (if stdenv.hostPlatform.system == "i686-linux" then src_i686
+                  else if stdenv.hostPlatform.system == "x86_64-linux" then src_x86_64
                   else throw "moneyplex requires i686-linux or x86_64-linux");
 
 
diff --git a/pkgs/applications/office/wpsoffice/default.nix b/pkgs/applications/office/wpsoffice/default.nix
index 46faf9ba651e..4c83d67f7cda 100644
--- a/pkgs/applications/office/wpsoffice/default.nix
+++ b/pkgs/applications/office/wpsoffice/default.nix
@@ -3,7 +3,7 @@
 , zlib, libpng12, libICE, libXrender, cups }:
 
 let
-  bits = if stdenv.system == "x86_64-linux" then "x86_64"
+  bits = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64"
          else "x86";
 
   version = "10.1.0.5672";
diff --git a/pkgs/applications/science/electronics/eagle/eagle7.nix b/pkgs/applications/science/electronics/eagle/eagle7.nix
index 9b8827187b26..d5720440f7cc 100644
--- a/pkgs/applications/science/electronics/eagle/eagle7.nix
+++ b/pkgs/applications/science/electronics/eagle/eagle7.nix
@@ -17,18 +17,18 @@ stdenv.mkDerivation rec {
   version = "7.7.0";
 
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "ftp://ftp.cadsoft.de/eagle/program/7.7/eagle-lin32-${version}.run";
         sha256 = "16fa66p77xigc7zvzfm7737mllrcs6nrgk2p7wvkjw3p9lvbz7z1";
       }
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "ftp://ftp.cadsoft.de/eagle/program/7.7/eagle-lin64-${version}.run";
         sha256 = "18dcn6wqph1sqh0ah98qzfi05wip8a8ifbkaq79iskbrsi8iqnrg";
       }
     else
-      throw "Unsupported system: ${stdenv.system}";
+      throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   desktopItem = makeDesktopItem {
     name = "eagle";
diff --git a/pkgs/applications/science/logic/isabelle/default.nix b/pkgs/applications/science/logic/isabelle/default.nix
index ae04c11d9590..ffe508569553 100644
--- a/pkgs/applications/science/logic/isabelle/default.nix
+++ b/pkgs/applications/science/logic/isabelle/default.nix
@@ -48,7 +48,7 @@ stdenv.mkDerivation {
       rm -rf $comp/x86*
     done
     '' + (if ! stdenv.isLinux then "" else ''
-    arch=${if stdenv.system == "x86_64-linux" then "x86_64-linux" else "x86-linux"}
+    arch=${if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux" else "x86-linux"}
     for f in contrib/*/$arch/{bash_process,epclextract,eprover,nunchaku,SPASS}; do
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f"
     done
diff --git a/pkgs/applications/science/logic/saw-tools/default.nix b/pkgs/applications/science/logic/saw-tools/default.nix
index 65d2b4d91c30..32ebdad51d94 100644
--- a/pkgs/applications/science/logic/saw-tools/default.nix
+++ b/pkgs/applications/science/logic/saw-tools/default.nix
@@ -12,7 +12,7 @@ let
   url = "https://github.com/GaloisInc/saw-script/releases/download";
 
   saw-bin =
-    if stdenv.system == "i686-linux"
+    if stdenv.hostPlatform.system == "i686-linux"
     then fetchurl {
       url    = url + "/v0.1.1-dev/saw-0.1.1-dev-2015-07-31-CentOS6-32.tar.gz";
       sha256 = "126iag5nnvndi78c921z7vjrjfwcspn1hlxwwhzmqm4rvbhhr9v9";
diff --git a/pkgs/applications/science/math/mathematica/10.nix b/pkgs/applications/science/math/mathematica/10.nix
index 4884ee1f93ab..c6802c3719e9 100644
--- a/pkgs/applications/science/math/mathematica/10.nix
+++ b/pkgs/applications/science/math/mathematica/10.nix
@@ -18,7 +18,7 @@
 
 let
   platform =
-    if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
       "Linux"
     else
       throw "Mathematica requires i686-linux or x86_64 linux";
@@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
   ]);
 
   ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
       (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
diff --git a/pkgs/applications/science/math/mathematica/9.nix b/pkgs/applications/science/math/mathematica/9.nix
index d60feb54695d..1023e7ca3d5c 100644
--- a/pkgs/applications/science/math/mathematica/9.nix
+++ b/pkgs/applications/science/math/mathematica/9.nix
@@ -16,7 +16,7 @@
 
 let
   platform =
-    if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
       "Linux"
     else
       throw "Mathematica requires i686-linux or x86_64 linux";
@@ -60,7 +60,7 @@ stdenv.mkDerivation rec {
   ]);
 
   ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
       (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
diff --git a/pkgs/applications/science/math/mathematica/default.nix b/pkgs/applications/science/math/mathematica/default.nix
index fa4ff8b00687..165a56605579 100644
--- a/pkgs/applications/science/math/mathematica/default.nix
+++ b/pkgs/applications/science/math/mathematica/default.nix
@@ -69,7 +69,7 @@ stdenv.mkDerivation rec {
   ]);
 
   ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
       (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
diff --git a/pkgs/applications/science/math/scilab-bin/default.nix b/pkgs/applications/science/math/scilab-bin/default.nix
index dacd3e730736..54b262fe5058 100644
--- a/pkgs/applications/science/math/scilab-bin/default.nix
+++ b/pkgs/applications/science/math/scilab-bin/default.nix
@@ -10,9 +10,9 @@ let
   badArch = throw "${name} requires i686-linux or x86_64-linux";
 
   architecture =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       "i686"
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       "x86_64"
     else
       badArch;
@@ -23,9 +23,9 @@ stdenv.mkDerivation rec {
   src = fetchurl {
     url = "https://www.scilab.org/download/${ver}/scilab-${ver}.bin.linux-${architecture}.tar.gz";
     sha256 =
-      if stdenv.system == "i686-linux" then
+      if stdenv.hostPlatform.system == "i686-linux" then
         "0fgjc2ak3b2qi6yin3fy50qwk2bcj0zbz1h4lyyic9n1n1qcliib"
-      else if stdenv.system == "x86_64-linux" then
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
         "1scswlznc14vyzg0gqa1q9gcpwx05kz1sbn563463mzkdp7nd35d"
       else
         badArch;
diff --git a/pkgs/applications/search/catfish/default.nix b/pkgs/applications/search/catfish/default.nix
index adf0f51fc4cc..c36baae0621b 100644
--- a/pkgs/applications/search/catfish/default.nix
+++ b/pkgs/applications/search/catfish/default.nix
@@ -5,13 +5,13 @@
 
 pythonPackages.buildPythonApplication rec {
   majorver = "1.4";
-  minorver = "4";
+  minorver = "6";
   version = "${majorver}.${minorver}";
   pname = "catfish";
 
   src = fetchurl {
-    url = "https://launchpad.net/catfish-search/${majorver}/${version}/+download/${pname}-${version}.tar.gz";
-    sha256 = "1mw7py6si6y88jblmzm04hf049bpww7h87k2wypq07zm1dw55m52";
+    url = "https://archive.xfce.org/src/apps/${pname}/${majorver}/${pname}-${version}.tar.bz2";
+    sha256 = "1gxdk5gx0gjq95jhdbpiq39cxpzd4vmw00a78f0wg2i6qlafxjp1";
   };
 
   nativeBuildInputs = [
@@ -52,7 +52,7 @@ pythonPackages.buildPythonApplication rec {
   doCheck = false;
 
   meta = with stdenv.lib; {
-    homepage = https://launchpad.net/catfish-search;
+    homepage = https://docs.xfce.org/apps/catfish/start;
     description = "A handy file search tool";
     longDescription = ''
       Catfish is a handy file searching tool. The interface is
diff --git a/pkgs/applications/search/recoll/default.nix b/pkgs/applications/search/recoll/default.nix
index 01a4f4023023..e56284ac5c53 100644
--- a/pkgs/applications/search/recoll/default.nix
+++ b/pkgs/applications/search/recoll/default.nix
@@ -5,7 +5,7 @@
 , ghostscript, gawk, gnugrep, gnused, gnutar, gzip, libiconv, zlib
 , withGui ? true }:
 
-assert stdenv.system != "powerpc-linux";
+assert stdenv.hostPlatform.system != "powerpc-linux";
 
 stdenv.mkDerivation rec {
   ver = "1.23.7";
diff --git a/pkgs/applications/version-management/git-and-tools/git-cola/default.nix b/pkgs/applications/version-management/git-and-tools/git-cola/default.nix
index 63894cc3dcdb..4b15d03d2007 100644
--- a/pkgs/applications/version-management/git-and-tools/git-cola/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git-cola/default.nix
@@ -4,13 +4,13 @@ let
   inherit (pythonPackages) buildPythonApplication pyqt5 sip pyinotify;
 in buildPythonApplication rec {
   name = "git-cola-${version}";
-  version = "3.1";
+  version = "3.2";
 
   src = fetchFromGitHub {
     owner = "git-cola";
     repo = "git-cola";
     rev = "v${version}";
-    sha256 = "1xzm8694zndl2pb4nanzhldn7wrsc1gjd5ldjncidw1msp9fczq1";
+    sha256 = "1ivaqhvdbmlp0lmrwb2pv3kjqlcpqbxbinbvjjn3g81r4avjs7yy";
   };
 
   buildInputs = [ git gettext ];
diff --git a/pkgs/applications/video/lightworks/default.nix b/pkgs/applications/video/lightworks/default.nix
index 64a967001b57..4bfd9e790070 100644
--- a/pkgs/applications/video/lightworks/default.nix
+++ b/pkgs/applications/video/lightworks/default.nix
@@ -23,12 +23,12 @@ let
     name = "lightworks-${version}";
     
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = "http://downloads.lwks.com/v14/lwks-14.0.0-amd64.deb";
           sha256 = "66eb9f9678d979db76199f1c99a71df0ddc017bb47dfda976b508849ab305033";
         }
-      else throw "${name} is not supported on ${stdenv.system}";
+      else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
 
     buildInputs = [ dpkg makeWrapper ];
 
diff --git a/pkgs/applications/video/mplayer/default.nix b/pkgs/applications/video/mplayer/default.nix
index 02a0c2c0ec49..e017e7cc0015 100644
--- a/pkgs/applications/video/mplayer/default.nix
+++ b/pkgs/applications/video/mplayer/default.nix
@@ -60,13 +60,13 @@ let
     let
       dir = http://www.mplayerhq.hu/MPlayer/releases/codecs/;
     in
-    if stdenv.system == "i686-linux" then fetchurl {
+    if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
       url = "${dir}/essential-20071007.tar.bz2";
       sha256 = "18vls12n12rjw0mzw4pkp9vpcfmd1c21rzha19d7zil4hn7fs2ic";
-    } else if stdenv.system == "x86_64-linux" then fetchurl {
+    } else if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
       url = "${dir}/essential-amd64-20071007.tar.bz2";
       sha256 = "13xf5b92w1ra5hw00ck151lypbmnylrnznq9hhb0sj36z5wz290x";
-    } else if stdenv.system == "powerpc-linux" then fetchurl {
+    } else if stdenv.hostPlatform.system == "powerpc-linux" then fetchurl {
       url = "${dir}/essential-ppc-20071007.tar.bz2";
       sha256 = "18mlj8dp4wnz42xbhdk1jlz2ygra6fbln9wyrcyvynxh96g1871z";
     } else null;
diff --git a/pkgs/applications/video/omxplayer/default.nix b/pkgs/applications/video/omxplayer/default.nix
index 00a419d0a85d..7a130bbdb418 100644
--- a/pkgs/applications/video/omxplayer/default.nix
+++ b/pkgs/applications/video/omxplayer/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl
 , raspberrypifw, pcre, boost, freetype, zlib
-, hostPlatform
 }:
 
 let
@@ -14,7 +13,7 @@ let
     
     configurePlatforms = [];
     configureFlags = [
-      "--arch=${hostPlatform.parsed.cpu.name}"
+      "--arch=${stdenv.hostPlatform.parsed.cpu.name}"
     ] ++ stdenv.lib.optionals stdenv.hostPlatform.isAarch32 [
       # TODO be better with condition
       "--cpu=arm1176jzf-s"
@@ -46,8 +45,8 @@ let
       "--enable-hardcoded-tables"
       "--disable-runtime-cpudetect"
       "--disable-debug"
-      "--arch=${hostPlatform.parsed.cpu.name}"
-      "--target_os=${hostPlatform.parsed.kernel.name}"
+      "--arch=${stdenv.hostPlatform.parsed.cpu.name}"
+      "--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
     ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
       "--cross-prefix=${stdenv.cc.targetPrefix}"
       "--enable-cross-compile"
diff --git a/pkgs/applications/video/webtorrent_desktop/default.nix b/pkgs/applications/video/webtorrent_desktop/default.nix
index c99aed0c1afb..086190000ab4 100644
--- a/pkgs/applications/video/webtorrent_desktop/default.nix
+++ b/pkgs/applications/video/webtorrent_desktop/default.nix
@@ -42,13 +42,13 @@
     version = "0.20.0";
 
     src =
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = "https://github.com/webtorrent/webtorrent-desktop/releases/download/v0.20.0/webtorrent-desktop_${version}-1_amd64.deb";
           sha256 = "1kkrnbimiip5pn2nwpln35bbdda9gc3cgrjwphq4fqasbjf2781k";
         }
         else
-          throw "Webtorrent is not currently supported on ${stdenv.system}";
+          throw "Webtorrent is not currently supported on ${stdenv.hostPlatform.system}";
     phases = [ "unpackPhase" "installPhase" ];
     nativeBuildInputs = [ dpkg ];
     unpackPhase = "dpkg-deb -x $src .";
diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix
index f9058ef89b65..bbb2a099666b 100644
--- a/pkgs/applications/virtualization/qemu/default.nix
+++ b/pkgs/applications/virtualization/qemu/default.nix
@@ -22,7 +22,7 @@
 
 with stdenv.lib;
 let
-  audio = optionalString (hasSuffix "linux" stdenv.system) "alsa,"
+  audio = optionalString (hasSuffix "linux" stdenv.hostPlatform.system) "alsa,"
     + optionalString pulseSupport "pa,"
     + optionalString sdlSupport "sdl,";
 
diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
index dcc58b04c8e3..cb7bcad3592d 100644
--- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
@@ -44,23 +44,23 @@ stdenv.mkDerivation {
   '';
 
   buildCommand = with xorg; ''
-    ${if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then ''
+    ${if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then ''
         isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run
         chmod 755 ./VBoxLinuxAdditions.run
         ./VBoxLinuxAdditions.run --noexec --keep
       ''
-      else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
+      else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
     }
 
     # Unpack files
     cd install
-    ${if stdenv.system == "i686-linux" then ''
+    ${if stdenv.hostPlatform.system == "i686-linux" then ''
         tar xfvj VBoxGuestAdditions-x86.tar.bz2
       ''
-      else if stdenv.system == "x86_64-linux" then ''
+      else if stdenv.hostPlatform.system == "x86_64-linux" then ''
         tar xfvj VBoxGuestAdditions-amd64.tar.bz2
       ''
-      else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
+      else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
     }
 
     cd ../
@@ -81,13 +81,13 @@ stdenv.mkDerivation {
     # Change the interpreter for various binaries
     for i in sbin/VBoxService bin/{VBoxClient,VBoxControl} other/mount.vboxsf
     do
-        ${if stdenv.system == "i686-linux" then ''
+        ${if stdenv.hostPlatform.system == "i686-linux" then ''
           patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $i
         ''
-        else if stdenv.system == "x86_64-linux" then ''
+        else if stdenv.hostPlatform.system == "x86_64-linux" then ''
           patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 $i
         ''
-        else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
+        else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
         }
         patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc dbus libX11 libXt libXext libXmu libXfixes libXrandr libXcursor ]} $i
     done
diff --git a/pkgs/applications/virtualization/vpcs/default.nix b/pkgs/applications/virtualization/vpcs/default.nix
index 65435e19366b..3d6efcfc8443 100644
--- a/pkgs/applications/virtualization/vpcs/default.nix
+++ b/pkgs/applications/virtualization/vpcs/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glibc, buildPlatform }:
+{ stdenv, fetchurl, glibc }:
 
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   buildPhase = ''(
     cd src
-    ./mk.sh ${buildPlatform.platform.kernelArch}
+    ./mk.sh ${stdenv.buildPlatform.platform.kernelArch}
   )'';
 
   installPhase = ''
diff --git a/pkgs/applications/virtualization/xen/4.10.nix b/pkgs/applications/virtualization/xen/4.10.nix
index 5e21f7ee6081..f3055fc79c35 100644
--- a/pkgs/applications/virtualization/xen/4.10.nix
+++ b/pkgs/applications/virtualization/xen/4.10.nix
@@ -1,4 +1,5 @@
 { stdenv, callPackage, fetchurl, fetchpatch, fetchgit
+, ocaml-ng
 , withInternalQemu ? true
 , withInternalTraditionalQemu ? true
 , withInternalSeabios ? true
@@ -177,4 +178,4 @@ callPackage (import ./generic.nix (rec {
       else throw "this xen has no qemu builtin";
   };
 
-})) args
+})) ({ ocamlPackages = ocaml-ng.ocamlPackages_4_05; } // args)
diff --git a/pkgs/applications/virtualization/xen/4.8.nix b/pkgs/applications/virtualization/xen/4.8.nix
index f99cdb69d2a8..2a59cd1f0615 100644
--- a/pkgs/applications/virtualization/xen/4.8.nix
+++ b/pkgs/applications/virtualization/xen/4.8.nix
@@ -1,4 +1,5 @@
 { stdenv, callPackage, fetchurl, fetchpatch, fetchgit
+, ocaml-ng
 , withInternalQemu ? true
 , withInternalTraditionalQemu ? true
 , withInternalSeabios ? true
@@ -181,4 +182,4 @@ callPackage (import ./generic.nix (rec {
       else throw "this xen has no qemu builtin";
   };
 
-})) args
+})) ({ ocamlPackages = ocaml-ng.ocamlPackages_4_05; } // args)
diff --git a/pkgs/applications/window-managers/i3/default.nix b/pkgs/applications/window-managers/i3/default.nix
index 513fe06df8f6..5c95b9daf251 100644
--- a/pkgs/applications/window-managers/i3/default.nix
+++ b/pkgs/applications/window-managers/i3/default.nix
@@ -36,9 +36,9 @@ stdenv.mkDerivation rec {
   # they shouldn't, and then even once that's fixed have some
   # perl-related errors later on. For more, see
   # https://github.com/NixOS/nixpkgs/issues/7957
-  doCheck = false; # stdenv.system == "x86_64-linux";
+  doCheck = false; # stdenv.hostPlatform.system == "x86_64-linux";
 
-  checkPhase = stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
+  checkPhase = stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
   ''
     (cd testcases && xvfb-run ./complete-run.pl -p 1 --keep-xserver-output)
     ! grep -q '^not ok' testcases/latest/complete-run.log
diff --git a/pkgs/applications/window-managers/way-cooler/way-cooler.nix b/pkgs/applications/window-managers/way-cooler/way-cooler.nix
index 8a740b15500d..d7816be56256 100644
--- a/pkgs/applications/window-managers/way-cooler/way-cooler.nix
+++ b/pkgs/applications/window-managers/way-cooler/way-cooler.nix
@@ -1,6 +1,6 @@
 # Generated by carnix 0.6.5: carnix -o way-cooler.nix Cargo.lock
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.buildPlatform.parsed.kernel.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/applications/window-managers/way-cooler/wc-bg.nix b/pkgs/applications/window-managers/way-cooler/wc-bg.nix
index c63123db7ccb..4d527715c5f2 100644
--- a/pkgs/applications/window-managers/way-cooler/wc-bg.nix
+++ b/pkgs/applications/window-managers/way-cooler/wc-bg.nix
@@ -1,6 +1,6 @@
 # Generated by carnix 0.6.5: carnix -o wc-bg.nix Cargo.lock
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.buildPlatform.parsed.kernel.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/applications/window-managers/way-cooler/wc-grab.nix b/pkgs/applications/window-managers/way-cooler/wc-grab.nix
index 947a9653e56d..6f936eb2e432 100644
--- a/pkgs/applications/window-managers/way-cooler/wc-grab.nix
+++ b/pkgs/applications/window-managers/way-cooler/wc-grab.nix
@@ -1,6 +1,6 @@
 # Generated by carnix 0.6.5: carnix -o wc-grab.nix Cargo.lock
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.hostPlatform.parsed.kernel.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/applications/window-managers/way-cooler/wc-lock.nix b/pkgs/applications/window-managers/way-cooler/wc-lock.nix
index 008df5479ce1..1b9e3df3508e 100644
--- a/pkgs/applications/window-managers/way-cooler/wc-lock.nix
+++ b/pkgs/applications/window-managers/way-cooler/wc-lock.nix
@@ -1,6 +1,6 @@
 # Generated by carnix 0.6.5: carnix -o wc-lock.nix Cargo.lock
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.hostPlatform.parsed.kernel.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/build-support/build-fhs-userenv/env.nix b/pkgs/build-support/build-fhs-userenv/env.nix
index d951fb9ab06e..23568f51b23e 100644
--- a/pkgs/build-support/build-fhs-userenv/env.nix
+++ b/pkgs/build-support/build-fhs-userenv/env.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildEnv, writeText, pkgs, pkgsi686Linux, system }:
+{ stdenv, buildEnv, writeText, pkgs, pkgsi686Linux }:
 
 { name, profile ? ""
 , targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
@@ -22,7 +22,7 @@
 # /lib will link to /lib32
 
 let
-  is64Bit = system == "x86_64-linux";
+  is64Bit = stdenv.hostPlatform.parsed.cpu.bits == 64;
   isMultiBuild  = multiPkgs != null && is64Bit;
   isTargetBuild = !isMultiBuild;
 
diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix
index 262bee608edd..22761af158af 100644
--- a/pkgs/build-support/kernel/make-initrd.nix
+++ b/pkgs/build-support/kernel/make-initrd.nix
@@ -13,14 +13,13 @@
 # argument.
 
 { stdenv, perl, cpio, contents, compressor, prepend, ubootTools
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
   name = "initrd";
   builder = ./make-initrd.sh;
 
-  makeUInitrd = hostPlatform.platform.kernelTarget == "uImage";
+  makeUInitrd = stdenv.hostPlatform.platform.kernelTarget == "uImage";
 
   nativeBuildInputs = [ perl cpio ]
     ++ stdenv.lib.optional makeUInitrd ubootTools;
diff --git a/pkgs/build-support/release/nix-build.nix b/pkgs/build-support/release/nix-build.nix
index d42538c7e5d5..feda54de46fe 100644
--- a/pkgs/build-support/release/nix-build.nix
+++ b/pkgs/build-support/release/nix-build.nix
@@ -148,7 +148,7 @@ stdenv.mkDerivation (
     postPhases = postPhases ++ ["finalPhase"];
 
     meta = (if args ? meta then args.meta else {}) // {
-      description = if doCoverageAnalysis then "Coverage analysis" else "Nix package for ${stdenv.system}";
+      description = if doCoverageAnalysis then "Coverage analysis" else "Nix package for ${stdenv.hostPlatform.system}";
     };
 
   }
diff --git a/pkgs/build-support/rust/build-rust-crate.nix b/pkgs/build-support/rust/build-rust-crate.nix
index 6c7dd67c4002..6605aa27b21e 100644
--- a/pkgs/build-support/rust/build-rust-crate.nix
+++ b/pkgs/build-support/rust/build-rust-crate.nix
@@ -4,7 +4,7 @@
 # This can be useful for deploying packages with NixOps, and to share
 # binary dependencies between projects.
 
-{ lib, buildPlatform, stdenv, defaultCrateOverrides, fetchCrate, ncurses, rustc  }:
+{ lib, stdenv, defaultCrateOverrides, fetchCrate, ncurses, rustc  }:
 
 let makeDeps = dependencies:
       (lib.concatMapStringsSep " " (dep:
@@ -12,14 +12,14 @@ let makeDeps = dependencies:
         (if dep.crateType == "lib" then
            " --extern ${extern}=${dep.out}/lib/lib${extern}-${dep.metadata}.rlib"
          else
-           " --extern ${extern}=${dep.out}/lib/lib${extern}-${dep.metadata}${buildPlatform.extensions.sharedLibrary}")
+           " --extern ${extern}=${dep.out}/lib/lib${extern}-${dep.metadata}${stdenv.hostPlatform.extensions.sharedLibrary}")
       ) dependencies);
 
     # This doesn't appear to be officially documented anywhere yet.
     # See https://github.com/rust-lang-nursery/rust-forge/issues/101.
-    target_os = if buildPlatform.isDarwin
+    target_os = if stdenv.hostPlatform.isDarwin
       then "macos"
-      else buildPlatform.parsed.kernel.name;
+      else stdenv.hostPlatform.parsed.kernel.name;
 
     echo_build_heading = colors: ''
       echo_build_heading() {
@@ -106,20 +106,20 @@ let makeDeps = dependencies:
       export CARGO_PKG_VERSION=${crateVersion}
       export CARGO_PKG_AUTHORS="${authors}"
 
-      export CARGO_CFG_TARGET_ARCH=${buildPlatform.parsed.cpu.name}
+      export CARGO_CFG_TARGET_ARCH=${stdenv.hostPlatform.parsed.cpu.name}
       export CARGO_CFG_TARGET_OS=${target_os}
       export CARGO_CFG_TARGET_FAMILY="unix"
       export CARGO_CFG_UNIX=1
       export CARGO_CFG_TARGET_ENV="gnu"
-      export CARGO_CFG_TARGET_ENDIAN=${if buildPlatform.parsed.cpu.significantByte.name == "littleEndian" then "little" else "big"}
-      export CARGO_CFG_TARGET_POINTER_WIDTH=${toString buildPlatform.parsed.cpu.bits}
-      export CARGO_CFG_TARGET_VENDOR=${buildPlatform.parsed.vendor.name}
+      export CARGO_CFG_TARGET_ENDIAN=${if stdenv.hostPlatform.parsed.cpu.significantByte.name == "littleEndian" then "little" else "big"}
+      export CARGO_CFG_TARGET_POINTER_WIDTH=${toString stdenv.hostPlatform.parsed.cpu.bits}
+      export CARGO_CFG_TARGET_VENDOR=${stdenv.hostPlatform.parsed.vendor.name}
 
       export CARGO_MANIFEST_DIR="."
       export DEBUG="${toString (!release)}"
       export OPT_LEVEL="${toString optLevel}"
-      export TARGET="${buildPlatform.config}"
-      export HOST="${buildPlatform.config}"
+      export TARGET="${stdenv.hostPlatform.config}"
+      export HOST="${stdenv.hostPlatform.config}"
       export PROFILE=${if release then "release" else "debug"}
       export OUT_DIR=$(pwd)/target/build/${crateName}.out
       export CARGO_PKG_VERSION_MAJOR=${builtins.elemAt version 0}
@@ -218,8 +218,8 @@ let makeDeps = dependencies:
            $BUILD_OUT_DIR $EXTRA_BUILD $EXTRA_FEATURES --color ${colors}
 
          EXTRA_LIB=" --extern $CRATE_NAME=target/lib/lib$CRATE_NAME-${metadata}.rlib"
-         if [ -e target/deps/lib$CRATE_NAME-${metadata}${buildPlatform.extensions.sharedLibrary} ]; then
-            EXTRA_LIB="$EXTRA_LIB --extern $CRATE_NAME=target/lib/lib$CRATE_NAME-${metadata}${buildPlatform.extensions.sharedLibrary}"
+         if [ -e target/deps/lib$CRATE_NAME-${metadata}${stdenv.hostPlatform.extensions.sharedLibrary} ]; then
+            EXTRA_LIB="$EXTRA_LIB --extern $CRATE_NAME=target/lib/lib$CRATE_NAME-${metadata}${stdenv.hostPlatform.extensions.sharedLibrary}"
          fi
       }
 
diff --git a/pkgs/build-support/rust/cargo-vendor/cargo-vendor.nix b/pkgs/build-support/rust/cargo-vendor/cargo-vendor.nix
index 486f365f78ac..0779ac0537f6 100644
--- a/pkgs/build-support/rust/cargo-vendor/cargo-vendor.nix
+++ b/pkgs/build-support/rust/cargo-vendor/cargo-vendor.nix
@@ -1,7 +1,7 @@
 # Generated by carnix 0.5.2: carnix Cargo.lock -o cargo-vendor.nix
-{ lib, buildPlatform, buildRustCrate }:
-let kernel = buildPlatform.parsed.kernel.name;
-    abi = buildPlatform.parsed.abi.name;
+{ lib, stdenv, buildRustCrate }:
+let kernel = stdenv.hostPlatform.parsed.kernel.name;
+    abi = stdenv.hostPlatform.parsed.abi.name;
     hasFeature = feature:
       lib.lists.any
         (originName: feature.${originName})
diff --git a/pkgs/build-support/rust/carnix.nix b/pkgs/build-support/rust/carnix.nix
index 22d3fcd0c1fa..0b8b3d60b6c9 100644
--- a/pkgs/build-support/rust/carnix.nix
+++ b/pkgs/build-support/rust/carnix.nix
@@ -1,7 +1,7 @@
 # Generated by carnix 0.7.2: carnix nix
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
-    abi = buildPlatform.parsed.abi.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.hostPlatform.parsed.kernel.name;
+    abi = stdenv.hostPlatform.parsed.abi.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix
index 17803a28330f..e000308bed8f 100644
--- a/pkgs/build-support/vm/windows/controller/default.nix
+++ b/pkgs/build-support/vm/windows/controller/default.nix
@@ -157,7 +157,7 @@ let
     "-net vde,vlan=0,sock=$QEMU_VDE_SOCKET"
   ]);
 
-  maybeKvm64 = optional (stdenv.system == "x86_64-linux") "-cpu kvm64";
+  maybeKvm64 = optional (stdenv.hostPlatform.system == "x86_64-linux") "-cpu kvm64";
 
   cygwinQemuArgs = concatStringsSep " " (maybeKvm64 ++ [
     "-monitor unix:$MONITOR_SOCKET,server,nowait"
diff --git a/pkgs/build-support/vm/windows/cygwin-iso/default.nix b/pkgs/build-support/vm/windows/cygwin-iso/default.nix
index 2c46d5fae907..76cd41a75bc7 100644
--- a/pkgs/build-support/vm/windows/cygwin-iso/default.nix
+++ b/pkgs/build-support/vm/windows/cygwin-iso/default.nix
@@ -17,7 +17,7 @@ let
   };
 
   cygwinCross = (import ../../../../.. {
-    inherit (stdenv) system;
+    localSystem = stdenv.hostPlatform;
     crossSystem = {
       libc = "msvcrt";
       platform = {};
diff --git a/pkgs/development/arduino/arduino-core/default.nix b/pkgs/development/arduino/arduino-core/default.nix
index a427023df56e..269df6a07cd0 100644
--- a/pkgs/development/arduino/arduino-core/default.nix
+++ b/pkgs/development/arduino/arduino-core/default.nix
@@ -13,15 +13,19 @@ assert withTeensyduino -> withGui;
 # xdotool script; the cause of this hang is not yet known.
 # TODO: There is a fair chance that Teensyduino works with arm-linux, but it
 # has not yet been tested.
-if withTeensyduino && (stdenv.system != "x86_64-linux") then throw
+if withTeensyduino && (stdenv.hostPlatform.system != "x86_64-linux") then throw
   "Teensyduino is only supported on x86_64-linux at this time (patches welcome)."
 else
 let
-  externalDownloads = import ./downloads.nix {inherit fetchurl; inherit (lib) optionalAttrs; inherit (stdenv) system;};
+  externalDownloads = import ./downloads.nix {
+    inherit fetchurl;
+    inherit (lib) optionalAttrs;
+    inherit (stdenv.hostPlatform) system;
+  };
   # Some .so-files are later copied from .jar-s to $HOME, so patch them beforehand
   patchelfInJars =
-       lib.optional (stdenv.system == "x86_64-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino1.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so";}
-    ++ lib.optional (stdenv.system == "i686-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino1.jar"; file = "libs/linux/libjSSC-2.8_x86.so";}
+       lib.optional (stdenv.hostPlatform.system == "x86_64-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino1.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so";}
+    ++ lib.optional (stdenv.hostPlatform.system == "i686-linux") {jar = "share/arduino/lib/jssc-2.8.0-arduino1.jar"; file = "libs/linux/libjSSC-2.8_x86.so";}
   ;
   # abiVersion 6 is default, but we need 5 for `avrdude_bin` executable
   ncurses5 = ncurses.override { abiVersion = "5"; };
@@ -46,9 +50,9 @@ let
     zlib
   ];
   teensy_architecture =
-      lib.optionalString (stdenv.system == "x86_64-linux") "linux64"
-      + lib.optionalString (stdenv.system == "i686-linux") "linux32"
-      + lib.optionalString (stdenv.system == "arm-linux") "linuxarm";
+      lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "linux64"
+      + lib.optionalString (stdenv.hostPlatform.system == "i686-linux") "linux32"
+      + lib.optionalString (stdenv.hostPlatform.system == "arm-linux") "linuxarm";
 
   flavor = (if withTeensyduino then "teensyduino" else "arduino")
              + stdenv.lib.optionalString (!withGui) "-core";
diff --git a/pkgs/development/compilers/ccl/default.nix b/pkgs/development/compilers/ccl/default.nix
index 9570b0eead85..ae6af8dd4b4f 100644
--- a/pkgs/development/compilers/ccl/default.nix
+++ b/pkgs/development/compilers/ccl/default.nix
@@ -29,7 +29,7 @@ let
     };
     armv6l-linux = armv7l-linux;
   };
-  cfg = options."${stdenv.system}" or (throw "missing source url for platform ${stdenv.system}");
+  cfg = options."${stdenv.hostPlatform.system}" or (throw "missing source url for platform ${stdenv.hostPlatform.system}");
 in
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/compilers/clean/default.nix b/pkgs/development/compilers/clean/default.nix
index 16ac8b787219..cc6197922fd3 100644
--- a/pkgs/development/compilers/clean/default.nix
+++ b/pkgs/development/compilers/clean/default.nix
@@ -4,11 +4,11 @@ stdenv.mkDerivation rec {
   name = "clean-2.4";
 
   src =
-    if stdenv.system == "i686-linux" then (fetchurl {
+    if stdenv.hostPlatform.system == "i686-linux" then (fetchurl {
       url = "http://clean.cs.ru.nl/download/Clean24/linux/clean2.4_boot.tar.gz";
       sha256 = "1w8vvmkwzq8g51639r62apcy75sj69nm08082a34xvqm9ymfgkq5";
     })
-    else if stdenv.system == "x86_64-linux" then (fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
         url = "https://clean.cs.ru.nl/download/Clean24/linux/clean2.4_64_boot.tar.gz";
         sha256 = "08gsa1pjl5wyzh4ah8ccfx8a7mdcn6ycsn1lzkrr9adygv1gmm7r";
     })
diff --git a/pkgs/development/compilers/cmucl/binary.nix b/pkgs/development/compilers/cmucl/binary.nix
index 2833c5378c1d..9e3184c42eb2 100644
--- a/pkgs/development/compilers/cmucl/binary.nix
+++ b/pkgs/development/compilers/cmucl/binary.nix
@@ -1,7 +1,7 @@
 {stdenv, fetchurl}:
 
 let
-  inherit (stdenv) system;
+  inherit (stdenv.hostPlatform) system;
   version = "21b";
   downloadUrl = arch:
     "http://common-lisp.net/project/cmucl/downloads/release/" +
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
index ce487c3c0e25..aa1c85ebcb00 100644
--- a/pkgs/development/compilers/crystal/default.nix
+++ b/pkgs/development/compilers/crystal/default.nix
@@ -15,14 +15,14 @@ stdenv.mkDerivation rec {
     "x86_64-linux" = "linux-x86_64";
     "i686-linux" = "linux-i686";
     "x86_64-darwin" = "darwin-x86_64";
-  }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
+  }."${stdenv.hostPlatform.system}" or (throw "system ${stdenv.hostPlatform.system} not supported");
   in fetchurl {
     url = "https://github.com/crystal-lang/crystal/releases/download/0.26.0/${prebuiltName}-${arch}.tar.gz";
     sha256 = {
       "x86_64-linux" = "1xban102yiiwmlklxvn3xp3q546bp8hlxxpakayajkhhnpl6yv45";
       "i686-linux" = "1igspf1lrv7wpmz0pfrkbx8m1ykvnv4zhic53cav4nicppm2v0ic";
       "x86_64-darwin" = "0hzc65ccajr0yhmvi5vbdgbzbp1gbjy56da24ds3zwwkam1ddk0k";
-    }."${stdenv.system}";
+    }."${stdenv.hostPlatform.system}";
   };
 
   unpackPhase = ''
diff --git a/pkgs/development/compilers/fpc/binary.nix b/pkgs/development/compilers/fpc/binary.nix
index 0ecf4437c9a2..cf13ab6f5954 100644
--- a/pkgs/development/compilers/fpc/binary.nix
+++ b/pkgs/development/compilers/fpc/binary.nix
@@ -4,17 +4,17 @@ stdenv.mkDerivation {
   name = "fpc-2.6.0-binary";
 
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "mirror://sourceforge/project/freepascal/Linux/2.6.0/fpc-2.6.0.i386-linux.tar";
         sha256 = "08yklvrfxvk59bxsd4rh1i6s3cjn0q06dzjs94h9fbq3n1qd5zdf";
       }
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "mirror://sourceforge/project/freepascal/Linux/2.6.0/fpc-2.6.0.x86_64-linux.tar";
         sha256 = "0k9vi75k39y735fng4jc2vppdywp82j4qhzn7x4r6qjkad64d8lx";
       }
-    else throw "Not supported on ${stdenv.system}.";
+    else throw "Not supported on ${stdenv.hostPlatform.system}.";
 
   builder = ./binary-builder.sh;
 
diff --git a/pkgs/development/compilers/fpc/default.nix b/pkgs/development/compilers/fpc/default.nix
index 51544783d8c6..b516019ffc9a 100644
--- a/pkgs/development/compilers/fpc/default.nix
+++ b/pkgs/development/compilers/fpc/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ startFPC gawk ];
 
   preConfigure =
-    if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then ''
+    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then ''
       sed -e "s@'/lib/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas
       sed -e "s@'/lib64/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas
     '' else "";
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 3e9ddacac1b4..ed185b4be1a2 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langJava ? false
 , langGo ? false
 , profiledCompiler ? false
@@ -20,14 +20,14 @@
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -42,7 +42,7 @@ assert cloog != null -> isl != null;
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -54,6 +54,8 @@ let version = "4.8.5";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches = [ ]
       ++ optional enableParallelBuilding ../parallel-bconfig.patch
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 9b4444b905de..3f13562c1b8c 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, noSysDirs, fetchpatch
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langJava ? false
 , langGo ? false
 , profiledCompiler ? false
@@ -20,14 +20,14 @@
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -42,7 +42,7 @@ assert cloog != null -> isl != null;
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -54,6 +54,8 @@ let version = "4.9.4";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
       [ ../use-source-date-epoch.patch ]
       ++ optionals enableParallelBuilding [ ../parallel-bconfig.patch ./parallel-strsignal.patch ]
diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix
index 3fdec1ec3103..497ca40c3ae6 100644
--- a/pkgs/development/compilers/gcc/5/default.nix
+++ b/pkgs/development/compilers/gcc/5/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langJava ? false
 , langGo ? false
 , profiledCompiler ? false
@@ -20,15 +20,15 @@
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -40,7 +40,7 @@ assert langJava     -> zip != null && unzip != null
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -53,6 +53,8 @@ let version = "5.5.0";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
       [ ../use-source-date-epoch.patch ]
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 099e26375f41..3f5d3172d12f 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langJava ? false
 , langGo ? false
 , profiledCompiler ? false
@@ -20,15 +20,15 @@
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , x11Support ? langJava
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -40,7 +40,7 @@ assert langJava     -> zip != null && unzip != null
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -52,6 +52,8 @@ let version = "6.4.0";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
       [ ../use-source-date-epoch.patch ]
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 60e429cc4da1..30c1611f5fb3 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -13,15 +13,15 @@
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -29,7 +29,7 @@
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -41,6 +41,8 @@ let version = "7.3.0";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
       [ # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html
         ./riscv-pthread-reentrant.patch
diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix
index a05c1c718128..727cd9cbdbd7 100644
--- a/pkgs/development/compilers/gcc/8/default.nix
+++ b/pkgs/development/compilers/gcc/8/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -13,15 +13,15 @@
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -29,7 +29,7 @@
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -41,6 +41,8 @@ let version = "8.2.0";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
          optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
       ++ optional noSysDirs ../no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix
index 275b380e90f7..dd6de818117f 100644
--- a/pkgs/development/compilers/gcc/snapshot/default.nix
+++ b/pkgs/development/compilers/gcc/snapshot/default.nix
@@ -1,7 +1,7 @@
 { stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
-, langObjC ? targetPlatform.isDarwin
-, langObjCpp ? targetPlatform.isDarwin
+, langObjC ? stdenv.targetPlatform.isDarwin
+, langObjCpp ? stdenv.targetPlatform.isDarwin
 , langGo ? false
 , profiledCompiler ? false
 , staticCompiler ? false
@@ -13,16 +13,16 @@
 , isl ? null # optional, for the Graphite optimization framework.
 , zlib ? null
 , enableMultilib ? false
-, enablePlugin ? hostPlatform == buildPlatform # Whether to support user-supplied plug-ins
+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
 , name ? "gcc"
 , libcCross ? null
 , crossStageStatic ? false
 , # Strip kills static libs of other archs (hence no cross)
-  stripped ? hostPlatform == buildPlatform && targetPlatform == hostPlatform
+  stripped ? stdenv.hostPlatform == stdenv.buildPlatform
+          && stdenv.targetPlatform == stdenv.hostPlatform
 , gnused ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , flex ? null
-, buildPlatform, hostPlatform, targetPlatform
 , buildPackages
 }:
 
@@ -30,7 +30,7 @@
 assert libelf != null -> zlib != null;
 
 # Make sure we get GNU sed.
-assert hostPlatform.isDarwin -> gnused != null;
+assert stdenv.hostPlatform.isDarwin -> gnused != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -42,6 +42,8 @@ let version = "7-20170409";
 
     enableParallelBuilding = true;
 
+    inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
     patches =
       [ ]
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
diff --git a/pkgs/development/compilers/ghc/7.10.3.nix b/pkgs/development/compilers/ghc/7.10.3.nix
index 0cf3a4cb12b4..9c87d815b4a9 100644
--- a/pkgs/development/compilers/ghc/7.10.3.nix
+++ b/pkgs/development/compilers/ghc/7.10.3.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, hscolour
@@ -8,7 +7,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -19,7 +18,7 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
@@ -27,10 +26,12 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 }:
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix
index ddd9c27589ac..935d09b57446 100644
--- a/pkgs/development/compilers/ghc/8.0.2.nix
+++ b/pkgs/development/compilers/ghc/8.0.2.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, hscolour
@@ -7,7 +6,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86
+, useLLVM ? !stdenv.targetPlatform.isx86
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -18,7 +17,7 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
@@ -26,12 +25,14 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 }:
 
 assert !enableIntegerSimple -> gmp != null;
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index 79c910e5fd21..cf448d8d849a 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, alex, happy, hscolour
@@ -8,7 +7,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86 || (targetPlatform.isMusl && hostPlatform != targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -19,7 +18,7 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
@@ -27,7 +26,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 , # Whether to backport https://phabricator.haskell.org/D4388 for
   # deterministic profiling symbol names, at the cost of a slightly
   # non-standard GHC API
@@ -37,6 +36,8 @@
 assert !enableIntegerSimple -> gmp != null;
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghc/8.4.3.nix b/pkgs/development/compilers/ghc/8.4.3.nix
index f30c8dd8622e..aa9fab184364 100644
--- a/pkgs/development/compilers/ghc/8.4.3.nix
+++ b/pkgs/development/compilers/ghc/8.4.3.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, alex, happy, hscolour
@@ -7,7 +6,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86 || (targetPlatform.isMusl && hostPlatform != targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -18,18 +17,18 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? !targetPlatform.isWindows && !targetPlatform.useiOSPrebuilt
+  enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
 
 , # Whetherto build terminfo.
-  enableTerminfo ? !targetPlatform.isWindows
+  enableTerminfo ? !stdenv.targetPlatform.isWindows
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 , # Whether to backport https://phabricator.haskell.org/D4388 for
   # deterministic profiling symbol names, at the cost of a slightly
   # non-standard GHC API
@@ -39,6 +38,8 @@
 assert !enableIntegerSimple -> gmp != null;
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghc/8.6.1.nix b/pkgs/development/compilers/ghc/8.6.1.nix
index fdb60ce3f2e8..7fcb52969151 100644
--- a/pkgs/development/compilers/ghc/8.6.1.nix
+++ b/pkgs/development/compilers/ghc/8.6.1.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, alex, happy, hscolour
@@ -7,7 +6,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86 || (targetPlatform.isMusl && hostPlatform != targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -18,23 +17,25 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? !targetPlatform.isWindows && !targetPlatform.useiOSPrebuilt
+  enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
 
 , # Whetherto build terminfo.
-  enableTerminfo ? !targetPlatform.isWindows
+  enableTerminfo ? !stdenv.targetPlatform.isWindows
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 }:
 
 assert !enableIntegerSimple -> gmp != null;
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index 2824ce669ee6..ee95bd0f6047 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -1,5 +1,4 @@
 { stdenv, targetPackages
-, buildPlatform, hostPlatform, targetPlatform
 
 # build-tools
 , bootPkgs, alex, happy, hscolour
@@ -7,7 +6,7 @@
 
 , libiconv ? null, ncurses
 
-, useLLVM ? !targetPlatform.isx86 || (targetPlatform.isMusl && hostPlatform != targetPlatform)
+, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
 , # LLVM is conceptually a run-time-only depedendency, but for
   # non-x86, we need LLVM to bootstrap later stages, so it becomes a
   # build-time dependency too.
@@ -18,22 +17,24 @@
   enableIntegerSimple ? !(gmp.meta.available or false), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
-  enableRelocatedStaticLibs ? targetPlatform != hostPlatform
+  enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt
+  enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useAndroidPrebuilt
 
 , # Whetherto build terminfo.
-  enableTerminfo ? !targetPlatform.isWindows
+  enableTerminfo ? !stdenv.targetPlatform.isWindows
 
 , version ? "8.5.20180118"
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
+  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross"
 }:
 
 let
+  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
diff --git a/pkgs/development/compilers/ghcjs-ng/default.nix b/pkgs/development/compilers/ghcjs-ng/default.nix
index ddabb7ca6bfc..5db2777c8bb0 100644
--- a/pkgs/development/compilers/ghcjs-ng/default.nix
+++ b/pkgs/development/compilers/ghcjs-ng/default.nix
@@ -59,7 +59,7 @@ let
   };
 
   bootGhcjs = haskellLib.justStaticExecutables passthru.bootPkgs.ghcjs;
-  libexec = "${bootGhcjs}/libexec/${builtins.replaceStrings ["darwin" "i686"] ["osx" "i386"] stdenv.system}-${passthru.bootPkgs.ghc.name}/${bootGhcjs.name}";
+  libexec = "${bootGhcjs}/libexec/${builtins.replaceStrings ["darwin" "i686"] ["osx" "i386"] stdenv.buildPlatform.system}-${passthru.bootPkgs.ghc.name}/${bootGhcjs.name}";
 
 in stdenv.mkDerivation {
     name = bootGhcjs.name;
diff --git a/pkgs/development/compilers/go/1.10.nix b/pkgs/development/compilers/go/1.10.nix
index 513d0307f6bf..fa4b4abafdee 100644
--- a/pkgs/development/compilers/go/1.10.nix
+++ b/pkgs/development/compilers/go/1.10.nix
@@ -134,12 +134,12 @@ stdenv.mkDerivation rec {
 
   GOOS = if stdenv.isDarwin then "darwin" else "linux";
   GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
+           else if stdenv.hostPlatform.system == "i686-linux" then "386"
+           else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
            else if stdenv.isAarch32 then "arm"
            else if stdenv.isAarch64 then "arm64"
            else throw "Unsupported system";
-  GOARM = optionalString (stdenv.system == "armv5tel-linux") "5";
+  GOARM = optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5";
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
diff --git a/pkgs/development/compilers/go/1.11.nix b/pkgs/development/compilers/go/1.11.nix
index eddd16dc1997..55cc654b0aa9 100644
--- a/pkgs/development/compilers/go/1.11.nix
+++ b/pkgs/development/compilers/go/1.11.nix
@@ -134,12 +134,12 @@ stdenv.mkDerivation rec {
 
   GOOS = if stdenv.isDarwin then "darwin" else "linux";
   GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
-           else if stdenv.isAarch32 then "arm"
-           else if stdenv.isAarch64 then "arm64"
+           else if stdenv.targetPlatform.isi686 then "386"
+           else if stdenv.targetPlatform.isx86_64 then "amd64"
+           else if stdenv.targetPlatform.isAarch32 then "arm"
+           else if stdenv.targetPlatform.isAarch64 then "arm64"
            else throw "Unsupported system";
-  GOARM = optionalString (stdenv.system == "armv5tel-linux") "5";
+  GOARM = stdenv.targetPlatform.parsed.cpu.version or "";
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
diff --git a/pkgs/development/compilers/go/1.4.nix b/pkgs/development/compilers/go/1.4.nix
index 32eb0d98d188..40fd3f15786b 100644
--- a/pkgs/development/compilers/go/1.4.nix
+++ b/pkgs/development/compilers/go/1.4.nix
@@ -128,11 +128,11 @@ stdenv.mkDerivation rec {
 
   GOOS = if stdenv.isDarwin then "darwin" else "linux";
   GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
+           else if stdenv.hostPlatform.system == "i686-linux" then "386"
+           else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
            else if stdenv.isAarch32 then "arm"
            else throw "Unsupported system";
-  GOARM = stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") "5";
+  GOARM = stdenv.lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5";
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 0;
 
diff --git a/pkgs/development/compilers/go/1.9.nix b/pkgs/development/compilers/go/1.9.nix
index d46e40f460b1..48f16c3ffa5a 100644
--- a/pkgs/development/compilers/go/1.9.nix
+++ b/pkgs/development/compilers/go/1.9.nix
@@ -134,12 +134,12 @@ stdenv.mkDerivation rec {
 
   GOOS = if stdenv.isDarwin then "darwin" else "linux";
   GOARCH = if stdenv.isDarwin then "amd64"
-           else if stdenv.system == "i686-linux" then "386"
-           else if stdenv.system == "x86_64-linux" then "amd64"
+           else if stdenv.hostPlatform.system == "i686-linux" then "386"
+           else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
            else if stdenv.isAarch32 then "arm"
            else if stdenv.isAarch64 then "arm64"
            else throw "Unsupported system";
-  GOARM = optionalString (stdenv.system == "armv5tel-linux") "5";
+  GOARM = optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5";
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
diff --git a/pkgs/development/compilers/jetbrains-jdk/default.nix b/pkgs/development/compilers/jetbrains-jdk/default.nix
index 1c62f79f907b..39fab8b25d8f 100644
--- a/pkgs/development/compilers/jetbrains-jdk/default.nix
+++ b/pkgs/development/compilers/jetbrains-jdk/default.nix
@@ -10,13 +10,13 @@ let drv = stdenv.mkDerivation rec {
   version = "152b1248.6";
   name = pname + "-" + version;
 
-  src = if stdenv.system == "x86_64-linux" then
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then
     fetchurl {
       url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbsdk8u${version}_linux_x64.tar.gz";
       sha256 = "12l81g8zhaymh4rzyfl9nyzmpkgzc7wrphm3j4plxx129yn9i7d7";
     }
   else
-    throw "unsupported system: ${stdenv.system}";
+    throw "unsupported system: ${stdenv.hostPlatform.system}";
 
   nativeBuildInputs = [ file ];
 
diff --git a/pkgs/development/compilers/julia/0.7.nix b/pkgs/development/compilers/julia/0.7.nix
new file mode 100644
index 000000000000..99c6b245ba67
--- /dev/null
+++ b/pkgs/development/compilers/julia/0.7.nix
@@ -0,0 +1,6 @@
+import ./shared.nix {
+  majorVersion = "0";
+  minorVersion = "7";
+  maintenanceVersion = "0";
+  src_sha256 = "1j57569qm2ii8ddzsp08hds2navpk7acdz83kh27dvk44axhwj6f";
+}
diff --git a/pkgs/development/compilers/julia/1.0.nix b/pkgs/development/compilers/julia/1.0.nix
new file mode 100644
index 000000000000..2301d0c1f437
--- /dev/null
+++ b/pkgs/development/compilers/julia/1.0.nix
@@ -0,0 +1,6 @@
+import ./shared.nix {
+  majorVersion = "1";
+  minorVersion = "0";
+  maintenanceVersion = "0";
+  src_sha256 = "083277z90m1jxr2d1ysb96rgjj9h5q97l6h54mx3pb3f38ykshz2";
+}
diff --git a/pkgs/development/compilers/julia/default.nix b/pkgs/development/compilers/julia/default.nix
index 84fdf8f9786d..086570f5ce20 100644
--- a/pkgs/development/compilers/julia/default.nix
+++ b/pkgs/development/compilers/julia/default.nix
@@ -101,7 +101,7 @@ stdenv.mkDerivation rec {
 
   makeFlags =
     let
-      arch = head (splitString "-" stdenv.system);
+      arch = head (splitString "-" stdenv.hostPlatform.system);
       march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
               or (throw "unsupported architecture: ${arch}");
       # Julia requires Pentium 4 (SSE2) or better
diff --git a/pkgs/development/compilers/julia/shared.nix b/pkgs/development/compilers/julia/shared.nix
new file mode 100644
index 000000000000..41c9c57bd034
--- /dev/null
+++ b/pkgs/development/compilers/julia/shared.nix
@@ -0,0 +1,218 @@
+{ majorVersion
+, minorVersion
+, maintenanceVersion
+, src_sha256
+}:
+{ stdenv, fetchurl, fetchzip
+# build tools
+, gfortran, m4, makeWrapper, patchelf, perl, which, python2, paxctl
+, llvm, cmake
+# libjulia dependencies
+, libunwind, readline, utf8proc, zlib
+# standard library dependencies
+, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
+# linear algebra
+, openblas, arpack
+# Darwin frameworks
+, CoreServices, ApplicationServices
+}:
+
+with stdenv.lib;
+
+# All dependencies must use the same OpenBLAS.
+let
+  arpack_ = arpack;
+in
+let
+  arpack = arpack_.override { inherit openblas; };
+in
+
+let
+  dsfmtVersion = "2.2.3";
+  dsfmt = fetchurl {
+    url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmtVersion}.tar.gz";
+    sha256 = "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42";
+  };
+
+  libuvVersion = "ed3700c849289ed01fe04273a7bf865340b2bd7e";
+  libuv = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}";
+    sha256 = "137w666zsjw1p0ma3lf94d75hr1q45sgkfmbizkyji2qm57cnxjs";
+  };
+
+  rmathVersion = "0.1";
+  rmath-julia = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
+  };
+
+  virtualenvVersion = "15.0.0";
+  virtualenv = fetchurl {
+    url = "mirror://pypi/v/virtualenv/virtualenv-${virtualenvVersion}.tar.gz";
+    sha256 = "06fw4liazpx5vf3am45q2pdiwrv0id7ckv7n6zmpml29x6vkzmkh";
+  };
+
+  libwhichVersion = "81e9723c0273d78493dc8c8ed570f68d9ce7e89e";
+  libwhich = fetchurl {
+    url = "https://api.github.com/repos/vtjnash/libwhich/tarball/${libwhichVersion}";
+    sha256 = "1p7zg31kpmpbmh1znrk1xrbd074agx13b9q4dcw8n2zrwwdlbz3b";
+  };
+
+  llvmVersion = "6.0.0";
+  llvm = fetchurl {
+    url = "http://releases.llvm.org/6.0.0/llvm-${llvmVersion}.src.tar.xz";
+    sha256 = "0224xvfg6h40y5lrbnb9qaq3grmdc5rg00xq03s1wxjfbf8krx8z";
+  };
+
+  suitesparseVersion = "4.4.5";
+  suitesparse = fetchurl {
+    url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${suitesparseVersion}.tar.gz";
+    sha256 = "1jcbxb8jx5wlcixzf6n5dca2rcfx6mlcms1k2rl5gp67ay3bix43";
+  };
+  version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
+in
+
+stdenv.mkDerivation rec {
+  pname = "julia";
+  inherit version;
+  name = "${pname}-${version}";
+
+  src = fetchzip {
+    url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz";
+    sha256 = src_sha256;
+  };
+  prePatch = ''
+    export PATH=$PATH:${cmake}/bin
+    mkdir deps/srccache
+    cp "${dsfmt}" "./deps/srccache/dsfmt-${dsfmtVersion}.tar.gz"
+    cp "${rmath-julia}" "./deps/srccache/Rmath-julia-${rmathVersion}.tar.gz"
+    cp "${libuv}" "./deps/srccache/libuv-${libuvVersion}.tar.gz"
+    cp "${virtualenv}" "./deps/srccache/virtualenv-${virtualenvVersion}.tar.gz"
+    cp "${libwhich}" "./deps/srccache/libwhich-${libwhichVersion}.tar.gz"
+    cp "${llvm}" "./deps/srccache/llvm-${llvmVersion}.src.tar.xz"
+    cp "${suitesparse}" "./deps/srccache/SuiteSparse-${suitesparseVersion}.tar.gz"
+  '';
+
+  patches = [
+    ./0001.1-use-system-utf8proc.patch
+  ] ++ stdenv.lib.optional stdenv.needsPax ./0004-hardened.patch;
+
+  postPatch = ''
+    patchShebangs . contrib
+    for i in backtrace cmdlineargs; do
+      mv test/$i.jl{,.off}
+      touch test/$i.jl
+    done
+    rm stdlib/Sockets/test/runtests.jl && touch stdlib/Sockets/test/runtests.jl
+    sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i ./stdlib/LibGit2/test/libgit2.jl
+    sed -e 's/Failed to resolve /failed to resolve /g' -i ./stdlib/LibGit2/test/libgit2.jl
+  '';
+
+  buildInputs = [
+    arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr
+    pcre2.dev openblas openlibm openspecfun readline utf8proc
+    zlib
+  ]
+  ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
+  ;
+
+  nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ]
+    ++ stdenv.lib.optional stdenv.needsPax paxctl;
+
+  makeFlags =
+    let
+      arch = head (splitString "-" stdenv.system);
+      march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+              or (throw "unsupported architecture: ${arch}");
+      # Julia requires Pentium 4 (SSE2) or better
+      cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+                  or (throw "unsupported architecture: ${arch}");
+    in [
+      "ARCH=${arch}"
+      "MARCH=${march}"
+      "JULIA_CPU_TARGET=${cpuTarget}"
+      "PREFIX=$(out)"
+      "prefix=$(out)"
+      "SHELL=${stdenv.shell}"
+
+      "USE_SYSTEM_BLAS=1"
+      "USE_BLAS64=${if openblas.blas64 then "1" else "0"}"
+      "LIBBLAS=-lopenblas"
+      "LIBBLASNAME=libopenblas"
+
+      "USE_SYSTEM_LAPACK=1"
+      "LIBLAPACK=-lopenblas"
+      "LIBLAPACKNAME=libopenblas"
+
+      "USE_SYSTEM_ARPACK=1"
+      "USE_SYSTEM_FFTW=1"
+      "USE_SYSTEM_GMP=1"
+      "USE_SYSTEM_LIBGIT2=1"
+      "USE_SYSTEM_LIBUNWIND=1"
+
+      #"USE_SYSTEM_LLVM=1"
+      "LLVM_VER=6.0.0"
+
+      "USE_SYSTEM_MPFR=1"
+      "USE_SYSTEM_OPENLIBM=1"
+      "USE_SYSTEM_OPENSPECFUN=1"
+      "USE_SYSTEM_PATCHELF=1"
+      "USE_SYSTEM_PCRE=1"
+      "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config"
+      "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
+      "USE_SYSTEM_READLINE=1"
+      "USE_SYSTEM_UTF8PROC=1"
+      "USE_SYSTEM_ZLIB=1"
+    ];
+
+  NIX_CFLAGS_COMPILE = [ "-fPIC" ];
+
+  LD_LIBRARY_PATH = makeLibraryPath [
+    arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm
+    openspecfun pcre2
+  ];
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  enableParallelBuilding = true;
+
+  doCheck = !stdenv.isDarwin;
+  checkTarget = "testall";
+  # Julia's tests require read/write access to $HOME
+  preCheck = ''
+    export HOME="$NIX_BUILD_TOP"
+  '';
+
+  preBuild = ''
+    sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
+    sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
+    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
+  '';
+
+  postInstall = ''
+    # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
+    # as using a wrapper with LD_LIBRARY_PATH causes segmentation
+    # faults when program returns an error:
+    #   $ julia -e 'throw(Error())'
+    find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
+      if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
+        ln -sv $lib $out/lib/julia/$(basename $lib)
+      fi
+    done
+  '';
+
+  passthru = {
+    inherit majorVersion minorVersion maintenanceVersion;
+    site = "share/julia/site/v${majorVersion}.${minorVersion}";
+  };
+
+  meta = {
+    description = "High-level performance-oriented dynamical language for technical computing";
+    homepage = https://julialang.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ raskin rob ];
+    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
+    broken = stdenv.isi686;
+  };
+}
diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix
index dfeddf2fe65a..9e7fbbe96c35 100644
--- a/pkgs/development/compilers/llvm/3.9/llvm.nix
+++ b/pkgs/development/compilers/llvm/3.9/llvm.nix
@@ -13,13 +13,11 @@
 , zlib
 , compiler-rt_src
 , debugVersion ? false
-, enableSharedLibraries ? (buildPlatform == hostPlatform)
+, enableSharedLibraries ? (stdenv.buildPlatform == stdenv.hostPlatform)
 , buildPackages
-, buildPlatform
-, hostPlatform
 }:
 
-assert (hostPlatform != buildPlatform) -> !enableSharedLibraries;
+assert (stdenv.hostPlatform != stdenv.buildPlatform) -> !enableSharedLibraries;
 
 let
   src = fetch "llvm" "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z";
@@ -131,7 +129,7 @@ in stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DCAN_TARGET_i386=false"
-  ] ++ stdenv.lib.optionals (buildPlatform != hostPlatform) [
+  ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
     "-DCMAKE_CROSSCOMPILING=True"
     "-DLLVM_TABLEGEN=${buildPackages.llvmPackages_39.llvm}/bin/llvm-tblgen"
   ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
diff --git a/pkgs/development/compilers/mezzo/default.nix b/pkgs/development/compilers/mezzo/default.nix
index 79dc479fae83..c0b535747133 100644
--- a/pkgs/development/compilers/mezzo/default.nix
+++ b/pkgs/development/compilers/mezzo/default.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, menhir, yojson, ulex, pprint, fix, functory }:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "mezzo is not available for OCaml ${ocaml.version}"
+else
+
 let
   check-ocaml-version = with stdenv.lib; versionAtLeast (getVersion ocaml);
 in
diff --git a/pkgs/development/compilers/mlton/default.nix b/pkgs/development/compilers/mlton/default.nix
index 583f6f80137f..6b6907b0b2e6 100644
--- a/pkgs/development/compilers/mlton/default.nix
+++ b/pkgs/development/compilers/mlton/default.nix
@@ -14,15 +14,15 @@ stdenv.mkDerivation rec {
   name = "mlton-${version}";
 
   binSrc =
-    if stdenv.system == "i686-linux" then (fetchurl {
+    if stdenv.hostPlatform.system == "i686-linux" then (fetchurl {
       url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.x86-linux.tgz";
       sha256 = "1kxjjmnw4xk2d9hpvz43w9dvyhb3025k4zvjx785c33nrwkrdn4j";
     })
-    else if stdenv.system == "x86_64-linux" then (fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
         url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-linux.tgz";
         sha256 = "0fyhwxb4nmpirjbjcvk9f6w67gmn2gkz7xcgz0xbfih9kc015ygn";
     })
-    else if stdenv.system == "x86_64-darwin" then (fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
         url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-darwin.gmp-macports.tgz";
         sha256 = "044wnh9hhg6if886xy805683k0as347xd37r0r1yi4x7qlxzzgx9";
     })
diff --git a/pkgs/development/compilers/mozart/binary.nix b/pkgs/development/compilers/mozart/binary.nix
index ebe562fcde32..ef6cd1160b33 100644
--- a/pkgs/development/compilers/mozart/binary.nix
+++ b/pkgs/development/compilers/mozart/binary.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
 
   preferLocalBuild = true;
 
-  src = binaries."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}");
+  src = binaries."${stdenv.hostPlatform.system}" or (throw "unsupported system: ${stdenv.hostPlatform.system}");
 
   libPath = stdenv.lib.makeLibraryPath
     [ stdenv.cc.cc
diff --git a/pkgs/development/compilers/nvidia-cg-toolkit/default.nix b/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
index 21ccf77e4a24..b6e2aea7eca5 100644
--- a/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
+++ b/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
@@ -10,17 +10,17 @@ stdenv.mkDerivation rec {
   name = "nvidia-cg-toolkit-${version}";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://developer.download.nvidia.com/cg/Cg_${version}/Cg-${version}_${date}_x86_64.tgz";
         sha256 = "e8ff01e6cc38d1b3fd56a083f5860737dbd2f319a39037528fb1a74a89ae9878";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "http://developer.download.nvidia.com/cg/Cg_${version}/Cg-${version}_${date}_x86.tgz";
         sha256 = "cef3591e436f528852db0e8c145d3842f920e0c89bcfb219c466797cb7b18879";
       }
-    else throw "nvidia-cg-toolkit does not support platform ${stdenv.system}";
+    else throw "nvidia-cg-toolkit does not support platform ${stdenv.hostPlatform.system}";
 
   installPhase = ''
     for b in cgc cgfxcat cginfo
diff --git a/pkgs/development/compilers/opendylan/bin.nix b/pkgs/development/compilers/opendylan/bin.nix
index 1abf44f23495..9b721312bb78 100644
--- a/pkgs/development/compilers/opendylan/bin.nix
+++ b/pkgs/development/compilers/opendylan/bin.nix
@@ -5,15 +5,15 @@
 stdenv.mkDerivation {
   name = "opendylan-2013.2";
 
-  src = if stdenv.system == "x86_64-linux" then fetchurl {
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
       url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86_64-linux.tar.bz2;
       sha256 = "035brbw3hm7zrs593q4zc42yglj1gmmkw3b1r7zzlw3ks4i2lg7h";
     }
-    else if stdenv.system == "i686-linux" then fetchurl {
+    else if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
       url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86-linux.tar.bz2;
       sha256 = "0c61ihvblcsjrw6ncr8x8ylhskcrqs8pajs4mg5di36cvqw12nq5";
     }
-    else throw "platform ${stdenv.system} not supported.";
+    else throw "platform ${stdenv.hostPlatform.system} not supported.";
 
   buildInputs = [ patchelf boehmgc gnused makeWrapper ];
 
diff --git a/pkgs/development/compilers/opendylan/default.nix b/pkgs/development/compilers/opendylan/default.nix
index 17d474359da4..8e732d7d8bf4 100644
--- a/pkgs/development/compilers/opendylan/default.nix
+++ b/pkgs/development/compilers/opendylan/default.nix
@@ -11,11 +11,11 @@ stdenv.mkDerivation {
     fetchSubmodules = true;
   };
 
-  buildInputs = (if stdenv.system == "i686-linux" then [ mps ] else [ boehmgc ]) ++ [
+  buildInputs = (if stdenv.hostPlatform.system == "i686-linux" then [ mps ] else [ boehmgc ]) ++ [
     opendylan-bootstrap boehmgc gnused autoconf automake perl makeWrapper
   ];
 
-  preConfigure = if stdenv.system == "i686-linux" then ''
+  preConfigure = if stdenv.hostPlatform.system == "i686-linux" then ''
     mkdir -p $TMPDIR/mps
     tar --strip-components=1 -xf ${mps.src} -C $TMPDIR/mps
     ./autogen.sh
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   '';
 
   configureFlags = [
-    (if stdenv.system == "i686-linux" then "--with-mps=$(TMPDIR)/mps" else "--with-gc=${boehmgc.out}")
+    (if stdenv.hostPlatform.system == "i686-linux" then "--with-mps=$(TMPDIR)/mps" else "--with-gc=${boehmgc.out}")
   ];
   buildPhase = "make 3-stage-bootstrap";
 
diff --git a/pkgs/development/compilers/openjdk/10.nix b/pkgs/development/compilers/openjdk/10.nix
index 6e8d9003bf43..750a4efe4968 100644
--- a/pkgs/development/compilers/openjdk/10.nix
+++ b/pkgs/development/compilers/openjdk/10.nix
@@ -13,7 +13,7 @@ let
    * The JRE libraries are in directories that depend on the CPU.
    */
   architecture =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       "i386"
     else "amd64";
 
diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
index baa136b798d9..5d55e0554e55 100644
--- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
@@ -46,7 +46,7 @@ let
     x86_64-linux  = "amd64";
     armv7l-linux  = "arm";
     aarch64-linux = "aarch64";
-  }.${stdenv.system};
+  }.${stdenv.hostPlatform.system};
 
   jce =
     if installjce then
@@ -77,9 +77,9 @@ let result = stdenv.mkDerivation rec {
       x86_64-linux  = "jdk-${productVersion}u${patchVersion}-linux-x64.tar.gz";
       armv7l-linux  = "jdk-${productVersion}u${patchVersion}-linux-arm32-vfp-hflt.tar.gz";
       aarch64-linux = "jdk-${productVersion}u${patchVersion}-linux-arm64-vfp-hflt.tar.gz";
-    }.${stdenv.system};
+    }.${stdenv.hostPlatform.system};
     url = downloadUrl;
-    sha256 = sha256.${stdenv.system};
+    sha256 = sha256.${stdenv.hostPlatform.system};
   };
 
   nativeBuildInputs = [ file ]
diff --git a/pkgs/development/compilers/orc/default.nix b/pkgs/development/compilers/orc/default.nix
index 9fc9007abb9e..3f3db48828d4 100644
--- a/pkgs/development/compilers/orc/default.nix
+++ b/pkgs/development/compilers/orc/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   '';
 
   # https://bugzilla.gnome.org/show_bug.cgi?id=728129#c15
-  doCheck = stdenv.system != "i686-linux"; # not sure about cross-compiling
+  doCheck = stdenv.hostPlatform.system != "i686-linux"; # not sure about cross-compiling
 
   meta = with stdenv.lib; {
     description = "The Oil Runtime Compiler";
diff --git a/pkgs/development/compilers/picat/default.nix b/pkgs/development/compilers/picat/default.nix
index 8ee904a6ed6c..b520a5e703c8 100644
--- a/pkgs/development/compilers/picat/default.nix
+++ b/pkgs/development/compilers/picat/default.nix
@@ -8,8 +8,8 @@ stdenv.mkDerivation {
     sha256 = "0wvl95gf4pjs93632g4wi0mw1glzzhjp9g4xg93ll2zxggbxibli";
   };
 
-  ARCH = if stdenv.system == "i686-linux" then "linux32"
-         else if stdenv.system == "x86_64-linux" then "linux64"
+  ARCH = if stdenv.hostPlatform.system == "i686-linux" then "linux32"
+         else if stdenv.hostPlatform.system == "x86_64-linux" then "linux64"
          else throw "Unsupported system";
 
   hardeningDisable = [ "format" ];
diff --git a/pkgs/development/compilers/rust/bootstrap.nix b/pkgs/development/compilers/rust/bootstrap.nix
index 563250097ae1..901675ff31b4 100644
--- a/pkgs/development/compilers/rust/bootstrap.nix
+++ b/pkgs/development/compilers/rust/bootstrap.nix
@@ -16,19 +16,19 @@ let
   };
 
   platform =
-    if stdenv.system == "i686-linux"
+    if stdenv.hostPlatform.system == "i686-linux"
     then "i686-unknown-linux-gnu"
-    else if stdenv.system == "x86_64-linux"
+    else if stdenv.hostPlatform.system == "x86_64-linux"
     then "x86_64-unknown-linux-gnu"
-    else if stdenv.system == "armv7l-linux"
+    else if stdenv.hostPlatform.system == "armv7l-linux"
     then "armv7-unknown-linux-gnueabihf"
-    else if stdenv.system == "aarch64-linux"
+    else if stdenv.hostPlatform.system == "aarch64-linux"
     then "aarch64-unknown-linux-gnu"
-    else if stdenv.system == "i686-darwin"
+    else if stdenv.hostPlatform.system == "i686-darwin"
     then "i686-apple-darwin"
-    else if stdenv.system == "x86_64-darwin"
+    else if stdenv.hostPlatform.system == "x86_64-darwin"
     then "x86_64-apple-darwin"
-    else throw "missing bootstrap url for platform ${stdenv.system}";
+    else throw "missing bootstrap url for platform ${stdenv.hostPlatform.system}";
 
   src = fetchurl {
      url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz";
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 23aa750060a3..9c9788ff4834 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -12,7 +12,6 @@
 , targetToolchains
 , doCheck ? true
 , broken ? false
-, buildPlatform, hostPlatform
 }:
 
 let
diff --git a/pkgs/development/compilers/sbcl/bootstrap.nix b/pkgs/development/compilers/sbcl/bootstrap.nix
index 529123398a57..ee662d39e451 100644
--- a/pkgs/development/compilers/sbcl/bootstrap.nix
+++ b/pkgs/development/compilers/sbcl/bootstrap.nix
@@ -39,9 +39,9 @@ let
       sha256 = "05c12fmac4ha72k1ckl6i780rckd7jh4g5s5hiic7fjxnf1kx8d0";
     };
   };
-  cfg = options.${stdenv.system};
+  cfg = options.${stdenv.hostPlatform.system};
 in
-assert builtins.hasAttr stdenv.system options;
+assert builtins.hasAttr stdenv.hostPlatform.system options;
 stdenv.mkDerivation rec {
   name    = "sbcl-bootstrap-${version}";
   version = cfg.version;
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 261a2fb6432c..a860aa7dc734 100644
--- a/pkgs/development/compilers/sbcl/default.nix
+++ b/pkgs/development/compilers/sbcl/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, writeText, sbclBootstrap
 , sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit"
-, threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.system)
+, threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system)
   # Meant for sbcl used for creating binaries portable to non-NixOS via save-lisp-and-die.
   # Note that the created binaries still need `patchelf --set-interpreter ...`
   # to get rid of ${glibc} dependency.
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index 0786238040b6..1b33954662db 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -1,10 +1,9 @@
 { stdenv, buildPackages, buildHaskellPackages, ghc
 , jailbreak-cabal, hscolour, cpphs, nodejs
-, buildPlatform, hostPlatform
 }:
 
 let
-  isCross = buildPlatform != hostPlatform;
+  isCross = stdenv.buildPlatform != stdenv.hostPlatform;
   inherit (buildPackages)
     fetchurl removeReferencesTo
     pkgconfig coreutils gnugrep gnused glibcLocales;
@@ -32,8 +31,8 @@ in
 , enableSharedExecutables ? false
 , enableSharedLibraries ? (ghc.enableShared or false)
 , enableDeadCodeElimination ? (!stdenv.isDarwin)  # TODO: use -dead_strip for darwin
-, enableStaticLibraries ? !hostPlatform.isWindows
-, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
+, enableStaticLibraries ? !stdenv.hostPlatform.isWindows
+, enableHsc2hsViaAsm ? stdenv.hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
 , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
 # On macOS, statically linking against system frameworks is not supported;
 # see https://developer.apple.com/library/content/qa/qa1118/_index.html
@@ -79,7 +78,7 @@ assert editedCabalFile != null -> revision != null;
 
 # --enable-static does not work on windows. This is a bug in GHC.
 # --enable-static will pass -staticlib to ghc, which only works for mach-o and elf.
-assert hostPlatform.isWindows -> enableStaticLibraries == false;
+assert stdenv.hostPlatform.isWindows -> enableStaticLibraries == false;
 
 let
 
@@ -144,7 +143,7 @@ let
     (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
     (optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES")
     (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
-    (enableFeature (enableDeadCodeElimination && !hostPlatform.isAarch32 && !hostPlatform.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
+    (enableFeature (enableDeadCodeElimination && !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
     (enableFeature enableLibraryProfiling "library-profiling")
     (optionalString ((enableExecutableProfiling || enableLibraryProfiling) && versionOlder "8" ghc.version) "--profiling-detail=${profilingDetail}")
     (enableFeature enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling"))
@@ -163,7 +162,7 @@ let
   ] ++ optionals isGhcjs [
     "--ghcjs"
   ] ++ optionals isCross ([
-    "--configure-option=--host=${hostPlatform.config}"
+    "--configure-option=--host=${stdenv.hostPlatform.config}"
   ] ++ crossCabalFlags);
 
   setupCompileFlags = [
@@ -285,7 +284,7 @@ stdenv.mkDerivation ({
       fi
     ''
     # It is not clear why --extra-framework-dirs does work fine on Linux
-    + optionalString (!buildPlatform.isDarwin || versionAtLeast nativeGhc.version "8.0") ''
+    + optionalString (!stdenv.buildPlatform.isDarwin || versionAtLeast nativeGhc.version "8.0") ''
       if [[ -d "$p/Library/Frameworks" ]]; then
         configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks"
       fi
@@ -486,5 +485,5 @@ stdenv.mkDerivation ({
 // optionalAttrs (postFixup != "")      { inherit postFixup; }
 // optionalAttrs (dontStrip)            { inherit dontStrip; }
 // optionalAttrs (hardeningDisable != []) { inherit hardeningDisable; }
-// optionalAttrs (buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
+// optionalAttrs (stdenv.buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
 )
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 1a29732b651a..49beed8549db 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -1,4 +1,4 @@
-{ lib, targetPlatform, ghc, llvmPackages, packages, symlinkJoin, makeWrapper
+{ lib, stdenv, ghc, llvmPackages, packages, symlinkJoin, makeWrapper
 , withLLVM ? false
 , postBuild ? ""
 , ghcLibdir ? null # only used by ghcjs, when resolving plugins
@@ -48,7 +48,7 @@ let
   # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
   llvm          = lib.makeBinPath
                   ([ llvmPackages.llvm ]
-                   ++ lib.optional targetPlatform.isDarwin llvmPackages.clang);
+                   ++ lib.optional stdenv.targetPlatform.isDarwin llvmPackages.clang);
 in
 if paths == [] && !withLLVM then ghc else
 symlinkJoin {
@@ -105,7 +105,7 @@ symlinkJoin {
         --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
     fi
 
-  '' + (lib.optionalString (targetPlatform.isDarwin && !isGhcjs && !targetPlatform.isiOS) ''
+  '' + (lib.optionalString (stdenv.targetPlatform.isDarwin && !isGhcjs && !stdenv.targetPlatform.isiOS) ''
     # Work around a linker limit in macOS Sierra (see generic-builder.nix):
     local packageConfDir="$out/lib/${ghc.name}/package.conf.d";
     local dynamicLinksDir="$out/lib/links"
diff --git a/pkgs/development/interpreters/dart/default.nix b/pkgs/development/interpreters/dart/default.nix
index ae7f8686b781..4c697ec4e802 100644
--- a/pkgs/development/interpreters/dart/default.nix
+++ b/pkgs/development/interpreters/dart/default.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation {
     unzip
   ];
 
-  src = sources."${version}-${stdenv.system}" or (throw "unsupported version/system: ${version}/${stdenv.system}");
+  src = sources."${version}-${stdenv.hostPlatform.system}" or (throw "unsupported version/system: ${version}/${stdenv.hostPlatform.system}");
 
   installPhase = ''
     mkdir -p $out
diff --git a/pkgs/development/interpreters/guile/1.8.nix b/pkgs/development/interpreters/guile/1.8.nix
index 53db5949f02b..13a0d45dbe41 100644
--- a/pkgs/development/interpreters/guile/1.8.nix
+++ b/pkgs/development/interpreters/guile/1.8.nix
@@ -1,5 +1,4 @@
 { stdenv, buildPackages
-, buildPlatform, hostPlatform
 , fetchurl, makeWrapper, gawk, pkgconfig
 , libtool, readline, gmp
 }:
@@ -23,7 +22,7 @@ stdenv.mkDerivation rec {
                           "--with-threads=no";
 
   depsBuildBuild = [ buildPackages.stdenv.cc ]
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform)
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
                            buildPackages.buildPackages.guile_1_8;
   nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool ];
diff --git a/pkgs/development/interpreters/guile/2.0.nix b/pkgs/development/interpreters/guile/2.0.nix
index 848b8666f27d..ea34fd61f3b7 100644
--- a/pkgs/development/interpreters/guile/2.0.nix
+++ b/pkgs/development/interpreters/guile/2.0.nix
@@ -1,5 +1,4 @@
 { stdenv, buildPackages
-, buildPlatform, hostPlatform
 , fetchpatch, fetchurl, makeWrapper, gawk, pkgconfig
 , libffi, libtool, readline, gmp, boehmgc, libunistring
 , coverageAnalysis ? null
@@ -22,7 +21,7 @@
   setOutputFlags = false; # $dev gets into the library otherwise
 
   depsBuildBuild = [ buildPackages.stdenv.cc ]
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform)
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
                            buildPackages.buildPackages.guile_2_0;
   nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool libunistring libffi ];
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index 8110598e1730..aacc5dc49a10 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -1,5 +1,4 @@
 { stdenv, buildPackages
-, buildPlatform, hostPlatform
 , fetchurl, makeWrapper, gawk, pkgconfig
 , libffi, libtool, readline, gmp, boehmgc, libunistring
 , coverageAnalysis ? null
@@ -23,7 +22,7 @@
   setOutputFlags = false; # $dev gets into the library otherwise
 
   depsBuildBuild = [ buildPackages.stdenv.cc ]
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform)
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
                            buildPackages.buildPackages.guile;
   nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool libunistring libffi ];
diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix
index fd84d924d7b8..df8e6ebf89ff 100644
--- a/pkgs/development/interpreters/python/cpython/2.7/default.nix
+++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, hostPlatform, buildPlatform, buildPackages, fetchurl
+{ stdenv, buildPackages, fetchurl
 , bzip2
 , gdbm
 , fetchpatch
@@ -85,7 +85,7 @@ let
       # libuuid, slowing down program startup a lot).
       ./no-ldconfig.patch
 
-    ] ++ optionals hostPlatform.isCygwin [
+    ] ++ optionals stdenv.hostPlatform.isCygwin [
       ./2.5.2-ctypes-util-find_library.patch
       ./2.5.2-tkinter-x11.patch
       ./2.6.2-ssl-threads.patch
@@ -125,14 +125,14 @@ let
     "--enable-shared"
     "--with-threads"
     "--enable-unicode=ucs${toString ucsEncoding}"
-  ] ++ optionals (hostPlatform.isCygwin || hostPlatform.isAarch64) [
+  ] ++ optionals (stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isAarch64) [
     "--with-system-ffi"
-  ] ++ optionals hostPlatform.isCygwin [
+  ] ++ optionals stdenv.hostPlatform.isCygwin [
     "--with-system-expat"
     "ac_cv_func_bind_textdomain_codeset=yes"
   ] ++ optionals stdenv.isDarwin [
     "--disable-toolbox-glue"
-  ] ++ optionals (hostPlatform != buildPlatform) [
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "PYTHON_FOR_BUILD=${getBin buildPackages.python}/bin/python"
     "ac_cv_buggy_getaddrinfo=no"
     # Assume little-endian IEEE 754 floating point when cross compiling
@@ -157,18 +157,18 @@ let
   ]
     # Never even try to use lchmod on linux,
     # don't rely on detecting glibc-isms.
-  ++ optional hostPlatform.isLinux "ac_cv_func_lchmod=no";
+  ++ optional stdenv.hostPlatform.isLinux "ac_cv_func_lchmod=no";
 
   buildInputs =
     optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
     [ bzip2 openssl zlib ]
-    ++ optional (hostPlatform.isCygwin || hostPlatform.isAarch64) libffi
-    ++ optional hostPlatform.isCygwin expat
+    ++ optional (stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isAarch64) libffi
+    ++ optional stdenv.hostPlatform.isCygwin expat
     ++ [ db gdbm ncurses sqlite readline ]
     ++ optionals x11Support [ tcl tk xlibsWrapper libX11 ]
     ++ optionals stdenv.isDarwin ([ CF ] ++ optional (configd != null) configd);
   nativeBuildInputs =
-    optionals (hostPlatform != buildPlatform)
+    optionals (stdenv.hostPlatform != stdenv.buildPlatform)
     [ buildPackages.stdenv.cc buildPackages.python ];
 
   mkPaths = paths: {
@@ -190,7 +190,7 @@ in stdenv.mkDerivation {
     inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
 
     NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2"
-      + optionalString hostPlatform.isMusl " -DTHREAD_STACK_SIZE=0x100000";
+      + optionalString stdenv.hostPlatform.isMusl " -DTHREAD_STACK_SIZE=0x100000";
     DETERMINISTIC_BUILD = 1;
 
     setupHook = python-setup-hook sitePackages;
@@ -235,7 +235,7 @@ in stdenv.mkDerivation {
         find $out -name "*.py" | $out/bin/python -m compileall -q -f -x "lib2to3" -i -
         find $out -name "*.py" | $out/bin/python -O -m compileall -q -f -x "lib2to3" -i -
         find $out -name "*.py" | $out/bin/python -OO -m compileall -q -f -x "lib2to3" -i -
-      '' + optionalString hostPlatform.isCygwin ''
+      '' + optionalString stdenv.hostPlatform.isCygwin ''
         cp libpython2.7.dll.a $out/lib
       '';
 
diff --git a/pkgs/development/interpreters/spidermonkey/1.8.5.nix b/pkgs/development/interpreters/spidermonkey/1.8.5.nix
index bd53450de4ef..466371955868 100644
--- a/pkgs/development/interpreters/spidermonkey/1.8.5.nix
+++ b/pkgs/development/interpreters/spidermonkey/1.8.5.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
   # of polkit, which is what matters most, it does not override the allocator
   # so the failure of that test does not matter much.
   configureFlags = [ "--enable-threadsafe" "--with-system-nspr" ] ++
-    stdenv.lib.optionals (stdenv.system == "armv5tel-linux") [
+    stdenv.lib.optionals (stdenv.hostPlatform.system == "armv5tel-linux") [
         "--with-cpu-arch=armv5t" 
         "--disable-tracejit" ];
 
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index c7e4a9c29ac8..7bbb1a5e1c92 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -1,10 +1,9 @@
 { stdenv, lib, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv
 , openglSupport ? false, libGL, libGLU
 , alsaSupport ? true, alsaLib
-, x11Support ? hostPlatform == buildPlatform, libXext, libICE, libXrandr
+, x11Support ? stdenv.hostPlatform == stdenv.buildPlatform, libXext, libICE, libXrandr
 , pulseaudioSupport ? true, libpulseaudio
 , OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa
-, hostPlatform, buildPlatform
 }:
 
 # NOTE: When editing this expression see if the same change applies to
@@ -41,7 +40,7 @@ stdenv.mkDerivation rec {
     ++ optional stdenv.isDarwin Cocoa;
 
   buildInputs = [ ]
-    ++ optional (!hostPlatform.isMinGW) audiofile
+    ++ optional (!stdenv.hostPlatform.isMinGW) audiofile
     ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
 
   configureFlags = [
diff --git a/pkgs/development/libraries/apr/default.nix b/pkgs/development/libraries/apr/default.nix
index 7d7acf90a95c..705f61445b59 100644
--- a/pkgs/development/libraries/apr/default.nix
+++ b/pkgs/development/libraries/apr/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
   configureFlags =
     # Including the Windows headers breaks unistd.h.
     # Based on ftp://sourceware.org/pub/cygwin/release/libapr1/libapr1-1.3.8-2-src.tar.bz2
-    stdenv.lib.optional (stdenv.system == "i686-cygwin") "ac_cv_header_windows_h=no";
+    stdenv.lib.optional (stdenv.hostPlatform.system == "i686-cygwin") "ac_cv_header_windows_h=no";
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 96fe5b89a18c..944f33b7a3f9 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gettext, hostPlatform }:
+{ stdenv, fetchurl, gettext }:
 
 stdenv.mkDerivation rec {
   name = "attr-2.4.47";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   installTargets = [ "install" "install-lib" "install-dev" ];
 
-  patches = if (hostPlatform.libc == "musl") then [ ./fix-headers-musl.patch ] else null;
+  patches = if (stdenv.hostPlatform.libc == "musl") then [ ./fix-headers-musl.patch ] else null;
 
   postPatch = ''
     for script in install-sh include/install-sh; do
diff --git a/pkgs/development/libraries/audio/libbass/default.nix b/pkgs/development/libraries/audio/libbass/default.nix
index ec93e2f64671..390ca6bb04b7 100644
--- a/pkgs/development/libraries/audio/libbass/default.nix
+++ b/pkgs/development/libraries/audio/libbass/default.nix
@@ -41,8 +41,8 @@ let
     dontBuild = true;
     installPhase =
       let so =
-            if bass.so ? ${stdenv.system} then bass.so.${stdenv.system}
-            else throw "${name} not packaged for ${stdenv.system} (yet).";
+            if bass.so ? ${stdenv.hostPlatform.system} then bass.so.${stdenv.hostPlatform.system}
+            else throw "${name} not packaged for ${stdenv.hostPlatform.system} (yet).";
       in ''
         mkdir -p $out/{lib,include}
         install -m644 -t $out/lib/ ${so}
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index c11d6689624d..da71e40187f4 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -1,6 +1,5 @@
 { lib, stdenv, fetchurl, fetchpatch, pkgconfig, libatomic_ops
 , enableLargeConfig ? false # doc: https://github.com/ivmai/bdwgc/blob/v7.6.6/doc/README.macros#L179
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -30,7 +29,7 @@ stdenv.mkDerivation rec {
     sha256 = "1gydwlklvci30f5dpp5ccw2p2qpph5y41r55wx9idamjlq66fbb3";
   }) ] ++
     # https://github.com/ivmai/bdwgc/pull/208
-    lib.optional hostPlatform.isRiscV ./riscv.patch;
+    lib.optional stdenv.hostPlatform.isRiscV ./riscv.patch;
 
   configureFlags =
     [ "--enable-cplusplus" ]
@@ -40,7 +39,7 @@ stdenv.mkDerivation rec {
   doCheck = true; # not cross;
 
   # Don't run the native `strip' when cross-compiling.
-  dontStrip = hostPlatform != buildPlatform;
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/boost/1.66.nix b/pkgs/development/libraries/boost/1.66.nix
index 932ebdcb463a..e8321c802359 100644
--- a/pkgs/development/libraries/boost/1.66.nix
+++ b/pkgs/development/libraries/boost/1.66.nix
@@ -1,4 +1,4 @@
-{ stdenv, callPackage, fetchurl, hostPlatform, buildPlatform, ... } @ args:
+{ stdenv, callPackage, fetchurl, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
   version = "1.66_0";
diff --git a/pkgs/development/libraries/boost/1.67.nix b/pkgs/development/libraries/boost/1.67.nix
index 150272df6ca3..0f341217dcab 100644
--- a/pkgs/development/libraries/boost/1.67.nix
+++ b/pkgs/development/libraries/boost/1.67.nix
@@ -1,4 +1,4 @@
-{ stdenv, callPackage, fetchurl, fetchpatch, hostPlatform, buildPlatform, ... } @ args:
+{ stdenv, callPackage, fetchurl, fetchpatch, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
   version = "1.67_0";
diff --git a/pkgs/development/libraries/boost/1.68.nix b/pkgs/development/libraries/boost/1.68.nix
index 081b105e2d20..97879051a67c 100644
--- a/pkgs/development/libraries/boost/1.68.nix
+++ b/pkgs/development/libraries/boost/1.68.nix
@@ -1,4 +1,4 @@
-{ stdenv, callPackage, fetchurl, fetchpatch, hostPlatform, buildPlatform, ... } @ args:
+{ stdenv, callPackage, fetchurl, fetchpatch, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
   version = "1.68_0";
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index dab6fac6f0cc..617484e5a403 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
 , which
-, buildPackages, buildPlatform, hostPlatform
+, buildPackages
 , toolset ? /**/ if stdenv.cc.isClang  then "clang"
             else null
 , enableRelease ? true
 , enableDebug ? false
 , enableSingleThreaded ? false
 , enableMultiThreaded ? true
-, enableShared ? !(hostPlatform.libc == "msvcrt") # problems for now
+, enableShared ? !(stdenv.hostPlatform.libc == "msvcrt") # problems for now
 , enableStatic ? !enableShared
 , enablePython ? false
 , enableNumpy ? false
@@ -24,7 +24,7 @@
 assert enableShared || enableStatic;
 
 # Python isn't supported when cross-compiling
-assert enablePython -> hostPlatform == buildPlatform;
+assert enablePython -> stdenv.hostPlatform == stdenv.buildPlatform;
 assert enableNumpy -> enablePython;
 
 with stdenv.lib;
@@ -59,23 +59,23 @@ let
     "-sEXPAT_LIBPATH=${expat.out}/lib"
 
     # TODO: make this unconditional
-  ] ++ optionals (hostPlatform != buildPlatform) [
-    "address-model=${toString hostPlatform.parsed.cpu.bits}"
-    "architecture=${toString hostPlatform.parsed.cpu.family}"
-    "binary-format=${toString hostPlatform.parsed.kernel.execFormat.name}"
-    "target-os=${toString hostPlatform.parsed.kernel.name}"
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "address-model=${toString stdenv.hostPlatform.parsed.cpu.bits}"
+    "architecture=${toString stdenv.hostPlatform.parsed.cpu.family}"
+    "binary-format=${toString stdenv.hostPlatform.parsed.kernel.execFormat.name}"
+    "target-os=${toString stdenv.hostPlatform.parsed.kernel.name}"
 
     # adapted from table in boost manual
     # https://www.boost.org/doc/libs/1_66_0/libs/context/doc/html/context/architectures.html
-    "abi=${if hostPlatform.parsed.cpu.family == "arm" then "aapcs"
-           else if hostPlatform.isWindows then "ms"
-           else if hostPlatform.isMips then "o32"
+    "abi=${if stdenv.hostPlatform.parsed.cpu.family == "arm" then "aapcs"
+           else if stdenv.hostPlatform.isWindows then "ms"
+           else if stdenv.hostPlatform.isMips then "o32"
            else "sysv"}"
   ] ++ optional (link != "static") "runtime-link=${runtime-link}"
     ++ optional (variant == "release") "debug-symbols=off"
     ++ optional (toolset != null) "toolset=${toolset}"
-    ++ optional (mpi != null || hostPlatform != buildPlatform) "--user-config=user-config.jam"
-    ++ optionals (hostPlatform.libc == "msvcrt") [
+    ++ optional (mpi != null || stdenv.hostPlatform != stdenv.buildPlatform) "--user-config=user-config.jam"
+    ++ optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "threadapi=win32"
   ]);
 
@@ -86,10 +86,10 @@ stdenv.mkDerivation {
 
   inherit src;
 
-  patchFlags = optionalString (hostPlatform.libc == "msvcrt") "-p0";
+  patchFlags = optionalString (stdenv.hostPlatform.libc == "msvcrt") "-p0";
   patches = patches
     ++ optional stdenv.isDarwin ./darwin-no-system-python.patch
-    ++ optional (hostPlatform.libc == "msvcrt") (fetchurl {
+    ++ optional (stdenv.hostPlatform.libc == "msvcrt") (fetchurl {
       url = "https://svn.boost.org/trac/boost/raw-attachment/tickaet/7262/"
           + "boost-mingw.patch";
       sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj";
@@ -113,7 +113,7 @@ stdenv.mkDerivation {
     cat << EOF >> user-config.jam
     using mpi : ${mpi}/bin/mpiCC ;
     EOF
-  '' + optionalString (hostPlatform != buildPlatform) ''
+  '' + optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     cat << EOF >> user-config.jam
     using gcc : cross : ${stdenv.cc.targetPrefix}c++ ;
     EOF
@@ -126,7 +126,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ which buildPackages.stdenv.cc ];
   buildInputs = [ expat zlib bzip2 libiconv ]
-    ++ optional (hostPlatform == buildPlatform) icu
+    ++ optional (stdenv.hostPlatform == stdenv.buildPlatform) icu
     ++ optional stdenv.isDarwin fixDarwinDylibNames
     ++ optional enablePython python
     ++ optional enableNumpy python.pkgs.numpy;
@@ -137,7 +137,7 @@ stdenv.mkDerivation {
     "--includedir=$(dev)/include"
     "--libdir=$(out)/lib"
   ] ++ optional enablePython "--with-python=${python.interpreter}"
-    ++ [ (if hostPlatform == buildPlatform then "--with-icu=${icu.dev}" else "--without-icu") ]
+    ++ [ (if stdenv.hostPlatform == stdenv.buildPlatform then "--with-icu=${icu.dev}" else "--without-icu") ]
     ++ optional (toolset != null) "--with-toolset=${toolset}";
 
   buildPhase = ''
@@ -157,7 +157,7 @@ stdenv.mkDerivation {
     # Make boost header paths relative so that they are not runtime dependencies
     cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
       -exec sed '1i#line 1 "{}"' -i '{}' \;
-  '' + optionalString (hostPlatform.libc == "msvcrt") ''
+  '' + optionalString (stdenv.hostPlatform.libc == "msvcrt") ''
     $RANLIB "$out/lib/"*.a
   '';
 
diff --git a/pkgs/development/libraries/bootil/default.nix b/pkgs/development/libraries/bootil/default.nix
index 160f62305945..b64cdd5245fd 100644
--- a/pkgs/development/libraries/bootil/default.nix
+++ b/pkgs/development/libraries/bootil/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   platform =
     if stdenv.isLinux then "linux"
     else if stdenv.isDarwin then "macosx"
-    else throw "unrecognized system ${stdenv.system}";
+    else throw "unrecognized system ${stdenv.hostPlatform.system}";
 
   buildInputs = [ premake4 ];
 
diff --git a/pkgs/development/libraries/c-ares/default.nix b/pkgs/development/libraries/c-ares/default.nix
index 176245491179..1835356e627d 100644
--- a/pkgs/development/libraries/c-ares/default.nix
+++ b/pkgs/development/libraries/c-ares/default.nix
@@ -1,4 +1,4 @@
-{ targetPlatform, stdenv, fetchurl, writeTextDir }:
+{ stdenv, fetchurl, writeTextDir }:
 
 let self =
 stdenv.mkDerivation rec {
@@ -40,8 +40,8 @@ stdenv.mkDerivation rec {
       )
       set_property(TARGET c-ares::cares APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
       set_target_properties(c-ares::cares PROPERTIES
-        IMPORTED_LOCATION_RELEASE "${self}/lib/libcares${targetPlatform.extensions.sharedLibrary}"
-        IMPORTED_SONAME_RELEASE "libcares${targetPlatform.extensions.sharedLibrary}"
+        IMPORTED_LOCATION_RELEASE "${self}/lib/libcares${stdenv.targetPlatform.extensions.sharedLibrary}"
+        IMPORTED_SONAME_RELEASE "libcares${stdenv.targetPlatform.extensions.sharedLibrary}"
         )
       add_library(c-ares::cares_shared INTERFACE IMPORTED)
       set_target_properties(c-ares::cares_shared PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares")
diff --git a/pkgs/development/libraries/crypto++/default.nix b/pkgs/development/libraries/crypto++/default.nix
index ba5b2aa43718..cbd3e4054159 100644
--- a/pkgs/development/libraries/crypto++/default.nix
+++ b/pkgs/development/libraries/crypto++/default.nix
@@ -12,9 +12,10 @@ stdenv.mkDerivation rec {
     sha256 = "1yk7jyf4va9425cg05llskpls2jm7n3jwy2hj5jm74zkr4mwpvl7";
   };
 
-  patches = with stdenv;
-    lib.optional (system != "i686-cygwin") ./dll.patch
-    ++ lib.optional isDarwin ./GNUmakefile-darwin.patch;
+  patches = stdenv.lib.concatLists [
+    (stdenv.lib.optional (stdenv.hostPlatform.system != "i686-cygwin") ./dll.patch)
+    (stdenv.lib.optional stdenv.hostPlatform.isDarwin ./GNUmakefile-darwin.patch)
+  ];
 
 
   configurePhase = let
diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix
index e413e29e7ca1..4c1ad34f6da3 100644
--- a/pkgs/development/libraries/ffmpeg-full/default.nix
+++ b/pkgs/development/libraries/ffmpeg-full/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, pkgconfig, perl, texinfo, yasm
-, hostPlatform
 /*
  *  Licensing options (yes some are listed twice, filters and such are not listed)
  */
@@ -253,8 +252,8 @@ stdenv.mkDerivation rec {
 
   configurePlatforms = [];
   configureFlags = [
-    "--target_os=${hostPlatform.parsed.kernel.name}"
-    "--arch=${hostPlatform.parsed.cpu.name}"
+    "--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
+    "--arch=${stdenv.hostPlatform.parsed.cpu.name}"
     /*
      *  Licensing flags
      */
diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix
index 4bb995ff0743..7d72de2a2ded 100644
--- a/pkgs/development/libraries/ffmpeg/generic.nix
+++ b/pkgs/development/libraries/ffmpeg/generic.nix
@@ -2,7 +2,6 @@
 , alsaLib, bzip2, fontconfig, freetype, gnutls, libiconv, lame, libass, libogg
 , libtheora, libva, libvorbis, libvpx, lzma, libpulseaudio, soxr
 , x264, x265, xvidcore, zlib, libopus
-, hostPlatform
 , openglSupport ? false, libGLU_combined ? null
 # Build options
 , runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime
@@ -83,8 +82,8 @@ stdenv.mkDerivation rec {
 
   configurePlatforms = [];
   configureFlags = [
-      "--arch=${hostPlatform.parsed.cpu.name}"
-      "--target_os=${hostPlatform.parsed.kernel.name}"
+      "--arch=${stdenv.hostPlatform.parsed.cpu.name}"
+      "--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
     # License
       "--enable-gpl"
       "--enable-version3"
diff --git a/pkgs/development/libraries/fontconfig/2.10.nix b/pkgs/development/libraries/fontconfig/2.10.nix
index eae93d96f453..1d66735569d5 100644
--- a/pkgs/development/libraries/fontconfig/2.10.nix
+++ b/pkgs/development/libraries/fontconfig/2.10.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, pkgconfig, freetype, expat
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -17,13 +16,13 @@ stdenv.mkDerivation rec {
   buildInputs = [ expat ];
 
   configureFlags = [
-    "--with-arch=${hostPlatform.parsed.cpu.name}"
+    "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
     "--sysconfdir=/etc"
     "--with-cache-dir=/var/cache/fontconfig"
     "--disable-docs"
     "--with-default-fonts="
   ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-    "--with-arch=${hostPlatform.parsed.cpu.name}"
+    "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix
index 01c4140f3b5c..1a028526726c 100644
--- a/pkgs/development/libraries/fontconfig/default.nix
+++ b/pkgs/development/libraries/fontconfig/default.nix
@@ -1,6 +1,5 @@
 { stdenv, substituteAll, fetchurl
 , pkgconfig, freetype, expat, libxslt, gperf, dejavu_fonts
-, hostPlatform
 }:
 
 /** Font configuration scheme
@@ -40,13 +39,13 @@ stdenv.mkDerivation rec {
   buildInputs = [ expat ];
 
   configureFlags = [
-    "--with-arch=${hostPlatform.parsed.cpu.name}"
+    "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
     "--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/
     "--disable-docs"
     # just <1MB; this is what you get when loading config fails for some reason
     "--with-default-fonts=${dejavu_fonts.minimal}"
   ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-    "--with-arch=${hostPlatform.parsed.cpu.name}"
+    "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/gbenchmark/default.nix b/pkgs/development/libraries/gbenchmark/default.nix
index d700c3d3c160..5ce08cbe636f 100644
--- a/pkgs/development/libraries/gbenchmark/default.nix
+++ b/pkgs/development/libraries/gbenchmark/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     description = "A microbenchmark support library";
     homepage = https://github.com/google/benchmark;
     license = licenses.asl20;
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.darwin;
     maintainers = with maintainers; [ abbradar ];
   };
 }
diff --git a/pkgs/development/libraries/gcc/libgcc/default.nix b/pkgs/development/libraries/gcc/libgcc/default.nix
index 0a29ab6927f7..d638c2bb2788 100644
--- a/pkgs/development/libraries/gcc/libgcc/default.nix
+++ b/pkgs/development/libraries/gcc/libgcc/default.nix
@@ -1,4 +1,4 @@
-{ stdenvNoLibs, buildPackages, buildPlatform, hostPlatform
+{ stdenvNoLibs, buildPackages
 , gcc, glibc
 , libiberty
 }:
@@ -29,8 +29,8 @@ stdenvNoLibs.mkDerivation rec {
   # Drop in libiberty, as external builds are not expected
   + ''
     (
-      mkdir -p build-${buildPlatform.config}/libiberty/
-      cd build-${buildPlatform.config}/libiberty/
+      mkdir -p build-${stdenvNoLibs.buildPlatform.config}/libiberty/
+      cd build-${stdenvNoLibs.buildPlatform.config}/libiberty/
       ln -s ${buildPackages.libiberty}/lib/libiberty.a ./
     )
   ''
@@ -83,8 +83,8 @@ stdenvNoLibs.mkDerivation rec {
   ''
   # Preparing to configure + build libgcc itself
   + ''
-    mkdir -p "$buildRoot/gcc/${hostPlatform.config}/libgcc"
-    cd "$buildRoot/gcc/${hostPlatform.config}/libgcc"
+    mkdir -p "$buildRoot/gcc/${stdenvNoLibs.hostPlatform.config}/libgcc"
+    cd "$buildRoot/gcc/${stdenvNoLibs.hostPlatform.config}/libgcc"
     configureScript=$sourceRoot/configure
     chmod +x "$configureScript"
 
@@ -107,9 +107,9 @@ stdenvNoLibs.mkDerivation rec {
   '';
 
   gccConfigureFlags = [
-    "--build=${buildPlatform.config}"
-    "--host=${buildPlatform.config}"
-    "--target=${hostPlatform.config}"
+    "--build=${stdenvNoLibs.buildPlatform.config}"
+    "--host=${stdenvNoLibs.buildPlatform.config}"
+    "--target=${stdenvNoLibs.hostPlatform.config}"
 
     "--disable-bootstrap"
     "--disable-multilib" "--with-multilib-list="
@@ -128,7 +128,7 @@ stdenvNoLibs.mkDerivation rec {
     "--disable-vtable-verify"
 
     "--with-system-zlib"
-  ] ++ stdenvNoLibs.lib.optional (hostPlatform.libc == "glibc")
+  ] ++ stdenvNoLibs.lib.optional (stdenvNoLibs.hostPlatform.libc == "glibc")
        "--with-glibc-version=${glibc.version}";
 
   configurePlatforms = [ "build" "host" ];
@@ -144,9 +144,9 @@ stdenvNoLibs.mkDerivation rec {
   makeFlags = [ "MULTIBUILDTOP:=../" ];
 
   postInstall = ''
-    moveToOutput "lib/gcc/${hostPlatform.config}/${version}/include" "$dev"
+    moveToOutput "lib/gcc/${stdenvNoLibs.hostPlatform.config}/${version}/include" "$dev"
     mkdir -p "$out/lib" "$dev/include"
-    ln -s "$out/lib/gcc/${hostPlatform.config}/${version}"/* "$out/lib"
-    ln -s "$dev/lib/gcc/${hostPlatform.config}/${version}/include"/* "$dev/include/"
+    ln -s "$out/lib/gcc/${stdenvNoLibs.hostPlatform.config}/${version}"/* "$out/lib"
+    ln -s "$dev/lib/gcc/${stdenvNoLibs.hostPlatform.config}/${version}/include"/* "$dev/include/"
   '';
 }
diff --git a/pkgs/development/libraries/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
index bbebcca6e2f0..685775e2918d 100644
--- a/pkgs/development/libraries/gdbm/default.nix
+++ b/pkgs/development/libraries/gdbm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, buildPlatform, fetchurl }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation rec {
   name = "gdbm-1.17";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   # Disable dbmfetch03.at test because it depends on unlink()
   # failing on a link in a chmod -w directory, which cygwin
   # apparently allows.
-  postPatch = lib.optionalString buildPlatform.isCygwin ''
+  postPatch = lib.optionalString stdenv.buildPlatform.isCygwin ''
       substituteInPlace tests/Makefile.in --replace \
         '_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la' \
         '_LDADD = ../compat/libgdbm_compat.la ../src/libgdbm.la'
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index 469dcbf75bbe..4531a5a01d4c 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, hostPlatform, fetchurl, libiconv, xz }:
+{ stdenv, lib, fetchurl, libiconv, xz }:
 
 stdenv.mkDerivation rec {
   name = "gettext-${version}";
@@ -35,20 +35,20 @@ stdenv.mkDerivation rec {
    substituteInPlace gettext-tools/projects/KDE/trigger --replace "/bin/pwd" pwd
    substituteInPlace gettext-tools/projects/GNOME/trigger --replace "/bin/pwd" pwd
    substituteInPlace gettext-tools/src/project-id --replace "/bin/pwd" pwd
-  '' + lib.optionalString hostPlatform.isCygwin ''
+  '' + lib.optionalString stdenv.hostPlatform.isCygwin ''
     sed -i -e "s/\(cldr_plurals_LDADD = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
     sed -i -e "s/\(libgettextsrc_la_LDFLAGS = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
   '';
 
   nativeBuildInputs = [ xz xz.bin ];
   # HACK, see #10874 (and 14664)
-  buildInputs = stdenv.lib.optional (!stdenv.isLinux && !hostPlatform.isCygwin) libiconv;
+  buildInputs = stdenv.lib.optional (!stdenv.isLinux && !stdenv.hostPlatform.isCygwin) libiconv;
 
   setupHooks = [
     ../../../build-support/setup-hooks/role.bash
     ./gettext-setup-hook.sh
   ];
-  gettextNeedsLdflags = hostPlatform.libc != "glibc" && !hostPlatform.isMusl;
+  gettextNeedsLdflags = stdenv.hostPlatform.libc != "glibc" && !stdenv.hostPlatform.isMusl;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/glew/1.10.nix b/pkgs/development/libraries/glew/1.10.nix
index af0830ab7042..b265cfcc0168 100644
--- a/pkgs/development/libraries/glew/1.10.nix
+++ b/pkgs/development/libraries/glew/1.10.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, libGLU, xlibsWrapper, libXmu, libXi
-, buildPlatform, hostPlatform
 , AGL ? null
 }:
 
@@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
 
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
-    ${optionalString (hostPlatform != buildPlatform) ''
+    ${optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
     ''}
   '';
@@ -39,7 +38,7 @@ stdenv.mkDerivation rec {
   '';
 
   makeFlags = [
-    "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
+    "SYSTEM=${if stdenv.hostPlatform.isMinGW then "mingw" else stdenv.hostPlatform.parsed.kernel.name}"
   ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix
index a8add880090f..ec56c544cac3 100644
--- a/pkgs/development/libraries/glew/default.nix
+++ b/pkgs/development/libraries/glew/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, libGLU, xlibsWrapper, libXmu, libXi
-, buildPlatform, hostPlatform
 }:
 
 with stdenv.lib;
@@ -20,7 +19,7 @@ stdenv.mkDerivation rec {
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
     substituteInPlace config/Makefile.darwin --replace /usr/local "$out"
-    ${optionalString (hostPlatform != buildPlatform) ''
+    ${optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
       sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
     ''}
   '';
@@ -41,7 +40,7 @@ stdenv.mkDerivation rec {
   '';
 
   makeFlags = [
-    "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
+    "SYSTEM=${if stdenv.hostPlatform.isMinGW then "mingw" else stdenv.hostPlatform.parsed.kernel.name}"
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index 8b4a213aae05..1eecfa902790 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -18,7 +18,6 @@
 */
 
 { stdenv, lib
-, buildPlatform, hostPlatform
 , buildPackages
 , fetchurl ? null
 , linuxHeaders ? null
@@ -119,12 +118,12 @@ stdenv.mkDerivation ({
        else "--disable-profile")
     ] ++ lib.optionals withLinuxHeaders [
       "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
-    ] ++ lib.optionals (hostPlatform != buildPlatform) [
-      (if hostPlatform.platform.gcc.float or (hostPlatform.parsed.abi.float or "hard") == "soft"
+    ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      (if stdenv.hostPlatform.platform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft"
        then "--without-fp"
        else "--with-fp")
       "--with-__thread"
-    ] ++ lib.optionals (hostPlatform == buildPlatform && hostPlatform.isAarch32) [
+    ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.isAarch32) [
       "--host=arm-linux-gnueabi"
       "--build=arm-linux-gnueabi"
 
@@ -176,7 +175,7 @@ stdenv.mkDerivation ({
     }
 
 
-  '' + lib.optionalString (hostPlatform != buildPlatform) ''
+  '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"
 
     cat > config.cache << "EOF"
@@ -210,7 +209,7 @@ stdenv.mkDerivation ({
   } // meta;
 }
 
-// lib.optionalAttrs (hostPlatform != buildPlatform) {
+// lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
   preInstall = null; # clobber the native hook
 
   dontStrip = true;
diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix
index 04c57d94666f..23a69282b41c 100644
--- a/pkgs/development/libraries/gmp/6.x.nix
+++ b/pkgs/development/libraries/gmp/6.x.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, m4, cxx ? !hostPlatform.useAndroidPrebuilt
-, buildPackages, hostPlatform
+{ stdenv, fetchurl, m4, cxx ? !stdenv.hostPlatform.useAndroidPrebuilt
+, buildPackages
 , withStatic ? false }:
 
 let inherit (stdenv.lib) optional optionalString; in
diff --git a/pkgs/development/libraries/gpgme/default.nix b/pkgs/development/libraries/gpgme/default.nix
index b3b00a1c7226..71fe23ea6b0d 100644
--- a/pkgs/development/libraries/gpgme/default.nix
+++ b/pkgs/development/libraries/gpgme/default.nix
@@ -7,7 +7,10 @@
 , withPython ? false, swig2 ? null, python ? null
 }:
 
-let inherit (stdenv) lib system; in
+let
+  inherit (stdenv) lib;
+  inherit (stdenv.hostPlatform) system;
+in
 
 stdenv.mkDerivation rec {
   name = "gpgme-${version}";
diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix
index 37d4843db8d4..8a419d678655 100644
--- a/pkgs/development/libraries/gsl/default.nix
+++ b/pkgs/development/libraries/gsl/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   ];
 
   # https://lists.gnu.org/archive/html/bug-gsl/2015-11/msg00012.html
-  doCheck = stdenv.system != "i686-linux" && stdenv.system != "aarch64-linux";
+  doCheck = stdenv.hostPlatform.system != "i686-linux" && stdenv.hostPlatform.system != "aarch64-linux";
 
   meta = {
     description = "The GNU Scientific Library, a large numerical library";
diff --git a/pkgs/development/libraries/icu/base.nix b/pkgs/development/libraries/icu/base.nix
index b8ad48326b2b..8ad58c5f90b0 100644
--- a/pkgs/development/libraries/icu/base.nix
+++ b/pkgs/development/libraries/icu/base.nix
@@ -1,7 +1,7 @@
 { version, sha256, patches ? [], patchFlags ? "" }:
 { stdenv, fetchurl, fixDarwinDylibNames
   # Cross-compiled icu4c requires a build-root of a native compile
-, buildRootOnly ? false, nativeBuildRoot, buildPlatform, hostPlatform
+, buildRootOnly ? false, nativeBuildRoot
 }:
 
 let
@@ -38,7 +38,7 @@ let
 
     configureFlags = [ "--disable-debug" ]
       ++ stdenv.lib.optional (stdenv.isFreeBSD || stdenv.isDarwin) "--enable-rpath"
-      ++ stdenv.lib.optional (buildPlatform != hostPlatform) "--with-cross-build=${nativeBuildRoot}";
+      ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) "--with-cross-build=${nativeBuildRoot}";
 
     enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/igraph/default.nix b/pkgs/development/libraries/igraph/default.nix
new file mode 100644
index 000000000000..4ac3ebc09889
--- /dev/null
+++ b/pkgs/development/libraries/igraph/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, lib, fetchFromGitHub,
+  pkgconfig, autoreconfHook,
+  flex, yacc, zlib, libxml2 }:
+
+stdenv.mkDerivation rec {
+  name = "igraph";
+  version = "0.7.1";
+
+  src = fetchFromGitHub {
+    owner = "igraph";
+    repo = name;
+    rev = version;
+    sha256 = "1wsy0r511gk069il6iqjs27q8cjvqz20gf0a7inybx1bw84845z8";
+  };
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  buildInputs = [ flex yacc zlib libxml2 ];
+
+  # This file is normally generated by igraph's bootstrap.sh, but we can do it
+  # ourselves. ~ C.
+  postPatch = ''
+    echo "${version}" > VERSION
+  '';
+
+  meta = {
+    description = "The network analysis package";
+    homepage = http://igraph.org/;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.MostAwesomeDude ];
+  };
+}
diff --git a/pkgs/development/libraries/java/jzmq/default.nix b/pkgs/development/libraries/java/jzmq/default.nix
index 7d229d2577ab..402f893034b6 100644
--- a/pkgs/development/libraries/java/jzmq/default.nix
+++ b/pkgs/development/libraries/java/jzmq/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ zeromq3 jdk ];
 
   preConfigure = ''
-    ${if stdenv.system == "x86_64-darwin" then
+    ${if stdenv.hostPlatform.system == "x86_64-darwin" then
       '' sed -i -e 's~/Headers~/include~' -e 's~_JNI_INC_SUBDIRS=\".*\"~_JNI_INC_SUBDIRS=\"darwin\"~' configure
       '' else ""}
   '';
diff --git a/pkgs/development/libraries/java/swt/default.nix b/pkgs/development/libraries/java/swt/default.nix
index 1a7153f99e67..0aa20f8b014f 100644
--- a/pkgs/development/libraries/java/swt/default.nix
+++ b/pkgs/development/libraries/java/swt/default.nix
@@ -16,7 +16,7 @@ let
         sha256 = "00k1mfbncvyh8klgmk0891w8jwnd5niqb16j1j8yacrm2smmlb05"; };
   };
 
-  metadata = assert platformMap ? ${stdenv.system}; platformMap.${stdenv.system};
+  metadata = assert platformMap ? ${stdenv.hostPlatform.system}; platformMap.${stdenv.hostPlatform.system};
 
 in stdenv.mkDerivation rec {
   version = "4.5";
diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix
index 5eb90aaf05c9..1ef453f24cdb 100644
--- a/pkgs/development/libraries/libav/default.nix
+++ b/pkgs/development/libraries/libav/default.nix
@@ -13,7 +13,6 @@
 , SDL # only for avplay in $bin, adds nontrivial closure to it
 , enableGPL ? true # ToDo: some additional default stuff may need GPL
 , enableUnfree ? faacSupport
-, hostPlatform
 }:
 
 assert faacSupport -> enableUnfree;
@@ -53,8 +52,8 @@ let
 
     configurePlatforms = [];
     configureFlags = assert stdenv.lib.all (x: x!=null) buildInputs; [
-      "--arch=${hostPlatform.parsed.cpu.name}"
-      "--target_os=${hostPlatform.parsed.kernel.name}"
+      "--arch=${stdenv.hostPlatform.parsed.cpu.name}"
+      "--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
       #"--enable-postproc" # it's now a separate package in upstream
       "--disable-avserver" # upstream says it's in a bad state
       "--enable-avplay"
diff --git a/pkgs/development/libraries/libb2/default.nix b/pkgs/development/libraries/libb2/default.nix
index 58961a18df17..f7fffa8b2987 100644
--- a/pkgs/development/libraries/libb2/default.nix
+++ b/pkgs/development/libraries/libb2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, hostPlatform, fetchurl, autoconf, automake, libtool }:
+{ stdenv, fetchurl, autoconf, automake, libtool }:
 
 stdenv.mkDerivation rec {
   name = "libb2-${version}";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
     ./autogen.sh
   '';
 
-  configureFlags = stdenv.lib.optional hostPlatform.isx86 "--enable-fat=yes";
+  configureFlags = stdenv.lib.optional stdenv.hostPlatform.isx86 "--enable-fat=yes";
 
   nativeBuildInputs = [ autoconf automake libtool ];
 
diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix
index bb1dbe51765e..5adafece3535 100644
--- a/pkgs/development/libraries/libelf/default.nix
+++ b/pkgs/development/libraries/libelf/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchurl, autoreconfHook, gettext
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -20,17 +19,17 @@ stdenv.mkDerivation rec {
   configureFlags = []
        # Configure check for dynamic lib support is broken, see
        # http://lists.uclibc.org/pipermail/uclibc-cvs/2005-August/019383.html
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform) "mr_cv_target_elf=yes"
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "mr_cv_target_elf=yes"
        # Libelf's custom NLS macros fail to determine the catalog file extension
        # on Darwin, so disable NLS for now.
-    ++ stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
+    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin "--disable-nls";
 
   nativeBuildInputs = [ gettext ]
        # Need to regenerate configure script with newer version in order to pass
        # "mr_cv_target_elf=yes", but `autoreconfHook` brings in `makeWrapper`
        # which doesn't work with the bootstrapTools bash, so can only do this
        # for cross builds when `stdenv.shell` is a newer bash.
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform) autoreconfHook;
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) autoreconfHook;
 
   meta = {
     description = "ELF object file access library";
diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix
index 6f1aeefa6758..215f587bb6b4 100644
--- a/pkgs/development/libraries/libffi/default.nix
+++ b/pkgs/development/libraries/libffi/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, fetchpatch
-, buildPlatform, hostPlatform, autoreconfHook
+, autoreconfHook
 
 # libffi is used in darwin stdenv
 # we cannot run checks within it
@@ -19,12 +19,12 @@ stdenv.mkDerivation rec {
       url = https://src.fedoraproject.org/rpms/libffi/raw/ccffc1700abfadb0969495a6e51b964117fc03f6/f/libffi-aarch64-rhbz1174037.patch;
       sha256 = "1vpirrgny43hp0885rswgv3xski8hg7791vskpbg3wdjdpb20wbc";
     })
-    ++ stdenv.lib.optional hostPlatform.isMusl (fetchpatch {
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
       name = "gnu-linux-define.patch";
       url = "https://git.alpinelinux.org/cgit/aports/plain/main/libffi/gnu-linux-define.patch?id=bb024fd8ec6f27a76d88396c9f7c5c4b5800d580";
       sha256 = "11pvy3xkhyvnjfyy293v51f1xjy3x0azrahv1nw9y9mw8bifa2j2";
     })
-    ++ stdenv.lib.optional hostPlatform.isRiscV (fetchpatch {
+    ++ stdenv.lib.optional stdenv.hostPlatform.isRiscV (fetchpatch {
       name = "riscv-support.patch";
       url = https://github.com/sorear/libffi-riscv/commit/e46492e8bb1695a19bc1053ed869e6c2bab02ff2.patch;
       sha256 = "1vl1vbvdkigs617kckxvj8j4m2cwg62kxm1clav1w5rnw9afxg0y";
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" "man" "info" ];
 
-  nativeBuildInputs = stdenv.lib.optional hostPlatform.isRiscV autoreconfHook;
+  nativeBuildInputs = stdenv.lib.optional stdenv.hostPlatform.isRiscV autoreconfHook;
 
   configureFlags = [
     "--with-gcc-arch=generic" # no detection of -march= or -mtune=
@@ -60,7 +60,7 @@ stdenv.mkDerivation rec {
 
   inherit doCheck;
 
-  dontStrip = hostPlatform != buildPlatform; # Don't run the native `strip' when cross-compiling.
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; # Don't run the native `strip' when cross-compiling.
 
   # Install headers and libs in the right places.
   postFixup = ''
diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix
index 24dd4f2465c6..d9773a1be4d8 100644
--- a/pkgs/development/libraries/libiconv/default.nix
+++ b/pkgs/development/libraries/libiconv/default.nix
@@ -1,10 +1,9 @@
 { fetchurl, stdenv, lib
-, buildPlatform, hostPlatform
 , enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
 , enableShared ? !stdenv.hostPlatform.useAndroidPrebuilt
 }:
 
-# assert !stdenv.isLinux || hostPlatform != buildPlatform; # TODO: improve on cross
+# assert !stdenv.hostPlatform.isLinux || stdenv.hostPlatform != stdenv.buildPlatform; # TODO: improve on cross
 
 stdenv.mkDerivation rec {
   name = "libiconv-${version}";
@@ -21,7 +20,7 @@ stdenv.mkDerivation rec {
   ];
 
   postPatch =
-    lib.optionalString ((hostPlatform != buildPlatform && hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc)
+    lib.optionalString ((stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc)
       ''
         sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h
       ''
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index e4f70b792fd5..84c6c96ea5de 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, nasm
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -12,7 +11,7 @@ stdenv.mkDerivation rec {
   }; # github releases still need autotools, surprisingly
 
   patches =
-    stdenv.lib.optional (hostPlatform.libc or null == "msvcrt")
+    stdenv.lib.optional (stdenv.hostPlatform.libc or null == "msvcrt")
       ./mingw-boolean.patch;
 
   outputs = [ "bin" "dev" "out" "man" "doc" ];
diff --git a/pkgs/development/libraries/libnfsidmap/default.nix b/pkgs/development/libraries/libnfsidmap/default.nix
deleted file mode 100644
index ce21cda4a5d4..000000000000
--- a/pkgs/development/libraries/libnfsidmap/default.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ stdenv, fetchurl }:
-
-stdenv.mkDerivation rec {
-  name = "libnfsidmap-0.25";
-
-  src = fetchurl {
-    url = "http://www.citi.umich.edu/projects/nfsv4/linux/libnfsidmap/${name}.tar.gz";
-    sha256 = "1kzgwxzh83qi97rblcm9qj80cdvnv8kml2plz0q103j0hifj8vb5";
-  };
-
-  postPatch = ''
-    sed -i '1i#include <sys/types.h>' cfg.h
-  '';
-
-  preConfigure =
-    ''
-      configureFlags="--with-pluginpath=$out/lib/libnfsidmap"
-    '';
-
-  meta = {
-    homepage = http://www.citi.umich.edu/projects/nfsv4/linux/;
-    description = "Library for holding mulitiple methods of mapping names to id's and visa versa, mainly for NFSv4";
-    license = "BSD";
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/libpng/12.nix b/pkgs/development/libraries/libpng/12.nix
index 0153ff8327b6..2cd8c1debaf2 100644
--- a/pkgs/development/libraries/libpng/12.nix
+++ b/pkgs/development/libraries/libpng/12.nix
@@ -1,8 +1,6 @@
-{ stdenv, fetchurl, zlib
-, buildPlatform, hostPlatform
-}:
+{ stdenv, fetchurl, zlib }:
 
-assert hostPlatform == buildPlatform -> zlib != null;
+assert stdenv.hostPlatform == stdenv.buildPlatform -> zlib != null;
 
 stdenv.mkDerivation rec {
   name = "libpng-1.2.57";
diff --git a/pkgs/development/libraries/libspotify/default.nix b/pkgs/development/libraries/libspotify/default.nix
index 3a01ff2944db..e472fe014ee7 100644
--- a/pkgs/development/libraries/libspotify/default.nix
+++ b/pkgs/development/libraries/libspotify/default.nix
@@ -2,26 +2,26 @@
 
 let
   version = "12.1.51";
-  isLinux = (stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux");
+  isLinux = (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "i686-linux");
 in
 
-if (stdenv.system != "x86_64-linux" && stdenv.system != "x86_64-darwin" && stdenv.system != "i686-linux")
+if (stdenv.hostPlatform.system != "x86_64-linux" && stdenv.hostPlatform.system != "x86_64-darwin" && stdenv.hostPlatform.system != "i686-linux")
 then throw "Check https://developer.spotify.com/technologies/libspotify/ for a tarball for your system and add it here"
 else stdenv.mkDerivation {
   name = "libspotify-${version}";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-x86_64-release.tar.gz";
         sha256 = "0n0h94i4xg46hfba95n3ypah93crwb80bhgsg00f6sms683lx8a3";
       }
-    else if stdenv.system == "x86_64-darwin" then
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then
       fetchurl {
         url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Darwin-universal.zip";
         sha256 = "1gcgrc8arim3hnszcc886lmcdb4iigc08abkaa02l6gng43ky1c0";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url    = "https://developer.spotify.com/download/libspotify/libspotify-${version}-Linux-i686-release.tar.gz";
         sha256 = "1bjmn64gbr4p9irq426yap4ipq9rb84zsyhjjr7frmmw22xb86ll";
@@ -46,7 +46,7 @@ else stdenv.mkDerivation {
 
 
   # darwin-specific
-  buildInputs = stdenv.lib.optional (stdenv.system == "x86_64-darwin") unzip;
+  buildInputs = stdenv.lib.optional (stdenv.hostPlatform.system == "x86_64-darwin") unzip;
 
   # linux-specific
   installFlags = stdenv.lib.optionalString (isLinux)
diff --git a/pkgs/development/libraries/libssh2/default.nix b/pkgs/development/libraries/libssh2/default.nix
index f85b709cf397..a6802a7f5183 100644
--- a/pkgs/development/libraries/libssh2/default.nix
+++ b/pkgs/development/libraries/libssh2/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurlBoot, openssl, zlib, windows
-, hostPlatform
-}:
+{ stdenv, fetchurlBoot, openssl, zlib, windows }:
 
 stdenv.mkDerivation rec {
   name = "libssh2-1.8.0";
@@ -13,7 +11,7 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" "devdoc" ];
 
   buildInputs = [ openssl zlib ]
-    ++ stdenv.lib.optional hostPlatform.isMinGW windows.mingw_w64;
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64;
 
   meta = {
     description = "A client-side C library implementing the SSH2 protocol";
diff --git a/pkgs/development/libraries/libvpx/default.nix b/pkgs/development/libraries/libvpx/default.nix
index 515aa2537443..cd0cc9798fa0 100644
--- a/pkgs/development/libraries/libvpx/default.nix
+++ b/pkgs/development/libraries/libvpx/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchFromGitHub, perl, yasm
-, hostPlatform
 , vp8DecoderSupport ? true # VP8 decoder
 , vp8EncoderSupport ? true # VP8 encoder
 , vp9DecoderSupport ? true # VP9 decoder
@@ -141,17 +140,17 @@ stdenv.mkDerivation rec {
     # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
     # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
     # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
-    "--force-target=${hostPlatform.config}${
-            if hostPlatform.isDarwin then
-              if      hostPlatform.osxMinVersion == "10.10" then "14"
-              else if hostPlatform.osxMinVersion == "10.9"  then "13"
-              else if hostPlatform.osxMinVersion == "10.8"  then "12"
-              else if hostPlatform.osxMinVersion == "10.7"  then "11"
-              else if hostPlatform.osxMinVersion == "10.6"  then "10"
-              else if hostPlatform.osxMinVersion == "10.5"  then "9"
+    "--force-target=${stdenv.hostPlatform.config}${
+            if stdenv.hostPlatform.isDarwin then
+              if      stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
+              else if stdenv.hostPlatform.osxMinVersion == "10.9"  then "13"
+              else if stdenv.hostPlatform.osxMinVersion == "10.8"  then "12"
+              else if stdenv.hostPlatform.osxMinVersion == "10.7"  then "11"
+              else if stdenv.hostPlatform.osxMinVersion == "10.6"  then "10"
+              else if stdenv.hostPlatform.osxMinVersion == "10.5"  then "9"
               else "8"
             else ""}-gcc"
-    (if hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
+    (if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
   ] # Experimental features
     ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
     ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
diff --git a/pkgs/development/libraries/libvpx/git.nix b/pkgs/development/libraries/libvpx/git.nix
index fb7f828f61f0..a39113e05b67 100644
--- a/pkgs/development/libraries/libvpx/git.nix
+++ b/pkgs/development/libraries/libvpx/git.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchgit, perl, yasm
-, hostPlatform
 , vp8DecoderSupport ? true # VP8 decoder
 , vp8EncoderSupport ? true # VP8 encoder
 , vp9DecoderSupport ? true # VP9 decoder
@@ -148,17 +147,17 @@ stdenv.mkDerivation rec {
       # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
       # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
       # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
-      "--force-target=${hostPlatform.config}${
-              if hostPlatform.isDarwin then
-                if      hostPlatform.osxMinVersion == "10.10" then "14"
-                else if hostPlatform.osxMinVersion == "10.9"  then "13"
-                else if hostPlatform.osxMinVersion == "10.8"  then "12"
-                else if hostPlatform.osxMinVersion == "10.7"  then "11"
-                else if hostPlatform.osxMinVersion == "10.6"  then "10"
-                else if hostPlatform.osxMinVersion == "10.5"  then "9"
+      "--force-target=${stdenv.hostPlatform.config}${
+              if stdenv.hostPlatform.isDarwin then
+                if      stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
+                else if stdenv.hostPlatform.osxMinVersion == "10.9"  then "13"
+                else if stdenv.hostPlatform.osxMinVersion == "10.8"  then "12"
+                else if stdenv.hostPlatform.osxMinVersion == "10.7"  then "11"
+                else if stdenv.hostPlatform.osxMinVersion == "10.6"  then "10"
+                else if stdenv.hostPlatform.osxMinVersion == "10.5"  then "9"
                 else "8"
               else ""}-gcc"
-      (if hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
+      (if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
   ] # Experimental features
     ++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
     ++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"
diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix
index 2f0f0f1425d1..c359ea10b665 100644
--- a/pkgs/development/libraries/libxml2/default.nix
+++ b/pkgs/development/libraries/libxml2/default.nix
@@ -1,9 +1,8 @@
 { stdenv, lib, fetchurl, fetchpatch
 , zlib, xz, python2, findXMLCatalogs
-, buildPlatform, hostPlatform
-, pythonSupport ? buildPlatform == hostPlatform
+, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
 , icuSupport ? false, icu ? null
-, enableShared ? hostPlatform.libc != "msvcrt"
+, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
 , enableStatic ? !enableShared,
 }:
 
@@ -56,7 +55,7 @@ in stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin &&
-    hostPlatform.libc != "musl";
+    stdenv.hostPlatform.libc != "musl";
 
   preInstall = lib.optionalString pythonSupport
     ''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 4dfdea582a25..6dc40bd45a0a 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -1,7 +1,6 @@
 { stdenv, fetchurl, libxml2, findXMLCatalogs, python2
-, buildPlatform, hostPlatform
 , cryptoSupport ? false
-, pythonSupport ? buildPlatform == hostPlatform
+, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
 }:
 
 assert pythonSupport -> python2 != null;
@@ -22,7 +21,7 @@ stdenv.mkDerivation rec {
   patches = stdenv.lib.optional stdenv.isSunOS ./patch-ah.patch;
 
   # fixes: can't build x86_64-unknown-cygwin shared library unless -no-undefined is specified
-  postPatch = optionalString hostPlatform.isCygwin ''
+  postPatch = optionalString stdenv.hostPlatform.isCygwin ''
     substituteInPlace tests/plugins/Makefile.in \
       --replace 'la_LDFLAGS =' 'la_LDFLAGS = $(WIN32_EXTRA_LDFLAGS)'
   '';
diff --git a/pkgs/development/libraries/live555/default.nix b/pkgs/development/libraries/live555/default.nix
index e0cf3328bac2..4dd5d8bcd26f 100644
--- a/pkgs/development/libraries/live555/default.nix
+++ b/pkgs/development/libraries/live555/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation {
       i686-linux = "linux";
       x86_64-linux = "linux-64bit";
       aarch64-linux = "linux-64bit";
-    }.${stdenv.system}}
+    }.${stdenv.hostPlatform.system}}
   '';
 
   installPhase = ''
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 50fb2daad70c..0a8a3c75a1c0 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -23,7 +23,7 @@
 
 with stdenv.lib;
 
-if ! lists.elem stdenv.system platforms.mesaPlatforms then
+if ! lists.elem stdenv.hostPlatform.system platforms.mesaPlatforms then
   throw "unsupported platform for Mesa"
 else
 
diff --git a/pkgs/development/libraries/microsoft_gsl/default.nix b/pkgs/development/libraries/microsoft_gsl/default.nix
index 1c10bd6f8fcd..c4c4d8e3a577 100644
--- a/pkgs/development/libraries/microsoft_gsl/default.nix
+++ b/pkgs/development/libraries/microsoft_gsl/default.nix
@@ -1,9 +1,8 @@
 { stdenv, fetchgit, cmake
-, hostPlatform, buildPlatform
 }:
 
 let
-  nativeBuild = hostPlatform == buildPlatform;
+  nativeBuild = stdenv.hostPlatform == stdenv.buildPlatform;
 in
 stdenv.mkDerivation rec {
   name = "microsoft_gsl-${version}";
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index afb44dd80f91..ea94a55a6199 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurl, gmp
-, hostPlatform
-}:
+{ stdenv, fetchurl, gmp }:
 
 stdenv.mkDerivation rec {
   version = "4.0.1";
@@ -17,8 +15,8 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ gmp ];
 
   configureFlags =
-    stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++
-    stdenv.lib.optional hostPlatform.is64bit "--with-pic";
+    stdenv.lib.optional stdenv.hostPlatform.isSunOS "--disable-thread-safe" ++
+    stdenv.lib.optional stdenv.hostPlatform.is64bit "--with-pic";
 
   doCheck = true; # not cross;
 
diff --git a/pkgs/development/libraries/msgpack/generic.nix b/pkgs/development/libraries/msgpack/generic.nix
index 67418b6666d4..306becf0c180 100644
--- a/pkgs/development/libraries/msgpack/generic.nix
+++ b/pkgs/development/libraries/msgpack/generic.nix
@@ -1,6 +1,5 @@
 { stdenv, cmake
 , version, src, patches ? [ ]
-, hostPlatform
 , ...
 }:
 
@@ -16,7 +15,7 @@ stdenv.mkDerivation rec {
   cmakeFlags = []
     ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
                            "-DMSGPACK_BUILD_EXAMPLES=OFF"
-    ++ stdenv.lib.optional (hostPlatform.libc == "msvcrt")
+    ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "msvcrt")
                            "-DCMAKE_SYSTEM_NAME=Windows"
     ;
 
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 861b387a993a..6293efcca8b2 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -8,7 +8,6 @@
 
 , gpm
 
-, buildPlatform, hostPlatform
 , buildPackages
 }:
 
@@ -36,7 +35,7 @@ stdenv.mkDerivation rec {
   ] ++ lib.optional unicode "--enable-widec"
     ++ lib.optional (!withCxx) "--without-cxx"
     ++ lib.optional (abiVersion == "5") "--with-abi-version=5"
-    ++ lib.optionals hostPlatform.isWindows [
+    ++ lib.optionals stdenv.hostPlatform.isWindows [
       "--enable-sp-funcs"
       "--enable-term-driver"
     ];
@@ -47,7 +46,7 @@ stdenv.mkDerivation rec {
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [
     pkgconfig
-  ] ++ lib.optionals (buildPlatform != hostPlatform) [
+  ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
     buildPackages.ncurses
   ];
   buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;
@@ -137,7 +136,7 @@ stdenv.mkDerivation rec {
     moveToOutput "bin/infotocap" "$out"
   '';
 
-  preFixup = lib.optionalString (!hostPlatform.isCygwin && !enableStatic) ''
+  preFixup = lib.optionalString (!stdenv.hostPlatform.isCygwin && !enableStatic) ''
     rm "$out"/lib/*.a
   '';
 
diff --git a/pkgs/development/libraries/nettle/generic.nix b/pkgs/development/libraries/nettle/generic.nix
index 3af93469cf16..2ef367b6c53a 100644
--- a/pkgs/development/libraries/nettle/generic.nix
+++ b/pkgs/development/libraries/nettle/generic.nix
@@ -16,11 +16,11 @@ stdenv.mkDerivation (rec {
   nativeBuildInputs = [ gnum4 ];
   propagatedBuildInputs = [ gmp ];
 
-  doCheck = (stdenv.system != "i686-cygwin" && !stdenv.isDarwin);
+  doCheck = (stdenv.hostPlatform.system != "i686-cygwin" && !stdenv.isDarwin);
 
   enableParallelBuilding = true;
 
-  patches = stdenv.lib.optional (stdenv.system == "i686-cygwin")
+  patches = stdenv.lib.optional (stdenv.hostPlatform.system == "i686-cygwin")
               ./cygwin.patch;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/nlohmann_json/default.nix b/pkgs/development/libraries/nlohmann_json/default.nix
index 0221722e4875..15bdbb1b48e8 100644
--- a/pkgs/development/libraries/nlohmann_json/default.nix
+++ b/pkgs/development/libraries/nlohmann_json/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchFromGitHub, cmake
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DBuildTests=${if doCheck then "ON" else "OFF"}"
-  ] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "-DCMAKE_SYSTEM_NAME=Windows"
   ];
 
diff --git a/pkgs/development/libraries/opencolorio/default.nix b/pkgs/development/libraries/opencolorio/default.nix
index 751d845f773e..42c0de4d493c 100644
--- a/pkgs/development/libraries/opencolorio/default.nix
+++ b/pkgs/development/libraries/opencolorio/default.nix
@@ -1,22 +1,39 @@
-{ stdenv, lib, fetchurl, cmake, unzip, boost }:
+{ stdenv, lib, fetchFromGitHub, cmake, boost, pkgconfig, lcms2, tinyxml, git }:
+
+with lib;
 
 stdenv.mkDerivation rec {
   name = "opencolorio-${version}";
   version = "1.1.0";
 
-  src = fetchurl {
-    url = "https://github.com/imageworks/OpenColorIO/archive/v1.0.9.zip";
-    sha256 = "1vi5pcgj7gv8fp6cdnhszwfh7lh38rl2rk4c5yzsvmgcb7xf48bx";
+  src = fetchFromGitHub {
+    owner = "imageworks";
+    repo = "OpenColorIO";
+    rev = "v${version}";
+    sha256 = "0cjsyn681xsg89lirlll5pqlsqg2vnk1278iiicmzjy2a2v8x7zq";
   };
 
   outputs = [ "bin" "out" "dev" ];
 
-  buildInputs = [ cmake unzip ] ++ lib.optional stdenv.isDarwin boost;
+  # TODO: Investigate whether git can be dropped: It's only used to apply patches
+  nativeBuildInputs = [ cmake pkgconfig git ];
+
+  buildInputs = [ lcms2 tinyxml ] ++ optional stdenv.isDarwin boost;
+
+  postPatch = ''
+    substituteInPlace src/core/CMakeLists.txt --replace "-Werror" ""
+    substituteInPlace src/pyglue/CMakeLists.txt --replace "-Werror" ""
+  '';
 
-  cmakeFlags = lib.optional stdenv.isDarwin "-DOCIO_USE_BOOST_PTR=ON";
+  cmakeFlags = [
+    "-DUSE_EXTERNAL_LCMS=ON"
+    "-DUSE_EXTERNAL_TINYXML=ON"
+    # External libyamlcpp 0.6.* not compatible: https://github.com/imageworks/OpenColorIO/issues/517
+    "-DUSE_EXTERNAL_YAML=OFF"
+  ] ++ optional stdenv.isDarwin "-DOCIO_USE_BOOST_PTR=ON"
+    ++ optional (!stdenv.hostPlatform.isi686 && !stdenv.hostPlatform.isx86_64) "-DOCIO_USE_SSE=OFF";
 
   postInstall = ''
-    rm $out/lib/*.a
     mkdir -p $bin/bin; mv $out/bin $bin/
   '';
 
diff --git a/pkgs/development/libraries/opencv/3.x.nix b/pkgs/development/libraries/opencv/3.x.nix
index e97aa0d391e0..81d106a2a40c 100644
--- a/pkgs/development/libraries/opencv/3.x.nix
+++ b/pkgs/development/libraries/opencv/3.x.nix
@@ -63,11 +63,11 @@ let
       sha256 = "1ys9mshfpm8iy8h4ml792gnqrq959dsrcv26axx14niivxyjbji8";
     } + "/ippicv";
     files = let name = platform : "ippicv_2017u3_${platform}_general_20180518.tgz"; in
-      if stdenv.system == "x86_64-linux" then
+      if stdenv.hostPlatform.system == "x86_64-linux" then
       { ${name "lnx_intel64"} = "b7cc351267db2d34b9efa1cd22ff0572"; }
-      else if stdenv.system == "i686-linux" then
+      else if stdenv.hostPlatform.system == "i686-linux" then
       { ${name "lnx_ia32"}    = "ea72de74dae3c604eb6348395366e78e"; }
-      else if stdenv.system == "x86_64-darwin" then
+      else if stdenv.hostPlatform.system == "x86_64-darwin" then
       { ${name "mac_intel64"} = "3ae52b9be0fe73dd45bc5e9429cd3732"; }
       else
       throw "ICV is not available for this platform (or not yet supported by this package)";
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 380c0c4af638..de13f963b674 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, buildPackages, perl
-, buildPlatform, hostPlatform
 , withCryptodev ? false, cryptodevHeaders
 , enableSSL2 ? false
 , static ? false
@@ -20,8 +19,8 @@ let
       (args.patches or [])
       ++ [ ./nix-ssl-cert-file.patch ]
       ++ optional (versionOlder version "1.1.0")
-          (if hostPlatform.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
-      ++ optional (versionOlder version "1.0.2" && hostPlatform.isDarwin)
+          (if stdenv.hostPlatform.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
+      ++ optional (versionOlder version "1.0.2" && stdenv.hostPlatform.isDarwin)
            ./darwin-arch.patch;
 
     postPatch = ''
@@ -40,7 +39,7 @@ let
 
     outputs = [ "bin" "dev" "out" "man" ];
     setOutputFlags = false;
-    separateDebugInfo = hostPlatform.isLinux;
+    separateDebugInfo = stdenv.hostPlatform.isLinux;
 
     nativeBuildInputs = [ perl ];
     buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
@@ -50,19 +49,19 @@ let
     configureScript = {
         "x86_64-darwin"  = "./Configure darwin64-x86_64-cc";
         "x86_64-solaris" = "./Configure solaris64-x86_64-gcc";
-      }.${hostPlatform.system} or (
-        if hostPlatform == buildPlatform
+      }.${stdenv.hostPlatform.system} or (
+        if stdenv.hostPlatform == stdenv.buildPlatform
           then "./config"
-        else if hostPlatform.isMinGW
+        else if stdenv.hostPlatform.isMinGW
           then "./Configure mingw${optionalString
-                                     (hostPlatform.parsed.cpu.bits != 32)
-                                     (toString hostPlatform.parsed.cpu.bits)}"
-        else if hostPlatform.isLinux
-          then "./Configure linux-generic${toString hostPlatform.parsed.cpu.bits}"
-        else if hostPlatform.isiOS
-          then "./Configure ios${toString hostPlatform.parsed.cpu.bits}-cross"
+                                     (stdenv.hostPlatform.parsed.cpu.bits != 32)
+                                     (toString stdenv.hostPlatform.parsed.cpu.bits)}"
+        else if stdenv.hostPlatform.isLinux
+          then "./Configure linux-generic${toString stdenv.hostPlatform.parsed.cpu.bits}"
+        else if stdenv.hostPlatform.isiOS
+          then "./Configure ios${toString stdenv.hostPlatform.parsed.cpu.bits}-cross"
         else
-          throw "Not sure what configuration to use for ${hostPlatform.config}"
+          throw "Not sure what configuration to use for ${stdenv.hostPlatform.config}"
       );
 
     configureFlags = [
@@ -73,7 +72,7 @@ let
       "-DHAVE_CRYPTODEV"
       "-DUSE_CRYPTODEV_DIGESTS"
     ] ++ stdenv.lib.optional enableSSL2 "enable-ssl2"
-      ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && hostPlatform.isAarch64) "no-afalgeng";
+      ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && stdenv.hostPlatform.isAarch64) "no-afalgeng";
 
     makeFlags = [ "MANDIR=$(man)/share/man" ];
 
diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix
index 0c05e2ec5f61..fe260e0c2ad2 100644
--- a/pkgs/development/libraries/oracle-instantclient/default.nix
+++ b/pkgs/development/libraries/oracle-instantclient/default.nix
@@ -14,12 +14,12 @@ let
     sha256 = hash;
   });
 
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   arch = {
     "x86_64-linux" = "linux.x64";
     "x86_64-darwin" = "macos.x64";
-  }."${stdenv.system}" or throwSystem;
+  }."${stdenv.hostPlatform.system}" or throwSystem;
 
   srcs = {
     "x86_64-linux" = [
@@ -32,7 +32,7 @@ let
       (requireSource "sdk" arch version "2" "e0befca9c4e71ebc9f444957ffa70f01aeeec5976ea27c40406471b04c34848b")
       (requireSource "sqlplus" arch version "2" "d147cbb5b2a954fdcb4b642df4f0bd1153fd56e0f56e7fa301601b4f7e2abe0e") ]
       ++ optional odbcSupport (requireSource "odbc" arch version "2" "1805c1ab6c8c5e8df7bdcc35d7f2b94c329ecf4dff9bde55d5f9b159ecd8b64e");
-  }."${stdenv.system}" or throwSystem;
+  }."${stdenv.hostPlatform.system}" or throwSystem;
 
   extLib = stdenv.hostPlatform.extensions.sharedLibrary;
 in stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 04104346748e..f9bd4ae91b46 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl
 , pcre, windows ? null
-, buildPlatform, hostPlatform
 , variant ? null
 }:
 
@@ -24,13 +23,13 @@ in stdenv.mkDerivation rec {
 
   outputs = [ "bin" "dev" "out" "doc" "man" ];
 
-  configureFlags = optional (!hostPlatform.isRiscV) "--enable-jit" ++ [
+  configureFlags = optional (!stdenv.hostPlatform.isRiscV) "--enable-jit" ++ [
     "--enable-unicode-properties"
     "--disable-cpp"
   ]
     ++ optional (variant != null) "--enable-${variant}";
 
-  buildInputs = optional (hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads;
+  buildInputs = optional (stdenv.hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads;
 
   # https://bugs.exim.org/show_bug.cgi?id=2173
   patches = [ ./stacksize-detection.patch ];
@@ -39,7 +38,7 @@ in stdenv.mkDerivation rec {
     patchShebangs RunGrepTest
   '';
 
-  doCheck = !(with hostPlatform; isCygwin || isFreeBSD) && hostPlatform == buildPlatform;
+  doCheck = !(with stdenv.hostPlatform; isCygwin || isFreeBSD) && stdenv.hostPlatform == stdenv.buildPlatform;
     # XXX: test failure on Cygwin
     # we are running out of stack on both freeBSDs on Hydra
 
diff --git a/pkgs/development/libraries/physics/geant4/fetch.nix b/pkgs/development/libraries/physics/geant4/fetch.nix
index 7dc4c8656279..5d539b480d7d 100644
--- a/pkgs/development/libraries/physics/geant4/fetch.nix
+++ b/pkgs/development/libraries/physics/geant4/fetch.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl }:
 
 let
-  fetch = { version, src ? builtins.getAttr stdenv.system sources, sources ? null }:
+  fetch = { version, src ? builtins.getAttr stdenv.hostPlatform.system sources, sources ? null }:
   {
     inherit version src;
   };
diff --git a/pkgs/development/libraries/readline/6.2.nix b/pkgs/development/libraries/readline/6.2.nix
index 2c800e23b27f..e97b31896c1d 100644
--- a/pkgs/development/libraries/readline/6.2.nix
+++ b/pkgs/development/libraries/readline/6.2.nix
@@ -1,5 +1,4 @@
 { fetchurl, stdenv, ncurses
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation (rec {
@@ -59,6 +58,6 @@ stdenv.mkDerivation (rec {
 //
 
 # Don't run the native `strip' when cross-compiling.
-(if hostPlatform != buildPlatform
+(if stdenv.hostPlatform != stdenv.buildPlatform
  then { dontStrip = true; }
  else { }))
diff --git a/pkgs/development/libraries/readline/6.3.nix b/pkgs/development/libraries/readline/6.3.nix
index 75c25e12d667..cfa70f423db3 100644
--- a/pkgs/development/libraries/readline/6.3.nix
+++ b/pkgs/development/libraries/readline/6.3.nix
@@ -1,6 +1,4 @@
-{ fetchurl, stdenv, ncurses
-, buildPlatform, hostPlatform
-}:
+{ fetchurl, stdenv, ncurses }:
 
 stdenv.mkDerivation rec {
   name = "readline-6.3p08";
@@ -37,7 +35,7 @@ stdenv.mkDerivation rec {
        import ./readline-6.3-patches.nix patch);
 
   # Don't run the native `strip' when cross-compiling.
-  dontStrip = hostPlatform != buildPlatform;
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
   bash_cv_func_sigsetjmp = if stdenv.isCygwin then "missing" else null;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/readline/7.0.nix b/pkgs/development/libraries/readline/7.0.nix
index a7306010a8b5..9c0c3d31b4b6 100644
--- a/pkgs/development/libraries/readline/7.0.nix
+++ b/pkgs/development/libraries/readline/7.0.nix
@@ -1,5 +1,4 @@
 { fetchurl, stdenv, ncurses
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -34,7 +33,7 @@ stdenv.mkDerivation rec {
     ++ upstreamPatches;
 
   # Don't run the native `strip' when cross-compiling.
-  dontStrip = hostPlatform != buildPlatform;
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
   bash_cv_func_sigsetjmp = if stdenv.isCygwin then "missing" else null;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index b258d2e5a9cc..3f271d015027 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -67,15 +67,15 @@ in
 
 let
   config =
-    configs.${stdenv.system}
-    or (throw "unsupported system: ${stdenv.system}");
+    configs.${stdenv.hostPlatform.system}
+    or (throw "unsupported system: ${stdenv.hostPlatform.system}");
 in
 
 let
   blas64 =
     if blas64_ != null
       then blas64_
-      else hasPrefix "x86_64" stdenv.system;
+      else hasPrefix "x86_64" stdenv.hostPlatform.system;
 in
 stdenv.mkDerivation rec {
   name = "openblas-${version}";
diff --git a/pkgs/development/libraries/scmccid/default.nix b/pkgs/development/libraries/scmccid/default.nix
index f88bd64f597b..b305fecc3933 100644
--- a/pkgs/development/libraries/scmccid/default.nix
+++ b/pkgs/development/libraries/scmccid/default.nix
@@ -5,11 +5,11 @@ assert stdenv ? cc && stdenv.cc.libc != null;
 stdenv.mkDerivation rec {
   name = "scmccid-5.0.11";
 
-  src = if stdenv.system == "i686-linux" then (fetchurl {
+  src = if stdenv.hostPlatform.system == "i686-linux" then (fetchurl {
       url = "http://www.scmmicro.com/support/download/scmccid_5.0.11_linux.tar.gz";
       sha256 = "1r5wkarhzl09ncgj55baizf573czw0nplh1pgddzx9xck66kh5bm";
     })
-    else if stdenv.system == "x86_64-linux" then (fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
         url = "http://www.scmmicro.com/support/download/scmccid_5.0.11_linux_x64.tar.gz";
         sha256 = "0k9lzlk01sl4ycfqgrqqy3bildz0mcr1r0kkicgjz96l4s0jgz0i";
     })
diff --git a/pkgs/development/libraries/skalibs/default.nix b/pkgs/development/libraries/skalibs/default.nix
index b3f5e12b0ecd..9d5bd170e20d 100644
--- a/pkgs/development/libraries/skalibs/default.nix
+++ b/pkgs/development/libraries/skalibs/default.nix
@@ -33,7 +33,7 @@ in stdenv.mkDerivation rec {
   # Explicitly setting target ensures code can be compiled against a skalibs
   # binary built on a different version of darwin.
   # http://www.skarnet.org/cgi-bin/archive.cgi?1:mss:623:heiodchokfjdkonfhdph
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/skalibs
diff --git a/pkgs/development/libraries/tachyon/default.nix b/pkgs/development/libraries/tachyon/default.nix
index d5d12e44df0a..27ac0fdd5ff9 100644
--- a/pkgs/development/libraries/tachyon/default.nix
+++ b/pkgs/development/libraries/tachyon/default.nix
@@ -34,15 +34,15 @@ stdenv.mkDerivation rec {
     export USEPNG=" -DUSEPNG"
     export PNGLIB=" -lpng -lz"
   '';
-  arch = if stdenv.system == "x86_64-linux"   then "linux-64-thr"  else
-         if stdenv.system == "i686-linux"     then "linux-thr"     else
-         if stdenv.system == "aarch64-linux"  then "linux-arm-thr" else
-         if stdenv.system == "armv7l-linux"   then "linux-arm-thr" else
-         if stdenv.system == "x86_64-darwin"  then "macosx-thr"    else
-         if stdenv.system == "i686-darwin"    then "macosx-64-thr" else
-         if stdenv.system == "i686-cygwin"    then "win32"         else
-         if stdenv.system == "x86_64-freebsd" then "bsd"           else
-         if stdenv.system == "x686-freebsd"   then "bsd"           else
+  arch = if stdenv.hostPlatform.system == "x86_64-linux"   then "linux-64-thr"  else
+         if stdenv.hostPlatform.system == "i686-linux"     then "linux-thr"     else
+         if stdenv.hostPlatform.system == "aarch64-linux"  then "linux-arm-thr" else
+         if stdenv.hostPlatform.system == "armv7l-linux"   then "linux-arm-thr" else
+         if stdenv.hostPlatform.system == "x86_64-darwin"  then "macosx-thr"    else
+         if stdenv.hostPlatform.system == "i686-darwin"    then "macosx-64-thr" else
+         if stdenv.hostPlatform.system == "i686-cygwin"    then "win32"         else
+         if stdenv.hostPlatform.system == "x86_64-freebsd" then "bsd"           else
+         if stdenv.hostPlatform.system == "x686-freebsd"   then "bsd"           else
          throw "Don't know what arch to select for tachyon build";
   makeFlags = "${arch}";
   patches = [
diff --git a/pkgs/development/libraries/v8/3.14.nix b/pkgs/development/libraries/v8/3.14.nix
index ce666becc855..827274251ed9 100644
--- a/pkgs/development/libraries/v8/3.14.nix
+++ b/pkgs/development/libraries/v8/3.14.nix
@@ -65,7 +65,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     install -vD out/Release/d8 "$out/bin/d8"
-    ${if stdenv.system == "x86_64-darwin" then ''
+    ${if stdenv.hostPlatform.system == "x86_64-darwin" then ''
     install -vD out/Release/lib.target/libv8.dylib "$out/lib/libv8.dylib"
     '' else ''
     install -vD out/Release/lib.target/libv8.so "$out/lib/libv8.so"
diff --git a/pkgs/development/libraries/vigra/default.nix b/pkgs/development/libraries/vigra/default.nix
index 4a002becdb3b..12c166beacbd 100644
--- a/pkgs/development/libraries/vigra/default.nix
+++ b/pkgs/development/libraries/vigra/default.nix
@@ -21,7 +21,7 @@ in stdenv.mkDerivation rec {
   preConfigure = "cmakeFlags+=\" -DVIGRANUMPY_INSTALL_DIR=$out/lib/${python.libPrefix}/site-packages\"";
 
   cmakeFlags = [ "-DWITH_OPENEXR=1" ]
-            ++ stdenv.lib.optionals (stdenv.system == "x86_64-linux")
+            ++ stdenv.lib.optionals (stdenv.hostPlatform.system == "x86_64-linux")
                   [ "-DCMAKE_CXX_FLAGS=-fPIC" "-DCMAKE_C_FLAGS=-fPIC" ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/vxl/default.nix b/pkgs/development/libraries/vxl/default.nix
index b9f3c0e64d6c..777b8bb1f403 100644
--- a/pkgs/development/libraries/vxl/default.nix
+++ b/pkgs/development/libraries/vxl/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   # in stdenv linux headers
   # BUILD_BRL fails to find open()
   cmakeFlags = "-DBUILD_TESTING=OFF -DBUILD_OUL=OFF -DBUILD_BRL=OFF -DBUILD_CONTRIB=OFF "
-    + (if stdenv.system == "x86_64-linux" then
+    + (if stdenv.hostPlatform.system == "x86_64-linux" then
       "-DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC"
     else
       "");
diff --git a/pkgs/development/libraries/wtk/default.nix b/pkgs/development/libraries/wtk/default.nix
index 0ed4f24ef86b..2791c97f5ae6 100644
--- a/pkgs/development/libraries/wtk/default.nix
+++ b/pkgs/development/libraries/wtk/default.nix
@@ -1,6 +1,6 @@
 { stdenv, requireFile, unzip, xorg }:
 
-assert stdenv.system == "i686-linux";
+assert stdenv.hostPlatform.system == "i686-linux";
 
 stdenv.mkDerivation rec {
   name = "sun-java-wtk-2.5.2_01";
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index fa6b8fb13b5a..d3fb0970cd00 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchurl
-, buildPlatform, hostPlatform
 , static ? false
 }:
 
@@ -16,9 +15,9 @@ stdenv.mkDerivation rec {
     sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1";
   };
 
-  patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch;
+  patches = stdenv.lib.optional stdenv.hostPlatform.isCygwin ./disable-cygwin-widechar.patch;
 
-  postPatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+  postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
     substituteInPlace configure \
       --replace '/usr/bin/libtool' 'ar' \
       --replace 'AR="libtool"' 'AR="ar"' \
@@ -37,25 +36,25 @@ stdenv.mkDerivation rec {
     # jww (2015-01-06): Sometimes this library install as a .so, even on
     # Darwin; others time it installs as a .dylib.  I haven't yet figured out
     # what causes this difference.
-  + stdenv.lib.optionalString hostPlatform.isDarwin ''
+  + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
     for file in $out/lib/*.so* $out/lib/*.dylib* ; do
       install_name_tool -id "$file" $file
     done
   ''
     # Non-typical naming confuses libtool which then refuses to use zlib's DLL
     # in some cases, e.g. when compiling libpng.
-  + stdenv.lib.optionalString (hostPlatform.libc == "msvcrt") ''
+  + stdenv.lib.optionalString (stdenv.hostPlatform.libc == "msvcrt") ''
     ln -s zlib1.dll $out/bin/libz.dll
   '';
 
   # As zlib takes part in the stdenv building, we don't want references
   # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!hostPlatform.isDarwin) "-static-libgcc";
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.hostPlatform.isDarwin) "-static-libgcc";
 
-  dontStrip = hostPlatform != buildPlatform && static;
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static;
   configurePlatforms = [];
 
-  installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
+  installFlags = stdenv.lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "BINARY_PATH=$(out)/bin"
     "INCLUDE_PATH=$(dev)/include"
     "LIBRARY_PATH=$(out)/lib"
@@ -63,7 +62,7 @@ stdenv.mkDerivation rec {
 
   makeFlags = [
     "PREFIX=${stdenv.cc.targetPrefix}"
-  ] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "-f" "win32/Makefile.gcc"
   ] ++ stdenv.lib.optionals (!static) [
     "SHARED_MODE=1"
diff --git a/pkgs/development/misc/amdapp-sdk/default.nix b/pkgs/development/misc/amdapp-sdk/default.nix
index 7da0fc148d42..79651db23ea4 100644
--- a/pkgs/development/misc/amdapp-sdk/default.nix
+++ b/pkgs/development/misc/amdapp-sdk/default.nix
@@ -5,10 +5,10 @@
 
 let
 
-  bits = if stdenv.system == "x86_64-linux" then "64"
+  bits = if stdenv.hostPlatform.system == "x86_64-linux" then "64"
          else "32";
 
-  arch = if stdenv.system == "x86_64-linux" then "x86_64"
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64"
          else "x86";
 
   src_info = {
diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix
index 0f43705c0d42..e4ea9508aeb9 100644
--- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix
+++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix
@@ -1,4 +1,4 @@
-{ lib, hostPlatform, targetPlatform
+{ lib
 , makeWrapper
 , runCommand, wrapBintoolsWith, wrapCCWith
 , buildAndroidndk, androidndk, targetAndroidndkPkgs
@@ -33,8 +33,8 @@ let
   }.${config} or
     (throw "Android NDK doesn't support ${config}, as far as we know");
 
-  hostInfo = ndkInfoFun hostPlatform;
-  targetInfo = ndkInfoFun targetPlatform;
+  hostInfo = ndkInfoFun stdenv.hostPlatform;
+  targetInfo = ndkInfoFun stdenv.targetPlatform;
 
 in
 
@@ -51,7 +51,7 @@ rec {
       mkdir -p $out/bin
       for prog in ${ndkBinDir}/${targetInfo.triple}-*; do
         prog_suffix=$(basename $prog | sed 's/${targetInfo.triple}-//')
-        ln -s $prog $out/bin/${targetPlatform.config}-$prog_suffix
+        ln -s $prog $out/bin/${stdenv.targetPlatform.config}-$prog_suffix
       done
     '';
 
@@ -68,11 +68,11 @@ rec {
     bintools = binutils;
     libc = targetAndroidndkPkgs.libraries;
     extraBuildCommands = ''
-      echo "-D__ANDROID_API__=${targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags
+      echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags
     ''
-    + lib.optionalString targetPlatform.isAarch32 (let
-        p =  targetPlatform.platform.gcc or {}
-          // targetPlatform.parsed.abi;
+    + lib.optionalString stdenv.targetPlatform.isAarch32 (let
+        p =  stdenv.targetPlatform.platform.gcc or {}
+          // stdenv.targetPlatform.parsed.abi;
         flags = lib.concatLists [
           (lib.optional (p ? arch) "-march=${p.arch}")
           (lib.optional (p ? cpu) "-mcpu=${p.cpu}")
@@ -84,10 +84,10 @@ rec {
         ];
       in ''
         sed -E -i \
-          $out/bin/${targetPlatform.config}-cc \
-          $out/bin/${targetPlatform.config}-c++ \
-          $out/bin/${targetPlatform.config}-gcc \
-          $out/bin/${targetPlatform.config}-g++ \
+          $out/bin/${stdenv.targetPlatform.config}-cc \
+          $out/bin/${stdenv.targetPlatform.config}-c++ \
+          $out/bin/${stdenv.targetPlatform.config}-gcc \
+          $out/bin/${stdenv.targetPlatform.config}-g++ \
           -e '130i    extraBefore+=(-Wl,--fix-cortex-a8)' \
           -e 's|^(extraBefore=)\(\)$|\1(${builtins.toString flags})|'
       '')
@@ -107,10 +107,10 @@ rec {
   libraries =
     let
       includePath = if buildAndroidndk.version == "10e" then
-          "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/include/"
+          "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/include/"
         else
           "${buildAndroidndk}/libexec/${buildAndroidndk.name}/sysroot/usr/include";
-      libPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
+      libPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
     in
     runCommand "bionic-prebuilt" {} ''
       mkdir -p $out
diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix
index 972c8a5dfbce..3ccdb237f894 100644
--- a/pkgs/development/mobile/androidenv/androidndk.nix
+++ b/pkgs/development/mobile/androidenv/androidndk.nix
@@ -10,10 +10,10 @@ stdenv.mkDerivation rec {
   name = "android-ndk-r${version}";
   inherit version;
 
-  src = if stdenv.system == "x86_64-linux" then fetchurl {
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
       url = "https://dl.google.com/android/repository/${name}-linux-x86_64.zip";
       inherit sha256;
-    } else throw "platform ${stdenv.system} not supported!";
+    } else throw "platform ${stdenv.hostPlatform.system} not supported!";
 
   phases = "buildPhase";
 
diff --git a/pkgs/development/mobile/androidenv/androidndk_r8e.nix b/pkgs/development/mobile/androidenv/androidndk_r8e.nix
index 3c12e16277d9..68d2150f972e 100644
--- a/pkgs/development/mobile/androidenv/androidndk_r8e.nix
+++ b/pkgs/development/mobile/androidenv/androidndk_r8e.nix
@@ -9,16 +9,16 @@
 stdenv.mkDerivation rec {
   name = "android-ndk-r8e";
 
-  src = if stdenv.system == "i686-linux"
+  src = if stdenv.hostPlatform.system == "i686-linux"
     then fetchurl {
       url = "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2";
       sha256 = "c2c4e0c8b3037149a0f5dbb08d72f814a52af4da9fff9d80328c675457e95a98";
     }
-    else if stdenv.system == "x86_64-linux" then fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
       url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2";
       sha256 = "093gf55zbh38p2gk5bdykj1vg9p5l774wjdzw5mhk4144jm1wdq7";
     }
-    else throw "platform ${stdenv.system} not supported!";
+    else throw "platform ${stdenv.hostPlatform.system} not supported!";
 
   phases = "buildPhase";
 
diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix
index 503e4f5c889b..5f61f25d54ee 100644
--- a/pkgs/development/mobile/androidenv/androidsdk.nix
+++ b/pkgs/development/mobile/androidenv/androidsdk.nix
@@ -22,16 +22,16 @@ stdenv.mkDerivation rec {
   name = "android-sdk-${version}";
   version = "25.2.5";
 
-  src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+  src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
     then fetchurl {
       url = "https://dl.google.com/android/repository/tools_r${version}-linux.zip";
       sha256 = "0gnk49pkwy4m0nqwm1xnf3w4mfpi9w0kk7841xlawpwbkj0icxap";
     }
-    else if stdenv.system == "x86_64-darwin" then fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
       url = "http://dl.google.com/android/repository/tools_r${version}-macosx.zip";
       sha256 = "0yg7wjmyw70xsh8k4hgbqb5rilam2a94yc8dwbh7fjwqcmpxgwqb";
     }
-    else throw "platform not ${stdenv.system} supported!";
+    else throw "platform not ${stdenv.hostPlatform.system} supported!";
 
   buildCommand = ''
     mkdir -p $out/libexec
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
         sed -i -e "s|/bin/ls|${coreutils}/bin/ls|" "$f"
     done
 
-    ${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
     ''
       # There are a number of native binaries. We must patch them to let them find the interpreter and libstdc++
 
@@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
           patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib $i
       done
 
-      ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
+      ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
         for i in bin64/{mkfs.ext4,fsck.ext4,e2fsck,tune2fs,resize2fs}
         do
             patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
@@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
         done
       ''}
 
-      ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
+      ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
         # We must also patch the 64-bit emulator instances, if needed
 
         for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-*
@@ -89,7 +89,7 @@ stdenv.mkDerivation rec {
 
       # The emulators need additional libraries, which are dynamically loaded => let's wrap them
 
-      ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
+      ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
         for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service
         do
             wrapProgram `pwd`/$i \
@@ -102,7 +102,7 @@ stdenv.mkDerivation rec {
 
     patchShebangs .
 
-    ${if stdenv.system == "i686-linux" then
+    ${if stdenv.hostPlatform.system == "i686-linux" then
       ''
         # The monitor requires some more patching
 
@@ -115,7 +115,7 @@ stdenv.mkDerivation rec {
 
         cd ../..
       ''
-      else if stdenv.system == "x86_64-linux" then
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
       ''
         # The monitor requires some more patching
 
diff --git a/pkgs/development/mobile/androidenv/build-tools.nix b/pkgs/development/mobile/androidenv/build-tools.nix
index 457a9b6720af..85e604bd3f44 100644
--- a/pkgs/development/mobile/androidenv/build-tools.nix
+++ b/pkgs/development/mobile/androidenv/build-tools.nix
@@ -3,16 +3,16 @@
 stdenv.mkDerivation rec {
   version = "26.0.2";
   name = "android-build-tools-r${version}";
-  src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+  src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
     then fetchurl {
       url = "https://dl.google.com/android/repository/build-tools_r${version}-linux.zip";
       sha256 = "1kii880bwhjkc343zwx1ysxyisxhczrwhphnxbwsgi45mjgq8lm7";
     }
-    else if stdenv.system == "x86_64-darwin" then fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
       url = "https://dl.google.com/android/repository/build-tools_r${version}-macosx.zip";
       sha256 = "1x0ycprl6hgsm23kck5ind7x00hzydc5k3h3ch4a13407xbpvzvx";
     }
-    else throw "System ${stdenv.system} not supported!";
+    else throw "System ${stdenv.hostPlatform.system} not supported!";
 
   buildCommand = ''
     mkdir -p $out/build-tools
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     unzip $src
     mv android-* ${version}
 
-    ${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
       ''
         cd ${version}
 
diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix
index 7d7c92cd0f57..4e9f139b95e9 100644
--- a/pkgs/development/mobile/androidenv/default.nix
+++ b/pkgs/development/mobile/androidenv/default.nix
@@ -25,15 +25,15 @@ rec {
     inherit (pkgs) stdenv fetchurl unzip;
   };
 
-  platforms = if (pkgs.stdenv.system == "i686-linux" || pkgs.stdenv.system == "x86_64-linux")
+  platforms = if (pkgs.stdenv.hostPlatform.system == "i686-linux" || pkgs.stdenv.hostPlatform.system == "x86_64-linux")
     then import ./platforms-linux.nix {
       inherit (pkgs) stdenv fetchurl unzip;
     }
-    else if pkgs.stdenv.system == "x86_64-darwin"
+    else if pkgs.stdenv.hostPlatform.system == "x86_64-darwin"
     then import ./platforms-macosx.nix {
       inherit (pkgs) stdenv fetchurl unzip;
     }
-    else throw "Platform: ${pkgs.stdenv.system} not supported!";
+    else throw "Platform: ${pkgs.stdenv.hostPlatform.system} not supported!";
 
   sysimages = import ./sysimages.nix {
     inherit (pkgs) stdenv fetchurl unzip;
diff --git a/pkgs/development/mobile/androidenv/platform-tools.nix b/pkgs/development/mobile/androidenv/platform-tools.nix
index f5e579942846..22b5cd81f870 100644
--- a/pkgs/development/mobile/androidenv/platform-tools.nix
+++ b/pkgs/development/mobile/androidenv/platform-tools.nix
@@ -8,16 +8,16 @@ in
 stdenv.mkDerivation rec {
   version = "26.0.2";
   name = "android-platform-tools-r${version}";
-  src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+  src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
     then fetchurl {
       url = "https://dl.google.com/android/repository/platform-tools_r${version}-linux.zip";
       sha256 = "0695npvxljbbh8xwfm65k34fcpyfkzvfkssgnp46wkmnq8w5mcb3";
     }
-    else if stdenv.system == "x86_64-darwin" then fetchurl {
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
       url = "https://dl.google.com/android/repository/platform-tools_r${version}-darwin.zip";
       sha256 = "0gy7apw9pmnnm41z6ywglw5va4ghmny4j57778may4q7ar751l56";
     }
-    else throw "System ${stdenv.system} not supported!";
+    else throw "System ${stdenv.hostPlatform.system} not supported!";
 
   buildCommand = ''
     mkdir -p $out
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
     unzip $src
     cd platform-tools
 
-    ${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
       ''
         for i in adb dmtracedump fastboot hprof-conv sqlite3
         do
diff --git a/pkgs/development/mobile/titaniumenv/build-app.nix b/pkgs/development/mobile/titaniumenv/build-app.nix
index 83bd941e5ffa..0250e5bf2e28 100644
--- a/pkgs/development/mobile/titaniumenv/build-app.nix
+++ b/pkgs/development/mobile/titaniumenv/build-app.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   name = stdenv.lib.replaceChars [" "] [""] name;
   inherit src;
 
-  buildInputs = [ nodejs titanium alloy jdk python which file ] ++ stdenv.lib.optional (stdenv.system == "x86_64-darwin") xcodewrapper;
+  buildInputs = [ nodejs titanium alloy jdk python which file ] ++ stdenv.lib.optional (stdenv.hostPlatform.system == "x86_64-darwin") xcodewrapper;
   
   buildPhase = ''
     ${preBuild}
diff --git a/pkgs/development/mobile/titaniumenv/default.nix b/pkgs/development/mobile/titaniumenv/default.nix
index b09a483290f7..f411a8d61fd0 100644
--- a/pkgs/development/mobile/titaniumenv/default.nix
+++ b/pkgs/development/mobile/titaniumenv/default.nix
@@ -3,7 +3,7 @@
 rec {
   androidenv = pkgs.androidenv;
 
-  xcodeenv = if pkgs.stdenv.system == "x86_64-darwin" then pkgs.xcodeenv.override {
+  xcodeenv = if pkgs.stdenv.hostPlatform.system == "x86_64-darwin" then pkgs.xcodeenv.override {
     version = xcodeVersion;
     inherit xcodeBaseDir;
   } else null;
diff --git a/pkgs/development/mobile/titaniumenv/titaniumsdk-6.3.nix b/pkgs/development/mobile/titaniumenv/titaniumsdk-6.3.nix
index 26adf373826e..b8c2688708bb 100644
--- a/pkgs/development/mobile/titaniumenv/titaniumsdk-6.3.nix
+++ b/pkgs/development/mobile/titaniumenv/titaniumsdk-6.3.nix
@@ -2,15 +2,15 @@
 
 stdenv.mkDerivation {
   name = "mobilesdk-6.3.1.GA";
-  src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") then fetchurl {
+  src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux") then fetchurl {
     url = http://builds.appcelerator.com/mobile/6_3_X/mobilesdk-6.3.1.v20171101154403-linux.zip;
     sha256 = "0g8dqqf5ffa7ll3rqm5naywipnv2vvfxcj9fmqg1wnvvxf0rflqj";
   }
-  else if stdenv.system == "x86_64-darwin" then fetchurl {
+  else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
     url = http://builds.appcelerator.com/mobile/6_3_X/mobilesdk-6.3.1.v20171101154403-osx.zip;
     sha256 = "00bm8vv70mg4kd7jvmxd1bfqafv6zdpdx816i0hvf801zwnak4nj";
   }
-  else throw "Platform: ${stdenv.system} not supported!";
+  else throw "Platform: ${stdenv.hostPlatform.system} not supported!";
   
   buildInputs = [ unzip makeWrapper ];
   
@@ -23,18 +23,18 @@ stdenv.mkDerivation {
     cd mobilesdk/*
     mv * 6.3.1.GA
     cd *
-    ${stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") ''
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-darwin") ''
       # Fixes a bad archive copying error when generating an IPA file
       sed -i -e "s|cp -rf|/bin/cp -rf|" iphone/cli/commands/_build.js
     ''}
 
     # Patch some executables
     
-    ${if stdenv.system == "i686-linux" then
+    ${if stdenv.hostPlatform.system == "i686-linux" then
       ''
         patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
       ''
-      else if stdenv.system == "x86_64-linux" then
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
       ''
         patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
       ''
diff --git a/pkgs/development/mobile/titaniumenv/titaniumsdk-7.1.nix b/pkgs/development/mobile/titaniumenv/titaniumsdk-7.1.nix
index a6de1f0ae8c6..4d3bd420969c 100644
--- a/pkgs/development/mobile/titaniumenv/titaniumsdk-7.1.nix
+++ b/pkgs/development/mobile/titaniumenv/titaniumsdk-7.1.nix
@@ -54,15 +54,15 @@ let
 in
 stdenv.mkDerivation {
   name = "mobilesdk-7.1.0.GA";
-  src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") then fetchurl {
+  src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux") then fetchurl {
     url = http://builds.appcelerator.com/mobile/7_1_X/mobilesdk-7.1.0.v20180314133955-linux.zip;
     sha256 = "18b3jnr65sdn5wj191bcl48gvhyklxmighxakv4vrz1fb59kyvqn";
   }
-  else if stdenv.system == "x86_64-darwin" then fetchurl {
+  else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
     url = http://builds.appcelerator.com/mobile/7_1_X/mobilesdk-7.1.0.v20180314133955-osx.zip;
     sha256 = "1f62616biwsw1fqxz2sq7lpa6bsfjazffliplyf5dpnh298cnc1m";
   }
-  else throw "Platform: ${stdenv.system} not supported!";
+  else throw "Platform: ${stdenv.hostPlatform.system} not supported!";
 
   buildInputs = [ unzip makeWrapper ];
 
@@ -89,11 +89,11 @@ stdenv.mkDerivation {
 
     # Patch some executables
 
-    ${if stdenv.system == "i686-linux" then
+    ${if stdenv.hostPlatform.system == "i686-linux" then
       ''
         patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
       ''
-      else if stdenv.system == "x86_64-linux" then
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
       ''
         patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
       ''
diff --git a/pkgs/development/node-packages/default-v10.nix b/pkgs/development/node-packages/default-v10.nix
index d7df19066bb3..a438c961513f 100644
--- a/pkgs/development/node-packages/default-v10.nix
+++ b/pkgs/development/node-packages/default-v10.nix
@@ -1,8 +1,9 @@
-{pkgs, system, nodejs, stdenv}:
+{ pkgs, nodejs, stdenv }:
 
 let
   nodePackages = import ./composition-v10.nix {
-    inherit pkgs system nodejs;
+    inherit pkgs nodejs;
+    inherit (stdenv.hostPlatform) system;
   };
 in
 nodePackages // {
diff --git a/pkgs/development/node-packages/default-v6.nix b/pkgs/development/node-packages/default-v6.nix
index 6b508b6f0cce..f4e28d0fd341 100644
--- a/pkgs/development/node-packages/default-v6.nix
+++ b/pkgs/development/node-packages/default-v6.nix
@@ -1,8 +1,9 @@
-{pkgs, system, nodejs, stdenv}:
+{ pkgs, nodejs, stdenv }:
 
 let
   nodePackages = import ./composition-v6.nix {
-    inherit pkgs system nodejs;
+    inherit pkgs nodejs;
+    inherit (stdenv.hostPlatform) system;
   };
 in
 nodePackages // {
diff --git a/pkgs/development/node-packages/default-v8.nix b/pkgs/development/node-packages/default-v8.nix
index 561f43271ffc..7e3691dcecb0 100644
--- a/pkgs/development/node-packages/default-v8.nix
+++ b/pkgs/development/node-packages/default-v8.nix
@@ -1,8 +1,9 @@
-{pkgs, system, nodejs, stdenv}:
+{ pkgs, nodejs, stdenv }:
 
 let
   nodePackages = import ./composition-v8.nix {
-    inherit pkgs system nodejs;
+    inherit pkgs nodejs;
+    inherit (stdenv.hostPlatform) system;
   };
 in
 nodePackages // {
diff --git a/pkgs/development/ocaml-modules/bin_prot/default.nix b/pkgs/development/ocaml-modules/bin_prot/default.nix
index 1acb17a8f7a3..bc075295cf33 100644
--- a/pkgs/development/ocaml-modules/bin_prot/default.nix
+++ b/pkgs/development/ocaml-modules/bin_prot/default.nix
@@ -1,4 +1,8 @@
-{stdenv, buildOcaml, fetchurl, type_conv}:
+{ stdenv, buildOcaml, fetchurl, ocaml, type_conv }:
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "bin_prot-112.24.00 is not available for OCaml ${ocaml.version}"
+else
 
 buildOcaml rec {
   name = "bin_prot";
diff --git a/pkgs/development/ocaml-modules/bolt/default.nix b/pkgs/development/ocaml-modules/bolt/default.nix
index 121f484ce419..b5a4f179b17a 100644
--- a/pkgs/development/ocaml-modules/bolt/default.nix
+++ b/pkgs/development/ocaml-modules/bolt/default.nix
@@ -5,6 +5,10 @@ let inherit (stdenv.lib) getVersion versionAtLeast; in
 assert versionAtLeast (getVersion ocaml) "4.00.0";
 assert versionAtLeast (getVersion findlib) "1.3.3";
 
+if versionAtLeast ocaml.version "4.06"
+then throw "bolt is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
 
   name = "bolt-1.4";
diff --git a/pkgs/development/ocaml-modules/camlimages/4.1.nix b/pkgs/development/ocaml-modules/camlimages/4.1.nix
index 77a252de52fd..31b4047efc81 100644
--- a/pkgs/development/ocaml-modules/camlimages/4.1.nix
+++ b/pkgs/development/ocaml-modules/camlimages/4.1.nix
@@ -2,6 +2,10 @@
 
 assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.00";
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "camlimages-4.1.2 is not available for OCaml ${ocaml.version}"
+else
+
 let
   pname = "camlimages";
   version = "4.1.2";
diff --git a/pkgs/development/ocaml-modules/cil/default.nix b/pkgs/development/ocaml-modules/cil/default.nix
index 0394266353ce..5fbb141b6cce 100644
--- a/pkgs/development/ocaml-modules/cil/default.nix
+++ b/pkgs/development/ocaml-modules/cil/default.nix
@@ -1,4 +1,9 @@
 { stdenv, fetchurl, perl, ocaml, findlib, ocamlbuild }:
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "cil is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-cil-1.7.3";
   src = fetchurl {
diff --git a/pkgs/development/ocaml-modules/cryptgps/default.nix b/pkgs/development/ocaml-modules/cryptgps/default.nix
index cb85ebce5016..f8eb80837a3e 100644
--- a/pkgs/development/ocaml-modules/cryptgps/default.nix
+++ b/pkgs/development/ocaml-modules/cryptgps/default.nix
@@ -1,5 +1,9 @@
 {stdenv, fetchurl, ocaml, findlib}:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "cryptgps is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   name = "ocaml-cryptgps-${version}";
   version = "0.2.1";
diff --git a/pkgs/development/ocaml-modules/dypgen/default.nix b/pkgs/development/ocaml-modules/dypgen/default.nix
index 1bdcae521dd8..1abf387bdd3f 100644
--- a/pkgs/development/ocaml-modules/dypgen/default.nix
+++ b/pkgs/development/ocaml-modules/dypgen/default.nix
@@ -4,6 +4,10 @@ let
   pname = "dypgen";
 in
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "${pname} is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   version = "20120619-1";
diff --git a/pkgs/development/ocaml-modules/enumerate/default.nix b/pkgs/development/ocaml-modules/enumerate/default.nix
index 557f2f88d8d2..4f0c182726de 100644
--- a/pkgs/development/ocaml-modules/enumerate/default.nix
+++ b/pkgs/development/ocaml-modules/enumerate/default.nix
@@ -2,6 +2,10 @@
 
 assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.00";
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "enumerate-111.08.00 is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-enumerate-111.08.00";
 
diff --git a/pkgs/development/ocaml-modules/erm_xml/default.nix b/pkgs/development/ocaml-modules/erm_xml/default.nix
index ae264b657d87..c944752ff6b6 100644
--- a/pkgs/development/ocaml-modules/erm_xml/default.nix
+++ b/pkgs/development/ocaml-modules/erm_xml/default.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchzip, ocaml, findlib, ocamlbuild }:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "erm_xml is not available for OCaml ${ocaml.version}"
+else
+
 let version = "0.3"; in
 
 stdenv.mkDerivation {
diff --git a/pkgs/development/ocaml-modules/faillib/default.nix b/pkgs/development/ocaml-modules/faillib/default.nix
index 98acc8032e3f..9b80433b6d19 100644
--- a/pkgs/development/ocaml-modules/faillib/default.nix
+++ b/pkgs/development/ocaml-modules/faillib/default.nix
@@ -1,4 +1,8 @@
-{stdenv, buildOcaml, fetchurl, herelib, camlp4}:
+{ stdenv, buildOcaml, fetchurl, ocaml, herelib, camlp4 }:
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "faillib-111.17.00 is not available for OCaml ${ocaml.version}"
+else
 
 buildOcaml rec {
   minimumSupportedOcamlVersion = "4.00";
diff --git a/pkgs/development/ocaml-modules/fieldslib/default.nix b/pkgs/development/ocaml-modules/fieldslib/default.nix
index 6a8db9e62816..36c1342e61fa 100644
--- a/pkgs/development/ocaml-modules/fieldslib/default.nix
+++ b/pkgs/development/ocaml-modules/fieldslib/default.nix
@@ -2,6 +2,10 @@
 
 assert stdenv.lib.versionOlder "4.00" (stdenv.lib.getVersion ocaml);
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "fieldslib-109.20.03 is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-fieldslib-109.20.03";
 
diff --git a/pkgs/development/ocaml-modules/frontc/default.nix b/pkgs/development/ocaml-modules/frontc/default.nix
index ecf1ddc8fbae..e5330789e262 100644
--- a/pkgs/development/ocaml-modules/frontc/default.nix
+++ b/pkgs/development/ocaml-modules/frontc/default.nix
@@ -1,4 +1,8 @@
-{lib, buildOcaml, fetchurl}:
+{ lib, buildOcaml, fetchurl, ocaml }:
+
+if lib.versionAtLeast ocaml.version "4.06"
+then throw "FrontC is not available for OCaml ${ocaml.version}"
+else
 
 buildOcaml rec {
   name = "FrontC";
diff --git a/pkgs/development/ocaml-modules/gtktop/default.nix b/pkgs/development/ocaml-modules/gtktop/default.nix
index de0334c2a183..07420693005d 100644
--- a/pkgs/development/ocaml-modules/gtktop/default.nix
+++ b/pkgs/development/ocaml-modules/gtktop/default.nix
@@ -2,6 +2,10 @@
 
 let pname = "gtktop-2.0"; in
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "${pname} is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-${pname}";
 
diff --git a/pkgs/development/ocaml-modules/lwt/legacy.nix b/pkgs/development/ocaml-modules/lwt/legacy.nix
index 53ba904f628e..cd40a5051be9 100644
--- a/pkgs/development/ocaml-modules/lwt/legacy.nix
+++ b/pkgs/development/ocaml-modules/lwt/legacy.nix
@@ -6,6 +6,7 @@
 }:
 
 if !stdenv.lib.versionAtLeast ocaml.version "4"
+ || stdenv.lib.versionAtLeast ocaml.version "4.06"
 then throw "lwt is not available for OCaml ${ocaml.version}"
 else
 
diff --git a/pkgs/development/ocaml-modules/magick/default.nix b/pkgs/development/ocaml-modules/magick/default.nix
index 021962154bd0..ca6ab458fff2 100644
--- a/pkgs/development/ocaml-modules/magick/default.nix
+++ b/pkgs/development/ocaml-modules/magick/default.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchurl, which, pkgconfig, ocaml, findlib, imagemagick }:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "magick is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-magick-0.34";
   src = fetchurl {
diff --git a/pkgs/development/ocaml-modules/ocaml-cairo/default.nix b/pkgs/development/ocaml-modules/ocaml-cairo/default.nix
index e1590bb0c9ae..22215b8da0dc 100644
--- a/pkgs/development/ocaml-modules/ocaml-cairo/default.nix
+++ b/pkgs/development/ocaml-modules/ocaml-cairo/default.nix
@@ -4,6 +4,10 @@ let
   pname = "ocaml-cairo";
 in
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "${pname} is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   version = "1.2.0";
diff --git a/pkgs/development/ocaml-modules/ocamlsdl/default.nix b/pkgs/development/ocaml-modules/ocamlsdl/default.nix
index e8441cf6937c..8cfe43a5d322 100644
--- a/pkgs/development/ocaml-modules/ocamlsdl/default.nix
+++ b/pkgs/development/ocaml-modules/ocamlsdl/default.nix
@@ -4,6 +4,10 @@ let
   pname = "ocamlsdl";
 in
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "${pname} is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   version = "0.9.1";
diff --git a/pkgs/development/ocaml-modules/odn/default.nix b/pkgs/development/ocaml-modules/odn/default.nix
index f30fea2c4192..a56a6140f8ea 100644
--- a/pkgs/development/ocaml-modules/odn/default.nix
+++ b/pkgs/development/ocaml-modules/odn/default.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchurl, ocaml, findlib, ocamlbuild, type_conv, ounit, camlp4 }:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "ocaml-data-notation is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-data-notation-0.0.11";
 
diff --git a/pkgs/development/ocaml-modules/ojquery/default.nix b/pkgs/development/ocaml-modules/ojquery/default.nix
index 2d697a285fd3..8cf5819c9002 100644
--- a/pkgs/development/ocaml-modules/ojquery/default.nix
+++ b/pkgs/development/ocaml-modules/ojquery/default.nix
@@ -1,5 +1,9 @@
 { stdenv, fetchgit, ocaml, findlib, ocamlbuild, js_of_ocaml, js_of_ocaml-camlp4, camlp4, lwt3, react }:
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "ojquery is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   version = "0.1";
   name = "ocaml-ojquery-${version}";
diff --git a/pkgs/development/ocaml-modules/pa_ounit/default.nix b/pkgs/development/ocaml-modules/pa_ounit/default.nix
index fa4ecfcc28b2..2471c855cf54 100644
--- a/pkgs/development/ocaml-modules/pa_ounit/default.nix
+++ b/pkgs/development/ocaml-modules/pa_ounit/default.nix
@@ -1,4 +1,8 @@
-{stdenv, buildOcaml, fetchurl, ounit}:
+{ stdenv, buildOcaml, ocaml, fetchurl, ounit }:
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "pa_ounit is not available for OCaml ${ocaml.version}"
+else
 
 buildOcaml rec {
   name = "pa_ounit";
diff --git a/pkgs/development/ocaml-modules/sqlite3EZ/default.nix b/pkgs/development/ocaml-modules/sqlite3EZ/default.nix
index ef9c254aba14..e8f248ee4a1c 100644
--- a/pkgs/development/ocaml-modules/sqlite3EZ/default.nix
+++ b/pkgs/development/ocaml-modules/sqlite3EZ/default.nix
@@ -2,6 +2,10 @@
 
 assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "3.12";
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "sqlite3EZ is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
   name = "ocaml-sqlite3EZ-0.1.0";
 
diff --git a/pkgs/development/ocaml-modules/ulex/0.8/default.nix b/pkgs/development/ocaml-modules/ulex/0.8/default.nix
index 288e9a6933e7..6c0cf9214f29 100644
--- a/pkgs/development/ocaml-modules/ulex/0.8/default.nix
+++ b/pkgs/development/ocaml-modules/ulex/0.8/default.nix
@@ -4,6 +4,10 @@ let
   pname = "ulex";
 in
 
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "ulex-0.8 is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   version = "0.8";
diff --git a/pkgs/development/ocaml-modules/variantslib/default.nix b/pkgs/development/ocaml-modules/variantslib/default.nix
index cb25b844606d..425383a64854 100644
--- a/pkgs/development/ocaml-modules/variantslib/default.nix
+++ b/pkgs/development/ocaml-modules/variantslib/default.nix
@@ -1,4 +1,8 @@
-{stdenv, buildOcaml, fetchurl, type_conv}:
+{ stdenv, buildOcaml, ocaml, fetchurl, type_conv }:
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "variantslib-109.15.03 is not available for OCaml ${ocaml.version}"
+else
 
 buildOcaml rec {
   name = "variantslib";
diff --git a/pkgs/development/python-modules/cozy/default.nix b/pkgs/development/python-modules/cozy/default.nix
new file mode 100644
index 000000000000..0feca2773b37
--- /dev/null
+++ b/pkgs/development/python-modules/cozy/default.nix
@@ -0,0 +1,38 @@
+{ buildPythonPackage, fetchFromGitHub, lib,
+  z3, ply, python-igraph, oset, ordered-set, dictionaries }:
+
+buildPythonPackage {
+  pname = "cozy";
+  version = "2.0a1";
+
+  propagatedBuildInputs = [
+    z3 ply python-igraph oset ordered-set dictionaries
+  ];
+
+  src = fetchFromGitHub {
+    owner = "CozySynthesizer";
+    repo = "cozy";
+    rev = "f553e9b";
+    sha256 = "1jhr5gzihj8dkg0yc5dmi081v2isxharl0ph7v2grqj0bwqzl40j";
+  };
+
+  # Yoink the Z3 dependency name, because our Z3 package doesn't provide it.
+  postPatch = ''
+    sed -i -e '/z3-solver/d' requirements.txt
+  '';
+
+  # Tests are not correctly set up in the source tree.
+  doCheck = false;
+
+  # There is some first-time-run codegen that we will force to happen.
+  postInstall = ''
+    $out/bin/cozy --help
+  '';
+
+  meta = {
+    description = "The collection synthesizer";
+    homepage = https://cozy.uwplse.org/;
+    license = lib.licenses.asl20;
+    maintainers = [ lib.maintainers.MostAwesomeDude ];
+  };
+}
diff --git a/pkgs/development/python-modules/dictionaries/default.nix b/pkgs/development/python-modules/dictionaries/default.nix
new file mode 100644
index 000000000000..0deab2762552
--- /dev/null
+++ b/pkgs/development/python-modules/dictionaries/default.nix
@@ -0,0 +1,19 @@
+{ buildPythonPackage, fetchPypi, lib, six }:
+
+buildPythonPackage rec {
+  pname = "dictionaries";
+  version = "0.0.1";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1jx2ph509sk4l7spslz16y8l6xn97d13nspn4ds2lxn5ward9ihy";
+  };
+
+  buildInputs = [ six ];
+
+  meta = {
+    description = "Dict implementations with attribute access";
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.MostAwesomeDude ];
+  };
+}
diff --git a/pkgs/development/python-modules/ecpy/default.nix b/pkgs/development/python-modules/ecpy/default.nix
index 5338a963cfb6..df843ed7c32e 100644
--- a/pkgs/development/python-modules/ecpy/default.nix
+++ b/pkgs/development/python-modules/ecpy/default.nix
@@ -1,21 +1,20 @@
-{ stdenv, fetchPypi, buildPythonPackage, isPy3k, hidapi
-, pycrypto, pillow, protobuf, future
-}:
+{ lib, fetchPypi, buildPythonPackage, isPy3k, future }:
 
 buildPythonPackage rec {
   pname = "ECPy";
   version = "0.9.1";
 
-  disabled = !isPy3k;
-
   src = fetchPypi {
     inherit pname version;
     sha256 = "f0df66be67f3de0152dfb3c453f4247bdfa2b4e37aa75b98617a637376032229";
   };
 
-  buildInputs = [ hidapi pycrypto pillow protobuf future ];
+  propagatedBuildInputs = lib.optional (!isPy3k) future;
+
+  # No tests implemented
+  doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pure Pyhton Elliptic Curve Library";
     homepage = https://github.com/ubinity/ECPy;
     license = licenses.asl20;
diff --git a/pkgs/development/python-modules/folium/default.nix b/pkgs/development/python-modules/folium/default.nix
index cd6bac2962dc..e1c4306b1f80 100644
--- a/pkgs/development/python-modules/folium/default.nix
+++ b/pkgs/development/python-modules/folium/default.nix
@@ -22,7 +22,7 @@ buildPythonPackage rec {
   };
 
   checkInputs = [ pytest numpy nbconvert pandas mock ];
-  propagatedBuildInputs = [ jinja2 branca six requests ];
+  propagatedBuildInputs = [ jinja2 branca six requests numpy ];
 
   # No tests in archive
   doCheck = false;
diff --git a/pkgs/development/python-modules/httpsig/default.nix b/pkgs/development/python-modules/httpsig/default.nix
new file mode 100644
index 000000000000..cff72de36077
--- /dev/null
+++ b/pkgs/development/python-modules/httpsig/default.nix
@@ -0,0 +1,32 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, setuptools_scm
+, pycryptodome
+, requests
+}:
+
+buildPythonPackage rec {
+  pname = "httpsig";
+  version = "1.2.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "19ng7y7blp13z081z5a6dxng1p8xlih7g6frmsg3q5ri8lvpybc7";
+  };
+
+  buildInputs = [ setuptools_scm ];
+  propagatedBuildInputs = [ pycryptodome requests ];
+
+  # Jailbreak pycryptodome
+  preBuild = ''
+    substituteInPlace setup.py --replace "==3.4.7" ""
+  '';
+
+  meta = with lib; {
+    description = "Sign HTTP requests with secure signatures";
+    license = licenses.mit;
+    maintainers = with maintainers; [ srhb ];
+    homepage = https://github.com/ahknight/httpsig;
+  };
+}
diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix
index 88fe33a6c358..af8815dbfb1b 100644
--- a/pkgs/development/python-modules/numpy/default.nix
+++ b/pkgs/development/python-modules/numpy/default.nix
@@ -1,4 +1,4 @@
-{lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, pytest, blas, hostPlatform }:
+{ stdenv, lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, pytest, blas }:
 
 buildPythonPackage rec {
   pname = "numpy";
@@ -20,7 +20,7 @@ buildPythonPackage rec {
     ./numpy-distutils-C++.patch
   ];
 
-  postPatch = lib.optionalString hostPlatform.isMusl ''
+  postPatch = lib.optionalString stdenv.hostPlatform.isMusl ''
     # Use fenv.h
     sed -i \
       numpy/core/src/npymath/ieee754.c.src \
diff --git a/pkgs/development/python-modules/ordered-set/default.nix b/pkgs/development/python-modules/ordered-set/default.nix
new file mode 100644
index 000000000000..bf20f7827be3
--- /dev/null
+++ b/pkgs/development/python-modules/ordered-set/default.nix
@@ -0,0 +1,26 @@
+{ buildPythonPackage, fetchPypi, lib, pytest }:
+
+buildPythonPackage rec {
+  pname = "ordered-set";
+  version = "3.0.1";
+
+  buildInputs = [ pytest ];
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "0yyfkkfzpwlx4jlfqzb7p1xpzmn2jyzq2qlakqx62pxizfzxfvrx";
+  };
+
+  checkPhase = ''
+    py.test test.py
+  '';
+
+  meta = {
+    description = "A MutableSet that remembers its order, so that every entry has an index.";
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.MostAwesomeDude ];
+  };
+}
+
+
+
diff --git a/pkgs/development/python-modules/pyserial/default.nix b/pkgs/development/python-modules/pyserial/default.nix
index c7787a42691b..98ffbe5ad9ec 100644
--- a/pkgs/development/python-modules/pyserial/default.nix
+++ b/pkgs/development/python-modules/pyserial/default.nix
@@ -1,4 +1,4 @@
-{ lib, fetchPypi, buildPythonPackage, hostPlatform }:
+{ stdenv, lib, fetchPypi, buildPythonPackage }:
 
 buildPythonPackage rec {
   pname = "pyserial";
@@ -10,7 +10,7 @@ buildPythonPackage rec {
   };
 
   checkPhase = "python -m unittest discover -s test";
-  doCheck = !hostPlatform.isDarwin; # broken on darwin
+  doCheck = !stdenv.hostPlatform.isDarwin; # broken on darwin
 
   meta = with lib; {
     homepage = "https://github.com/pyserial/pyserial";
diff --git a/pkgs/development/python-modules/python-igraph/default.nix b/pkgs/development/python-modules/python-igraph/default.nix
new file mode 100644
index 000000000000..a24f3a9fedc8
--- /dev/null
+++ b/pkgs/development/python-modules/python-igraph/default.nix
@@ -0,0 +1,22 @@
+{ buildPythonPackage, fetchPypi, lib,
+  pkgconfig, igraph }:
+
+buildPythonPackage rec {
+  pname = "python-igraph";
+  version = "0.7.1.post6";
+
+  buildInputs = [ pkgconfig igraph ];
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "0xp61zz710qlzhmzbfr65d5flvsi8zf2xy78s6rsszh719wl5sm5";
+  };
+
+  meta = {
+    description = "High performance graph data structures and algorithms";
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.MostAwesomeDude ];
+  };
+}
+
+
diff --git a/pkgs/development/ruby-modules/testing/stubs.nix b/pkgs/development/ruby-modules/testing/stubs.nix
index 7e6d1102f666..aaab2f689602 100644
--- a/pkgs/development/ruby-modules/testing/stubs.nix
+++ b/pkgs/development/ruby-modules/testing/stubs.nix
@@ -6,7 +6,7 @@ let
     text = (builtins.toJSON (lib.filterAttrs ( n: v: builtins.any (x: x == n) ["name" "system"]) argSet));
     builder = stdenv.shell;
     args = [ "-c" "echo  $(<$textPath) > $out"];
-    system = stdenv.system;
+    system = stdenv.hostPlatform.system;
     passAsFile = ["text"];
   };
   fetchurl = {url?"", urls ? [],...}: "fetchurl:${if urls == [] then url else builtins.head urls}";
diff --git a/pkgs/development/tools/analysis/cov-build/default.nix b/pkgs/development/tools/analysis/cov-build/default.nix
index fef98f1e04aa..bd0a4ee5e40a 100644
--- a/pkgs/development/tools/analysis/cov-build/default.nix
+++ b/pkgs/development/tools/analysis/cov-build/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   version = "7.0.2";
 
   src =
-    if stdenv.system == "i686-linux"
+    if stdenv.hostPlatform.system == "i686-linux"
     then requireFile {
       name = "cov-analysis-linux32-${version}.tar.gz";
       sha256 = "0i06wbd7blgx9adh9w09by4i18vwmldfp9ix97a5dph2cjymsviy";
diff --git a/pkgs/development/tools/analysis/valgrind/default.nix b/pkgs/development/tools/analysis/valgrind/default.nix
index cbcfa981b6b5..5734a0f27953 100644
--- a/pkgs/development/tools/analysis/valgrind/default.nix
+++ b/pkgs/development/tools/analysis/valgrind/default.nix
@@ -57,7 +57,7 @@ stdenv.mkDerivation rec {
     '';
 
   configureFlags =
-    stdenv.lib.optional (stdenv.system == "x86_64-linux" || stdenv.system == "x86_64-darwin") "--enable-only64bit";
+    stdenv.lib.optional (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin") "--enable-only64bit";
 
   doCheck = false; # fails
 
diff --git a/pkgs/development/tools/build-managers/cmake/2.8.nix b/pkgs/development/tools/build-managers/cmake/2.8.nix
index a57d20e2702a..2cbc87a5267a 100644
--- a/pkgs/development/tools/build-managers/cmake/2.8.nix
+++ b/pkgs/development/tools/build-managers/cmake/2.8.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl, fetchpatch, curl, expat, zlib, bzip2
 , useNcurses ? false, ncurses, useQt4 ? false, qt4, ps
-, buildPlatform, hostPlatform
 }:
 
 with stdenv.lib;
@@ -35,7 +34,7 @@ stdenv.mkDerivation rec {
     })] ++
     # Don't search in non-Nix locations such as /usr, but do search in our libc.
     [ ./search-path.patch ] ++
-    optional (hostPlatform != buildPlatform) (fetchurl {
+    optional (stdenv.hostPlatform != stdenv.buildPlatform) (fetchurl {
       name = "fix-darwin-cross-compile.patch";
       url = "https://public.kitware.com/Bug/file_download.php?"
           + "file_id=4981&type=bug";
diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix
index ca53c4d8c535..35ae59af617c 100644
--- a/pkgs/development/tools/build-managers/meson/default.nix
+++ b/pkgs/development/tools/build-managers/meson/default.nix
@@ -1,4 +1,4 @@
-{ lib, python3Packages, stdenv, targetPlatform, writeTextDir, substituteAll }:
+{ lib, python3Packages, stdenv, writeTextDir, substituteAll }:
 
 python3Packages.buildPythonApplication rec {
   version = "0.46.1";
@@ -57,10 +57,10 @@ python3Packages.buildPythonApplication rec {
     needs_exe_wrapper = true
 
     [host_machine]
-    system = '${targetPlatform.parsed.kernel.name}'
-    cpu_family = '${targetPlatform.parsed.cpu.family}'
-    cpu = '${targetPlatform.parsed.cpu.name}'
-    endian = ${if targetPlatform.isLittleEndian then "'little'" else "'big'"}
+    system = '${stdenv.targetPlatform.parsed.kernel.name}'
+    cpu_family = '${stdenv.targetPlatform.parsed.cpu.family}'
+    cpu = '${stdenv.targetPlatform.parsed.cpu.name}'
+    endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
   '';
 
   # 0.45 update enabled tests but they are failing
diff --git a/pkgs/development/tools/electron/default.nix b/pkgs/development/tools/electron/default.nix
index 695a532305a9..942748a38106 100644
--- a/pkgs/development/tools/electron/default.nix
+++ b/pkgs/development/tools/electron/default.nix
@@ -4,7 +4,7 @@ let
   version = "1.8.2";
   name = "electron-${version}";
 
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   meta = with stdenv.lib; {
     description = "Cross platform desktop application shell";
@@ -34,7 +34,7 @@ let
         url = "https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-linux-arm64.zip";
         sha256 = "0k4np2d4y15x1qfay8y9m8v9y223vdpbq5fdxa3ywbbyf8j361zd";
       };
-    }.${stdenv.system} or throwSystem;
+    }.${stdenv.hostPlatform.system} or throwSystem;
 
     buildInputs = [ unzip makeWrapper ];
 
diff --git a/pkgs/development/tools/github/github-release/default.nix b/pkgs/development/tools/github/github-release/default.nix
index 1ccd1061a136..b80ddff054a9 100644
--- a/pkgs/development/tools/github/github-release/default.nix
+++ b/pkgs/development/tools/github/github-release/default.nix
@@ -1,9 +1,9 @@
 { stdenv, fetchurl }:
 
 let
-  linuxPredicate = stdenv.system == "x86_64-linux";
-  bsdPredicate = stdenv.system == "x86_64-freebsd";
-  darwinPredicate = stdenv.system == "x86_64-darwin";
+  linuxPredicate = stdenv.hostPlatform.system == "x86_64-linux";
+  bsdPredicate = stdenv.hostPlatform.system == "x86_64-freebsd";
+  darwinPredicate = stdenv.hostPlatform.system == "x86_64-darwin";
   metadata = assert linuxPredicate || bsdPredicate || darwinPredicate;
     if linuxPredicate then
       { arch = "linux-amd64";
diff --git a/pkgs/development/tools/google-app-engine-go-sdk/default.nix b/pkgs/development/tools/google-app-engine-go-sdk/default.nix
index c85186e1c0b2..ba4f4bb3f519 100644
--- a/pkgs/development/tools/google-app-engine-go-sdk/default.nix
+++ b/pkgs/development/tools/google-app-engine-go-sdk/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation rec {
   name = "google-app-engine-go-sdk-${version}";
   version = "1.9.61";
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchzip {
         url = "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-${version}.zip";
         sha256 = "1i2j9ympl1218akwsmm7yb31v0gibgpzlb657bcravi1irfv1hhs";
diff --git a/pkgs/development/tools/minizinc/default.nix b/pkgs/development/tools/minizinc/default.nix
index d569b8d30687..8c210cb93601 100644
--- a/pkgs/development/tools/minizinc/default.nix
+++ b/pkgs/development/tools/minizinc/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchFromGitHub, cmake, flex, bison }:
 let
-  version = "2.1.7";
+  version = "2.2.0";
 in
 stdenv.mkDerivation {
   name = "minizinc-${version}";
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
     rev = "${version}";
     owner = "MiniZinc";
     repo = "libminizinc";
-    sha256 = "05rifsgzfaalv5ymv59sjcvhr6i1byzbmq5p36hj3hpi5f929kip";
+    sha256 = "05is1r5y06jfqwvka90dn2ffxnvbgyswaxl00aqz6455hnggnxvm";
   };
 
   # meta is all the information about the package..
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 3ca9e539ddd8..3205366f80eb 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,6 +1,5 @@
 { stdenv, buildPackages
 , fetchurl, zlib, autoreconfHook264
-, hostPlatform, buildPlatform, targetPlatform
 , noSysDirs, gold ? true, bison ? null
 }:
 
@@ -13,7 +12,7 @@ let
   inherit (stdenv.lib) optionals optionalString;
   # The targetPrefix prepended to binary names to allow multiple binuntils on the
   # PATH to both be usable.
-  targetPrefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
+  targetPrefix = optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "${stdenv.targetPlatform.config}-";
 in
 
 stdenv.mkDerivation rec {
@@ -65,14 +64,14 @@ stdenv.mkDerivation rec {
     # be satisfied on aarch64 platform. Add backported fix from bugzilla.
     # https://sourceware.org/bugzilla/show_bug.cgi?id=22764
     ./relax-R_AARCH64_ABS32-R_AARCH64_ABS16-absolute.patch
-  ] ++ stdenv.lib.optional targetPlatform.isiOS ./support-ios.patch;
+  ] ++ stdenv.lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch;
 
   outputs = [ "out" "info" "man" ];
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [
     bison
-  ] ++ stdenv.lib.optionals targetPlatform.isiOS [
+  ] ++ stdenv.lib.optionals stdenv.targetPlatform.isiOS [
     autoreconfHook264
   ];
   buildInputs = [ zlib ];
@@ -94,14 +93,14 @@ stdenv.mkDerivation rec {
 
   # As binutils takes part in the stdenv building, we don't want references
   # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
-  NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
+  NIX_CFLAGS_COMPILE = if stdenv.hostPlatform.isDarwin
     then "-Wno-string-plus-int -Wno-deprecated-declarations"
     else "-static-libgcc";
 
   hardeningDisable = [ "format" ];
 
   # TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
 
   configureFlags = [
     "--enable-targets=all" "--enable-64-bit-bfd"
@@ -122,7 +121,7 @@ stdenv.mkDerivation rec {
   doCheck = false; # fails
 
   # else fails with "./sanity.sh: line 36: $out/bin/size: not found"
-  doInstallCheck = buildPlatform == hostPlatform && hostPlatform == targetPlatform;
+  doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/tools/misc/cflow/default.nix b/pkgs/development/tools/misc/cflow/default.nix
index 8ec0ecd5785d..16098bda3ee5 100644
--- a/pkgs/development/tools/misc/cflow/default.nix
+++ b/pkgs/development/tools/misc/cflow/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ gettext ] ++
     # We don't have Emacs/GTK/etc. on {Dar,Cyg}win.
     stdenv.lib.optional
-      (! (stdenv.lib.lists.any (x: stdenv.system == x)
+      (! (stdenv.lib.lists.any (x: stdenv.hostPlatform.system == x)
               [ "i686-cygwin" ]))
       emacs;
 
diff --git a/pkgs/development/tools/misc/gdb/default.nix b/pkgs/development/tools/misc/gdb/default.nix
index 1c2efbeea76f..a60a77bed30b 100644
--- a/pkgs/development/tools/misc/gdb/default.nix
+++ b/pkgs/development/tools/misc/gdb/default.nix
@@ -6,9 +6,7 @@
 # Run time
 , ncurses, readline, gmp, mpfr, expat, zlib, dejagnu
 
-, buildPlatform, hostPlatform, targetPlatform
-
-, pythonSupport ? hostPlatform == buildPlatform && !hostPlatform.isCygwin, python ? null
+, pythonSupport ? stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.hostPlatform.isCygwin, python ? null
 , guile ? null
 
 }:
@@ -22,8 +20,8 @@ assert pythonSupport -> python != null;
 
 stdenv.mkDerivation rec {
   name =
-    stdenv.lib.optionalString (targetPlatform != hostPlatform)
-                              (targetPlatform.config + "-")
+    stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+                              (stdenv.targetPlatform.config + "-")
     + basename;
 
   src = fetchurl {
@@ -50,7 +48,7 @@ stdenv.mkDerivation rec {
   NIX_CFLAGS_COMPILE = "-Wno-format-nonliteral";
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
 
   configureFlags = with stdenv.lib; [
     "--enable-targets=all" "--enable-64-bit-bfd"
diff --git a/pkgs/development/tools/misc/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index 7e92df1a9978..e5ea17841aa6 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, hostPlatform, fetchurl }:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   name = "gnum4-1.4.18";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   configureFlags = [ "--with-syscmd-shell=${stdenv.shell}" ];
 
   # Upstream is aware of it; it may be in the next release.
-  patches = [ ./s_isdir.patch ] ++ stdenv.lib.optional hostPlatform.isDarwin stdenv.secure-format-patch;
+  patches = [ ./s_isdir.patch ] ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin stdenv.secure-format-patch;
 
   meta = {
     homepage = http://www.gnu.org/software/m4/;
diff --git a/pkgs/development/tools/misc/help2man/default.nix b/pkgs/development/tools/misc/help2man/default.nix
index b786aa2123f6..7e2dc49fe0f2 100644
--- a/pkgs/development/tools/misc/help2man/default.nix
+++ b/pkgs/development/tools/misc/help2man/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, hostPlatform, fetchurl, perl, gettext, LocaleGettext }:
+{ stdenv, fetchurl, perl, gettext, LocaleGettext }:
 
 stdenv.mkDerivation rec {
   name = "help2man-1.47.6";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   doCheck = false;                                # target `check' is missing
 
-  patches = if hostPlatform.isCygwin then [ ./1.40.4-cygwin-nls.patch ] else null;
+  patches = if stdenv.hostPlatform.isCygwin then [ ./1.40.4-cygwin-nls.patch ] else null;
 
   # We don't use makeWrapper here because it uses substitutions our
   # bootstrap shell can't handle.
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
     cat > $out/bin/help2man <<EOF
     #! $SHELL -e
     export PERL5LIB=\''${PERL5LIB:+:}$gettext_perl
-    ${stdenv.lib.optionalString hostPlatform.isCygwin
+    ${stdenv.lib.optionalString stdenv.hostPlatform.isCygwin
         "export PATH=\''${PATH:+:}${gettext}/bin"}
     exec -a \$0 $out/bin/.help2man-wrapped "\$@"
     EOF
diff --git a/pkgs/development/tools/misc/iozone/default.nix b/pkgs/development/tools/misc/iozone/default.nix
index 31d70d280e32..1d5da65df7e0 100644
--- a/pkgs/development/tools/misc/iozone/default.nix
+++ b/pkgs/development/tools/misc/iozone/default.nix
@@ -1,15 +1,15 @@
 { stdenv, fetchurl, gnuplot }:
 
 let
-  target = if stdenv.system == "i686-linux" then
+  target = if stdenv.hostPlatform.system == "i686-linux" then
     "linux"
-  else if stdenv.system == "x86_64-linux" then
+  else if stdenv.hostPlatform.system == "x86_64-linux" then
     "linux-AMD64"
-  else if stdenv.system == "x86_64-darwin" then
+  else if stdenv.hostPlatform.system == "x86_64-darwin" then
     "macosx"
-  else if stdenv.system == "aarch64-linux" then
+  else if stdenv.hostPlatform.system == "aarch64-linux" then
     "linux-arm"
-  else throw "Platform ${stdenv.system} not yet supported.";
+  else throw "Platform ${stdenv.hostPlatform.system} not yet supported.";
 in
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/tools/misc/kibana/5.x.nix b/pkgs/development/tools/misc/kibana/5.x.nix
index 4aa9dc8b89a0..0529a2764924 100644
--- a/pkgs/development/tools/misc/kibana/5.x.nix
+++ b/pkgs/development/tools/misc/kibana/5.x.nix
@@ -6,7 +6,7 @@ let
   archOverrides = {
     "i686" = "x86";
   };
-  info = splitString "-" stdenv.system;
+  info = splitString "-" stdenv.hostPlatform.system;
   arch = (elemAt info 0);
   elasticArch = archOverrides."${arch}" or arch;
   plat = elemAt info 1;
@@ -21,7 +21,7 @@ in stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://artifacts.elastic.co/downloads/kibana/${name}-${plat}-${elasticArch}.tar.gz";
-    sha256 = shas."${stdenv.system}" or (throw "Unknown architecture");
+    sha256 = shas."${stdenv.hostPlatform.system}" or (throw "Unknown architecture");
   };
 
   buildInputs = [ makeWrapper ];
diff --git a/pkgs/development/tools/misc/kibana/default.nix b/pkgs/development/tools/misc/kibana/default.nix
index 1fd52f435574..72321f560c7f 100644
--- a/pkgs/development/tools/misc/kibana/default.nix
+++ b/pkgs/development/tools/misc/kibana/default.nix
@@ -12,7 +12,7 @@
 with stdenv.lib;
 let
   inherit (builtins) elemAt;
-  info = splitString "-" stdenv.system;
+  info = splitString "-" stdenv.hostPlatform.system;
   arch = elemAt info 0;
   plat = elemAt info 1;
   shas =
@@ -44,7 +44,7 @@ in stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://artifacts.elastic.co/downloads/kibana/${name}-${plat}-${arch}.tar.gz";
-    sha256 = shas."${stdenv.system}" or (throw "Unknown architecture");
+    sha256 = shas."${stdenv.hostPlatform.system}" or (throw "Unknown architecture");
   };
 
   buildInputs = [ makeWrapper ];
diff --git a/pkgs/development/tools/misc/libtool/libtool2.nix b/pkgs/development/tools/misc/libtool/libtool2.nix
index d1d35d9a4824..bd7f62a7bcd2 100644
--- a/pkgs/development/tools/misc/libtool/libtool2.nix
+++ b/pkgs/development/tools/misc/libtool/libtool2.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, m4, perl, help2man
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -26,7 +25,7 @@ stdenv.mkDerivation rec {
 
   # Don't run the native `strip' when cross-compiling.  This breaks at least
   # with `.a' files for MinGW.
-  dontStrip = hostPlatform != buildPlatform;
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
 
   meta = {
     description = "GNU Libtool, a generic library support script";
diff --git a/pkgs/development/tools/misc/lsof/default.nix b/pkgs/development/tools/misc/lsof/default.nix
index 005fb09fba09..28c2660ac3d7 100644
--- a/pkgs/development/tools/misc/lsof/default.nix
+++ b/pkgs/development/tools/misc/lsof/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, buildPackages, ncurses }:
 
-let dialect = with stdenv.lib; last (splitString "-" stdenv.system); in
+let dialect = with stdenv.lib; last (splitString "-" stdenv.hostPlatform.system); in
 
 stdenv.mkDerivation rec {
   name = "lsof-${version}";
diff --git a/pkgs/development/tools/misc/saleae-logic/default.nix b/pkgs/development/tools/misc/saleae-logic/default.nix
index a8183aa4ba08..c89492287db4 100644
--- a/pkgs/development/tools/misc/saleae-logic/default.nix
+++ b/pkgs/development/tools/misc/saleae-logic/default.nix
@@ -27,13 +27,13 @@ stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         name = "saleae-logic-${version}-32bit.zip";
         url = "http://downloads.saleae.com/logic/${version}/Logic%20${version}%20(32-bit).zip";
         sha256 = "1dyrj07cgj2fvwi1sk97vady9ri8f8n7mxy9zyzmw9isngs7bmll";
       }
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         name = "saleae-logic-${version}-64bit.zip";
         url = "http://downloads.saleae.com/logic/${version}/Logic%20${version}%20(64-bit).zip";
diff --git a/pkgs/development/tools/neoload/default.nix b/pkgs/development/tools/neoload/default.nix
index c68c29f86dea..06945f10eb23 100644
--- a/pkgs/development/tools/neoload/default.nix
+++ b/pkgs/development/tools/neoload/default.nix
@@ -34,7 +34,7 @@ in stdenv.mkDerivation rec {
   name = "neoload-4.1.4";
 
   src = fetchurl (
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       { url = http://neoload.installers.neotys.com/documents/download/neoload/v4.1/neoload_4_1_4_linux_x64.sh;
         sha256 = "199jcf5a0nwfm8wfld2rcjgq64g91vvz2bkmki8dxfzf1yasifcd"; }
     else
diff --git a/pkgs/development/tools/node-webkit/nw12.nix b/pkgs/development/tools/node-webkit/nw12.nix
index df7630e2d16f..099e31b8d62d 100644
--- a/pkgs/development/tools/node-webkit/nw12.nix
+++ b/pkgs/development/tools/node-webkit/nw12.nix
@@ -3,7 +3,7 @@
 , gdk_pixbuf, cairo, nss, nspr, gconf, expat, systemd, libcap
 , libnotify}:
 let
-  bits = if stdenv.system == "x86_64-linux" then "x64"
+  bits = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
          else "ia32";
 
   nwEnv = buildEnv {
diff --git a/pkgs/development/tools/nwjs/default.nix b/pkgs/development/tools/nwjs/default.nix
index 90c377c4472f..bd0c7f5002c3 100644
--- a/pkgs/development/tools/nwjs/default.nix
+++ b/pkgs/development/tools/nwjs/default.nix
@@ -7,7 +7,7 @@
 , sqlite, udev
 }:
 let
-  bits = if stdenv.system == "x86_64-linux" then "x64"
+  bits = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
          else "ia32";
 
   nwEnv = buildEnv {
diff --git a/pkgs/development/tools/ocaml/omake/0.9.8.6-rc1.nix b/pkgs/development/tools/ocaml/omake/0.9.8.6-rc1.nix
index 84365889638c..4d7900de80d2 100644
--- a/pkgs/development/tools/ocaml/omake/0.9.8.6-rc1.nix
+++ b/pkgs/development/tools/ocaml/omake/0.9.8.6-rc1.nix
@@ -4,6 +4,11 @@ let
   version = "0.9.8.6-0.rc1";
   webpage = "http://omake.metaprl.org";
 in
+
+if stdenv.lib.versionAtLeast ocaml.version "4.06"
+then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
+else
+
 stdenv.mkDerivation {
 
   name = "${pname}-${version}";
diff --git a/pkgs/development/tools/phantomjs/default.nix b/pkgs/development/tools/phantomjs/default.nix
index 51a83760be39..43fdeff9090b 100644
--- a/pkgs/development/tools/phantomjs/default.nix
+++ b/pkgs/development/tools/phantomjs/default.nix
@@ -12,13 +12,13 @@ stdenv.mkDerivation rec {
   # because it has bundled a lot of external libraries (like QT and Webkit)
   # and no easy/nice way to use the system versions of these
 
-  src = if stdenv.system == "i686-linux" then
+  src = if stdenv.hostPlatform.system == "i686-linux" then
           fetchurl {
             url = "https://bitbucket.org/ariya/phantomjs/downloads/${name}-linux-i686.tar.bz2";
             sha256 = "11fzmssz9pqf3arh4f36w06sl2nyz8l9h8iyxyd7w5aqnq5la0j1";
           }
         else
-          if stdenv.system == "x86_64-linux" then
+          if stdenv.hostPlatform.system == "x86_64-linux" then
             fetchurl {
               url = "https://bitbucket.org/ariya/phantomjs/downloads/${name}-linux-x86_64.tar.bz2";
               sha256 = "0fhnqxxsxhy125fmif1lwgnlhfx908spy7fx9mng4w72320n5nd1";
diff --git a/pkgs/development/tools/sauce-connect/default.nix b/pkgs/development/tools/sauce-connect/default.nix
index fe32f7c24506..d5f7c8e6e89f 100644
--- a/pkgs/development/tools/sauce-connect/default.nix
+++ b/pkgs/development/tools/sauce-connect/default.nix
@@ -7,10 +7,10 @@ stdenv.mkDerivation rec {
   version = "4.4.12";
 
   src = fetchurl (
-    if stdenv.system == "x86_64-linux" then {
+    if stdenv.hostPlatform.system == "x86_64-linux" then {
       url = "https://saucelabs.com/downloads/sc-${version}-linux.tar.gz";
       sha256 = "1yqvx64bgiq27hdhwkzgmzyib8pbjn1idpq6783srxq64asf6iyw";
-    } else if stdenv.system == "i686-linux" then {
+    } else if stdenv.hostPlatform.system == "i686-linux" then {
       url = "https://saucelabs.com/downloads/sc-${version}-linux32.tar.gz";
       sha256 = "02kib56lv4lhwkj5r15484lvvbyjvf9ydi5vccsmxgsxrzmddnl6";
     } else {
diff --git a/pkgs/development/tools/selenium/chromedriver/default.nix b/pkgs/development/tools/selenium/chromedriver/default.nix
index 238c3bc704d0..abbd2a9116ca 100644
--- a/pkgs/development/tools/selenium/chromedriver/default.nix
+++ b/pkgs/development/tools/selenium/chromedriver/default.nix
@@ -15,8 +15,8 @@ let
     };
   };
 
-  spec = allSpecs."${stdenv.system}"
-    or (throw "missing chromedriver binary for ${stdenv.system}");
+  spec = allSpecs."${stdenv.hostPlatform.system}"
+    or (throw "missing chromedriver binary for ${stdenv.hostPlatform.system}");
 
   libs = stdenv.lib.makeLibraryPath [
     stdenv.cc.cc.lib
diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix
index 4aa08f994576..b2455095a01a 100644
--- a/pkgs/development/tools/xcbuild/wrapper.nix
+++ b/pkgs/development/tools/xcbuild/wrapper.nix
@@ -1,9 +1,8 @@
 { stdenv, lib, buildPackages, makeWrapper, writeText, runCommand
 , CoreServices, ImageIO, CoreGraphics
-, targetPlatform
-, xcodePlatform ? targetPlatform.xcodePlatform or "MacOSX"
-, xcodeVer ? targetPlatform.xcodeVer or "9.4.1"
-, sdkVer ? targetPlatform.sdkVer or "10.10" }:
+, xcodePlatform ? stdenv.targetPlatform.xcodePlatform or "MacOSX"
+, xcodeVer ? stdenv.targetPlatform.xcodeVer or "9.4.1"
+, sdkVer ? stdenv.targetPlatform.sdkVer or "10.10" }:
 
 let
 
diff --git a/pkgs/development/web/remarkjs/default.nix b/pkgs/development/web/remarkjs/default.nix
index 03cbf74cbad3..22404481f35c 100644
--- a/pkgs/development/web/remarkjs/default.nix
+++ b/pkgs/development/web/remarkjs/default.nix
@@ -13,7 +13,7 @@ let
   
   nodePackages = import ./nodepkgs.nix {
     inherit pkgs;
-    inherit (stdenv) system;
+    inherit (stdenv.hostPlatform) system;
   };
 
 in stdenv.mkDerivation rec {
diff --git a/pkgs/games/andyetitmoves/default.nix b/pkgs/games/andyetitmoves/default.nix
index 092f07737084..97cbe616c57c 100644
--- a/pkgs/games/andyetitmoves/default.nix
+++ b/pkgs/games/andyetitmoves/default.nix
@@ -7,9 +7,9 @@ in
 stdenv.mkDerivation rec {
   name = "${plainName}-${version}";
 
-  src = if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"
+  src = if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux"
     then
-      let postfix        = if stdenv.system == "i686-linux" then "i386" else "x86_64";
+      let postfix        = if stdenv.hostPlatform.system == "i686-linux" then "i386" else "x86_64";
           commercialName = "${plainName}-${version}_${postfix}.tar.gz";
           demoUrl        = "http://www.andyetitmoves.net/demo/${plainName}Demo-${version}_${postfix}.tar.gz";
       in
@@ -22,13 +22,13 @@ stdenv.mkDerivation rec {
                  directory where yousaved it.
                '';
                name = commercialName;
-               sha256 = if stdenv.system == "i686-linux"
+               sha256 = if stdenv.hostPlatform.system == "i686-linux"
                           then "15wvzmmidvykwjrbnq70h5jrvnjx1hcrm0357qj85q4aqbzavh01"
                           else "1v8z16qa9ka8sf7qq45knsxj87s6sipvv3a7xq11pb5xk08fb2ql";
              }
         else fetchurl {
                url = demoUrl;
-               sha256 = if stdenv.system == "i686-linux"
+               sha256 = if stdenv.hostPlatform.system == "i686-linux"
                           then "0f14vrrbq05hsbdajrb5y9za65fpng1lc8f0adb4aaz27x7sh525"
                           else "0mg41ya0b27blq3b5498kwl4rj46dj21rcd7qd0rw1kyvr7sx4v4";
              }
diff --git a/pkgs/games/dwarf-fortress/dfhack/default.nix b/pkgs/games/dwarf-fortress/dfhack/default.nix
index a7b059bb6892..4a8c84cf92dc 100644
--- a/pkgs/games/dwarf-fortress/dfhack/default.nix
+++ b/pkgs/games/dwarf-fortress/dfhack/default.nix
@@ -13,8 +13,8 @@ let
   xmlRev = "23500e4e9bd1885365d0a2ef1746c321c1dd5094";
 
   arch =
-    if stdenv.system == "x86_64-linux" then "64"
-    else if stdenv.system == "i686-linux" then "32"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "32"
     else throw "Unsupported architecture";
 
   fakegit = writeScriptBin "git" ''
diff --git a/pkgs/games/dwarf-fortress/game.nix b/pkgs/games/dwarf-fortress/game.nix
index f57e9703fabf..2547bb83f3f5 100644
--- a/pkgs/games/dwarf-fortress/game.nix
+++ b/pkgs/games/dwarf-fortress/game.nix
@@ -33,9 +33,9 @@ let
   game = if hasAttr dfVersion df-hashes
          then getAttr dfVersion df-hashes
          else throw "Unknown Dwarf Fortress version: ${dfVersion}";
-  dfPlatform = if hasAttr stdenv.system platforms
-               then getAttr stdenv.system platforms
-               else throw "Unsupported system: ${stdenv.system}";
+  dfPlatform = if hasAttr stdenv.hostPlatform.system platforms
+               then getAttr stdenv.hostPlatform.system platforms
+               else throw "Unsupported system: ${stdenv.hostPlatform.system}";
   sha256 = if hasAttr dfPlatform game
            then getAttr dfPlatform game
            else throw "Unsupported dfPlatform: ${dfPlatform}";
diff --git a/pkgs/games/eduke32/default.nix b/pkgs/games/eduke32/default.nix
index 733b6070b1fc..502a554bae22 100644
--- a/pkgs/games/eduke32/default.nix
+++ b/pkgs/games/eduke32/default.nix
@@ -15,7 +15,7 @@ in stdenv.mkDerivation rec {
   };
 
   buildInputs = [ flac gtk2 libvorbis libvpx libGLU_combined SDL2 SDL2_mixer ]
-    ++ stdenv.lib.optional (stdenv.system == "i686-linux") nasm;
+    ++ stdenv.lib.optional (stdenv.hostPlatform.system == "i686-linux") nasm;
   nativeBuildInputs = [ pkgconfig ];
 
   postPatch = ''
diff --git a/pkgs/games/ezquake/default.nix b/pkgs/games/ezquake/default.nix
index 14885e7a3b2b..85433e116fbc 100644
--- a/pkgs/games/ezquake/default.nix
+++ b/pkgs/games/ezquake/default.nix
@@ -20,8 +20,8 @@ stdenv.mkDerivation rec {
   ];
 
   installPhase = with stdenv.lib; let
-    sys = last (splitString "-" stdenv.system);
-    arch = head (splitString "-" stdenv.system);
+    sys = last (splitString "-" stdenv.hostPlatform.system);
+    arch = head (splitString "-" stdenv.hostPlatform.system);
   in ''
     mkdir -p $out/bin
     find .
diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix
index d0ffa10baeca..bb019e570260 100644
--- a/pkgs/games/factorio/default.nix
+++ b/pkgs/games/factorio/default.nix
@@ -46,7 +46,7 @@ let
       };
     };
   };
-  actual = binDists.${stdenv.system}.${releaseType}.${branch} or (throw "Factorio: unsupported platform");
+  actual = binDists.${stdenv.hostPlatform.system}.${releaseType}.${branch} or (throw "Factorio: unsupported platform");
 
   bdistForArch = arch: { sha256 ? null
                        , version ? "0.16.51"
diff --git a/pkgs/games/nethack/default.nix b/pkgs/games/nethack/default.nix
index 3f9ec93f8618..2a39e3499ed9 100644
--- a/pkgs/games/nethack/default.nix
+++ b/pkgs/games/nethack/default.nix
@@ -6,7 +6,7 @@
 let
   platform =
     if stdenv.hostPlatform.isUnix then "unix"
-    else throw "Unknown platform for NetHack: ${stdenv.system}";
+    else throw "Unknown platform for NetHack: ${stdenv.hostPlatform.system}";
   unixHint =
     if x11Mode then "linux-x11"
     else if qtMode then "linux-qt4"
diff --git a/pkgs/games/oilrush/default.nix b/pkgs/games/oilrush/default.nix
index d637c1595954..319cdb610ca6 100644
--- a/pkgs/games/oilrush/default.nix
+++ b/pkgs/games/oilrush/default.nix
@@ -13,8 +13,8 @@ stdenv.mkDerivation {
     assert url != null && sha256 != null;
     fetchurl { inherit url sha256; };
   shell = stdenv.shell;
-  arch = if stdenv.system == "x86_64-linux" then "x64"
-         else if stdenv.system == "i686-linux" then "x86"
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
+         else if stdenv.hostPlatform.system == "i686-linux" then "x86"
          else "";
   unpackPhase = ''
     mkdir oilrush
diff --git a/pkgs/games/openarena/default.nix b/pkgs/games/openarena/default.nix
index 22ce05cb38a7..19e608f393a1 100644
--- a/pkgs/games/openarena/default.nix
+++ b/pkgs/games/openarena/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     cd $out
     unzip $src
 
-    ${if stdenv.system == "x86_64-linux" then ''
+    ${if stdenv.hostPlatform.system == "x86_64-linux" then ''
       patchelf --set-interpreter "${interpreter}" "${gameDir}/openarena.x86_64"
       makeWrapper "${gameDir}/openarena.x86_64" "$out/bin/openarena" \
         --prefix LD_LIBRARY_PATH : "${libPath}"
diff --git a/pkgs/games/racer/default.nix b/pkgs/games/racer/default.nix
index 4cbc5397bb3e..d11315cd6dfa 100644
--- a/pkgs/games/racer/default.nix
+++ b/pkgs/games/racer/default.nix
@@ -3,10 +3,10 @@
 stdenv.mkDerivation rec {
   name = "racer-1.1";
 
-  src = if stdenv.system == "i686-linux" then fetchurl {
+  src = if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
     url = http://hippo.nipax.cz/src/racer-1.1.tar.gz;
     sha256 = "0fll1qkqfcjq87k0jzsilcw701z92lfxn2y5ga1n038772lymxl9";
-  } else if stdenv.system == "x86_64-linux" then fetchurl {
+  } else if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
     url = https://hippo.nipax.cz/src/racer-1.1.64.tar.gz;
     sha256 = "0rjy3gmlhwfkb9zs58j0mc0dar0livwpbc19r6zw5r2k6r7xdan0";
   } else
diff --git a/pkgs/games/scummvm/default.nix b/pkgs/games/scummvm/default.nix
index 7625061953bb..2ebc2c82e506 100644
--- a/pkgs/games/scummvm/default.nix
+++ b/pkgs/games/scummvm/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl, nasm
 , alsaLib, flac, fluidsynth, freetype, libjpeg, libmad, libmpeg2, libogg, libvorbis, libGLU_combined, SDL2, zlib
-, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/games/sdlmame/default.nix b/pkgs/games/sdlmame/default.nix
index fa498b8e0411..9f90c9f14aac 100644
--- a/pkgs/games/sdlmame/default.nix
+++ b/pkgs/games/sdlmame/default.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation rec {
   version = "0.151.u0-1";
   name    = "sdlmame-${version}";
 
-  src = if stdenv.system == "x86_64-linux"
+  src = if stdenv.hostPlatform.system == "x86_64-linux"
     then fetchurl {
       url    = "http://seblu.net/a/archive/packages/s/sdlmame/${name}-x86_64.pkg.tar.xz";
       sha256 = "1j9vjxhrhsskrlk5wr7al4wk2hh3983kcva42mqal09bmc8qg3m9";
diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix
index b7dbba552698..e8a911bebd5e 100644
--- a/pkgs/games/steam/default.nix
+++ b/pkgs/games/steam/default.nix
@@ -4,9 +4,9 @@ let
   callPackage = newScope self;
 
   self = rec {
-    steamArch = if pkgs.stdenv.system == "x86_64-linux" then "amd64"
-                else if pkgs.stdenv.system == "i686-linux" then "i386"
-                else throw "Unsupported platform: ${pkgs.stdenv.system}";
+    steamArch = if pkgs.stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
+                else if pkgs.stdenv.hostPlatform.system == "i686-linux" then "i386"
+                else throw "Unsupported platform: ${pkgs.stdenv.hostPlatform.system}";
 
     steam-runtime = callPackage ./runtime.nix { };
     steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { };
diff --git a/pkgs/games/ut2004/demo.nix b/pkgs/games/ut2004/demo.nix
index 1a7ea2da75b6..9aea992ac750 100644
--- a/pkgs/games/ut2004/demo.nix
+++ b/pkgs/games/ut2004/demo.nix
@@ -2,8 +2,8 @@
 
 let
   arch =
-    if stdenv.system == "x86_64-linux" then "amd64"
-    else if stdenv.system == "i686-linux" then "x86"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "x86"
     else throw "Unsupported architecture";
 
 in stdenv.mkDerivation rec {
diff --git a/pkgs/games/vessel/default.nix b/pkgs/games/vessel/default.nix
index 62feeb97d521..ab6f1ca765ce 100644
--- a/pkgs/games/vessel/default.nix
+++ b/pkgs/games/vessel/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
       message = goBuyItNow;
       name = "${name}-bin";
       sha256 = "1vpwcrjiln2mx43h7ib3jnccyr3chk7a5x2bw9kb4lw8ycygvg96";
-    } else throw "unsupported platform ${stdenv.system} only i686-linux supported for now.";
+    } else throw "unsupported platform ${stdenv.hostPlatform.system} only i686-linux supported for now.";
 
   phases = "installPhase";
   ld_preload = ./isatty.c;
diff --git a/pkgs/games/worldofgoo/default.nix b/pkgs/games/worldofgoo/default.nix
index 9684f3b876a8..ad86072dd1ca 100644
--- a/pkgs/games/worldofgoo/default.nix
+++ b/pkgs/games/worldofgoo/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     then "WorldOfGooDemo-1.41"
     else "WorldofGoo-1.41";
 
-  arch = if stdenv.system == "x86_64-linux" then "supported"
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "supported"
     else throw "Sorry. World of Goo only is only supported on x86_64 now.";
 
   goBuyItNow = '' 
diff --git a/pkgs/games/xjump/default.nix b/pkgs/games/xjump/default.nix
index df9ff30f2101..028b5f49b66a 100644
--- a/pkgs/games/xjump/default.nix
+++ b/pkgs/games/xjump/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPlatform, fetchFromGitHub, autoconf, automake, libX11, libXt, libXpm, libXaw, localStateDir?null }:
+{ stdenv, fetchFromGitHub, autoconf, automake, libX11, libXt, libXpm, libXaw, localStateDir?null }:
 
 stdenv.mkDerivation rec {
   name = "xjump-${version}";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ autoconf automake ];
   buildInputs = [ libX11 libXt libXpm libXaw ];
   preConfigure = "autoreconf --install";
-  patches = if buildPlatform.isDarwin then [ ./darwin.patch ] else [];
+  patches = if stdenv.buildPlatform.isDarwin then [ ./darwin.patch ] else [];
   configureFlags =
     if localStateDir != null then
       ["--localstatedir=${localStateDir}"]
diff --git a/pkgs/games/zandronum/fmod.nix b/pkgs/games/zandronum/fmod.nix
index 2c53d93e4011..a5d9098242bd 100644
--- a/pkgs/games/zandronum/fmod.nix
+++ b/pkgs/games/zandronum/fmod.nix
@@ -1,7 +1,7 @@
 { stdenv, lib, fetchurl, alsaLib, libpulseaudio, undmg }:
 
 let
-  bits = stdenv.lib.optionalString (stdenv.system == "x86_64-linux") "64";
+  bits = stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "64";
   libPath = lib.makeLibraryPath [ stdenv.cc.cc alsaLib libpulseaudio ];
 
 in
diff --git a/pkgs/misc/base16-builder/default.nix b/pkgs/misc/base16-builder/default.nix
index be8d42a4292b..3d713848223b 100644
--- a/pkgs/misc/base16-builder/default.nix
+++ b/pkgs/misc/base16-builder/default.nix
@@ -11,6 +11,6 @@ let
   #
   nodePackages = import ./node-packages.nix {
     inherit pkgs;
-    inherit (stdenv) system;
+    inherit (stdenv.hostPlatform) system;
   };
 in nodePackages.base16-builder
diff --git a/pkgs/misc/cups/drivers/cnijfilter_4_00/default.nix b/pkgs/misc/cups/drivers/cnijfilter_4_00/default.nix
index b83e84154bbe..c8e5ddd09b14 100644
--- a/pkgs/misc/cups/drivers/cnijfilter_4_00/default.nix
+++ b/pkgs/misc/cups/drivers/cnijfilter_4_00/default.nix
@@ -7,9 +7,9 @@
    file included in the tarball */
 
 let arch = 
-  if stdenv.system == "x86_64-linux" then "64"
-    else if stdenv.system == "i686-linux" then "32"
-    else throw "Unsupported system ${stdenv.system}";
+  if stdenv.hostPlatform.system == "x86_64-linux" then "64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "32"
+    else throw "Unsupported system ${stdenv.hostPlatform.system}";
 
 in stdenv.mkDerivation rec {
   name = "cnijfilter-${version}";
diff --git a/pkgs/misc/cups/drivers/kyocera/default.nix b/pkgs/misc/cups/drivers/kyocera/default.nix
index 0711bad86a1e..9b40e4ff50e1 100644
--- a/pkgs/misc/cups/drivers/kyocera/default.nix
+++ b/pkgs/misc/cups/drivers/kyocera/default.nix
@@ -2,9 +2,9 @@
 
 let
   platform =
-    if stdenv.system == "x86_64-linux" then "64bit"
-    else if stdenv.system == "i686-linux" then "32bit"
-         else throw "Unsupported system: ${stdenv.system}";
+    if stdenv.hostPlatform.system == "x86_64-linux" then "64bit"
+    else if stdenv.hostPlatform.system == "i686-linux" then "32bit"
+         else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
   libPath = lib.makeLibraryPath [ cups ];
 in
diff --git a/pkgs/misc/cups/drivers/kyodialog3/default.nix b/pkgs/misc/cups/drivers/kyodialog3/default.nix
index 073bd4ccbbfc..bcd2914da0ce 100644
--- a/pkgs/misc/cups/drivers/kyodialog3/default.nix
+++ b/pkgs/misc/cups/drivers/kyodialog3/default.nix
@@ -6,9 +6,9 @@
 
 let
   platform =
-    if stdenv.system == "x86_64-linux" then "64bit"
-    else if stdenv.system == "i686-linux" then "32bit"
-         else throw "Unsupported system: ${stdenv.system}";
+    if stdenv.hostPlatform.system == "x86_64-linux" then "64bit"
+    else if stdenv.hostPlatform.system == "i686-linux" then "32bit"
+         else throw "Unsupported system: ${stdenv.hostPlatform.system}";
   debPlatform =
     if platform == "64bit" then "amd64"
     else "i386";
diff --git a/pkgs/misc/cups/drivers/samsung/4.01.17.nix b/pkgs/misc/cups/drivers/samsung/4.01.17.nix
index b30b4c4a2c18..547e25b6514e 100644
--- a/pkgs/misc/cups/drivers/samsung/4.01.17.nix
+++ b/pkgs/misc/cups/drivers/samsung/4.01.17.nix
@@ -16,8 +16,8 @@
 # Do not bump lightly! Visit <http://www.bchemnet.com/suldr/supported.html>
 # to see what will break when upgrading. Consider a new versioned attribute.
 let
-  installationPath = if stdenv.system == "x86_64-linux" then "x86_64" else "i386";
-  appendPath = if stdenv.system == "x86_64-linux" then "64" else "";
+  installationPath = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64" else "i386";
+  appendPath = if stdenv.hostPlatform.system == "x86_64-linux" then "64" else "";
   libPath = stdenv.lib.makeLibraryPath [ cups libusb ] + ":$out/lib:${stdenv.cc.cc.lib}/lib${appendPath}";
 in stdenv.mkDerivation rec {
   name = "samsung-UnifiedLinuxDriver-${version}";
diff --git a/pkgs/misc/cups/drivers/samsung/default.nix b/pkgs/misc/cups/drivers/samsung/default.nix
index 48636e1f76aa..b2c4bbb0f203 100644
--- a/pkgs/misc/cups/drivers/samsung/default.nix
+++ b/pkgs/misc/cups/drivers/samsung/default.nix
@@ -2,7 +2,7 @@
 
 let
 
-    arch = if stdenv.system == "x86_64-linux"
+    arch = if stdenv.hostPlatform.system == "x86_64-linux"
       then "x86_64"
       else "i386";
 
diff --git a/pkgs/misc/drivers/gutenprint/bin.nix b/pkgs/misc/drivers/gutenprint/bin.nix
index 3832c4de2dcc..6cf754192f86 100644
--- a/pkgs/misc/drivers/gutenprint/bin.nix
+++ b/pkgs/misc/drivers/gutenprint/bin.nix
@@ -27,7 +27,7 @@ TODO tidy this all up. Find source instead of binary. Fix paths ... Find out how
 stdenv.mkDerivation {
   name = "cups-gutenprint-binary-5.0.1";
 
-  src = if stdenv.system == "x86_64-linux" then fetchurl {
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl {
     url = https://www.openprinting.org/download/printdriver/debian/dists/lsb3.1/main/binary-amd64/gutenprint_5.0.1-1lsb3.1_amd64.deb;
     sha256 = "0an5gba6r6v54r53s2gj2fjk8fzpl4lrksjas2333528b0k8gbbc";
   } else throw "TODO"; # get from openprint.com -> drivers -> gutenprint
diff --git a/pkgs/misc/drivers/hplip/3.16.11.nix b/pkgs/misc/drivers/hplip/3.16.11.nix
index 91dce834a4bd..8982834d9a99 100644
--- a/pkgs/misc/drivers/hplip/3.16.11.nix
+++ b/pkgs/misc/drivers/hplip/3.16.11.nix
@@ -34,15 +34,15 @@ let
     "armv7l-linux" = "arm32";
   };
 
-  hplipArch = hplipPlatforms."${stdenv.system}"
-    or (throw "HPLIP not supported on ${stdenv.system}");
+  hplipArch = hplipPlatforms."${stdenv.hostPlatform.system}"
+    or (throw "HPLIP not supported on ${stdenv.hostPlatform.system}");
 
   pluginArches = [ "x86_32" "x86_64" "arm32" ];
 
 in
 
 assert withPlugin -> builtins.elem hplipArch pluginArches
-  || throw "HPLIP plugin not supported on ${stdenv.system}";
+  || throw "HPLIP plugin not supported on ${stdenv.hostPlatform.system}";
 
 pythonPackages.buildPythonApplication {
   inherit name src;
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix
index 59a75dab8832..f03d75dfa02d 100644
--- a/pkgs/misc/drivers/hplip/default.nix
+++ b/pkgs/misc/drivers/hplip/default.nix
@@ -36,15 +36,15 @@ let
     "armv7l-linux" = "arm32";
   };
 
-  hplipArch = hplipPlatforms."${stdenv.system}"
-    or (throw "HPLIP not supported on ${stdenv.system}");
+  hplipArch = hplipPlatforms."${stdenv.hostPlatform.system}"
+    or (throw "HPLIP not supported on ${stdenv.hostPlatform.system}");
 
   pluginArches = [ "x86_32" "x86_64" "arm32" ];
 
 in
 
 assert withPlugin -> builtins.elem hplipArch pluginArches
-  || throw "HPLIP plugin not supported on ${stdenv.system}";
+  || throw "HPLIP plugin not supported on ${stdenv.hostPlatform.system}";
 
 pythonPackages.buildPythonApplication {
   inherit name src;
diff --git a/pkgs/misc/emulators/retroarch/cores.nix b/pkgs/misc/emulators/retroarch/cores.nix
index 8f6e66c18c39..371ace848fb7 100644
--- a/pkgs/misc/emulators/retroarch/cores.nix
+++ b/pkgs/misc/emulators/retroarch/cores.nix
@@ -272,7 +272,7 @@ in with stdenv.lib.licenses;
 
     extraBuildInputs = [ libGLU_combined libpng ];
   }).override {
-    buildPhase = "make WITH_DYNAREC=${if stdenv.system == "x86_64-linux" then "x86_64" else "x86"}";
+    buildPhase = "make WITH_DYNAREC=${if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64" else "x86"}";
   };
 
   nestopia = (mkLibRetroCore rec {
@@ -300,7 +300,7 @@ in with stdenv.lib.licenses;
 
     extraBuildInputs = [ libGLU_combined libpng ];
   }).override {
-    buildPhase = "make WITH_DYNAREC=${if stdenv.system == "x86_64-linux" then "x86_64" else "x86"}";
+    buildPhase = "make WITH_DYNAREC=${if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64" else "x86"}";
   };
 
   picodrive = (mkLibRetroCore rec {
diff --git a/pkgs/misc/emulators/retroarch/default.nix b/pkgs/misc/emulators/retroarch/default.nix
index c834f6c9047d..a37d299fbf70 100644
--- a/pkgs/misc/emulators/retroarch/default.nix
+++ b/pkgs/misc/emulators/retroarch/default.nix
@@ -12,7 +12,7 @@
 , udev ? null
 , enableNvidiaCgToolkit ? false, nvidia_cg_toolkit ? null
 , withVulkan ? stdenv.isLinux, vulkan-loader ? null
-, targetPlatform, fetchurl
+, fetchurl
 }:
 
 with stdenv.lib;
@@ -50,7 +50,7 @@ in stdenv.mkDerivation rec {
 
   postInstall = optionalString withVulkan ''
     wrapProgram $out/bin/retroarch --prefix LD_LIBRARY_PATH ':' ${vulkan-loader}/lib
-  '' + optionalString targetPlatform.isDarwin ''
+  '' + optionalString stdenv.targetPlatform.isDarwin ''
     EXECUTABLE_NAME=RetroArch
     PRODUCT_NAME=RetroArch
     MACOSX_DEPLOYMENT_TARGET=10.5
diff --git a/pkgs/misc/emulators/wine/default.nix b/pkgs/misc/emulators/wine/default.nix
index a8eacbe234c6..91323ab6de7f 100644
--- a/pkgs/misc/emulators/wine/default.nix
+++ b/pkgs/misc/emulators/wine/default.nix
@@ -6,9 +6,9 @@
 # };
 # Make additional configurations on demand:
 # wine.override { wineBuild = "wine32"; wineRelease = "staging"; };
-{ lib, system, callPackage,
+{ lib, stdenv, callPackage,
   wineRelease ? "stable",
-  wineBuild ? (if system == "x86_64-linux" then "wineWow" else "wine32"),
+  wineBuild ? if stdenv.hostPlatform.system == "x86_64-linux" then "wineWow" else "wine32",
   libtxc_dxtn_Name ? "libtxc_dxtn_s2tc",
   pngSupport ? false,
   jpegSupport ? false,
diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix
index e31d6fea378e..2d1909547b61 100644
--- a/pkgs/os-specific/bsd/netbsd/default.nix
+++ b/pkgs/os-specific/bsd/netbsd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, hostPlatform, fetchcvs, lib, groff, mandoc, zlib, buildPackages
+{ stdenv, fetchcvs, lib, groff, mandoc, zlib, buildPackages
 , yacc, flex, libressl, bash, less, writeText }:
 
 let
@@ -32,8 +32,8 @@ let
     MKUNPRIVED = "yes";
     HOST_SH = "${bash}/bin/sh";
     OBJCOPY = if stdenv.isDarwin then "true" else "objcopy";
-    MACHINE_ARCH = hostPlatform.parsed.cpu.name;
-    MACHINE_CPU = hostPlatform.parsed.cpu.name;
+    MACHINE_ARCH = stdenv.hostPlatform.parsed.cpu.name;
+    MACHINE_CPU = stdenv.hostPlatform.parsed.cpu.name;
 
     INSTALL_FILE = "install -U -c";
     INSTALL_DIR = "xinstall -U -d";
@@ -478,7 +478,7 @@ in rec {
       "-DOXTABS=XTABS"
       "-DRANDOM_MAX=RAND_MAX"
       "-DINFTIM=-1"
-      (lib.optionalString hostPlatform.isMusl "-include sys/ttydefaults.h -include sys/file.h")
+      (lib.optionalString stdenv.hostPlatform.isMusl "-include sys/ttydefaults.h -include sys/file.h")
       "-DBE32TOH(x)=((void)0)"
       "-DBE64TOH(x)=((void)0)"
       "-D__c99inline=__inline"
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
index 3d62c3961221..ea5a59536062 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, appleDerivation, lib, targetPlatform
-, enableStatic ? targetPlatform.isiOS
-, enableShared ? !targetPlatform.isiOS
+{ stdenv, appleDerivation, lib
+, enableStatic ? stdenv.targetPlatform.isiOS
+, enableShared ? !stdenv.targetPlatform.isiOS
 }:
 
 appleDerivation {
diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix
index 995e9af38cb8..fff6eaaa5c1d 100644
--- a/pkgs/os-specific/darwin/cctools/port.nix
+++ b/pkgs/os-specific/darwin/cctools/port.nix
@@ -1,7 +1,6 @@
 { stdenv, fetchFromGitHub, autoconf, automake, libtool_2, autoreconfHook
 , libcxxabi, libuuid
 , libobjc ? null, maloader ? null
-, hostPlatform, targetPlatform
 , enableDumpNormalizedLibArgs ? false
 }:
 
@@ -12,17 +11,17 @@ let
   # 10.x. For 11.0 and higher we will need to upgrade to a newer cctools than the
   # default version here, which can support the new TBD format via Apple's
   # libtapi.
-  useOld = targetPlatform.isiOS;
+  useOld = stdenv.targetPlatform.isiOS;
 
   # The targetPrefix prepended to binary names to allow multiple binuntils on the
   # PATH to both be usable.
   targetPrefix = stdenv.lib.optionalString
-    (targetPlatform != hostPlatform)
-    "${targetPlatform.config}-";
+    (stdenv.targetPlatform != stdenv.hostPlatform)
+    "${stdenv.targetPlatform.config}-";
 in
 
 # Non-Darwin alternatives
-assert (!hostPlatform.isDarwin) -> maloader != null;
+assert (!stdenv.hostPlatform.isDarwin) -> maloader != null;
 
 assert enableDumpNormalizedLibArgs -> (!useOld);
 
@@ -77,7 +76,7 @@ let
     enableParallelBuilding = true;
 
     # TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
-    configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
 
     postPatch = ''
       sed -i -e 's/addStandardLibraryDirectories = true/addStandardLibraryDirectories = false/' cctools/ld64/src/ld/Options.cpp
@@ -131,7 +130,7 @@ let
     };
 
     meta = {
-      broken = !targetPlatform.isDarwin; # Only supports darwin targets
+      broken = !stdenv.targetPlatform.isDarwin; # Only supports darwin targets
       homepage = http://www.opensource.apple.com/source/cctools/;
       description = "MacOS Compiler Tools (cross-platform port)";
       license = stdenv.lib.licenses.apsl20;
diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix
index 910f1b91c215..369529d71675 100644
--- a/pkgs/os-specific/darwin/xcode/default.nix
+++ b/pkgs/os-specific/darwin/xcode/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, requireFile, targetPlatform, lib }:
+{ stdenv, requireFile, lib }:
 
 let requireXcode = version: sha256:
   let
@@ -46,5 +46,5 @@ in lib.makeExtensible (self: {
   xcode_9_1 = requireXcode "9.1" "0ab1403wy84ys3yn26fj78cazhpnslmh3nzzp1wxib3mr1afjvic";
   xcode_9_2 = requireXcode "9.2" "1bgfgdp266cbbqf2axcflz92frzvhi0qw0jdkcw6r85kdpc8dj4c";
   xcode_9_4 = requireXcode "9.4" "6731381785075602a52489f7ea47ece8f6daf225007ba3ffae1fd59b1c0b5f01";
-  xcode = self."xcode_${lib.replaceStrings ["."] ["_"] (if targetPlatform.useiOSPrebuilt then targetPlatform.xcodeVer else "8.2")}";
+  xcode = self."xcode_${lib.replaceStrings ["."] ["_"] (if stdenv.targetPlatform.useiOSPrebuilt then stdenv.targetPlatform.xcodeVer else "8.2")}";
 })
diff --git a/pkgs/os-specific/linux/alsa-plugins/wrapper.nix b/pkgs/os-specific/linux/alsa-plugins/wrapper.nix
index 7dbd01bf058e..60262a14c9b2 100644
--- a/pkgs/os-specific/linux/alsa-plugins/wrapper.nix
+++ b/pkgs/os-specific/linux/alsa-plugins/wrapper.nix
@@ -1,5 +1,5 @@
 { writeScriptBin, stdenv, alsaPlugins }:
-writeScriptBin "ap${if stdenv.system == "i686-linux" then "32" else "64"}" ''
+writeScriptBin "ap${if stdenv.hostPlatform.system == "i686-linux" then "32" else "64"}" ''
   #/bin/sh
   ALSA_PLUGIN_DIRS=${alsaPlugins}/lib/alsa-lib "$@"
 ''
diff --git a/pkgs/os-specific/linux/amdgpu-pro/default.nix b/pkgs/os-specific/linux/amdgpu-pro/default.nix
index 97658c831eb0..b72944a49eb1 100644
--- a/pkgs/os-specific/linux/amdgpu-pro/default.nix
+++ b/pkgs/os-specific/linux/amdgpu-pro/default.nix
@@ -16,9 +16,9 @@ let
   bitness = if stdenv.is64bit then "64" else "32";
 
   libArch =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       "i386-linux-gnu"
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       "x86_64-linux-gnu"
     else throw "amdgpu-pro is Linux only. Sorry. The build was stopped.";
 
diff --git a/pkgs/os-specific/linux/ati-drivers/default.nix b/pkgs/os-specific/linux/ati-drivers/default.nix
index df6fa3555fee..d5d42faa913e 100644
--- a/pkgs/os-specific/linux/ati-drivers/default.nix
+++ b/pkgs/os-specific/linux/ati-drivers/default.nix
@@ -37,9 +37,9 @@ stdenv.mkDerivation rec {
   build = "15.302";
 
   linuxonly =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       true
-    else if stdenv.system == "x86_64-linux" then
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
       true
     else throw "ati-drivers are Linux only. Sorry. The build was stopped.";
 
diff --git a/pkgs/os-specific/linux/broadcom-sta/default.nix b/pkgs/os-specific/linux/broadcom-sta/default.nix
index 9848882f3b86..541539522f85 100644
--- a/pkgs/os-specific/linux/broadcom-sta/default.nix
+++ b/pkgs/os-specific/linux/broadcom-sta/default.nix
@@ -7,7 +7,7 @@ let
     x86_64-linux = "1gj485qqr190idilacpxwgqyw21il03zph2rddizgj7fbd6pfyaz";
   };
 
-  arch = stdenv.lib.optionalString (stdenv.system == "x86_64-linux") "_64";
+  arch = stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "_64";
   tarballVersion = stdenv.lib.replaceStrings ["."] ["_"] version;
   tarball = "hybrid-v35${arch}-nodebug-pcoem-${tarballVersion}.tar.gz";
 in
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/${tarball}";
-    sha256 = hashes.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
+    sha256 = hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
   };
 
   hardeningDisable = [ "pic" ];
diff --git a/pkgs/os-specific/linux/busybox/sandbox-shell.nix b/pkgs/os-specific/linux/busybox/sandbox-shell.nix
index b94fae7f787b..de8865ba3acc 100644
--- a/pkgs/os-specific/linux/busybox/sandbox-shell.nix
+++ b/pkgs/os-specific/linux/busybox/sandbox-shell.nix
@@ -1,9 +1,9 @@
-{ busybox, hostPlatform }:
+{ busybox, stdenv}:
 
 # Minimal shell for use as basic /bin/sh in sandbox builds
 busybox.override {
   # musl roadmap has RISC-V support projected for 1.1.20
-  useMusl = !hostPlatform.isRiscV;
+  useMusl = !stdenv.hostPlatform.isRiscV;
   enableStatic = true;
   enableMinimal = true;
   extraConfig = ''
diff --git a/pkgs/os-specific/linux/displaylink/default.nix b/pkgs/os-specific/linux/displaylink/default.nix
index ad42590ad19c..af8c790e325f 100644
--- a/pkgs/os-specific/linux/displaylink/default.nix
+++ b/pkgs/os-specific/linux/displaylink/default.nix
@@ -3,8 +3,8 @@
 
 let
   arch =
-    if stdenv.system == "x86_64-linux" then "x64"
-    else if stdenv.system == "i686-linux" then "x86"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "x86"
     else throw "Unsupported architecture";
   bins = "${arch}-ubuntu-1604";
   libPath = lib.makeLibraryPath [ stdenv.cc.cc utillinux libusb1 evdi ];
diff --git a/pkgs/os-specific/linux/fusionio/util.nix b/pkgs/os-specific/linux/fusionio/util.nix
index 0f1e2748c889..6327a95f39d7 100644
--- a/pkgs/os-specific/linux/fusionio/util.nix
+++ b/pkgs/os-specific/linux/fusionio/util.nix
@@ -39,7 +39,7 @@ stdenv.mkDerivation {
     description = "Fusionio command line utilities";
     license = licenses.unfree;
     platforms = [ "x86_64-linux" ];
-    broken = stdenv.system != "x86_64-linux";
+    broken = stdenv.hostPlatform.system != "x86_64-linux";
     maintainers = with maintainers; [ wkennington ];
   };
 }
diff --git a/pkgs/os-specific/linux/fusionio/vsl.nix b/pkgs/os-specific/linux/fusionio/vsl.nix
index 665c4b4d0813..6ebe2e0cdaf5 100644
--- a/pkgs/os-specific/linux/fusionio/vsl.nix
+++ b/pkgs/os-specific/linux/fusionio/vsl.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     description = "Kernel driver for accessing fusion-io cards";
     license = licenses.unfree;
     platforms = [ "x86_64-linux" ];
-    broken = stdenv.system != "x86_64-linux";
+    broken = stdenv.hostPlatform.system != "x86_64-linux";
     maintainers = with maintainers; [ wkennington ];
   };
 }
diff --git a/pkgs/os-specific/linux/jool/cli.nix b/pkgs/os-specific/linux/jool/cli.nix
index 50f0398e1343..d851a47924d6 100644
--- a/pkgs/os-specific/linux/jool/cli.nix
+++ b/pkgs/os-specific/linux/jool/cli.nix
@@ -24,6 +24,7 @@ stdenv.mkDerivation {
     homepage = https://www.jool.mx/;
     description = "Fairly compliant SIIT and Stateful NAT64 for Linux - CLI tools";
     platforms = platforms.linux;
+    license = licenses.gpl2;
     maintainers = with maintainers; [ fpletz ];
   };
 }
diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix
index 677bb076b0c8..e82b785f624a 100644
--- a/pkgs/os-specific/linux/kernel-headers/default.nix
+++ b/pkgs/os-specific/linux/kernel-headers/default.nix
@@ -1,9 +1,8 @@
 { stdenvNoCC, lib, buildPackages
-, hostPlatform
 , fetchurl, perl
 }:
 
-assert hostPlatform.isLinux;
+assert stdenvNoCC.hostPlatform.isLinux;
 
 let
   common = { version, sha256, patches ? null }: stdenvNoCC.mkDerivation {
@@ -14,14 +13,14 @@ let
       inherit sha256;
     };
 
-    ARCH = hostPlatform.platform.kernelArch;
+    ARCH = stdenvNoCC.hostPlatform.platform.kernelArch;
 
     # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
     # We do this so we have a build->build, not build->host, C compiler.
     depsBuildBuild = [ buildPackages.stdenv.cc ];
     nativeBuildInputs = [ perl ];
 
-    extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"];
+    extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"];
 
     # "patches" array defaults to 'null' to avoid changing hash
     # and causing mass rebuild
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index bf99729b33e3..27a615d7bb96 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -114,7 +114,7 @@ let
       IP_DCCP_CCID3      = no; # experimental
       CLS_U32_PERF       = yes;
       CLS_U32_MARK       = yes;
-      BPF_JIT            = when (stdenv.system == "x86_64-linux") yes;
+      BPF_JIT            = when (stdenv.hostPlatform.system == "x86_64-linux") yes;
       WAN                = yes;
       # Required by systemd per-cgroup firewalling
       CGROUP_BPF                  = option yes;
@@ -184,7 +184,7 @@ let
       FB_VESA             = yes;
       FRAMEBUFFER_CONSOLE = yes;
       FRAMEBUFFER_CONSOLE_ROTATION = yes;
-      FB_GEODE            = when (stdenv.system == "i686-linux") yes;
+      FB_GEODE            = when (stdenv.hostPlatform.system == "i686-linux") yes;
     };
 
     video = {
@@ -497,7 +497,7 @@ let
     };
 
     # Support x2APIC (which requires IRQ remapping)
-    x2apic = optionalAttrs (stdenv.system == "x86_64-linux") {
+    x2apic = optionalAttrs (stdenv.hostPlatform.system == "x86_64-linux") {
       X86_X2APIC = yes;
       IRQ_REMAP  = yes;
     };
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 4af5e80a655a..e424dff596d3 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -35,15 +35,14 @@
   # symbolic name and `patch' is the actual patch.  The patch may
   # optionally be compressed with gzip or bzip2.
   kernelPatches ? []
-, ignoreConfigErrors ? hostPlatform.platform.name != "pc" ||
-                       hostPlatform != stdenv.buildPlatform
+, ignoreConfigErrors ? stdenv.hostPlatform.platform.name != "pc" ||
+                       stdenv.hostPlatform != stdenv.buildPlatform
 , extraMeta ? {}
-, hostPlatform
 
-# easy overrides to hostPlatform.platform members
-, autoModules ? hostPlatform.platform.kernelAutoModules
-, preferBuiltin ? hostPlatform.platform.kernelPreferBuiltin or false
-, kernelArch ? hostPlatform.platform.kernelArch
+# easy overrides to stdenv.hostPlatform.platform members
+, autoModules ? stdenv.hostPlatform.platform.kernelAutoModules
+, preferBuiltin ? stdenv.hostPlatform.platform.kernelPreferBuiltin or false
+, kernelArch ? stdenv.hostPlatform.platform.kernelArch
 
 , mkValueOverride ? null
 , ...
@@ -69,7 +68,7 @@ let
     inherit stdenv version structuredExtraConfig mkValueOverride;
 
     # append extraConfig for backwards compatibility but also means the user can't override the kernelExtraConfig part
-    extraConfig = extraConfig + lib.optionalString (hostPlatform.platform ? kernelExtraConfig) hostPlatform.platform.kernelExtraConfig;
+    extraConfig = extraConfig + lib.optionalString (stdenv.hostPlatform.platform ? kernelExtraConfig) stdenv.hostPlatform.platform.kernelExtraConfig;
 
     features = kernelFeatures; # Ensure we know of all extra patches, etc.
   };
@@ -93,11 +92,11 @@ let
     nativeBuildInputs = [ perl ]
       ++ lib.optionals (stdenv.lib.versionAtLeast version "4.16") [ bison flex ];
 
-    platformName = hostPlatform.platform.name;
+    platformName = stdenv.hostPlatform.platform.name;
     # e.g. "defconfig"
-    kernelBaseConfig = if defconfig != null then defconfig else hostPlatform.platform.kernelBaseConfig;
+    kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.platform.kernelBaseConfig;
     # e.g. "bzImage"
-    kernelTarget = hostPlatform.platform.kernelTarget;
+    kernelTarget = stdenv.hostPlatform.platform.kernelTarget;
 
     prePatch = kernel.prePatch + ''
       # Patch kconfig to print "###" after every question so that
@@ -128,7 +127,7 @@ let
   };
 
   kernel = (callPackage ./manual-config.nix {}) {
-    inherit version modDirVersion src kernelPatches stdenv extraMeta configfile hostPlatform;
+    inherit version modDirVersion src kernelPatches stdenv extraMeta configfile;
 
     config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
   };
diff --git a/pkgs/os-specific/linux/kernel/linux-4.14.nix b/pkgs/os-specific/linux/kernel/linux-4.14.nix
index bbc985925030..000764eca9b3 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.14.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.14.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
 
 with stdenv.lib;
 
diff --git a/pkgs/os-specific/linux/kernel/linux-4.17.nix b/pkgs/os-specific/linux/kernel/linux-4.17.nix
index c9a79fd23cba..5c13f366221e 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.17.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.17.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
 
 with stdenv.lib;
 
diff --git a/pkgs/os-specific/linux/kernel/linux-4.18.nix b/pkgs/os-specific/linux/kernel/linux-4.18.nix
index bbd0bbfbb21c..e76beadc27bf 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.18.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.18.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
 
 with stdenv.lib;
 
diff --git a/pkgs/os-specific/linux/kernel/linux-4.4.nix b/pkgs/os-specific/linux/kernel/linux-4.4.nix
index a4433cc434c5..7c5f345e3400 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.4.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.4.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.4.153";
diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix
index 8fa710a0e469..ed0075b7876b 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.9.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.9.124";
diff --git a/pkgs/os-specific/linux/kernel/linux-beagleboard.nix b/pkgs/os-specific/linux/kernel/linux-beagleboard.nix
index 4f0ff53c59ce..e98104f11ca9 100644
--- a/pkgs/os-specific/linux/kernel/linux-beagleboard.nix
+++ b/pkgs/os-specific/linux/kernel/linux-beagleboard.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ubootTools, dtc, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ubootTools, dtc, ... } @ args:
 
 let
   modDirVersion = "4.14.12";
diff --git a/pkgs/os-specific/linux/kernel/linux-copperhead-lts.nix b/pkgs/os-specific/linux/kernel/linux-copperhead-lts.nix
index 85ad00efcd67..366cfd39e4af 100644
--- a/pkgs/os-specific/linux/kernel/linux-copperhead-lts.nix
+++ b/pkgs/os-specific/linux/kernel/linux-copperhead-lts.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
 
 with stdenv.lib;
 
diff --git a/pkgs/os-specific/linux/kernel/linux-hardkernel-4.14.nix b/pkgs/os-specific/linux/kernel/linux-hardkernel-4.14.nix
index 2bce56e1e529..d1d7d240cce5 100644
--- a/pkgs/os-specific/linux/kernel/linux-hardkernel-4.14.nix
+++ b/pkgs/os-specific/linux/kernel/linux-hardkernel-4.14.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.14.66-147";
diff --git a/pkgs/os-specific/linux/kernel/linux-mptcp-93.nix b/pkgs/os-specific/linux/kernel/linux-mptcp-93.nix
index 2efe357cbd68..8be59fbea903 100644
--- a/pkgs/os-specific/linux/kernel/linux-mptcp-93.nix
+++ b/pkgs/os-specific/linux/kernel/linux-mptcp-93.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
 
 buildLinux (rec {
   mptcpVersion = "0.93";
diff --git a/pkgs/os-specific/linux/kernel/linux-mptcp.nix b/pkgs/os-specific/linux/kernel/linux-mptcp.nix
index a439fd0a6ec5..8014cb565267 100644
--- a/pkgs/os-specific/linux/kernel/linux-mptcp.nix
+++ b/pkgs/os-specific/linux/kernel/linux-mptcp.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
 
 buildLinux (rec {
   mptcpVersion = "0.94";
diff --git a/pkgs/os-specific/linux/kernel/linux-riscv.nix b/pkgs/os-specific/linux/kernel/linux-riscv.nix
index 60370311865f..dbc69144c4da 100644
--- a/pkgs/os-specific/linux/kernel/linux-riscv.nix
+++ b/pkgs/os-specific/linux/kernel/linux-riscv.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.16-rc6";
diff --git a/pkgs/os-specific/linux/kernel/linux-rpi.nix b/pkgs/os-specific/linux/kernel/linux-rpi.nix
index e68a0ed26719..e6d7b1cee9db 100644
--- a/pkgs/os-specific/linux/kernel/linux-rpi.nix
+++ b/pkgs/os-specific/linux/kernel/linux-rpi.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
 
 let
   modDirVersion = "4.14.50";
@@ -18,7 +18,7 @@ stdenv.lib.overrideDerivation (buildLinux (args // rec {
   defconfig = {
     "armv6l-linux" = "bcmrpi_defconfig";
     "armv7l-linux" = "bcm2709_defconfig";
-  }.${stdenv.system} or (throw "linux_rpi not supported on '${stdenv.system}'");
+  }.${stdenv.hostPlatform.system} or (throw "linux_rpi not supported on '${stdenv.hostPlatform.system}'");
 
   features = {
     efiBootStub = false;
diff --git a/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix b/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix
index 442c89675119..0a936c6c053b 100644
--- a/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix
+++ b/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ncurses, ... } @ args:
+{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ncurses, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.12.2";
diff --git a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix
index 1fb9866f4e95..f9d2bd11813e 100644
--- a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix
+++ b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchgit, perl, buildLinux, ... } @ args:
+{ stdenv, buildPackages, fetchgit, perl, buildLinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.16.2018.08.03";
diff --git a/pkgs/os-specific/linux/kernel/linux-testing.nix b/pkgs/os-specific/linux/kernel/linux-testing.nix
index c2feeceb0729..44f267bf7151 100644
--- a/pkgs/os-specific/linux/kernel/linux-testing.nix
+++ b/pkgs/os-specific/linux/kernel/linux-testing.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, libelf, utillinux, ... } @ args:
+{ stdenv, buildPackages, fetchurl, perl, buildLinux, libelf, utillinux, ... } @ args:
 
 buildLinux (args // rec {
   version = "4.19-rc1";
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 33aa22abaf22..2cc83e62d11e 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -36,8 +36,6 @@ in {
   allowImportFromDerivation ? false,
   # ignored
   features ? null,
-
-  hostPlatform
 }:
 
 let
@@ -56,8 +54,8 @@ let
 
   commonMakeFlags = [
     "O=$(buildRoot)"
-  ] ++ stdenv.lib.optionals (hostPlatform.platform ? kernelMakeFlags)
-    hostPlatform.platform.kernelMakeFlags;
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.platform ? kernelMakeFlags)
+    stdenv.hostPlatform.platform.kernelMakeFlags;
 
   drvAttrs = config_: platform: kernelPatches: configfile:
     let
@@ -255,7 +253,7 @@ in
 
 assert stdenv.lib.versionAtLeast version "4.14" -> libelf != null;
 assert stdenv.lib.versionAtLeast version "4.15" -> utillinux != null;
-stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches configfile) // {
+stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches configfile) // {
   name = "linux-${version}";
 
   enableParallelBuilding = true;
@@ -279,5 +277,5 @@ stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches config
     "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
   ];
 
-  karch = hostPlatform.platform.kernelArch;
+  karch = stdenv.hostPlatform.platform.kernelArch;
 })
diff --git a/pkgs/os-specific/linux/klibc/default.nix b/pkgs/os-specific/linux/klibc/default.nix
index c503b982aa29..8cae61d56a92 100644
--- a/pkgs/os-specific/linux/klibc/default.nix
+++ b/pkgs/os-specific/linux/klibc/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurl, linuxHeaders, perl
-, buildPlatform, hostPlatform
-}:
+{ stdenv, fetchurl, linuxHeaders, perl }:
 
 let
   commonMakeFlags = [
@@ -25,12 +23,12 @@ stdenv.mkDerivation rec {
   hardeningDisable = [ "format" "stackprotector" ];
 
   makeFlags = commonMakeFlags ++ [
-    "KLIBCARCH=${hostPlatform.platform.kernelArch}"
+    "KLIBCARCH=${stdenv.hostPlatform.platform.kernelArch}"
     "KLIBCKERNELSRC=${linuxHeaders}"
   ] # TODO(@Ericson2314): We now can get the ABI from
-    # `hostPlatform.parsed.abi`, is this still a good idea?
-    ++ stdenv.lib.optional (hostPlatform.platform.kernelArch == "arm") "CONFIG_AEABI=y"
-    ++ stdenv.lib.optional (hostPlatform != buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
+    # `stdenv.hostPlatform.parsed.abi`, is this still a good idea?
+    ++ stdenv.lib.optional (stdenv.hostPlatform.platform.kernelArch == "arm") "CONFIG_AEABI=y"
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
 
   # Install static binaries as well.
   postInstall = ''
diff --git a/pkgs/os-specific/linux/kmod/default.nix b/pkgs/os-specific/linux/kmod/default.nix
index 142c176a15fa..43d69ac9574d 100644
--- a/pkgs/os-specific/linux/kmod/default.nix
+++ b/pkgs/os-specific/linux/kmod/default.nix
@@ -33,9 +33,10 @@ in stdenv.mkDerivation rec {
     ln -s bin $out/sbin
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = https://www.kernel.org/pub/linux/utils/kernel/kmod/;
     description = "Tools for loading and managing Linux kernel modules";
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/libatasmart/default.nix b/pkgs/os-specific/linux/libatasmart/default.nix
index 81333ce790ed..3c8c71bdde57 100644
--- a/pkgs/os-specific/linux/libatasmart/default.nix
+++ b/pkgs/os-specific/linux/libatasmart/default.nix
@@ -11,9 +11,10 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ udev ];
 
-  meta = {
-    homepage = http://0pointer.de/public/;
+  meta = with stdenv.lib; {
+    homepage = http://0pointer.de/blog/projects/being-smart.html;
     description = "Library for querying ATA SMART status";
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/lksctp-tools/default.nix b/pkgs/os-specific/linux/lksctp-tools/default.nix
index f5f08a3e7c69..6c644c9482a3 100644
--- a/pkgs/os-specific/linux/lksctp-tools/default.nix
+++ b/pkgs/os-specific/linux/lksctp-tools/default.nix
@@ -8,9 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "05da6c2v3acc18ndvmkrag6x5lf914b7s0xkkr6wkvrbvd621sqs";
   };
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Linux Kernel Stream Control Transmission Protocol Tools.";
     homepage = http://lksctp.sourceforge.net/;
-    platforms = stdenv.lib.platforms.linux;
+    license = with licenses; [ gpl2 lgpl21 ]; # library is lgpl21
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/lm-sensors/default.nix b/pkgs/os-specific/linux/lm-sensors/default.nix
index 25b868369ae1..af52dc551ddd 100644
--- a/pkgs/os-specific/linux/lm-sensors/default.nix
+++ b/pkgs/os-specific/linux/lm-sensors/default.nix
@@ -27,9 +27,10 @@ stdenv.mkDerivation rec {
     ${stdenv.lib.optionalString sensord "PROG_EXTRA=sensord"})
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://www.lm-sensors.org/;
     description = "Tools for reading hardware sensors";
-    platforms = stdenv.lib.platforms.linux;
+    license = with licenses; [ gpl2 lgpl21 ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/mdadm/default.nix b/pkgs/os-specific/linux/mdadm/default.nix
index 6de666630bb3..52a5f16bc52c 100644
--- a/pkgs/os-specific/linux/mdadm/default.nix
+++ b/pkgs/os-specific/linux/mdadm/default.nix
@@ -1,6 +1,5 @@
 { stdenv, writeScript
 , fetchurl, groff
-, buildPlatform, hostPlatform
 }:
 
 let
@@ -32,7 +31,7 @@ stdenv.mkDerivation rec {
     "NIXOS=1" "INSTALL=install" "INSTALL_BINDIR=$(out)/sbin"
     "MANDIR=$(out)/share/man" "RUN_DIR=/dev/.mdadm"
     "STRIP="
-  ] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
   ];
 
diff --git a/pkgs/os-specific/linux/multipath-tools/default.nix b/pkgs/os-specific/linux/multipath-tools/default.nix
index a1b207ffea09..6488f98565a9 100644
--- a/pkgs/os-specific/linux/multipath-tools/default.nix
+++ b/pkgs/os-specific/linux/multipath-tools/default.nix
@@ -31,9 +31,10 @@ stdenv.mkDerivation rec {
     "unitdir=$(out)/lib/systemd/system"
   ];
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Tools for the Linux multipathing driver";
     homepage = http://christophe.varoqui.free.fr/;
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/musl/default.nix b/pkgs/os-specific/linux/musl/default.nix
index e586539db08d..9628ec516763 100644
--- a/pkgs/os-specific/linux/musl/default.nix
+++ b/pkgs/os-specific/linux/musl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, hostPlatform
+{ stdenv, lib, fetchurl
 , linuxHeaders ? null
 , useBSDCompatHeaders ? true
 }:
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     configureFlagsArray+=("--syslibdir=$out/lib")
   '';
 
-  CFLAGS="-fstack-protector-strong" + lib.optionalString hostPlatform.isPower " -mlong-double-64";
+  CFLAGS="-fstack-protector-strong" + lib.optionalString stdenv.hostPlatform.isPower " -mlong-double-64";
 
   configureFlags = [
     "--enable-shared"
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index 359d18690843..f67663b31061 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, lib, pkgconfig, utillinux, libcap, libtirpc, libevent, libnfsidmap
+{ stdenv, fetchurl, fetchpatch, lib, pkgconfig, utillinux, libcap, libtirpc, libevent
 , sqlite, kerberos, kmod, libuuid, keyutils, lvm2, systemd, coreutils, tcp_wrappers
 , buildEnv
 }:
@@ -14,17 +14,21 @@ let
 
 in stdenv.mkDerivation rec {
   name = "nfs-utils-${version}";
-  version = "2.1.1";
+  version = "2.3.2";
 
   src = fetchurl {
-    url = "mirror://sourceforge/nfs/${name}.tar.bz2";
-    sha256 = "02dvxphndpm8vpqqnl0zvij97dq9vsq2a179pzrjcv2i91ll2a0a";
+    url = "https://kernel.org/pub/linux/utils/nfs-utils/${version}/${name}.tar.xz";
+    sha256 = "06av6cjf8h18dpaxh8cd1awsra75zf6s5sj5r2z5g7scbj051ziw";
   };
 
+  # libnfsidmap is built together with nfs-utils from the same source,
+  # put it in the "lib" output, and the headers in "dev"
+  outputs = [ "out" "dev" "lib" "man" ];
+
   nativeBuildInputs = [ pkgconfig ];
 
   buildInputs = [
-    libtirpc libcap libevent libnfsidmap sqlite lvm2
+    libtirpc libcap libevent sqlite lvm2
     libuuid keyutils kerberos tcp_wrappers
   ];
 
@@ -34,8 +38,9 @@ in stdenv.mkDerivation rec {
     [ "--enable-gss"
       "--with-statedir=/var/lib/nfs"
       "--with-krb5=${kerberosEnv}"
-      "--with-systemd=$(out)/etc/systemd/system"
+      "--with-systemd=${placeholder "out"}/etc/systemd/system"
       "--enable-libmount-mount"
+      "--with-pluginpath=${placeholder "lib"}/lib/libnfsidmap" # this installs libnfsidmap
     ]
     ++ lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc.bin}/bin/rpcgen";
 
@@ -99,7 +104,7 @@ in stdenv.mkDerivation rec {
       daemons.
     '';
 
-    homepage = https://sourceforge.net/projects/nfs/;
+    homepage = https://linux-nfs.org/;
     license = licenses.gpl2;
     platforms = platforms.linux;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/os-specific/linux/nvidia-x11/generic.nix b/pkgs/os-specific/linux/nvidia-x11/generic.nix
index 0ededc08050d..06125787a588 100644
--- a/pkgs/os-specific/linux/nvidia-x11/generic.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/generic.nix
@@ -34,22 +34,22 @@ let
     builder = ./builder.sh;
 
     src =
-      if stdenv.system == "i686-linux" then
+      if stdenv.hostPlatform.system == "i686-linux" then
         fetchurl {
           url = "https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run";
           sha256 = sha256_32bit;
         }
-      else if stdenv.system == "x86_64-linux" then
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
         fetchurl {
           url = "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run";
           sha256 = sha256_64bit;
         }
-      else throw "nvidia-x11 does not support platform ${stdenv.system}";
+      else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
 
     patches = if libsOnly then null else patches;
     inherit prePatch;
     inherit version useGLVND useProfiles;
-    inherit (stdenv) system;
+    inherit (stdenv.hostPlatform) system;
 
     outputs = [ "out" ] ++ optional (!libsOnly) "bin";
     outputDev = if libsOnly then null else "bin";
diff --git a/pkgs/os-specific/linux/pam/default.nix b/pkgs/os-specific/linux/pam/default.nix
index 0e7033972496..9db581ad527d 100644
--- a/pkgs/os-specific/linux/pam/default.nix
+++ b/pkgs/os-specific/linux/pam/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPackages, hostPlatform, fetchurl, fetchpatch, flex, cracklib, db4 }:
+{ stdenv, buildPackages, fetchurl, fetchpatch, flex, cracklib, db4 }:
 
 stdenv.mkDerivation rec {
   name = "linux-pam-${version}";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "1fyi04d5nsh8ivd0rn2y0z83ylgc0licz7kifbb6xxi2ylgfs6i4";
   };
 
-  patches = stdenv.lib.optionals (hostPlatform.libc == "musl") [
+  patches = stdenv.lib.optionals (stdenv.hostPlatform.libc == "musl") [
     (fetchpatch {
       url = "https://git.alpinelinux.org/cgit/aports/plain/main/linux-pam/fix-compat.patch?id=05a62bda8ec255d7049a2bd4cf0fdc4b32bdb2cc";
       sha256 = "1h5yp5h2mqp1fcwiwwklyfpa69a3i03ya32pivs60fd7g5bqa7sf";
@@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
 
   preConfigure = ''
     configureFlags="$configureFlags --includedir=$out/include/security"
-  '' + stdenv.lib.optionalString (hostPlatform.libc == "musl") ''
+  '' + stdenv.lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
       # export ac_cv_search_crypt=no
       # (taken from Alpine linux, apparently insecure but also doesn't build O:))
       # disable insecure modules
diff --git a/pkgs/os-specific/linux/pam_ccreds/default.nix b/pkgs/os-specific/linux/pam_ccreds/default.nix
index 6026ac1d41aa..8293ac0a830a 100644
--- a/pkgs/os-specific/linux/pam_ccreds/default.nix
+++ b/pkgs/os-specific/linux/pam_ccreds/default.nix
@@ -11,10 +11,12 @@ stdenv.mkDerivation {
     sed 's/-o root -g root//' -i Makefile.in
   '';
 
-  buildInputs = [pam openssl db];
-  meta = {
+  buildInputs = [ pam openssl db ];
+
+  meta = with stdenv.lib; {
     homepage = http://www.padl.com/OSS/pam_ccreds.html;
     description = "PAM module to locally authenticate using an enterprise identity when the network is unavailable";
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/pam_mount/default.nix b/pkgs/os-specific/linux/pam_mount/default.nix
index c38990bdf8fd..29ed9375c2e3 100644
--- a/pkgs/os-specific/linux/pam_mount/default.nix
+++ b/pkgs/os-specific/linux/pam_mount/default.nix
@@ -27,10 +27,11 @@ stdenv.mkDerivation rec {
     rm -r $out/nix
     '';
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://pam-mount.sourceforge.net/;
     description = "PAM module to mount volumes for a user session";
-    maintainers = [ stdenv.lib.maintainers.tstrobel ];
-    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ maintainers.tstrobel ];
+    license = with licenses; [ gpl2 gpl3 lgpl21 lgpl3 ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/perf-tools/default.nix b/pkgs/os-specific/linux/perf-tools/default.nix
index 31f86965ee8d..ee12251ae5e3 100644
--- a/pkgs/os-specific/linux/perf-tools/default.nix
+++ b/pkgs/os-specific/linux/perf-tools/default.nix
@@ -34,10 +34,11 @@ stdenv.mkDerivation {
       mv $d/man $out/share/
     '';
 
-  meta = {
-    platforms = lib.platforms.linux;
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
     homepage = https://github.com/brendangregg/perf-tools;
     description = "Performance analysis tools based on Linux perf_events (aka perf) and ftrace";
-    maintainers = [ lib.maintainers.eelco ];
+    maintainers = [ maintainers.eelco ];
+    license = licenses.gpl2;
   };
 }
diff --git a/pkgs/os-specific/linux/prl-tools/default.nix b/pkgs/os-specific/linux/prl-tools/default.nix
index be93ff6f2eb9..1a4919a5d9d4 100644
--- a/pkgs/os-specific/linux/prl-tools/default.nix
+++ b/pkgs/os-specific/linux/prl-tools/default.nix
@@ -10,8 +10,8 @@ assert kernel != null -> stdenv.lib.versionOlder kernel.version "4.15";
 
 let xorgFullVer = (builtins.parseDrvName xorg.xorgserver.name).version;
     xorgVer = lib.concatStringsSep "." (lib.take 2 (lib.splitString "." xorgFullVer));
-    x64 = if stdenv.system == "x86_64-linux" then true
-          else if stdenv.system == "i686-linux" then false
+    x64 = if stdenv.hostPlatform.system == "x86_64-linux" then true
+          else if stdenv.hostPlatform.system == "i686-linux" then false
           else throw "Parallels Tools for Linux only support {x86-64,i686}-linux targets";
 in
 stdenv.mkDerivation rec {
diff --git a/pkgs/os-specific/linux/rfkill/default.nix b/pkgs/os-specific/linux/rfkill/default.nix
index 48be4fbc3438..6b6bef29cc36 100644
--- a/pkgs/os-specific/linux/rfkill/default.nix
+++ b/pkgs/os-specific/linux/rfkill/default.nix
@@ -10,10 +10,11 @@ stdenv.mkDerivation rec {
 
   makeFlags = "PREFIX=$(out)";
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://wireless.kernel.org/en/users/Documentation/rfkill;
     description = "A tool to query, enable and disable wireless devices";
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.eelco ];
+    platforms = platforms.linux;
+    maintainers = [ maintainers.eelco ];
+    license = licenses.isc;
   };
 }
diff --git a/pkgs/os-specific/linux/rtkit/default.nix b/pkgs/os-specific/linux/rtkit/default.nix
index 868dcc9a58ea..059b09449619 100644
--- a/pkgs/os-specific/linux/rtkit/default.nix
+++ b/pkgs/os-specific/linux/rtkit/default.nix
@@ -35,9 +35,10 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ dbus libcap ];
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://0pointer.de/blog/projects/rtkit;
     description = "A daemon that hands out real-time priority to processes";
-    platforms = stdenv.lib.platforms.linux;
+    license = with licenses; [ gpl3 bsd0 ]; # lib is bsd license
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/shadow/default.nix b/pkgs/os-specific/linux/shadow/default.nix
index 885ea3421f65..8c778e72b704 100644
--- a/pkgs/os-specific/linux/shadow/default.nix
+++ b/pkgs/os-specific/linux/shadow/default.nix
@@ -1,15 +1,14 @@
 { stdenv, fetchpatch, fetchFromGitHub, autoreconfHook, libxslt, libxml2
 , docbook_xml_dtd_412, docbook_xsl, gnome-doc-utils, flex, bison
 , pam ? null, glibcCross ? null
-, buildPlatform, hostPlatform
 }:
 
 let
 
   glibc =
-    if hostPlatform != buildPlatform
+    if stdenv.hostPlatform != stdenv.buildPlatform
     then glibcCross
-    else assert hostPlatform.libc == "glibc"; stdenv.cc.libc;
+    else assert stdenv.hostPlatform.libc == "glibc"; stdenv.cc.libc;
 
   dots_in_usernames = fetchpatch {
     url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/shadow/files/shadow-4.1.3-dots-in-usernames.patch;
@@ -63,9 +62,9 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--enable-man"
     "--with-group-name-max-length=32"
-  ] ++ stdenv.lib.optional (hostPlatform.libc != "glibc") "--disable-nscd";
+  ] ++ stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc") "--disable-nscd";
 
-  preBuild = stdenv.lib.optionalString (hostPlatform.libc == "glibc")
+  preBuild = stdenv.lib.optionalString (stdenv.hostPlatform.libc == "glibc")
     ''
       substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc.bin}/bin/nscd
     '';
diff --git a/pkgs/os-specific/linux/sssd/default.nix b/pkgs/os-specific/linux/sssd/default.nix
index 0a55608af968..4224c4900db6 100644
--- a/pkgs/os-specific/linux/sssd/default.nix
+++ b/pkgs/os-specific/linux/sssd/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgs, glibc, augeas, dnsutils, c-ares, curl,
-  cyrus_sasl, ding-libs, libnl, libunistring, nss, samba, libnfsidmap, doxygen,
+  cyrus_sasl, ding-libs, libnl, libunistring, nss, samba, nfs-utils, doxygen,
   python, python3, pam, popt, talloc, tdb, tevent, pkgconfig, ldb, openldap,
   pcre, kerberos, cifs-utils, glib, keyutils, dbus, fakeroot, libxslt, libxml2,
   libuuid, ldap, systemd, nspr, check, cmocka, uid_wrapper,
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
   buildInputs = [ augeas dnsutils c-ares curl cyrus_sasl ding-libs libnl libunistring nss
-                  samba libnfsidmap doxygen python python3 popt
+                  samba nfs-utils doxygen python python3 popt
                   talloc tdb tevent pkgconfig ldb pam openldap pcre kerberos
                   cifs-utils glib keyutils dbus fakeroot libxslt libxml2
                   libuuid ldap systemd nspr check cmocka uid_wrapper
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index 912ba5b5e0ef..b4caa63799c7 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -8,7 +8,6 @@
 , ninja, meson, python3Packages, glibcLocales
 , patchelf
 , getent
-, hostPlatform
 , buildPackages
 , withSelinux ? false, libselinux
 , withLibseccomp ? libseccomp.meta.available, libseccomp
@@ -79,7 +78,7 @@ in stdenv.mkDerivation rec {
     "-Dsystem-gid-max=499"
     # "-Dtime-epoch=1"
 
-    (if stdenv.isAarch32 || stdenv.isAarch64 || !hostPlatform.isEfi then "-Dgnu-efi=false" else "-Dgnu-efi=true")
+    (if stdenv.isAarch32 || stdenv.isAarch64 || !stdenv.hostPlatform.isEfi then "-Dgnu-efi=false" else "-Dgnu-efi=true")
     "-Defi-libdir=${toString gnu-efi}/lib"
     "-Defi-includedir=${toString gnu-efi}/include/efi"
     "-Defi-ldsdir=${toString gnu-efi}/lib"
diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix
index 3da12c41dc12..de1e47faf666 100644
--- a/pkgs/os-specific/linux/uclibc/default.nix
+++ b/pkgs/os-specific/linux/uclibc/default.nix
@@ -1,6 +1,5 @@
 { stdenv, buildPackages
 , fetchurl, linuxHeaders, libiconvReal
-, buildPlatform, hostPlatform
 , extraConfig ? ""
 }:
 
@@ -40,7 +39,7 @@ let
     UCLIBC_SUSV4_LEGACY y
     UCLIBC_HAS_THREADS_NATIVE y
     KERNEL_HEADERS "${linuxHeaders}/include"
-  '' + stdenv.lib.optionalString (stdenv.isAarch32 && buildPlatform != hostPlatform) ''
+  '' + stdenv.lib.optionalString (stdenv.isAarch32 && stdenv.buildPlatform != stdenv.hostPlatform) ''
     CONFIG_ARM_EABI y
     ARCH_WANTS_BIG_ENDIAN n
     ARCH_BIG_ENDIAN n
@@ -69,7 +68,7 @@ stdenv.mkDerivation {
     cat << EOF | parseconfig
     ${nixConfig}
     ${extraConfig}
-    ${hostPlatform.platform.uclibc.extraConfig or ""}
+    ${stdenv.hostPlatform.platform.uclibc.extraConfig or ""}
     EOF
     ( set +o pipefail; yes "" | make oldconfig )
   '';
@@ -82,7 +81,7 @@ stdenv.mkDerivation {
   depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   makeFlags = [
-    "ARCH=${hostPlatform.parsed.cpu.name}"
+    "ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
     "VERBOSE=1"
   ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
     "CROSS=${stdenv.cc.targetPrefix}"
diff --git a/pkgs/os-specific/linux/udisks/1-default.nix b/pkgs/os-specific/linux/udisks/1-default.nix
index bdc6a63f0697..d48c21f6b52a 100644
--- a/pkgs/os-specific/linux/udisks/1-default.nix
+++ b/pkgs/os-specific/linux/udisks/1-default.nix
@@ -35,9 +35,10 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--localstatedir=/var" "--enable-lvm2" ];
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://www.freedesktop.org/wiki/Software/udisks;
     description = "A daemon and command-line utility for querying and manipulating storage devices";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = platforms.linux;
+    license = with licenses; [ gpl2 lgpl2Plus ];
   };
 }
diff --git a/pkgs/os-specific/linux/usbutils/default.nix b/pkgs/os-specific/linux/usbutils/default.nix
index adb2a0ee2fb1..657d6cc24a8d 100644
--- a/pkgs/os-specific/linux/usbutils/default.nix
+++ b/pkgs/os-specific/linux/usbutils/default.nix
@@ -17,9 +17,10 @@ stdenv.mkDerivation rec {
         --replace /usr/share/usb.ids ${hwdata}/data/hwdata/usb.ids
     '';
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://www.linux-usb.org/;
     description = "Tools for working with USB devices, such as lsusb";
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/wpa_supplicant/gui.nix b/pkgs/os-specific/linux/wpa_supplicant/gui.nix
index f4ef1b1498f8..891de61c0170 100644
--- a/pkgs/os-specific/linux/wpa_supplicant/gui.nix
+++ b/pkgs/os-specific/linux/wpa_supplicant/gui.nix
@@ -23,8 +23,10 @@ stdenv.mkDerivation {
     cp -av icons/hicolor $out/share/icons
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Qt-based GUI for wpa_supplicant";
-    platforms = stdenv.lib.platforms.linux;
+    homepage = http://hostap.epitest.fi/wpa_supplicant/;
+    license = licenses.bsd3;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/windows/pthread-w32/default.nix b/pkgs/os-specific/windows/pthread-w32/default.nix
index e84270270f8a..226bbfb16df1 100644
--- a/pkgs/os-specific/windows/pthread-w32/default.nix
+++ b/pkgs/os-specific/windows/pthread-w32/default.nix
@@ -1,7 +1,7 @@
-{ fetchurl, stdenv, hostPlatform, buildPlatform, mingwrt }:
+{ fetchurl, stdenv, mingwrt }:
 
 # This file is tweaked for cross-compilation only.
-assert hostPlatform != buildPlatform;
+assert stdenv.hostPlatform != stdenv.buildPlatform;
 
 stdenv.mkDerivation {
   name = "pthread-w32-1.10.0";
diff --git a/pkgs/os-specific/windows/wxMSW-2.8/default.nix b/pkgs/os-specific/windows/wxMSW-2.8/default.nix
index 748bf39a1f20..65690af98697 100644
--- a/pkgs/os-specific/windows/wxMSW-2.8/default.nix
+++ b/pkgs/os-specific/windows/wxMSW-2.8/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurl, compat24 ? false, compat26 ? true, unicode ? true
-, hostPlatform
-}:
+{ stdenv, fetchurl, compat24 ? false, compat26 ? true, unicode ? true }:
 
 stdenv.mkDerivation {
   name = "wxMSW-2.8.11";
diff --git a/pkgs/servers/fingerd/bsd-fingerd/default.nix b/pkgs/servers/fingerd/bsd-fingerd/default.nix
index f7f2f93cf99e..d5671921abad 100644
--- a/pkgs/servers/fingerd/bsd-fingerd/default.nix
+++ b/pkgs/servers/fingerd/bsd-fingerd/default.nix
@@ -18,7 +18,8 @@ stdenv.mkDerivation rec {
 
   preInstall = '' mkdir -p $out/man/man8 $out/sbin '';
 
-  meta = {
-    platforms = stdenv.lib.platforms.linux;
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    license = licenses.bsdOriginal;
   };
 }
diff --git a/pkgs/servers/http/nginx/mainline.nix b/pkgs/servers/http/nginx/mainline.nix
index ecde2430f522..49f212a8fe57 100644
--- a/pkgs/servers/http/nginx/mainline.nix
+++ b/pkgs/servers/http/nginx/mainline.nix
@@ -1,6 +1,6 @@
 { callPackage, ... }@args:
 
 callPackage ./generic.nix (args // {
-  version = "1.15.2";
-  sha256 = "145dcypq8dqc5as03iy1ycwifwynq9p4i8m56fn7g0myryp0kfpf";
+  version = "1.15.3";
+  sha256 = "11dysslkz76cdzhshc6w5qivdplk10pjpb73li0d1sz2qf8zp4ck";
 })
diff --git a/pkgs/servers/matrix-synapse/default.nix b/pkgs/servers/matrix-synapse/default.nix
index d0c496d38577..74cd233710cd 100644
--- a/pkgs/servers/matrix-synapse/default.nix
+++ b/pkgs/servers/matrix-synapse/default.nix
@@ -26,13 +26,13 @@ let
   };
 in python2Packages.buildPythonApplication rec {
   name = "matrix-synapse-${version}";
-  version = "0.33.0";
+  version = "0.33.3";
 
   src = fetchFromGitHub {
     owner = "matrix-org";
     repo = "synapse";
     rev = "v${version}";
-    sha256 = "1immk6k0wgiks1s39dhyjg79n6rgans9zy85r5wmkp4dlc3r5rx6";
+    sha256 = "0yxxrs8yrrkp3pffdfab8apdmyhdcl90wgmglryy4q8vsksxn7d4";
   };
 
   patches = [
diff --git a/pkgs/servers/web-apps/wallabag/default.nix b/pkgs/servers/web-apps/wallabag/default.nix
index c0d5876a3a2d..ed399f58bcf1 100644
--- a/pkgs/servers/web-apps/wallabag/default.nix
+++ b/pkgs/servers/web-apps/wallabag/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "wallabag-${version}";
-  version = "2.3.2";
+  version = "2.3.3";
 
   # remember to rm -r var/cache/* after a rebuild or unexpected errors will occur
 
   src = fetchurl {
     url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz";
-    sha256 = "17yczdvgl43j6wa7hksxi2b51afvyd56vdya6hbbv68iiba4jyh4";
+    sha256 = "12q5daigqn4xqp9pyfzac881qm9ywrflm8sivhl3spczyh41gwpg";
   };
 
   outputs = [ "out" ];
diff --git a/pkgs/shells/bash/4.4.nix b/pkgs/shells/bash/4.4.nix
index de8efd5af270..313a2710b287 100644
--- a/pkgs/shells/bash/4.4.nix
+++ b/pkgs/shells/bash/4.4.nix
@@ -1,6 +1,5 @@
 { stdenv, buildPackages
 , fetchurl, binutils ? null, bison, autoconf, utillinux
-, buildPlatform, hostPlatform
 
 # patch for cygwin requires readline support
 , interactive ? stdenv.isCygwin, readline70 ? null
@@ -11,7 +10,7 @@ with stdenv.lib;
 
 assert interactive -> readline70 != null;
 assert withDocs -> texinfo != null;
-assert hostPlatform.isDarwin -> binutils != null;
+assert stdenv.hostPlatform.isDarwin -> binutils != null;
 
 let
   upstreamPatches = import ./bash-4.4-patches.nix (nr: sha256: fetchurl {
@@ -45,26 +44,26 @@ stdenv.mkDerivation rec {
   patchFlags = "-p0";
 
   patches = upstreamPatches
-    ++ optional hostPlatform.isCygwin ./cygwin-bash-4.4.11-2.src.patch
+    ++ optional stdenv.hostPlatform.isCygwin ./cygwin-bash-4.4.11-2.src.patch
     # https://lists.gnu.org/archive/html/bug-bash/2016-10/msg00006.html
-    ++ optional hostPlatform.isMusl (fetchurl {
+    ++ optional stdenv.hostPlatform.isMusl (fetchurl {
       url = "https://lists.gnu.org/archive/html/bug-bash/2016-10/patchJxugOXrY2y.patch";
       sha256 = "1m4v9imidb1cc1h91f2na0b8y9kc5c5fgmpvy9apcyv2kbdcghg1";
     });
 
   configureFlags = [
     (if interactive then "--with-installed-readline" else "--disable-readline")
-  ] ++ optionals (hostPlatform != buildPlatform) [
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "bash_cv_job_control_missing=nomissing"
     "bash_cv_sys_named_pipes=nomissing"
     "bash_cv_getcwd_malloc=yes"
-  ] ++ optionals hostPlatform.isCygwin [
+  ] ++ optionals stdenv.hostPlatform.isCygwin [
     "--without-libintl-prefix --without-libiconv-prefix"
     "--with-installed-readline"
     "bash_cv_dev_stdin=present"
     "bash_cv_dev_fd=standard"
     "bash_cv_termcap_lib=libncurses"
-  ] ++ optionals (hostPlatform.libc == "musl") [
+  ] ++ optionals (stdenv.hostPlatform.libc == "musl") [
     "--without-bash-malloc"
     "--disable-nls"
   ];
@@ -73,8 +72,8 @@ stdenv.mkDerivation rec {
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [ bison ]
     ++ optional withDocs texinfo
-    ++ optional hostPlatform.isDarwin binutils
-    ++ optional (hostPlatform.libc == "musl") autoconf;
+    ++ optional stdenv.hostPlatform.isDarwin binutils
+    ++ optional (stdenv.hostPlatform.libc == "musl") autoconf;
 
   buildInputs = optional interactive readline70;
 
@@ -82,7 +81,7 @@ stdenv.mkDerivation rec {
   # build `version.h'.
   enableParallelBuilding = false;
 
-  makeFlags = optional hostPlatform.isCygwin [
+  makeFlags = optional stdenv.hostPlatform.isCygwin [
     "LOCAL_LDFLAGS=-Wl,--export-all,--out-implib,libbash.dll.a"
     "SHOBJ_LIBS=-lbash"
   ];
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
index bc8d772530a1..31ca9f2c82e4 100644
--- a/pkgs/stdenv/cross/default.nix
+++ b/pkgs/stdenv/cross/default.nix
@@ -23,8 +23,9 @@ in lib.init bootStages ++ [
     inherit config overlays;
     selfBuild = false;
     stdenv =
-      assert vanillaPackages.hostPlatform == localSystem;
-      assert vanillaPackages.targetPlatform == localSystem;
+      assert vanillaPackages.stdenv.buildPlatform == localSystem;
+      assert vanillaPackages.stdenv.hostPlatform == localSystem;
+      assert vanillaPackages.stdenv.targetPlatform == localSystem;
       vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
     # It's OK to change the built-time dependencies
     allowCustomOverrides = true;
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 22dd700b2dda..cda643c42fe3 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -348,10 +348,10 @@ in rec {
 
       darwin = super.darwin // {
         inherit (darwin) dyld ICU Libsystem libiconv;
-      } // lib.optionalAttrs (super.targetPlatform == localSystem) {
+      } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
         inherit (darwin) binutils binutils-unwrapped cctools;
       };
-    } // lib.optionalAttrs (super.targetPlatform == localSystem) {
+    } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
       # Need to get rid of these when cross-compiling.
       inherit binutils binutils-unwrapped;
     };
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 560aa72eb392..8af6d0e04008 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -187,7 +187,7 @@ rec {
           builder = attrs.realBuilder or stdenv.shell;
           args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
           inherit stdenv;
-          inherit (stdenv) system;
+          inherit (stdenv.hostPlatform) system;
           userHook = config.stdenv.userHook or null;
           __ignoreNulls = true;
 
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index c7fc2ebac35b..de58178a34ba 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -366,7 +366,7 @@ in
           gnumake gnused gnutar gnugrep gnupatch patchelf
           attr acl paxctl zlib pcre;
         ${localSystem.libc} = getLibc prevStage;
-      } // lib.optionalAttrs (super.targetPlatform == localSystem) {
+      } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
         # Need to get rid of these when cross-compiling.
         inherit (prevStage) binutils binutils-unwrapped;
         gcc = cc;
diff --git a/pkgs/tools/X11/xwinwrap/default.nix b/pkgs/tools/X11/xwinwrap/default.nix
index cc2eb50ce1fd..dbbdb0c04e91 100644
--- a/pkgs/tools/X11/xwinwrap/default.nix
+++ b/pkgs/tools/X11/xwinwrap/default.nix
@@ -16,11 +16,11 @@ stdenv.mkDerivation {
     xlibsWrapper
   ];
 
-  buildPhase = if stdenv.system == "x86_64-linux" then ''
+  buildPhase = if stdenv.hostPlatform.system == "x86_64-linux" then ''
     make all64
-  '' else if stdenv.system == "i686-linux" then ''
+  '' else if stdenv.hostPlatform.system == "i686-linux" then ''
     make all32
-  '' else throw "xwinwrap is not supported on ${stdenv.system}";
+  '' else throw "xwinwrap is not supported on ${stdenv.hostPlatform.system}";
 
   installPhase = ''
     mkdir -p $out/bin
diff --git a/pkgs/tools/admin/bluemix-cli/default.nix b/pkgs/tools/admin/bluemix-cli/default.nix
index 7ae54aab4b9d..8b6395d85d04 100644
--- a/pkgs/tools/admin/bluemix-cli/default.nix
+++ b/pkgs/tools/admin/bluemix-cli/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "0.8.0";
 
   src =
-    if stdenv.system == "i686-linux" then
+    if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         name = "linux32-${version}.tar.gz";
         url = "https://clis.ng.bluemix.net/download/bluemix-cli/${version}/linux32";
diff --git a/pkgs/tools/admin/google-cloud-sdk/default.nix b/pkgs/tools/admin/google-cloud-sdk/default.nix
index c2f73cea9558..8b98636b3475 100644
--- a/pkgs/tools/admin/google-cloud-sdk/default.nix
+++ b/pkgs/tools/admin/google-cloud-sdk/default.nix
@@ -32,7 +32,7 @@ in stdenv.mkDerivation rec {
   name = "google-cloud-sdk-${version}";
   version = "206.0.0";
 
-  src = fetchurl (sources name stdenv.system);
+  src = fetchurl (sources name stdenv.hostPlatform.system);
 
   buildInputs = [ python makeWrapper ];
 
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index 7532cd899cc6..0cde72069848 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
 
   # May have some issues with root compilation because the bootstrap tool
   # cannot be used as a login shell for now.
-  FORCE_UNSAFE_CONFIGURE = stdenv.lib.optionalString (stdenv.system == "armv7l-linux" || stdenv.isSunOS) "1";
+  FORCE_UNSAFE_CONFIGURE = stdenv.lib.optionalString (stdenv.hostPlatform.system == "armv7l-linux" || stdenv.isSunOS) "1";
 
   preConfigure = if stdenv.isCygwin then ''
     sed -i gnu/fpending.h -e 's,include <stdio_ext.h>,,'
diff --git a/pkgs/tools/archivers/zpaq/zpaqd.nix b/pkgs/tools/archivers/zpaq/zpaqd.nix
index 0d60e7962460..344f08890906 100644
--- a/pkgs/tools/archivers/zpaq/zpaqd.nix
+++ b/pkgs/tools/archivers/zpaq/zpaqd.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurl, unzip
-, hostPlatform
-}:
+{ stdenv, fetchurl, unzip }:
 
 let
   # Generated upstream information
@@ -14,10 +12,10 @@ let
   };
 
   compileFlags = stdenv.lib.concatStringsSep " " ([ "-O3" "-mtune=generic" "-DNDEBUG" ]
-    ++ stdenv.lib.optional (hostPlatform.isUnix) "-Dunix -pthread"
-    ++ stdenv.lib.optional (hostPlatform.isi686) "-march=i686"
-    ++ stdenv.lib.optional (hostPlatform.isx86_64) "-march=nocona"
-    ++ stdenv.lib.optional (!hostPlatform.isx86) "-DNOJIT");
+    ++ stdenv.lib.optional (stdenv.hostPlatform.isUnix) "-Dunix -pthread"
+    ++ stdenv.lib.optional (stdenv.hostPlatform.isi686) "-march=i686"
+    ++ stdenv.lib.optional (stdenv.hostPlatform.isx86_64) "-march=nocona"
+    ++ stdenv.lib.optional (!stdenv.hostPlatform.isx86) "-DNOJIT");
 in
 stdenv.mkDerivation {
   inherit (s) name version;
diff --git a/pkgs/tools/bootloaders/refind/default.nix b/pkgs/tools/bootloaders/refind/default.nix
index 73463bbef897..5f4d77e34b6a 100644
--- a/pkgs/tools/bootloaders/refind/default.nix
+++ b/pkgs/tools/bootloaders/refind/default.nix
@@ -7,7 +7,7 @@ let
   };
 
   inherit
-    (archids.${stdenv.system} or (throw "unsupported system: ${stdenv.system}"))
+    (archids.${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}"))
     hostarch efiPlatform;
 in
 
diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix
index 4b127417ca8d..4a2ba2fcb94c 100644
--- a/pkgs/tools/compression/bzip2/default.nix
+++ b/pkgs/tools/compression/bzip2/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl
-, linkStatic ? (stdenv.system == "i686-cygwin")
+, linkStatic ? (stdenv.hostPlatform.system == "i686-cygwin")
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/tools/filesystems/sshfs-fuse/default.nix b/pkgs/tools/filesystems/sshfs-fuse/default.nix
index 183cfb2ddbe4..ddec6b7eff89 100644
--- a/pkgs/tools/filesystems/sshfs-fuse/default.nix
+++ b/pkgs/tools/filesystems/sshfs-fuse/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   checkInputs = [ which python3Packages.pytest ];
 
   NIX_CFLAGS_COMPILE = stdenv.lib.optional
-    (stdenv.system == "i686-linux")
+    (stdenv.hostPlatform.system == "i686-linux")
     "-D_FILE_OFFSET_BITS=64";
 
   postInstall = ''
diff --git a/pkgs/tools/graphics/optipng/default.nix b/pkgs/tools/graphics/optipng/default.nix
index fd0b0caea4ca..bc849b21117f 100644
--- a/pkgs/tools/graphics/optipng/default.nix
+++ b/pkgs/tools/graphics/optipng/default.nix
@@ -1,5 +1,4 @@
 { stdenv, fetchurl, libpng, static ? false
-, buildPlatform, hostPlatform
 }:
 
 # This package comes with its own copy of zlib, libpng and pngxtern
@@ -26,11 +25,11 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--with-system-zlib"
     "--with-system-libpng"
-  ] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
+  ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     #"-prefix=$out"
   ];
 
-  postInstall = if hostPlatform != buildPlatform && hostPlatform.isWindows then ''
+  postInstall = if stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isWindows then ''
     mv "$out"/bin/optipng{,.exe}
   '' else null;
 
diff --git a/pkgs/tools/graphics/pngout/default.nix b/pkgs/tools/graphics/pngout/default.nix
index afc1a2519fe1..333e5f600765 100644
--- a/pkgs/tools/graphics/pngout/default.nix
+++ b/pkgs/tools/graphics/pngout/default.nix
@@ -1,9 +1,9 @@
 {stdenv, fetchurl}:
 
 let
-  folder = if stdenv.system == "i686-linux" then "i686"
-  else if stdenv.system == "x86_64-linux" then "x86_64"
-  else throw "Unsupported system: ${stdenv.system}";
+  folder = if stdenv.hostPlatform.system == "i686-linux" then "i686"
+  else if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64"
+  else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 in
 stdenv.mkDerivation {
   name = "pngout-20130221";
@@ -17,9 +17,9 @@ stdenv.mkDerivation {
     mkdir -p $out/bin
     cp ${folder}/pngout $out/bin
     
-    ${if stdenv.system == "i686-linux" then ''
+    ${if stdenv.hostPlatform.system == "i686-linux" then ''
         patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $out/bin/pngout
-      '' else if stdenv.system == "x86_64-linux" then ''
+      '' else if stdenv.hostPlatform.system == "x86_64-linux" then ''
         patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 $out/bin/pngout
       '' else ""}
   '';
diff --git a/pkgs/tools/misc/bandwidth/default.nix b/pkgs/tools/misc/bandwidth/default.nix
index e8ea9117bc5a..e50faaca8995 100644
--- a/pkgs/tools/misc/bandwidth/default.nix
+++ b/pkgs/tools/misc/bandwidth/default.nix
@@ -2,11 +2,11 @@
 
 let
   arch =
-    if      stdenv.system == "x86_64-linux" then "bandwidth64"
-    else if stdenv.system == "i686-linux" then "bandwidth32"
-    else if stdenv.system == "x86_64-darwin" then "bandwidth-mac64"
-    else if stdenv.system == "i686-darwin" then "bandwidth-mac32"
-    else if stdenv.system == "i686-cygwin" then "bandwidth-win32"
+    if      stdenv.hostPlatform.system == "x86_64-linux" then "bandwidth64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "bandwidth32"
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then "bandwidth-mac64"
+    else if stdenv.hostPlatform.system == "i686-darwin" then "bandwidth-mac32"
+    else if stdenv.hostPlatform.system == "i686-cygwin" then "bandwidth-win32"
     else throw "Unknown architecture";
 in
 stdenv.mkDerivation rec {
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 69d751a629ea..6ffdd3b5d47d 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -1,6 +1,5 @@
 { stdenv, lib, buildPackages
 , autoreconfHook, texinfo, fetchurl, perl, xz, libiconv, gmp ? null
-, hostPlatform, buildPlatform
 , aclSupport ? false, acl ? null
 , attrSupport ? false, attr ? null
 , selinuxSupport? false, libselinux ? null, libsepol ? null
@@ -21,10 +20,10 @@ stdenv.mkDerivation rec {
     sha256 = "0plm1zs9il6bb5mk881qvbghq4glc8ybbgakk2lfzb0w64fgml4j";
   };
 
-  patches = optional hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch;
+  patches = optional stdenv.hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch;
 
   # The test tends to fail on btrfs and maybe other unusual filesystems.
-  postPatch = optionalString (!hostPlatform.isDarwin) ''
+  postPatch = optionalString (!stdenv.hostPlatform.isDarwin) ''
     sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh
     sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh
     sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh
@@ -40,9 +39,9 @@ stdenv.mkDerivation rec {
   configureFlags =
     optional (singleBinary != false)
       ("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}")
-    ++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
+    ++ optional stdenv.hostPlatform.isSunOS "ac_cv_func_inotify_init=no"
     ++ optional withPrefix "--program-prefix=g"
-    ++ optionals (hostPlatform != buildPlatform && hostPlatform.libc == "glibc") [
+    ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.libc == "glibc") [
       # TODO(19b98110126fde7cbb1127af7e3fe1568eacad3d): Needed for fstatfs() I
       # don't know why it is not properly detected cross building with glibc.
       "fu_cv_sys_stat_statfs2_bsize=yes"
@@ -52,37 +51,37 @@ stdenv.mkDerivation rec {
   buildInputs = [ gmp ]
     ++ optional aclSupport acl
     ++ optional attrSupport attr
-    ++ optionals hostPlatform.isCygwin [ autoreconfHook texinfo ]   # due to patch
+    ++ optionals stdenv.hostPlatform.isCygwin [ autoreconfHook texinfo ]   # due to patch
     ++ optionals selinuxSupport [ libselinux libsepol ]
        # TODO(@Ericson2314): Investigate whether Darwin could benefit too
-    ++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv;
+    ++ optional (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.libc != "glibc") libiconv;
 
   # The tests are known broken on Cygwin
   # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
   # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
   # and {Open,Free}BSD.
   # With non-standard storeDir: https://github.com/NixOS/nix/issues/512
-  doCheck = hostPlatform == buildPlatform
-    && hostPlatform.libc == "glibc"
+  doCheck = stdenv.hostPlatform == stdenv.buildPlatform
+    && stdenv.hostPlatform.libc == "glibc"
     && builtins.storeDir == "/nix/store";
 
   # Prevents attempts of running 'help2man' on cross-built binaries.
-  PERL = if hostPlatform == buildPlatform then null else "missing";
+  PERL = if stdenv.hostPlatform == stdenv.buildPlatform then null else "missing";
 
   # Saw random failures like ‘help2man: can't get '--help' info from
   # man/sha512sum.td/sha512sum’.
   enableParallelBuilding = false;
 
   NIX_LDFLAGS = optionalString selinuxSupport "-lsepol";
-  FORCE_UNSAFE_CONFIGURE = optionalString hostPlatform.isSunOS "1";
+  FORCE_UNSAFE_CONFIGURE = optionalString stdenv.hostPlatform.isSunOS "1";
 
   # Works around a bug with 8.26:
   # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually).  Stop.
-  preInstall = optionalString (hostPlatform != buildPlatform) ''
+  preInstall = optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|'
   '';
 
-  postInstall = optionalString (hostPlatform != buildPlatform) ''
+  postInstall = optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     rm $out/share/man/man1/*
     cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1
   '';
diff --git a/pkgs/tools/misc/execline/default.nix b/pkgs/tools/misc/execline/default.nix
index 0b606882a5c3..360808f4280b 100644
--- a/pkgs/tools/misc/execline/default.nix
+++ b/pkgs/tools/misc/execline/default.nix
@@ -32,7 +32,7 @@ in stdenv.mkDerivation rec {
     "--with-dynlib=${skalibs.lib}/lib"
   ]
   ++ (if stdenv.isDarwin then [ "--disable-shared" ] else [ "--enable-shared" ])
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/execline
diff --git a/pkgs/tools/misc/findutils/default.nix b/pkgs/tools/misc/findutils/default.nix
index 66b7ef4c2919..d6eca100411b 100644
--- a/pkgs/tools/misc/findutils/default.nix
+++ b/pkgs/tools/misc/findutils/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl
 , coreutils
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -17,10 +16,10 @@ stdenv.mkDerivation rec {
 
   # Since glibc-2.25 the i686 tests hang reliably right after test-sleep.
   doCheck
-    =  !hostPlatform.isDarwin
-    && !(hostPlatform.libc == "glibc" && hostPlatform.isi686)
-    && (hostPlatform.libc != "musl")
-    && hostPlatform == buildPlatform;
+    =  !stdenv.hostPlatform.isDarwin
+    && !(stdenv.hostPlatform.libc == "glibc" && stdenv.hostPlatform.isi686)
+    && (stdenv.hostPlatform.libc != "musl")
+    && stdenv.hostPlatform == stdenv.buildPlatform;
 
   outputs = [ "out" "info" ];
 
diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix
index 63511782f00b..481a07ef491b 100644
--- a/pkgs/tools/misc/grub/2.0x.nix
+++ b/pkgs/tools/misc/grub/2.0x.nix
@@ -28,8 +28,8 @@ let
     "aarch64-linux".target = "arm64";
   };
 
-  canEfi = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) efiSystemsBuild);
-  inPCSystems = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) pcSystems);
+  canEfi = any (system: stdenv.hostPlatform.system == system) (mapAttrsToList (name: _: name) efiSystemsBuild);
+  inPCSystems = any (system: stdenv.hostPlatform.system == system) (mapAttrsToList (name: _: name) pcSystems);
 
   version = "2.02";
 
@@ -86,14 +86,14 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--enable-grub-mount" ] # dep of os-prober
     ++ optional zfsSupport "--enable-libzfs"
-    ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ]
-    ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.system}.target}"];
+    ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}" "--program-prefix=" ]
+    ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"];
 
   # save target that grub is compiled for
   grubTarget = if efiSupport
-               then "${efiSystemsInstall.${stdenv.system}.target}-efi"
+               then "${efiSystemsInstall.${stdenv.hostPlatform.system}.target}-efi"
                else if inPCSystems
-                    then "${pcSystems.${stdenv.system}.target}-pc"
+                    then "${pcSystems.${stdenv.hostPlatform.system}.target}-pc"
                     else "";
 
   doCheck = false;
diff --git a/pkgs/tools/misc/grub/pvgrub_image/default.nix b/pkgs/tools/misc/grub/pvgrub_image/default.nix
index df5e3f15e95a..19d8afb18575 100644
--- a/pkgs/tools/misc/grub/pvgrub_image/default.nix
+++ b/pkgs/tools/misc/grub/pvgrub_image/default.nix
@@ -22,11 +22,11 @@ stdenv.mkDerivation rec {
     tar -cf memdisk.tar grub.cfg
     # We include all modules except all_video.mod as otherwise grub will fail printing "no symbol table"
     # if we include it.
-    grub-mkimage -O "${efiSystemsBuild.${stdenv.system}.target}-xen" -c grub-bootstrap.cfg \
-      -m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" \
-      $(ls "${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.system}.target}-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$')
+    grub-mkimage -O "${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen" -c grub-bootstrap.cfg \
+      -m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" \
+      $(ls "${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$')
     mkdir -p "$out/lib/grub-xen"
-    cp "grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin" $out/lib/grub-xen/
+    cp "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" $out/lib/grub-xen/
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/tools/misc/grub/trusted.nix b/pkgs/tools/misc/grub/trusted.nix
index 63a73658e0ac..0e867d7cffd0 100644
--- a/pkgs/tools/misc/grub/trusted.nix
+++ b/pkgs/tools/misc/grub/trusted.nix
@@ -10,7 +10,7 @@ let
     "x86_64-linux".target = "i386";
   };
 
-  inPCSystems = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) pcSystems);
+  inPCSystems = any (system: stdenv.hostPlatform.system == system) (mapAttrsToList (name: _: name) pcSystems);
 
   version = if for_HP_laptop then "1.2.1" else "1.2.0";
 
@@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
 
   # save target that grub is compiled for
   grubTarget = if inPCSystems
-               then "${pcSystems.${stdenv.system}.target}-pc"
+               then "${pcSystems.${stdenv.hostPlatform.system}.target}-pc"
                else "";
 
   doCheck = false;
diff --git a/pkgs/tools/misc/mongodb-compass/default.nix b/pkgs/tools/misc/mongodb-compass/default.nix
index f8475ee2e0e0..840d4eacd378 100644
--- a/pkgs/tools/misc/mongodb-compass/default.nix
+++ b/pkgs/tools/misc/mongodb-compass/default.nix
@@ -43,13 +43,13 @@ let
   ] + ":${stdenv.cc.cc.lib}/lib64";
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "https://downloads.mongodb.com/compass/mongodb-compass_${version}_amd64.deb";
         sha256 = "0x23jshnr0rafm5sn2vhq2y2gryg8mksahzyv5fszblgaxay234p";
       }
     else
-      throw "MongoDB compass is not supported on ${stdenv.system}";
+      throw "MongoDB compass is not supported on ${stdenv.hostPlatform.system}";
 
 in stdenv.mkDerivation {
   name = "mongodb-compass-${version}";
diff --git a/pkgs/tools/misc/mprime/default.nix b/pkgs/tools/misc/mprime/default.nix
index 850ed32998b4..e18e9020e1da 100644
--- a/pkgs/tools/misc/mprime/default.nix
+++ b/pkgs/tools/misc/mprime/default.nix
@@ -2,15 +2,15 @@
 
 let
   srcDir =
-    if stdenv.system == "x86_64-linux" then "linux64"
-    else if stdenv.system == "i686-linux" then "linux"
-    else if stdenv.system == "x86_64-darwin" then "macosx64"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "linux64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "linux"
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then "macosx64"
     else throwSystem;
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
   gwnum =
-    if stdenv.system == "x86_64-linux" then "make64"
-    else if stdenv.system == "i686-linux" then "makefile"
-    else if stdenv.system == "x86_64-darwin" then "makemac"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "make64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "makefile"
+    else if stdenv.hostPlatform.system == "x86_64-darwin" then "makemac"
     else throwSystem;
 in
 
diff --git a/pkgs/tools/misc/ocz-ssd-guru/default.nix b/pkgs/tools/misc/ocz-ssd-guru/default.nix
index afe7a81ebac8..9ffb89aca6b1 100644
--- a/pkgs/tools/misc/ocz-ssd-guru/default.nix
+++ b/pkgs/tools/misc/ocz-ssd-guru/default.nix
@@ -1,7 +1,7 @@
 { fetchurl, stdenv, xorg, freetype, fontconfig, libGLU_combined, glibc, makeWrapper }:
 
 let
-  system = if stdenv.system == "x86_64-linux" then "linux64" else "linux32";
+  system = if stdenv.hostPlatform.system == "x86_64-linux" then "linux64" else "linux32";
 in
 stdenv.mkDerivation rec {
   name = "ocz-ssd-guru-${version}";
diff --git a/pkgs/tools/misc/os-prober/default.nix b/pkgs/tools/misc/os-prober/default.nix
index 6211c863bd49..59a60e356b80 100644
--- a/pkgs/tools/misc/os-prober/default.nix
+++ b/pkgs/tools/misc/os-prober/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
     install -Dt $out/share common.sh
 
     # probes
-    case "${stdenv.system}" in
+    case "${stdenv.hostPlatform.system}" in
         i686*|x86_64*) ARCH=x86;;
         powerpc*) ARCH=powerpc;;
         arm*) ARCH=arm;;
diff --git a/pkgs/tools/misc/otfcc/default.nix b/pkgs/tools/misc/otfcc/default.nix
index 052999033a1e..acf46a58a6bf 100644
--- a/pkgs/tools/misc/otfcc/default.nix
+++ b/pkgs/tools/misc/otfcc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, premake5, ninja, hostPlatform }:
+{ stdenv, fetchFromGitHub, premake5, ninja }:
 
 stdenv.mkDerivation rec {
   name = "otfcc-${version}";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     premake5 ninja
   '';
 
-  ninjaFlags = let x = if hostPlatform.isi686 then "x86" else "x64"; in
+  ninjaFlags = let x = if stdenv.hostPlatform.isi686 then "x86" else "x64"; in
     [ "-C" "build/ninja" "otfccdump_release_${x}" "otfccbuild_release_${x}" ];
 
   installPhase = ''
diff --git a/pkgs/tools/misc/pspg/default.nix b/pkgs/tools/misc/pspg/default.nix
index a1492259e8c4..21d81507dee0 100644
--- a/pkgs/tools/misc/pspg/default.nix
+++ b/pkgs/tools/misc/pspg/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "pspg-${version}";
-  version = "1.3.0";
+  version = "1.4.2";
 
   src = fetchFromGitHub {
     owner = "okbob";
     repo = "pspg";
     rev = "${version}";
-    sha256 = "1m63bhhglrpc2g68i5bigrzlpvg98qs83jgvf2gsbc4gnx9hywk5";
+    sha256 = "0hmx9p5pbydnf8sil4vqpmly5mq2rvcj8a33s9fvfisnxxsqz73v";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/tools/misc/s6-portable-utils/default.nix b/pkgs/tools/misc/s6-portable-utils/default.nix
index 014e000eabdb..5f56daf3a48d 100644
--- a/pkgs/tools/misc/s6-portable-utils/default.nix
+++ b/pkgs/tools/misc/s6-portable-utils/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   # Explicitly setting target ensures code can be compiled against a skalibs
   # binary built on a different version of darwin.
   # http://www.skarnet.org/cgi-bin/archive.cgi?1:mss:623:heiodchokfjdkonfhdph
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/s6-portable-utils/
diff --git a/pkgs/tools/misc/staruml/default.nix b/pkgs/tools/misc/staruml/default.nix
index 2a06400b411f..486634452ae9 100644
--- a/pkgs/tools/misc/staruml/default.nix
+++ b/pkgs/tools/misc/staruml/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   name = "staruml-${version}";
 
   src =
-    if stdenv.system == "i686-linux" then fetchurl {
+    if stdenv.hostPlatform.system == "i686-linux" then fetchurl {
       url = "http://staruml.io/download/release/v${version}/StarUML-v${version}-32-bit.deb";
       sha256 = "0vb3k9m3l6pmsid4shlk0xdjsriq3gxzm8q7l04didsppg0vvq1n";
     } else fetchurl {
diff --git a/pkgs/tools/misc/ttyrec/default.nix b/pkgs/tools/misc/ttyrec/default.nix
index c7cd71ffb6d7..ca6651718117 100644
--- a/pkgs/tools/misc/ttyrec/default.nix
+++ b/pkgs/tools/misc/ttyrec/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, buildPlatform }:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   name = "ttyrec-${version}";
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
 
   patches = [ ./clang-fixes.patch ];
 
-  makeFlags = stdenv.lib.optional buildPlatform.isLinux "CFLAGS=-DSVR4"
+  makeFlags = stdenv.lib.optional stdenv.buildPlatform.isLinux "CFLAGS=-DSVR4"
     ++ stdenv.lib.optional stdenv.cc.isClang "CC=clang";
 
   installPhase = ''
diff --git a/pkgs/tools/misc/youtube-dl/default.nix b/pkgs/tools/misc/youtube-dl/default.nix
index ebdd08b23a84..7ed8f3bfd71b 100644
--- a/pkgs/tools/misc/youtube-dl/default.nix
+++ b/pkgs/tools/misc/youtube-dl/default.nix
@@ -15,11 +15,11 @@
 buildPythonPackage rec {
 
   pname = "youtube-dl";
-  version = "2018.08.04";
+  version = "2018.08.28";
 
   src = fetchurl {
     url = "https://yt-dl.org/downloads/${version}/${pname}-${version}.tar.gz";
-    sha256 = "1hcx99qbbyigc8k98c8bcc6a2wnhq6493fmrkl7rysc8krlxr0pm";
+    sha256 = "1swdp4czvm0752psbi8a4qw5i9x18s7nhivh7iw92274pmqxq9wi";
   };
 
   nativeBuildInputs = [ makeWrapper ];
diff --git a/pkgs/tools/networking/airfield/default.nix b/pkgs/tools/networking/airfield/default.nix
index 6f6009c107ba..70005038f99d 100644
--- a/pkgs/tools/networking/airfield/default.nix
+++ b/pkgs/tools/networking/airfield/default.nix
@@ -6,7 +6,7 @@
 let
   nodePackages = import ./node.nix {
     inherit pkgs;
-    system = stdenv.system;
+    system = stdenv.hostPlatform.system;
   };
 
   runtimeEnv = buildEnv {
diff --git a/pkgs/tools/networking/filegive/default.nix b/pkgs/tools/networking/filegive/default.nix
index 6fef6a9e7fa9..a76519b36b57 100644
--- a/pkgs/tools/networking/filegive/default.nix
+++ b/pkgs/tools/networking/filegive/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ go ];
 
   buildPhase = ''
-    ${stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") "export GOARM=5"}
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "export GOARM=5"}
 
     mkdir $TMPDIR/go
     export GOPATH=$TMPDIR/go
diff --git a/pkgs/tools/networking/logmein-hamachi/default.nix b/pkgs/tools/networking/logmein-hamachi/default.nix
index 2e045ad8de91..c5c7e18ba6d2 100644
--- a/pkgs/tools/networking/logmein-hamachi/default.nix
+++ b/pkgs/tools/networking/logmein-hamachi/default.nix
@@ -4,13 +4,13 @@ with stdenv.lib;
 
 let
   arch =
-    if stdenv.system == "x86_64-linux" then "x64"
-    else if stdenv.system == "i686-linux" then "x86"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "x86"
     else throwSystem;
-  throwSystem = throw "Unsupported system: ${stdenv.system}";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
   sha256 =
-    if stdenv.system == "x86_64-linux" then "11mxa4kls5xjj3462ycrfvfxb1xkk23p5m9iirvwsi0zdmhpnwm8"
-    else if stdenv.system == "i686-linux" then "03ml9xv19km99f0z7fpr21b1zkxvw7q39kjzd8wpb2pds51wnc62"
+    if stdenv.hostPlatform.system == "x86_64-linux" then "11mxa4kls5xjj3462ycrfvfxb1xkk23p5m9iirvwsi0zdmhpnwm8"
+    else if stdenv.hostPlatform.system == "i686-linux" then "03ml9xv19km99f0z7fpr21b1zkxvw7q39kjzd8wpb2pds51wnc62"
     else throwSystem;
   libraries = stdenv.lib.makeLibraryPath [ stdenv.cc.cc ];
 
diff --git a/pkgs/tools/networking/ngrok-2/default.nix b/pkgs/tools/networking/ngrok-2/default.nix
index 23725fb2d874..fdf9067dfee9 100644
--- a/pkgs/tools/networking/ngrok-2/default.nix
+++ b/pkgs/tools/networking/ngrok-2/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   } else if stdenv.isDarwin then fetchurl {
     url = "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip";
     sha256 = "0yfd250b55wcpgqd00rqfaa7a82f35fmybb31q5xwdbgc2i47pbh";
-  } else throw "platform ${stdenv.system} not supported!";
+  } else throw "platform ${stdenv.hostPlatform.system} not supported!";
 
   sourceRoot = ".";
 
diff --git a/pkgs/tools/networking/s6-dns/default.nix b/pkgs/tools/networking/s6-dns/default.nix
index db2071ab17da..29d66e4be2ce 100644
--- a/pkgs/tools/networking/s6-dns/default.nix
+++ b/pkgs/tools/networking/s6-dns/default.nix
@@ -33,7 +33,7 @@ in stdenv.mkDerivation rec {
     "--with-dynlib=${skalibs.lib}/lib"
   ]
   ++ (if stdenv.isDarwin then [ "--disable-shared" ] else [ "--enable-shared" ])
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/s6-dns/
diff --git a/pkgs/tools/networking/s6-networking/default.nix b/pkgs/tools/networking/s6-networking/default.nix
index 1971bbffa406..f7278d5c6a24 100644
--- a/pkgs/tools/networking/s6-networking/default.nix
+++ b/pkgs/tools/networking/s6-networking/default.nix
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
        "--with-include=${lib.getDev sslLibs.${sslSupport}}/include"
        "--with-lib=${lib.getLib sslLibs.${sslSupport}}/lib"
      ])
-  ++ (lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/s6-networking/
diff --git a/pkgs/tools/networking/strongswan/default.nix b/pkgs/tools/networking/strongswan/default.nix
index 74405a472f8a..2f19294784ec 100644
--- a/pkgs/tools/networking/strongswan/default.nix
+++ b/pkgs/tools/networking/strongswan/default.nix
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
       "--enable-af-alg" "--enable-xauth-pam" "--enable-chapoly"
       "--enable-curl" ]
     ++ optionals stdenv.isx86_64 [ "--enable-aesni" "--enable-rdrand" ]
-    ++ optional (stdenv.system == "i686-linux") "--enable-padlock"
+    ++ optional (stdenv.hostPlatform.system == "i686-linux") "--enable-padlock"
     ++ optionals enableTNC [
          "--disable-gmp" "--disable-aes" "--disable-md5" "--disable-sha1" "--disable-sha2" "--disable-fips-prf"
          "--enable-eap-tnc" "--enable-eap-ttls" "--enable-eap-dynamic" "--enable-tnccs-20"
diff --git a/pkgs/tools/package-management/cargo-edit/cargo-edit.nix b/pkgs/tools/package-management/cargo-edit/cargo-edit.nix
index 67aa52f47894..7224c11f183f 100644
--- a/pkgs/tools/package-management/cargo-edit/cargo-edit.nix
+++ b/pkgs/tools/package-management/cargo-edit/cargo-edit.nix
@@ -2,7 +2,7 @@
 { pkgs }:
 
 with pkgs;
-let kernel = buildPlatform.parsed.kernel.name;
+let kernel = stdenv.buildPlatform.parsed.kernel.name;
     updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
     mapFeatures = features: map (fun: fun { features = features; });
     mkFeatures = feat: lib.lists.foldl (features: featureName:
diff --git a/pkgs/tools/package-management/cargo-update/cargo-update.nix b/pkgs/tools/package-management/cargo-update/cargo-update.nix
index 83fdaad5bfdb..1bd8aadf4982 100644
--- a/pkgs/tools/package-management/cargo-update/cargo-update.nix
+++ b/pkgs/tools/package-management/cargo-update/cargo-update.nix
@@ -1,7 +1,7 @@
 # Generated by carnix 0.6.6: carnix -o cargo-update.nix --src ./. Cargo.lock --standalone
-{ lib, buildPlatform, buildRustCrate, fetchgit }:
-let kernel = buildPlatform.parsed.kernel.name;
-    abi = buildPlatform.parsed.abi.name;
+{ lib, stdenv, buildRustCrate, fetchgit }:
+let kernel = stdenv.hostPlatform.parsed.kernel.name;
+    abi = stdenv.hostPlatform.parsed.abi.name;
     include = includedFiles: src: builtins.filterSource (path: type:
       lib.lists.any (f:
         let p = toString (src + ("/" + f)); in
diff --git a/pkgs/tools/package-management/checkinstall/default.nix b/pkgs/tools/package-management/checkinstall/default.nix
index fea6ccedd34f..df1bf794062f 100644
--- a/pkgs/tools/package-management/checkinstall/default.nix
+++ b/pkgs/tools/package-management/checkinstall/default.nix
@@ -37,7 +37,7 @@ stdenv.mkDerivation {
     ./set-buildroot.patch
   ]
 
-  ++ stdenv.lib.optional (stdenv.system == "x86_64-linux") 
+  ++ stdenv.lib.optional (stdenv.hostPlatform.system == "x86_64-linux") 
     # Force use of old memcpy so that installwatch works on Glibc <
     # 2.14.
     ./use-old-memcpy.patch;
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index c06a4f41afb1..bc07dd457f38 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -2,7 +2,6 @@
 , pkgconfig, boehmgc, perlPackages, libsodium, aws-sdk-cpp, brotli, boost
 , autoreconfHook, autoconf-archive, bison, flex, libxml2, libxslt, docbook5, docbook_xsl_ns
 , busybox-sandbox-shell
-, hostPlatform, buildPlatform
 , storeDir ? "/nix/store"
 , stateDir ? "/nix/var"
 , confDir ? "/etc"
@@ -73,8 +72,8 @@ let
         "--with-sandbox-shell=${sh}/bin/busybox"
       ]
       ++ lib.optional (
-          hostPlatform != buildPlatform && hostPlatform ? nix && hostPlatform.nix ? system
-      ) ''--with-system=${hostPlatform.nix.system}''
+          stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform ? nix && stdenv.hostPlatform.nix ? system
+      ) ''--with-system=${stdenv.hostPlatform.nix.system}''
          # RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
       ++ lib.optional (!libseccomp.meta.available) "--disable-seccomp-sandboxing";
 
diff --git a/pkgs/tools/package-management/nixui/default.nix b/pkgs/tools/package-management/nixui/default.nix
index 6f46b39e65b1..804bbbdf8d71 100644
--- a/pkgs/tools/package-management/nixui/default.nix
+++ b/pkgs/tools/package-management/nixui/default.nix
@@ -9,7 +9,7 @@ let
   };
   nixui = (import ./nixui.nix {
     inherit pkgs;
-    inherit (stdenv) system;
+    inherit (stdenv.hostPlatform) system;
   })."nixui-git://github.com/matejc/nixui.git#0.2.1";
   script = writeScript "nixui" ''
     #! ${stdenv.shell}
diff --git a/pkgs/tools/security/afl/default.nix b/pkgs/tools/security/afl/default.nix
index c61cbeb32682..3476606049d1 100644
--- a/pkgs/tools/security/afl/default.nix
+++ b/pkgs/tools/security/afl/default.nix
@@ -4,9 +4,9 @@
 
 let
   afl-qemu = callPackage ./qemu.nix {};
-  qemu-exe-name = if stdenv.system == "x86_64-linux" then "qemu-x86_64"
-    else if stdenv.system == "i686-linux" then "qemu-i386"
-    else throw "afl: no support for ${stdenv.system}!";
+  qemu-exe-name = if stdenv.hostPlatform.system == "x86_64-linux" then "qemu-x86_64"
+    else if stdenv.hostPlatform.system == "i686-linux" then "qemu-i386"
+    else throw "afl: no support for ${stdenv.hostPlatform.system}!";
 in
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/tools/security/afl/qemu.nix b/pkgs/tools/security/afl/qemu.nix
index 7637dcf246af..82de6474e598 100644
--- a/pkgs/tools/security/afl/qemu.nix
+++ b/pkgs/tools/security/afl/qemu.nix
@@ -16,9 +16,9 @@ let
   aflTypesFile = writeText "afl-types.h"
     (builtins.readFile ./qemu-patches/afl-types.h);
 
-  cpuTarget = if stdenv.system == "x86_64-linux" then "x86_64-linux-user"
-    else if stdenv.system == "i686-linux" then "i386-linux-user"
-    else throw "afl: no support for ${stdenv.system}!";
+  cpuTarget = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux-user"
+    else if stdenv.hostPlatform.system == "i686-linux" then "i386-linux-user"
+    else throw "afl: no support for ${stdenv.hostPlatform.system}!";
 in
 stdenv.mkDerivation rec {
   name = "afl-${n}";
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
       vde2 texinfo libuuid flex bison lzo snappy autoconf
       libcap_ng gnutls
     ]
-    ++ optionals (hasSuffix "linux" stdenv.system) [ libaio ];
+    ++ optionals (hasSuffix "linux" stdenv.hostPlatform.system) [ libaio ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/tools/security/encryptr/default.nix b/pkgs/tools/security/encryptr/default.nix
index 2cf07c63a84a..8d0c78764319 100644
--- a/pkgs/tools/security/encryptr/default.nix
+++ b/pkgs/tools/security/encryptr/default.nix
@@ -5,13 +5,13 @@
 }:
 
 let
-  arch = if stdenv.system == "x86_64-linux" then "amd"
-    else if stdenv.system == "i686-linux" then "i386"
-    else throw "Encryptr for ${stdenv.system} not supported!";
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "amd"
+    else if stdenv.hostPlatform.system == "i686-linux" then "i386"
+    else throw "Encryptr for ${stdenv.hostPlatform.system} not supported!";
 
-  sha256 = if stdenv.system == "x86_64-linux" then "1j3g467g7ar86hpnh6q9mf7mh2h4ia94mwhk1283zh739s2g53q2"
-    else if stdenv.system == "i686-linux" then "02j9hg9b1jlv25q1sjfhv8d46mii33f94dj0ccn83z9z18q4y2cm"
-    else throw "Encryptr for ${stdenv.system} not supported!";
+  sha256 = if stdenv.hostPlatform.system == "x86_64-linux" then "1j3g467g7ar86hpnh6q9mf7mh2h4ia94mwhk1283zh739s2g53q2"
+    else if stdenv.hostPlatform.system == "i686-linux" then "02j9hg9b1jlv25q1sjfhv8d46mii33f94dj0ccn83z9z18q4y2cm"
+    else throw "Encryptr for ${stdenv.hostPlatform.system} not supported!";
 
 in stdenv.mkDerivation rec {
   name = "encryptr-${version}";
diff --git a/pkgs/tools/security/enpass/default.nix b/pkgs/tools/security/enpass/default.nix
index b99087e475d2..0f0c4233ca9d 100644
--- a/pkgs/tools/security/enpass/default.nix
+++ b/pkgs/tools/security/enpass/default.nix
@@ -1,8 +1,9 @@
-{stdenv, system, fetchurl, dpkg, openssl, xorg
+{ stdenv, fetchurl, dpkg, openssl, xorg
 , glib, libGLU_combined, libpulseaudio, zlib, dbus, fontconfig, freetype
 , gtk2, pango, atk, cairo, gdk_pixbuf, jasper, xkeyboardconfig
 , makeWrapper , python, pythonPackages, lib
-, libredirect, lsof}:
+, libredirect, lsof
+}:
 
 let
   all_data = builtins.fromJSON (builtins.readFile ./data.json);
@@ -11,7 +12,7 @@ let
     x86_64-linux = "amd64";
   };
 
-  data = all_data.${system_map.${system} or (throw "Unsupported platform")};
+  data = all_data.${system_map.${stdenv.hostPlatform.system} or (throw "Unsupported platform")};
 
   baseUrl = http://repo.sinew.in;
 
diff --git a/pkgs/tools/security/pcsc-scm-scl011/default.nix b/pkgs/tools/security/pcsc-scm-scl011/default.nix
index 1418a4ead580..88ca8a3d1b1a 100644
--- a/pkgs/tools/security/pcsc-scm-scl011/default.nix
+++ b/pkgs/tools/security/pcsc-scm-scl011/default.nix
@@ -1,9 +1,9 @@
 { stdenv, fetchurl, unzip, libusb }:
 
 let
-  arch = if stdenv.system == "i686-linux" then "32"
-  else if stdenv.system == "x86_64-linux" then "64"
-  else throw "Unsupported system: ${stdenv.system}";
+  arch = if stdenv.hostPlatform.system == "i686-linux" then "32"
+  else if stdenv.hostPlatform.system == "x86_64-linux" then "64"
+  else throw "Unsupported system: ${stdenv.hostPlatform.system}";
 in
 stdenv.mkDerivation rec {
   name = "pcsc-scm-scl-${version}";
diff --git a/pkgs/tools/security/sshuttle/default.nix b/pkgs/tools/security/sshuttle/default.nix
index f7878df228f2..c701b9dba73d 100644
--- a/pkgs/tools/security/sshuttle/default.nix
+++ b/pkgs/tools/security/sshuttle/default.nix
@@ -12,7 +12,7 @@ python3Packages.buildPythonApplication rec {
 
   patches = [ ./sudo.patch ];
 
-  nativeBuildInputs = [ makeWrapper python3Packages.setuptools_scm ] ++ stdenv.lib.optional (stdenv.system != "i686-linux") pandoc;
+  nativeBuildInputs = [ makeWrapper python3Packages.setuptools_scm ] ++ stdenv.lib.optional (stdenv.hostPlatform.system != "i686-linux") pandoc;
   buildInputs =
     [ coreutils openssh procps nettools ]
     ++ stdenv.lib.optionals stdenv.isLinux [ iptables ];
diff --git a/pkgs/tools/system/at/default.nix b/pkgs/tools/system/at/default.nix
index baac00bfa763..1e3bf0c0050c 100644
--- a/pkgs/tools/system/at/default.nix
+++ b/pkgs/tools/system/at/default.nix
@@ -5,12 +5,12 @@
 
 stdenv.mkDerivation rec {
   name = "at-${version}";
-  version = "3.1.20";
+  version = "3.1.23";
 
   src = fetchurl {
     # Debian is apparently the last location where it can be found.
     url = "mirror://debian/pool/main/a/at/at_${version}.orig.tar.gz";
-    sha256 = "1fgsrqpx0r6qcjxmlsqnwilydhfxn976c870mjc0n1bkmcy94w88";
+    sha256 = "040pr2ivfbrhvrhzis97cpwfkzpr7nin33nc301aga5aajlhlicp";
   };
 
   patches = [
diff --git a/pkgs/tools/system/incron/default.nix b/pkgs/tools/system/incron/default.nix
new file mode 100644
index 000000000000..2afbed2f9bb2
--- /dev/null
+++ b/pkgs/tools/system/incron/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, bash }:
+
+stdenv.mkDerivation rec {
+  name = "incron-0.5.12";
+  src = fetchFromGitHub {
+    owner = "ar-";
+    repo = "incron";
+    rev = name;
+    sha256 = "11d5f98cjafiv9h9zzzrw2s06s2fvdg8gp64km7mdprd2xmy6dih";
+  };
+
+  patches = [ ./default_path.patch ];
+
+  prePatch = ''
+    sed -i "s|/bin/bash|${bash}/bin/bash|g" usertable.cpp
+  '';
+
+  installFlags = [ "PREFIX=$(out)" ];
+  installTargets = [ "install-man" ];
+
+  preInstall = ''
+    mkdir -p $out/bin
+
+    # make install doesn't work because setuid and permissions
+    # just manually install the binaries instead
+    cp incrond incrontab $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A cron-like daemon which handles filesystem events.";
+    homepage = https://github.com/ar-/incron;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.aanderse ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/tools/system/incron/default_path.patch b/pkgs/tools/system/incron/default_path.patch
new file mode 100644
index 000000000000..ae173ea29e62
--- /dev/null
+++ b/pkgs/tools/system/incron/default_path.patch
@@ -0,0 +1,36 @@
+diff --git usertable.cpp usertable.cpp
+index 11fd04b..a8681bd 100644
+--- a/usertable.cpp
++++ b/usertable.cpp
+@@ -43,9 +43,6 @@
+ #define DONT_FOLLOW(mask) (false)
+ #endif // IN_DONT_FOLLOW
+ 
+-// this is not enough, but...
+-#define DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin"
+-
+ 
+ PROC_MAP UserTable::s_procMap;
+ 
+@@ -597,12 +594,20 @@ void UserTable::RunAsUser(std::string cmd) const
+     if (clearenv() != 0)
+       goto failed;
+ 
++    // try to recreate the user path as best as possible
++    std::string DEFAULT_PATH;
++    DEFAULT_PATH += "/run/wrappers/bin:";
++    DEFAULT_PATH += pwd->pw_dir;
++    DEFAULT_PATH += "/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/";
++    DEFAULT_PATH += pwd->pw_name;
++    DEFAULT_PATH += "/bin";
++
+     if (    setenv("LOGNAME",   pwd->pw_name,   1) != 0
+         ||  setenv("USER",      pwd->pw_name,   1) != 0
+         ||  setenv("USERNAME",  pwd->pw_name,   1) != 0
+         ||  setenv("HOME",      pwd->pw_dir,    1) != 0
+         ||  setenv("SHELL",     pwd->pw_shell,  1) != 0
+-        ||  setenv("PATH",      DEFAULT_PATH,   1) != 0)
++        ||  setenv("PATH",      DEFAULT_PATH.c_str(),   1) != 0)
+     {
+       goto failed;
+     }
diff --git a/pkgs/tools/system/s6-rc/default.nix b/pkgs/tools/system/s6-rc/default.nix
index f6eed5671cea..40c999d80f13 100644
--- a/pkgs/tools/system/s6-rc/default.nix
+++ b/pkgs/tools/system/s6-rc/default.nix
@@ -39,7 +39,7 @@ in stdenv.mkDerivation rec {
     "--with-dynlib=${s6.out}/lib"
   ]
   ++ (if stdenv.isDarwin then [ "--disable-shared" ] else [ "--enable-shared" ])
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/s6-rc/
diff --git a/pkgs/tools/system/s6/default.nix b/pkgs/tools/system/s6/default.nix
index 035d4280494c..d7ade3cdb290 100644
--- a/pkgs/tools/system/s6/default.nix
+++ b/pkgs/tools/system/s6/default.nix
@@ -40,7 +40,7 @@ in stdenv.mkDerivation rec {
     "--with-dynlib=${execline.lib}/lib"
   ]
   ++ (if stdenv.isDarwin then [ "--disable-shared" ] else [ "--enable-shared" ])
-  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.system}");
+  ++ (stdenv.lib.optional stdenv.isDarwin "--build=${stdenv.hostPlatform.system}");
 
   postInstall = ''
     mkdir -p $doc/share/doc/s6/
diff --git a/pkgs/tools/system/storebrowse/default.nix b/pkgs/tools/system/storebrowse/default.nix
index e56919acc5d5..e3b58a50c925 100644
--- a/pkgs/tools/system/storebrowse/default.nix
+++ b/pkgs/tools/system/storebrowse/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     mkdir $TMPDIR/go
     export GOPATH=$TMPDIR/go
 
-    ${stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") "export GOARM=5"}
+    ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "export GOARM=5"}
 
     GOSQLITE=$GOPATH/src/code.google.com/p/gosqlite
     mkdir -p $GOSQLITE
diff --git a/pkgs/tools/text/gawk/default.nix b/pkgs/tools/text/gawk/default.nix
index c0c06813dc94..15d54f4a2a4d 100644
--- a/pkgs/tools/text/gawk/default.nix
+++ b/pkgs/tools/text/gawk/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 # TODO: links -lsigsegv but loses the reference for some reason
-, withSigsegv ? (false && stdenv.system != "x86_64-cygwin"), libsigsegv
+, withSigsegv ? (false && stdenv.hostPlatform.system != "x86_64-cygwin"), libsigsegv
 , interactive ? false, readline
 
 /* Test suite broke on:
diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix
index 0ad2a18236f6..e22850a63f01 100644
--- a/pkgs/tools/text/gnupatch/default.nix
+++ b/pkgs/tools/text/gnupatch/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl
 , ed, autoreconfHook
-, buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
@@ -27,11 +26,11 @@ stdenv.mkDerivation rec {
   buildInputs = stdenv.lib.optional doCheck ed;
   nativeBuildInputs = [ autoreconfHook ];
 
-  configureFlags = stdenv.lib.optionals (hostPlatform != buildPlatform) [
+  configureFlags = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "ac_cv_func_strnlen_working=yes"
   ];
 
-  doCheck = hostPlatform.libc != "musl"; # not cross;
+  doCheck = stdenv.hostPlatform.libc != "musl"; # not cross;
 
   meta = {
     description = "GNU Patch, a program to apply differences to files";
diff --git a/pkgs/tools/text/html-tidy/default.nix b/pkgs/tools/text/html-tidy/default.nix
index ccd927002464..51ce4baa0beb 100644
--- a/pkgs/tools/text/html-tidy/default.nix
+++ b/pkgs/tools/text/html-tidy/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, libxslt
-, hostPlatform
-}:
+{ stdenv, fetchFromGitHub, cmake, libxslt }:
 
 stdenv.mkDerivation rec {
   name = "html-tidy-${version}";
@@ -16,7 +14,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake libxslt/*manpage*/ ];
 
   cmakeFlags = stdenv.lib.optional
-    (hostPlatform.libc or null == "msvcrt") "-DCMAKE_SYSTEM_NAME=Windows";
+    (stdenv.hostPlatform.libc or null == "msvcrt") "-DCMAKE_SYSTEM_NAME=Windows";
 
   # ATM bin/tidy is statically linked, as upstream provides no other option yet.
   # https://github.com/htacg/tidy-html5/issues/326#issuecomment-160322107
diff --git a/pkgs/tools/text/xidel/default.nix b/pkgs/tools/text/xidel/default.nix
index e1a0a5abf965..66dfa1c6b348 100644
--- a/pkgs/tools/text/xidel/default.nix
+++ b/pkgs/tools/text/xidel/default.nix
@@ -11,17 +11,17 @@ stdenv.mkDerivation rec {
   #};
 
   src =
-    if stdenv.system == "x86_64-linux" then
+    if stdenv.hostPlatform.system == "x86_64-linux" then
       fetchurl {
         url = "mirror://sourceforge/videlibri/Xidel/Xidel%20${version}/xidel_${version}-1_amd64.deb";
         sha256 = "0hskc74y7p4j1x33yx0w4fvr610p2yimas8pxhr6bs7mb9b300h7";
       }
-    else if stdenv.system == "i686-linux" then
+    else if stdenv.hostPlatform.system == "i686-linux" then
       fetchurl {
         url = "mirror://sourceforge/videlibri/Xidel/Xidel%20${version}/xidel_${version}-1_i386.deb";
         sha256 = "07yk5sk1p4jm0jmgjwdm2wq8d2wybi1wkn1qq5j5y03z1pdc3fi6";
       }
-    else throw "xidel is not supported on ${stdenv.system}";
+    else throw "xidel is not supported on ${stdenv.hostPlatform.system}";
 
   buildInputs = [ dpkg ];
 
diff --git a/pkgs/tools/typesetting/kindlegen/default.nix b/pkgs/tools/typesetting/kindlegen/default.nix
index 4e9a40239bfe..fc43ed0abe27 100644
--- a/pkgs/tools/typesetting/kindlegen/default.nix
+++ b/pkgs/tools/typesetting/kindlegen/default.nix
@@ -11,7 +11,7 @@ let
     "i686-darwin"   = "0zniyn0s41fxqrajbgwxbcsj5vzf9m7a6yvdz2b11mphr00kpbbs";
     "x86_64-cygwin" = "02slfh1bbpijay4skj85cjiv7z43ha8vm5aa1lwiqjk86qbl1f3h";
     "i686-cygwin"   = "02slfh1bbpijay4skj85cjiv7z43ha8vm5aa1lwiqjk86qbl1f3h";
-  }."${stdenv.system}" or (throw "system #{stdenv.system.} is not supported");
+  }."${stdenv.hostPlatform.system}" or (throw "system #{stdenv.hostPlatform.system.} is not supported");
 
   url = {
     "x86_64-linux"  = "http://kindlegen.s3.amazonaws.com/kindlegen_linux_2.6_i386_v${fileVersion}.tar.gz";
@@ -20,7 +20,7 @@ let
     "i686-darwin"   = "http://kindlegen.s3.amazonaws.com/KindleGen_Mac_i386_v${fileVersion}.zip";
     "x86_64-cygwin" = "http://kindlegen.s3.amazonaws.com/kindlegen_win32_v${fileVersion}.zip";
     "i686-cygwin"   = "http://kindlegen.s3.amazonaws.com/kindlegen_win32_v${fileVersion}.zip";
-  }."${stdenv.system}" or (throw "system #{stdenv.system.} is not supported");
+  }."${stdenv.hostPlatform.system}" or (throw "system #{stdenv.hostPlatform.system.} is not supported");
 
 in stdenv.mkDerivation rec {
   name = "kindlegen-${version}";
diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix
index 634a3e4c17e4..ae7137d3a6a4 100644
--- a/pkgs/top-level/aliases.nix
+++ b/pkgs/top-level/aliases.nix
@@ -151,7 +151,7 @@ mapAliases ({
   libgnome_keyring = libgnome-keyring; # added 2018-02-25
   libgnome_keyring3 = libgnome-keyring3; # added 2018-02-25
   libgumbo = gumbo; # added 2018-01-21
-  libintlOrEmpty = stdenv.lib.optional (!stdenv.isLinux || hostPlatform.libc != "glibc") gettext; # added 2018-03-14
+  libintlOrEmpty = stdenv.lib.optional (!stdenv.isLinux || stdenv.hostPlatform.libc != "glibc") gettext; # added 2018-03-14
   libjson_rpc_cpp = libjson-rpc-cpp; # added 2017-02-28
   libmysql = mysql.connector-c; # added # 2017-12-28, this was a misnomer refering to libmysqlclient
   librecad2 = librecad;  # backwards compatibility alias, added 2015-10
@@ -278,6 +278,7 @@ mapAliases ({
   tex-gyre-schola-math = tex-gyre-math.schola; # added 2018-04-03
   tex-gyre-termes-math = tex-gyre-math.termes; # added 2018-04-03
   tftp_hpa = tftp-hpa; # added 2015-04-03
+  torbrowser = tor-browser-bundle-bin; # added 2017-04-05
   trang = jing-trang; # added 2018-04-25
   transmission_gtk = transmission-gtk; # added 2018-01-06
   transmission_remote_gtk = transmission-remote-gtk; # added 2018-01-06
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 43957a6700de..5ace2e0cd54a 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -18,7 +18,7 @@ with pkgs;
   # A stdenv capable of building 32-bit binaries.  On x86_64-linux,
   # it uses GCC compiled with multilib support; on i686-linux, it's
   # just the plain stdenv.
-  stdenv_32bit = lowPrio (if hostPlatform.is32bit then stdenv else multiStdenv);
+  stdenv_32bit = lowPrio (if stdenv.hostPlatform.is32bit then stdenv else multiStdenv);
 
   stdenvNoCC = stdenv.override { cc = null; };
 
@@ -1744,7 +1744,7 @@ with pkgs;
   chunksync = callPackage ../tools/backup/chunksync { };
 
   cipherscan = callPackage ../tools/security/cipherscan {
-    openssl = if stdenv.system == "x86_64-linux"
+    openssl = if stdenv.hostPlatform.system == "x86_64-linux"
       then openssl-chacha
       else openssl;
   };
@@ -3267,6 +3267,8 @@ with pkgs;
 
   inboxer = callPackage ../applications/networking/mailreaders/inboxer { };
 
+  incron = callPackage ../tools/system/incron { };
+
   inetutils = callPackage ../tools/networking/inetutils { };
 
   infiniband-diags = callPackage ../tools/networking/infiniband-diags { };
@@ -4292,6 +4294,8 @@ with pkgs;
 
   notify-osd = callPackage ../applications/misc/notify-osd { };
 
+  notify-osd-customizable = callPackage ../applications/misc/notify-osd-customizable { };
+
   nox = callPackage ../tools/package-management/nox { };
 
   nq = callPackage ../tools/system/nq { };
@@ -5564,13 +5568,6 @@ with pkgs;
 
   tor-arm = callPackage ../tools/security/tor/tor-arm.nix { };
 
-  # added 2017-04-05
-  torbrowser = /* builtins.trace ''
-    WARNING: torbrowser package was renamed to tor-browser-bundle-bin.
-
-    Also, consider using nix-built tor-browser-unwrapped package instead. Read its longDescription.
-  '' */ tor-browser-bundle-bin;
-
   tor-browser-bundle-bin = callPackage ../applications/networking/browsers/tor-browser-bundle-bin { };
 
   tor-browser-bundle = callPackage ../applications/networking/browsers/tor-browser-bundle {
@@ -6058,7 +6055,9 @@ with pkgs;
 
   wv2 = callPackage ../tools/misc/wv2 { };
 
-  wyrd = callPackage ../tools/misc/wyrd { };
+  wyrd = callPackage ../tools/misc/wyrd {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   x86info = callPackage ../os-specific/linux/x86info { };
 
@@ -6423,14 +6422,14 @@ with pkgs;
     cc = gcc;
     # Remove libcxx/libcxxabi, and add clang for AS if on darwin (it uses
     # clang's internal assembler).
-    extraBuildInputs = lib.optional hostPlatform.isDarwin clang.cc;
+    extraBuildInputs = lib.optional stdenv.hostPlatform.isDarwin clang.cc;
   };
 
   gcc7Stdenv = overrideCC gccStdenv gcc7;
   gcc8Stdenv = overrideCC gccStdenv gcc8;
 
   wrapCCMulti = cc:
-    if system == "x86_64-linux" then let
+    if stdenv.targetPlatform.system == "x86_64-linux" then let
       # Binutils with glibc multi
       bintools = cc.bintools.override {
         libc = glibc_multi;
@@ -6450,16 +6449,16 @@ with pkgs;
       extraBuildCommands = ''
         echo "dontMoveLib64=1" >> $out/nix-support/setup-hook
       '';
-  }) else throw "Multilib ${cc.name} not supported on ‘${system}’";
+  }) else throw "Multilib ${cc.name} not supported for ‘${stdenv.targetPlatform.system}’";
 
   wrapClangMulti = clang:
-    if system == "x86_64-linux" then
+    if stdenv.targetPlatform.system == "x86_64-linux" then
       callPackage ../development/compilers/llvm/multi.nix {
         inherit clang;
         gcc32 = pkgsi686Linux.gcc;
         gcc64 = pkgs.gcc;
       }
-    else throw "Multilib ${clang.cc.name} not supported on '${system}'";
+    else throw "Multilib ${clang.cc.name} not supported for '${stdenv.targetPlatform.system}'";
 
   gcc_multi = wrapCCMulti gcc;
   clang_multi = wrapClangMulti clang;
@@ -6480,11 +6479,11 @@ with pkgs;
 
   # The GCC used to build libc for the target platform. Normal gccs will be
   # built with, and use, that cross-compiled libc.
-  gccCrossStageStatic = assert targetPlatform != buildPlatform; let
+  gccCrossStageStatic = assert stdenv.targetPlatform != stdenv.hostPlatform; let
     libcCross1 =
-      if targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
-      else if targetPlatform.libc == "libSystem" then darwin.xcode
-      else if targetPlatform.libc == "musl" then musl
+      if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
+      else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
+      else if stdenv.targetPlatform.libc == "musl" then musl
       else null;
     binutils1 = wrapBintoolsWith {
       bintools = binutils-unwrapped;
@@ -6515,7 +6514,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isSunOS && !isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_14 else null;
     cloog = if !stdenv.isDarwin then cloog else null;
@@ -6528,7 +6527,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_11 else null;
 
@@ -6541,7 +6540,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_14 else null;
   }));
@@ -6552,7 +6551,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_14 else null;
   }));
@@ -6563,7 +6562,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_17 else null;
   }));
@@ -6574,7 +6573,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = if !stdenv.isDarwin then isl_0_17 else null;
   }));
@@ -6585,7 +6584,7 @@ with pkgs;
     # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
     profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
 
-    libcCross = if targetPlatform != buildPlatform then libcCross else null;
+    libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
 
     isl = isl_0_17;
   }));
@@ -6724,7 +6723,7 @@ with pkgs;
       graphviz = graphviz-nox;
     });
 
-  inherit (ocamlPackages.haxe) haxe_3_2 haxe_3_4;
+  inherit (ocaml-ng.ocamlPackages_4_05.haxe) haxe_3_2 haxe_3_4;
   haxe = haxe_3_4;
   haxePackages = recurseIntoAttrs (callPackage ./haxe-packages.nix { });
   inherit (haxePackages) hxcpp;
@@ -6741,13 +6740,9 @@ with pkgs;
     mono = mono46;
   };
 
-  fstar = callPackage ../development/compilers/fstar {
-    ocamlPackages = ocaml-ng.ocamlPackages_4_06;
-  };
+  fstar = callPackage ../development/compilers/fstar { };
 
-  pyre = callPackage ../development/tools/pyre {
-    ocamlPackages = ocaml-ng.ocamlPackages_4_06;
-  };
+  pyre = callPackage ../development/tools/pyre { };
 
   dotnetPackages = recurseIntoAttrs (callPackage ./dotnet-packages.nix {});
 
@@ -6915,6 +6910,18 @@ with pkgs;
     llvm = llvm_39;
   };
 
+  julia_07 = callPackage ../development/compilers/julia/0.7.nix {
+    gmp = gmp6;
+    openblas = openblasCompat;
+    inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
+  };
+
+  julia_10 = callPackage ../development/compilers/julia/1.0.nix {
+    gmp = gmp6;
+    openblas = openblasCompat;
+    inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
+  };
+
   jwasm =  callPackage ../development/compilers/jwasm { };
 
   kotlin = callPackage ../development/compilers/kotlin { };
@@ -7096,7 +7103,9 @@ with pkgs;
 
   nvidia_cg_toolkit = callPackage ../development/compilers/nvidia-cg-toolkit { };
 
-  obliv-c = callPackage ../development/compilers/obliv-c {};
+  obliv-c = callPackage ../development/compilers/obliv-c {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   ocaml-ng = callPackage ./ocaml-packages.nix { };
   ocaml = ocamlPackages.ocaml;
@@ -7121,7 +7130,9 @@ with pkgs;
 
   opaline = callPackage ../development/tools/ocaml/opaline { };
 
-  opam = callPackage ../development/tools/ocaml/opam { };
+  opam = callPackage ../development/tools/ocaml/opam {
+    inherit (ocaml-ng.ocamlPackages_4_05) ocaml;
+  };
 
   picat = callPackage ../development/compilers/picat {
     stdenv = overrideCC stdenv gcc49;
@@ -7286,13 +7297,13 @@ with pkgs;
       # Others should instead delegate to the next stage's choice with
       # `targetPackages.stdenv.cc.bintools`. This one is different just to
       # provide the default choice, avoiding infinite recursion.
-      bintools ? if targetPlatform.isDarwin then darwin.binutils else binutils
+      bintools ? if stdenv.targetPlatform.isDarwin then darwin.binutils else binutils
     , libc ? bintools.libc
     , ...
     } @ extraArgs:
       callPackage ../build-support/cc-wrapper (let self = {
-    nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
-    nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
+    nativeTools = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeTools or false;
+    nativeLibc = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeLibc or false;
     nativePrefix = stdenv.cc.nativePrefix or "";
     noLibc = !self.nativeLibc && (self.libc == null);
 
@@ -7308,12 +7319,12 @@ with pkgs;
 
   wrapBintoolsWith =
     { bintools
-    , libc ? if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc
+    , libc ? if stdenv.targetPlatform != stdenv.hostPlatform then libcCross else stdenv.cc.libc
     , ...
     } @ extraArgs:
       callPackage ../build-support/bintools-wrapper (let self = {
-    nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
-    nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
+    nativeTools = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeTools or false;
+    nativeLibc = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeLibc or false;
     nativePrefix = stdenv.cc.nativePrefix or "";
 
     noLibc = (self.libc == null);
@@ -7952,7 +7963,7 @@ with pkgs;
 
   binutils-unwrapped = callPackage ../development/tools/misc/binutils {
     # FHS sys dirs presumably only have stuff for the build platform
-    noSysDirs = (targetPlatform != buildPlatform) || noSysDirs;
+    noSysDirs = (stdenv.targetPlatform != stdenv.hostPlatform) || noSysDirs;
   };
   binutils = wrapBintoolsWith {
     bintools = binutils-unwrapped;
@@ -8095,7 +8106,9 @@ with pkgs;
   # Does not actually depend on Qt 5
   inherit (kdeFrameworks) extra-cmake-modules kapidox kdoctools;
 
-  coccinelle = callPackage ../development/tools/misc/coccinelle { };
+  coccinelle = callPackage ../development/tools/misc/coccinelle {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   cpptest = callPackage ../development/libraries/cpptest { };
 
@@ -8938,8 +8951,8 @@ with pkgs;
   bicgl = callPackage ../development/libraries/science/biology/bicgl { };
 
   # TODO(@Ericson2314): Build bionic libc from source
-  bionic = assert hostPlatform.useAndroidPrebuilt;
-    androidenv."androidndkPkgs_${hostPlatform.ndkVer}".libraries;
+  bionic = assert stdenv.hostPlatform.useAndroidPrebuilt;
+    androidenv."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries;
 
   bobcat = callPackage ../development/libraries/bobcat { };
 
@@ -9518,14 +9531,14 @@ with pkgs;
     else if name == "uclibc" then targetPackages.uclibcCross
     else if name == "musl" then targetPackages.muslCross or muslCross
     else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
-    else if targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries
+    else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries
     else if name == "libSystem" then targetPackages.darwin.xcode
     else throw "Unknown libc";
 
-  libcCross = assert targetPlatform != buildPlatform; libcCrossChooser targetPlatform.libc;
+  libcCross = assert stdenv.targetPlatform != stdenv.buildPlatform; libcCrossChooser stdenv.targetPlatform.libc;
 
   # Only supported on Linux, using glibc
-  glibcLocales = if hostPlatform.libc == "glibc" then callPackage ../development/libraries/glibc/locales.nix { } else null;
+  glibcLocales = if stdenv.hostPlatform.libc == "glibc" then callPackage ../development/libraries/glibc/locales.nix { } else null;
 
   glibcInfo = callPackage ../development/libraries/glibc/info.nix { };
 
@@ -9643,7 +9656,7 @@ with pkgs;
 
   gnu-config = callPackage ../development/libraries/gnu-config { };
 
-  gnu-efi = if hostPlatform.isEfi
+  gnu-efi = if stdenv.hostPlatform.isEfi
               then callPackage ../development/libraries/gnu-efi { }
             else null;
 
@@ -10105,7 +10118,7 @@ with pkgs;
   libb2 = callPackage ../development/libraries/libb2 { };
 
   libbap = callPackage ../development/libraries/libbap {
-    inherit (ocamlPackages) bap ocaml findlib ctypes;
+    inherit (ocaml-ng.ocamlPackages_4_05) bap ocaml findlib ctypes;
   };
 
   libbass = (callPackage ../development/libraries/audio/libbass { }).bass;
@@ -10539,8 +10552,6 @@ with pkgs;
 
   libnfs = callPackage ../development/libraries/libnfs { };
 
-  libnfsidmap = callPackage ../development/libraries/libnfsidmap { };
-
   libnice = callPackage ../development/libraries/libnice { };
 
   libnsl = callPackage ../development/libraries/libnsl { };
@@ -10589,11 +10600,11 @@ with pkgs;
   # We also provide `libiconvReal`, which will always be a standalone libiconv,
   # just in case you want it regardless of platform.
   libiconv =
-    if (hostPlatform.libc == "glibc" || hostPlatform.libc == "musl")
-      then glibcIconv (if hostPlatform != buildPlatform
+    if (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl")
+      then glibcIconv (if stdenv.hostPlatform != stdenv.buildPlatform
                        then libcCross
                        else stdenv.cc.libc)
-    else if hostPlatform.isDarwin
+    else if stdenv.hostPlatform.isDarwin
       then darwin.libiconv
     else libiconvReal;
 
@@ -10610,7 +10621,7 @@ with pkgs;
   };
 
   # On non-GNU systems we need GNU Gettext for libintl.
-  libintl = if hostPlatform.libc != "glibc" then gettext else null;
+  libintl = if stdenv.hostPlatform.libc != "glibc" then gettext else null;
 
   libid3tag = callPackage ../development/libraries/libid3tag {
     gperf = gperf_3_0;
@@ -11139,7 +11150,7 @@ with pkgs;
   # Default derivation with libGL.so.1 to link into /run/opengl-drivers (if need)
   libGL_driver = libGLDarwinOr mesa_drivers;
 
-  libGLSupported = lib.elem system lib.platforms.mesaPlatforms;
+  libGLSupported = lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms;
 
   libGLDarwin = callPackage ../development/libraries/mesa-darwin {
     inherit (darwin.apple_sdk.frameworks) OpenGL;
@@ -11253,7 +11264,7 @@ with pkgs;
     abiVersion = "6";
   };
   ncurses =
-    if hostPlatform.useiOSPrebuilt
+    if stdenv.hostPlatform.useiOSPrebuilt
     then null
     else callPackage ../development/libraries/ncurses { };
 
@@ -12412,21 +12423,21 @@ with pkgs;
 
   wxGTK28 = callPackage ../development/libraries/wxwidgets/2.8 {
     inherit (gnome2) GConf;
-    withMesa = lib.elem system lib.platforms.mesaPlatforms;
+    withMesa = lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms;
   };
 
   wxGTK29 = callPackage ../development/libraries/wxwidgets/2.9 {
     inherit (gnome2) GConf;
     inherit (darwin.stubs) setfile;
     inherit (darwin.apple_sdk.frameworks) AGL Carbon Cocoa Kernel QuickTime;
-    withMesa = lib.elem system lib.platforms.mesaPlatforms;
+    withMesa = lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms;
   };
 
   wxGTK30 = callPackage ../development/libraries/wxwidgets/3.0 {
     inherit (gnome2) GConf;
     inherit (darwin.stubs) setfile;
     inherit (darwin.apple_sdk.frameworks) AGL Carbon Cocoa Kernel QTKit;
-    withMesa = lib.elem system lib.platforms.mesaPlatforms;
+    withMesa = lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms;
   };
 
   wxGTK31 = callPackage ../development/libraries/wxwidgets/3.1 {};
@@ -14215,7 +14226,6 @@ with pkgs;
   linuxPackages_custom = { version, src, configfile, allowImportFromDerivation ? true }:
     recurseIntoAttrs (linuxPackagesFor (pkgs.linuxManualConfig {
       inherit version src configfile stdenv allowImportFromDerivation;
-      inherit (stdenv) hostPlatform;
     }));
 
   # This serves as a test for linuxPackages_custom
@@ -16866,7 +16876,9 @@ with pkgs;
     extra-packages = [ csound ];
   };
 
-  jackline = callPackage ../applications/networking/instant-messengers/jackline { };
+  jackline = callPackage ../applications/networking/instant-messengers/jackline {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   slack = callPackage ../applications/networking/instant-messengers/slack { };
 
@@ -17470,7 +17482,9 @@ with pkgs;
 
   mjpg-streamer = callPackage ../applications/video/mjpg-streamer { };
 
-  mldonkey = callPackage ../applications/networking/p2p/mldonkey { };
+  mldonkey = callPackage ../applications/networking/p2p/mldonkey {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   MMA = callPackage ../applications/audio/MMA { };
 
@@ -17650,7 +17664,7 @@ with pkgs;
     }) murmur_git;
 
   mumble_overlay = callPackage ../applications/networking/mumble/overlay.nix {
-    mumble_i686 = if system == "x86_64-linux"
+    mumble_i686 = if stdenv.hostPlatform.system == "x86_64-linux"
       then pkgsi686Linux.mumble
       else null;
   };
@@ -18920,7 +18934,7 @@ with pkgs;
 
   unigine-valley = callPackage ../applications/graphics/unigine-valley { };
 
-  inherit (ocamlPackages) unison;
+  inherit (ocaml-ng.ocamlPackages_4_05) unison;
 
   unpaper = callPackage ../tools/graphics/unpaper { };
 
@@ -19051,7 +19065,7 @@ with pkgs;
   };
 
   virtualgl = callPackage ../tools/X11/virtualgl {
-    virtualglLib_i686 = if system == "x86_64-linux"
+    virtualglLib_i686 = if stdenv.hostPlatform.system == "x86_64-linux"
       then pkgsi686Linux.virtualglLib
       else null;
   };
@@ -19064,17 +19078,17 @@ with pkgs;
 
   primus = callPackage ../tools/X11/primus {
     stdenv_i686 = pkgsi686Linux.stdenv;
-    primusLib_i686 = if system == "x86_64-linux"
+    primusLib_i686 = if stdenv.hostPlatform.system == "x86_64-linux"
       then pkgsi686Linux.primusLib
       else null;
   };
 
   bumblebee = callPackage ../tools/X11/bumblebee {
     nvidia_x11 = linuxPackages.nvidia_x11;
-    nvidia_x11_i686 = if system == "x86_64-linux"
+    nvidia_x11_i686 = if stdenv.hostPlatform.system == "x86_64-linux"
       then pkgsi686Linux.linuxPackages.nvidia_x11.override { libsOnly = true; }
       else null;
-    libglvnd_i686 = if system == "x86_64-linux"
+    libglvnd_i686 = if stdenv.hostPlatform.system == "x86_64-linux"
       then pkgsi686Linux.libglvnd
       else null;
   };
@@ -20857,9 +20871,13 @@ with pkgs;
 
   abella = callPackage ../applications/science/logic/abella {};
 
-  acgtk = callPackage ../applications/science/logic/acgtk { };
+  acgtk = callPackage ../applications/science/logic/acgtk {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
-  alt-ergo = callPackage ../applications/science/logic/alt-ergo { };
+  alt-ergo = callPackage ../applications/science/logic/alt-ergo {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   aspino = callPackage ../applications/science/logic/aspino {};
 
@@ -20869,7 +20887,9 @@ with pkgs;
 
   inherit (callPackage ./coq-packages.nix {
     inherit (ocaml-ng) ocamlPackages_3_12_1
-                       ocamlPackages_4_02;
+                       ocamlPackages_4_02
+                       ocamlPackages_4_05
+    ;
   }) mkCoqPackages
     coq_8_3 coq_8_4 coq_8_5 coq_8_6 coq_8_7 coq_8_8
     coqPackages_8_5 coqPackages_8_6 coqPackages_8_7 coqPackages_8_8
@@ -20884,7 +20904,9 @@ with pkgs;
 
   caprice32 = callPackage ../misc/emulators/caprice32 { };
 
-  cubicle = callPackage ../applications/science/logic/cubicle { };
+  cubicle = callPackage ../applications/science/logic/cubicle {
+    ocamlPackages = ocaml-ng.ocamlPackages_4_05;
+  };
 
   cvc3 = callPackage ../applications/science/logic/cvc3 {
     gmp = lib.overrideDerivation gmp (a: { dontDisableStatic = true; });
@@ -20980,7 +21002,9 @@ with pkgs;
 
   proverif = callPackage ../applications/science/logic/proverif { };
 
-  sapic = callPackage ../applications/science/logic/sapic { };
+  sapic = callPackage ../applications/science/logic/sapic {
+    inherit (ocaml-ng.ocamlPackages_4_05) ocaml;
+  };
 
   satallax = callPackage ../applications/science/logic/satallax {
     ocaml = ocaml-ng.ocamlPackages_4_01_0.ocaml;
@@ -20992,7 +21016,9 @@ with pkgs;
     stdenv = gccStdenv;
   };
 
-  statverif = callPackage ../applications/science/logic/statverif { };
+  statverif = callPackage ../applications/science/logic/statverif {
+    inherit (ocaml-ng.ocamlPackages_4_05) ocaml;
+  };
 
   tptp = callPackage ../applications/science/logic/tptp {};
 
@@ -21023,7 +21049,9 @@ with pkgs;
   z3 = callPackage ../applications/science/logic/z3 { python = python2; };
 
   tlaplus = callPackage ../applications/science/logic/tlaplus {};
-  tlaps = callPackage ../applications/science/logic/tlaplus/tlaps.nix {};
+  tlaps = callPackage ../applications/science/logic/tlaplus/tlaps.nix {
+    inherit (ocaml-ng.ocamlPackages_4_05) ocaml;
+  };
   tlaplusToolbox = callPackage ../applications/science/logic/tlaplus/toolbox.nix {gtk = gtk2;};
 
   aiger = callPackage ../applications/science/logic/aiger {};
@@ -21525,6 +21553,8 @@ with pkgs;
 
   idsk = callPackage ../tools/filesystems/idsk { };
 
+  igraph = callPackage ../development/libraries/igraph { };
+
   illum = callPackage ../tools/system/illum { };
 
   # using the new configuration style proposal which is unstable
@@ -21631,7 +21661,7 @@ with pkgs;
    */
   nixos = configuration:
     (import (self.path + "/nixos/lib/eval-config.nix") {
-      inherit (pkgs) system;
+      inherit (pkgs.stdenv.hostPlatform) system;
       modules = [(
                   { lib, ... }: {
                     config.nixpkgs.pkgs = lib.mkDefault pkgs;
@@ -21867,9 +21897,7 @@ with pkgs;
 
   sane-frontends = callPackage ../applications/graphics/sane/frontends.nix { };
 
-  satysfi = callPackage ../tools/typesetting/satysfi {
-    ocamlPackages = ocaml-ng.ocamlPackages_4_06;
-  };
+  satysfi = callPackage ../tools/typesetting/satysfi { };
 
   sc-controller = pythonPackages.callPackage ../misc/drivers/sc-controller {
     inherit libusb1; # Shadow python.pkgs.libusb1.
@@ -22303,7 +22331,7 @@ with pkgs;
                       mount wall hostname more sysctl getconf
                       getent locale killall xxd watch;
 
-  fts = if hostPlatform.isMusl then netbsd.fts else null;
+  fts = if stdenv.hostPlatform.isMusl then netbsd.fts else null;
 
   inherit (recurseIntoAttrs (callPackages ../os-specific/bsd { }))
           netbsd;
diff --git a/pkgs/top-level/coq-packages.nix b/pkgs/top-level/coq-packages.nix
index 5f784e645349..818f896048ba 100644
--- a/pkgs/top-level/coq-packages.nix
+++ b/pkgs/top-level/coq-packages.nix
@@ -2,6 +2,7 @@
 , gnumake3
 , ocamlPackages_3_12_1
 , ocamlPackages_4_02
+, ocamlPackages_4_05
 }:
 
 let
@@ -65,9 +66,11 @@ in rec {
     camlp5 = ocamlPackages_4_02.camlp5_transitional;
   };
   coq_8_5 = callPackage ../applications/science/logic/coq {
+    ocamlPackages = ocamlPackages_4_05;
     version = "8.5pl3";
   };
   coq_8_6 = callPackage ../applications/science/logic/coq {
+    ocamlPackages = ocamlPackages_4_05;
     version = "8.6.1";
   };
   coq_8_7 = callPackage ../applications/science/logic/coq {
diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix
index 047eab83bb42..b0c82508c114 100644
--- a/pkgs/top-level/darwin-packages.nix
+++ b/pkgs/top-level/darwin-packages.nix
@@ -19,7 +19,7 @@ in
 
   binutils = pkgs.wrapBintoolsWith {
     libc =
-      if pkgs.targetPlatform != pkgs.hostPlatform
+      if stdenv.targetPlatform != stdenv.hostPlatform
       then pkgs.libcCross
       else pkgs.stdenv.cc.libc;
     bintools = darwin.binutils-unwrapped;
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
index bef3c2d0a219..0dd0e8edf17a 100644
--- a/pkgs/top-level/haskell-packages.nix
+++ b/pkgs/top-level/haskell-packages.nix
@@ -1,6 +1,5 @@
 { buildPackages, pkgs
 , newScope
-, buildPlatform, targetPlatform
 }:
 
 let
@@ -61,7 +60,6 @@ in rec {
     ghc822 = callPackage ../development/compilers/ghc/8.2.2.nix rec {
       bootPkgs = packages.ghc821Binary;
       inherit (bootPkgs) hscolour alex happy;
-      inherit buildPlatform targetPlatform;
       sphinx = pkgs.python3Packages.sphinx;
       buildLlvmPackages = buildPackages.llvmPackages_39;
       llvmPackages = pkgs.llvmPackages_39;
diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix
index 5787f84335b0..7b6af70ebcf9 100644
--- a/pkgs/top-level/ocaml-packages.nix
+++ b/pkgs/top-level/ocaml-packages.nix
@@ -1,6 +1,8 @@
-{ lib, callPackage, newScope, pkgs, config, system }:
+{ lib, callPackage, newScope, pkgs, config }:
 
 let
+  inherit (pkgs.stdenv.hostPlatform) system;
+
   mkOcamlPackages = ocaml: overrides:
     let
       packageSet = self:
@@ -610,9 +612,6 @@ let
       else null;
 
     ocaml_extlib = callPackage ../development/ocaml-modules/extlib { };
-    ocaml_extlib_maximal = callPackage ../development/ocaml-modules/extlib {
-      minimal = false;
-    };
 
     ocb-stubblr = callPackage ../development/ocaml-modules/ocb-stubblr { };
 
@@ -1075,10 +1074,5 @@ in rec
 
   ocamlPackages_latest = ocamlPackages_4_07;
 
-  ocamlPackages =
-    # OCaml 4.05 is broken on aarch64
-    if system == "aarch64-linux" then
-      ocamlPackages_4_06
-    else
-      ocamlPackages_4_05;
+  ocamlPackages = ocamlPackages_4_06;
 }
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index a3d39cb37628..51d1a1c2215e 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -16588,9 +16588,11 @@ let
       url = mirror://cpan/authors/id/L/LD/LDACHARY/Text-Unaccent-1.08.tar.gz;
       sha256 = "0avk50kia78kxryh2whmaj5l18q2wvmkdyqyjsf6kwr4kgy6x3i7";
     };
+    # https://rt.cpan.org/Public/Bug/Display.html?id=124815
+    NIX_CFLAGS_COMPILE = [ "-DHAS_VPRINTF" ];
     meta = {
       maintainers = with maintainers; [ ];
-      platforms   = stdenv.lib.platforms.unix;
+      platforms = stdenv.lib.platforms.linux;
     };
   };
 
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 0aafe96d9277..451f7e86c525 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -242,6 +242,8 @@ in {
 
   clustershell = callPackage ../development/python-modules/clustershell { };
 
+  cozy = callPackage ../development/python-modules/cozy { };
+
   dendropy = callPackage ../development/python-modules/dendropy { };
 
   dbf = callPackage ../development/python-modules/dbf { };
@@ -252,6 +254,8 @@ in {
 
   dkimpy = callPackage ../development/python-modules/dkimpy { };
 
+  dictionaries = callPackage ../development/python-modules/dictionaries { };
+
   diff_cover = callPackage ../development/python-modules/diff_cover { };
 
   docrep = callPackage ../development/python-modules/docrep { };
@@ -310,6 +314,8 @@ in {
 
   habanero = callPackage ../development/python-modules/habanero { };
 
+  httpsig = callPackage ../development/python-modules/httpsig { };
+
   i3ipc = callPackage ../development/python-modules/i3ipc { };
 
   intelhex = callPackage ../development/python-modules/intelhex { };
@@ -354,6 +360,8 @@ in {
 
   oauthenticator = callPackage ../development/python-modules/oauthenticator { };
 
+  ordered-set = callPackage ../development/python-modules/ordered-set { };
+
   outcome = callPackage ../development/python-modules/outcome {};
 
   palettable = callPackage ../development/python-modules/palettable { };
@@ -487,6 +495,11 @@ in {
 
   python-hosts = callPackage ../development/python-modules/python-hosts { };
 
+  python-igraph = callPackage ../development/python-modules/python-igraph {
+    pkgconfig = pkgs.pkgconfig;
+    igraph = pkgs.igraph;
+  };
+
   python3-openid = callPackage ../development/python-modules/python3-openid { };
 
   python-periphery = callPackage ../development/python-modules/python-periphery { };
@@ -2805,13 +2818,13 @@ in {
     };
   };
 
-  gurobipy = if stdenv.system == "x86_64-darwin"
+  gurobipy = if stdenv.hostPlatform.system == "x86_64-darwin"
   then callPackage ../development/python-modules/gurobipy/darwin.nix {
     inherit (pkgs.darwin) cctools insert_dylib;
   }
-  else if stdenv.system == "x86_64-linux"
+  else if stdenv.hostPlatform.system == "x86_64-linux"
   then callPackage ../development/python-modules/gurobipy/linux.nix {}
-  else throw "gurobipy not yet supported on ${stdenv.system}";
+  else throw "gurobipy not yet supported on ${stdenv.hostPlatform.system}";
 
   hbmqtt = callPackage ../development/python-modules/hbmqtt { };
 
diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix
index 27e8136cd397..41fdc22d1477 100644
--- a/pkgs/top-level/splice.nix
+++ b/pkgs/top-level/splice.nix
@@ -27,9 +27,9 @@ let
   defaultBuildBuildScope = pkgs.buildPackages.buildPackages // pkgs.buildPackages.buildPackages.xorg;
   defaultBuildHostScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
   defaultBuildTargetScope =
-    if pkgs.targetPlatform == pkgs.hostPlatform
+    if pkgs.stdenv.targetPlatform == pkgs.stdenv.hostPlatform
     then defaultBuildHostScope
-    else assert pkgs.hostPlatform == pkgs.buildPlatform; defaultHostTargetScope;
+    else assert pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform; defaultHostTargetScope;
   defaultHostHostScope = {}; # unimplemented
   defaultHostTargetScope = pkgs // pkgs.xorg;
   defaultTargetTargetScope = pkgs.targetPackages // pkgs.targetPackages.xorg or {};
@@ -114,8 +114,8 @@ let
     pkgsTargetTarget = defaultTargetTargetScope;
   } // {
     # These should never be spliced under any circumstances
-    inherit (pkgs) pkgs buildPackages targetPackages
-      buildPlatform targetPlatform hostPlatform;
+    inherit (pkgs) pkgs buildPackages targetPackages;
+    inherit (pkgs.stdenv) buildPlatform targetPlatform hostPlatform;
   };
 
 in
diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix
index 52c3de3166ff..bc166382a608 100644
--- a/pkgs/top-level/unix-tools.nix
+++ b/pkgs/top-level/unix-tools.nix
@@ -1,4 +1,4 @@
-{ pkgs, buildEnv, runCommand, hostPlatform, lib, stdenv }:
+{ pkgs, buildEnv, runCommand, lib, stdenv }:
 
 # These are some unix tools that are commonly included in the /usr/bin
 # and /usr/sbin directory under more normal distributions. Along with
@@ -16,7 +16,7 @@ let
   version = "1003.1-2008";
 
   singleBinary = cmd: providers: let
-      provider = providers.${hostPlatform.parsed.kernel.name};
+      provider = providers.${stdenv.hostPlatform.parsed.kernel.name};
       bin = "${getBin provider}/bin/${cmd}";
       manpage = "${getOutput "man" provider}/share/man/man1/${cmd}.1.gz";
     in runCommand "${cmd}-${version}" {
@@ -59,12 +59,12 @@ let
       linux = pkgs.utillinux;
     };
     getconf = {
-      linux = if hostPlatform.libc == "glibc" then pkgs.glibc
+      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.glibc
               else pkgs.netbsd.getconf;
       darwin = pkgs.darwin.system_cmds;
     };
     getent = {
-      linux = if hostPlatform.libc == "glibc" then pkgs.glibc
+      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.glibc
               else pkgs.netbsd.getent;
       darwin = pkgs.netbsd.getent;
     };