summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development')
-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/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/3.9/llvm.nix8
-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/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/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/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/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/python-modules/numpy/default.nix4
-rw-r--r--pkgs/development/python-modules/pyserial/default.nix4
-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/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/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
159 files changed, 516 insertions, 532 deletions
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/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/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/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/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/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/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 e1a9477dcd63..063ed381e01a 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/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 18483f9e327c..b5efdc585848 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/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix
index d9e884dabbe0..5577004465ee 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, nose, blas, hostPlatform }:
+{ stdenv, lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, nose, 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/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/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/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/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 {