summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/tests/chromium.nix19
-rw-r--r--pkgs/applications/blockchains/polkadot/default.nix13
-rw-r--r--pkgs/applications/misc/syncthingtray/default.nix1
-rw-r--r--pkgs/applications/networking/browsers/chromium/common.nix2
-rw-r--r--pkgs/applications/networking/gmailctl/default.nix2
-rw-r--r--pkgs/applications/networking/mailreaders/mailnag/goa-plugin.nix2
-rw-r--r--pkgs/development/compilers/4th/default.nix4
-rw-r--r--pkgs/development/compilers/abcl/default.nix8
-rw-r--r--pkgs/development/compilers/acme/default.nix4
-rw-r--r--pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix6
-rw-r--r--pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix2
-rw-r--r--pkgs/development/compilers/adoptopenjdk-icedtea-web/default.nix4
-rw-r--r--pkgs/development/compilers/aldor/default.nix6
-rw-r--r--pkgs/development/compilers/aliceml/default.nix6
-rw-r--r--pkgs/development/compilers/apache-flex-sdk/default.nix4
-rw-r--r--pkgs/development/compilers/arachne-pnr/default.nix8
-rw-r--r--pkgs/development/compilers/asn1c/default.nix4
-rw-r--r--pkgs/development/compilers/aspectj/default.nix6
-rw-r--r--pkgs/development/compilers/ats/default.nix8
-rw-r--r--pkgs/development/compilers/ats2/default.nix10
-rw-r--r--pkgs/development/compilers/avian/default.nix10
-rw-r--r--pkgs/development/compilers/avra/default.nix4
-rw-r--r--pkgs/development/compilers/bigloo/default.nix12
-rw-r--r--pkgs/development/compilers/binaryen/default.nix4
-rw-r--r--pkgs/development/compilers/bluespec/default.nix6
-rw-r--r--pkgs/development/compilers/bs-platform/build-bs-platform.nix4
-rw-r--r--pkgs/development/compilers/bs-platform/default.nix6
-rw-r--r--pkgs/development/compilers/bs-platform/ocaml.nix4
-rw-r--r--pkgs/development/compilers/bupc/default.nix4
-rw-r--r--pkgs/development/compilers/cakelisp/default.nix6
-rw-r--r--pkgs/development/compilers/carp/default.nix8
-rw-r--r--pkgs/development/compilers/cc65/default.nix4
-rw-r--r--pkgs/development/compilers/ccl/default.nix4
-rw-r--r--pkgs/development/compilers/chez/default.nix12
-rw-r--r--pkgs/development/compilers/chicken/4/chicken.nix9
-rw-r--r--pkgs/development/compilers/chicken/4/egg2nix.nix6
-rw-r--r--pkgs/development/compilers/chicken/4/eggDerivation.nix8
-rw-r--r--pkgs/development/compilers/chicken/5/chicken.nix9
-rw-r--r--pkgs/development/compilers/chicken/5/egg2nix.nix8
-rw-r--r--pkgs/development/compilers/chicken/5/eggDerivation.nix8
-rw-r--r--pkgs/development/compilers/ciao/default.nix4
-rw-r--r--pkgs/development/compilers/clasp/default.nix12
-rw-r--r--pkgs/development/compilers/clean/default.nix6
-rw-r--r--pkgs/development/compilers/closure/default.nix4
-rw-r--r--pkgs/development/compilers/cmdstan/default.nix6
-rw-r--r--pkgs/development/compilers/cmucl/binary.nix8
-rw-r--r--pkgs/development/compilers/colm/default.nix4
-rw-r--r--pkgs/development/compilers/compcert/default.nix6
-rw-r--r--pkgs/development/compilers/computecpp/default.nix4
-rw-r--r--pkgs/development/compilers/copper/default.nix4
-rw-r--r--pkgs/development/compilers/coreclr/default.nix4
-rw-r--r--pkgs/development/compilers/crystal/default.nix2
-rw-r--r--pkgs/development/compilers/cudatoolkit/common.nix4
-rw-r--r--pkgs/development/compilers/dale/default.nix4
-rw-r--r--pkgs/development/compilers/dasm/default.nix4
-rw-r--r--pkgs/development/compilers/dev86/default.nix4
-rw-r--r--pkgs/development/compilers/dmd/default.nix10
-rw-r--r--pkgs/development/compilers/dotnet/build-dotnet.nix8
-rw-r--r--pkgs/development/compilers/ecl/16.1.2.nix12
-rw-r--r--pkgs/development/compilers/ecl/default.nix12
-rw-r--r--pkgs/development/compilers/eli/default.nix8
-rw-r--r--pkgs/development/compilers/elm/default.nix14
-rw-r--r--pkgs/development/compilers/elm/packages/elm-format.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/elm-instrument.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/elm.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/elmi-to-json.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/indents.nix4
-rw-r--r--pkgs/development/compilers/emscripten/default.nix4
-rw-r--r--pkgs/development/compilers/eql/default.nix4
-rw-r--r--pkgs/development/compilers/factor-lang/default.nix8
-rw-r--r--pkgs/development/compilers/fasmg/default.nix4
-rw-r--r--pkgs/development/compilers/flasm/default.nix4
-rw-r--r--pkgs/development/compilers/flutter/flutter.nix4
-rw-r--r--pkgs/development/compilers/fpc/default.nix4
-rw-r--r--pkgs/development/compilers/fpc/lazarus.nix2
-rw-r--r--pkgs/development/compilers/fsharp/default.nix8
-rw-r--r--pkgs/development/compilers/fsharp41/default.nix8
-rw-r--r--pkgs/development/compilers/fstar/default.nix4
-rw-r--r--pkgs/development/compilers/gavrasm/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-arm-embedded/10/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-arm-embedded/6/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-arm-embedded/7/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-arm-embedded/8/default.nix6
-rw-r--r--pkgs/development/compilers/gcc-arm-embedded/9/default.nix6
-rw-r--r--pkgs/development/compilers/gcc/10/default.nix31
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix21
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix21
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix27
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix33
-rw-r--r--pkgs/development/compilers/gcc/8/default.nix31
-rw-r--r--pkgs/development/compilers/gcc/9/default.nix31
-rw-r--r--pkgs/development/compilers/gcc/common/configure-flags.nix8
-rw-r--r--pkgs/development/compilers/gcc/common/extra-target-flags.nix2
-rw-r--r--pkgs/development/compilers/gcl/2.6.13-pre.nix6
-rw-r--r--pkgs/development/compilers/gcl/default.nix4
-rw-r--r--pkgs/development/compilers/gforth/default.nix8
-rw-r--r--pkgs/development/compilers/ghc/8.10.1.nix66
-rw-r--r--pkgs/development/compilers/ghc/8.10.2-binary.nix46
-rw-r--r--pkgs/development/compilers/ghc/8.10.2.nix66
-rw-r--r--pkgs/development/compilers/ghc/8.10.3.nix66
-rw-r--r--pkgs/development/compilers/ghc/8.2.2-binary.nix36
-rw-r--r--pkgs/development/compilers/ghc/8.6.5-binary.nix38
-rw-r--r--pkgs/development/compilers/ghc/8.6.5.nix64
-rw-r--r--pkgs/development/compilers/ghc/8.8.2.nix64
-rw-r--r--pkgs/development/compilers/ghc/8.8.3.nix66
-rw-r--r--pkgs/development/compilers/ghc/8.8.4.nix68
-rw-r--r--pkgs/development/compilers/ghc/9.0.1.nix66
-rw-r--r--pkgs/development/compilers/ghc/head.nix74
-rw-r--r--pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix14
-rw-r--r--pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix2
-rw-r--r--pkgs/development/compilers/gleam/default.nix6
-rw-r--r--pkgs/development/compilers/glslang/default.nix4
-rw-r--r--pkgs/development/compilers/gnatboot/default.nix4
-rw-r--r--pkgs/development/compilers/gnu-cobol/default.nix11
-rw-r--r--pkgs/development/compilers/gnu-smalltalk/default.nix12
-rw-r--r--pkgs/development/compilers/go/1.14.nix8
-rw-r--r--pkgs/development/compilers/go/1.15.nix8
-rw-r--r--pkgs/development/compilers/go/1.4.nix4
-rw-r--r--pkgs/development/compilers/go/2-dev.nix8
-rw-r--r--pkgs/development/compilers/gprolog/default.nix10
-rw-r--r--pkgs/development/compilers/graalvm/community-edition.nix8
-rw-r--r--pkgs/development/compilers/graalvm/default.nix4
-rw-r--r--pkgs/development/compilers/graalvm/enterprise-edition.nix8
-rw-r--r--pkgs/development/compilers/gwt/2.4.0.nix6
-rw-r--r--pkgs/development/compilers/haxe/default.nix4
-rw-r--r--pkgs/development/compilers/hhvm/default.nix4
-rw-r--r--pkgs/development/compilers/hop/default.nix6
-rw-r--r--pkgs/development/compilers/iasl/default.nix6
-rw-r--r--pkgs/development/compilers/idris2/default.nix8
-rw-r--r--pkgs/development/compilers/inform6/default.nix6
-rw-r--r--pkgs/development/compilers/inform7/default.nix4
-rw-r--r--pkgs/development/compilers/intel-graphics-compiler/default.nix6
-rw-r--r--pkgs/development/compilers/intercal/default.nix4
-rw-r--r--pkgs/development/compilers/ios-cross-compile/9.2.nix8
-rw-r--r--pkgs/development/compilers/ispc/default.nix4
-rw-r--r--pkgs/development/compilers/jasmin/default.nix4
-rw-r--r--pkgs/development/compilers/javacard-devkit/default.nix6
-rw-r--r--pkgs/development/compilers/jetbrains-jdk/default.nix6
-rw-r--r--pkgs/development/compilers/julia/1.0.nix12
-rw-r--r--pkgs/development/compilers/julia/1.3.nix10
-rw-r--r--pkgs/development/compilers/julia/1.5.nix10
-rw-r--r--pkgs/development/compilers/jwasm/default.nix4
-rw-r--r--pkgs/development/compilers/kotlin/default.nix8
-rw-r--r--pkgs/development/compilers/ldc/generic.nix18
-rw-r--r--pkgs/development/compilers/llvm/10/clang/default.nix18
-rw-r--r--pkgs/development/compilers/llvm/10/compiler-rt.nix28
-rw-r--r--pkgs/development/compilers/llvm/10/default.nix22
-rw-r--r--pkgs/development/compilers/llvm/10/libc++/default.nix18
-rw-r--r--pkgs/development/compilers/llvm/10/libc++abi.nix24
-rw-r--r--pkgs/development/compilers/llvm/10/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/10/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/10/lldb.nix16
-rw-r--r--pkgs/development/compilers/llvm/10/llvm.nix14
-rw-r--r--pkgs/development/compilers/llvm/10/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/11/clang/default.nix18
-rw-r--r--pkgs/development/compilers/llvm/11/compiler-rt.nix28
-rw-r--r--pkgs/development/compilers/llvm/11/default.nix24
-rw-r--r--pkgs/development/compilers/llvm/11/libc++/default.nix14
-rw-r--r--pkgs/development/compilers/llvm/11/libc++abi.nix24
-rw-r--r--pkgs/development/compilers/llvm/11/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/11/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/11/lldb.nix16
-rw-r--r--pkgs/development/compilers/llvm/11/llvm.nix14
-rw-r--r--pkgs/development/compilers/llvm/11/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/5/clang/default.nix16
-rw-r--r--pkgs/development/compilers/llvm/5/compiler-rt.nix28
-rw-r--r--pkgs/development/compilers/llvm/5/default.nix8
-rw-r--r--pkgs/development/compilers/llvm/5/libc++/default.nix12
-rw-r--r--pkgs/development/compilers/llvm/5/libc++abi.nix14
-rw-r--r--pkgs/development/compilers/llvm/5/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/5/lldb.nix6
-rw-r--r--pkgs/development/compilers/llvm/5/llvm.nix38
-rw-r--r--pkgs/development/compilers/llvm/5/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/6/clang/default.nix16
-rw-r--r--pkgs/development/compilers/llvm/6/compiler-rt.nix28
-rw-r--r--pkgs/development/compilers/llvm/6/default.nix8
-rw-r--r--pkgs/development/compilers/llvm/6/libc++/default.nix12
-rw-r--r--pkgs/development/compilers/llvm/6/libc++abi.nix14
-rw-r--r--pkgs/development/compilers/llvm/6/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/6/lldb.nix6
-rw-r--r--pkgs/development/compilers/llvm/6/llvm.nix16
-rw-r--r--pkgs/development/compilers/llvm/6/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/7/clang/default.nix20
-rw-r--r--pkgs/development/compilers/llvm/7/compiler-rt.nix30
-rw-r--r--pkgs/development/compilers/llvm/7/default.nix16
-rw-r--r--pkgs/development/compilers/llvm/7/libc++/default.nix14
-rw-r--r--pkgs/development/compilers/llvm/7/libc++abi.nix22
-rw-r--r--pkgs/development/compilers/llvm/7/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/7/lldb.nix8
-rw-r--r--pkgs/development/compilers/llvm/7/llvm.nix16
-rw-r--r--pkgs/development/compilers/llvm/7/openmp.nix6
-rw-r--r--pkgs/development/compilers/llvm/8/clang/default.nix20
-rw-r--r--pkgs/development/compilers/llvm/8/compiler-rt.nix30
-rw-r--r--pkgs/development/compilers/llvm/8/default.nix22
-rw-r--r--pkgs/development/compilers/llvm/8/libc++/default.nix18
-rw-r--r--pkgs/development/compilers/llvm/8/libc++abi.nix24
-rw-r--r--pkgs/development/compilers/llvm/8/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/8/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/8/lldb.nix6
-rw-r--r--pkgs/development/compilers/llvm/8/llvm.nix14
-rw-r--r--pkgs/development/compilers/llvm/8/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/clang/default.nix20
-rw-r--r--pkgs/development/compilers/llvm/9/compiler-rt.nix28
-rw-r--r--pkgs/development/compilers/llvm/9/default.nix22
-rw-r--r--pkgs/development/compilers/llvm/9/libc++/default.nix18
-rw-r--r--pkgs/development/compilers/llvm/9/libc++abi.nix24
-rw-r--r--pkgs/development/compilers/llvm/9/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/lld.nix6
-rw-r--r--pkgs/development/compilers/llvm/9/lldb.nix6
-rw-r--r--pkgs/development/compilers/llvm/9/llvm.nix14
-rw-r--r--pkgs/development/compilers/llvm/9/openmp.nix4
-rw-r--r--pkgs/development/compilers/llvm/rocm/clang.nix6
-rw-r--r--pkgs/development/compilers/llvm/rocm/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/rocm/lld.nix4
-rw-r--r--pkgs/development/compilers/llvm/rocm/llvm.nix12
-rw-r--r--pkgs/development/compilers/lobster/default.nix4
-rw-r--r--pkgs/development/compilers/mcpp/default.nix4
-rw-r--r--pkgs/development/compilers/mercury/default.nix6
-rw-r--r--pkgs/development/compilers/meta-environment/meta-build-env/default.nix4
-rw-r--r--pkgs/development/compilers/mezzo/default.nix10
-rw-r--r--pkgs/development/compilers/microscheme/default.nix4
-rw-r--r--pkgs/development/compilers/miranda/default.nix2
-rw-r--r--pkgs/development/compilers/mit-scheme/default.nix4
-rw-r--r--pkgs/development/compilers/mkcl/default.nix4
-rw-r--r--pkgs/development/compilers/mlkit/default.nix4
-rw-r--r--pkgs/development/compilers/mlton/20130715.nix12
-rw-r--r--pkgs/development/compilers/mlton/20180207-binary.nix8
-rw-r--r--pkgs/development/compilers/mono/generic.nix10
-rw-r--r--pkgs/development/compilers/mono/llvm.nix8
-rw-r--r--pkgs/development/compilers/mosml/default.nix6
-rw-r--r--pkgs/development/compilers/mozart/binary.nix10
-rw-r--r--pkgs/development/compilers/mruby/default.nix4
-rw-r--r--pkgs/development/compilers/nasm/default.nix4
-rw-r--r--pkgs/development/compilers/neko/default.nix8
-rw-r--r--pkgs/development/compilers/obliv-c/default.nix8
-rw-r--r--pkgs/development/compilers/ocaml/3.08.0.nix2
-rw-r--r--pkgs/development/compilers/ocaml/3.10.0.nix4
-rw-r--r--pkgs/development/compilers/ocaml/3.11.2.nix4
-rw-r--r--pkgs/development/compilers/ocaml/3.12.1.nix4
-rw-r--r--pkgs/development/compilers/ocaml/4.00.1.nix6
-rw-r--r--pkgs/development/compilers/ocaml/ber-metaocaml.nix6
-rw-r--r--pkgs/development/compilers/ocaml/generic.nix22
-rw-r--r--pkgs/development/compilers/ocaml/metaocaml-3.09.nix4
-rw-r--r--pkgs/development/compilers/opa/default.nix12
-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/11.nix2
-rw-r--r--pkgs/development/compilers/openjdk/12.nix2
-rw-r--r--pkgs/development/compilers/openjdk/13.nix2
-rw-r--r--pkgs/development/compilers/openjdk/14.nix2
-rw-r--r--pkgs/development/compilers/openjdk/darwin/11.nix4
-rw-r--r--pkgs/development/compilers/openjdk/darwin/8.nix4
-rw-r--r--pkgs/development/compilers/openjdk/darwin/default.nix4
-rw-r--r--pkgs/development/compilers/openjdk/default.nix2
-rw-r--r--pkgs/development/compilers/openjdk/openjfx/11.nix2
-rw-r--r--pkgs/development/compilers/openjdk/openjfx/15.nix2
-rw-r--r--pkgs/development/compilers/openspin/default.nix4
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk-linux-base.nix10
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk11-linux.nix6
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk14-linux.nix6
-rw-r--r--pkgs/development/compilers/orc/default.nix6
-rw-r--r--pkgs/development/compilers/osl/default.nix4
-rw-r--r--pkgs/development/compilers/owl-lisp/default.nix4
-rw-r--r--pkgs/development/compilers/pakcs/curry-base.nix4
-rw-r--r--pkgs/development/compilers/pakcs/curry-frontend.nix4
-rw-r--r--pkgs/development/compilers/pakcs/default.nix6
-rw-r--r--pkgs/development/compilers/pforth/default.nix8
-rw-r--r--pkgs/development/compilers/picat/default.nix4
-rw-r--r--pkgs/development/compilers/polyml/5.6.nix12
-rw-r--r--pkgs/development/compilers/polyml/5.7.nix8
-rw-r--r--pkgs/development/compilers/polyml/default.nix8
-rw-r--r--pkgs/development/compilers/ponyc/default.nix14
-rw-r--r--pkgs/development/compilers/ponyc/pony-corral.nix4
-rw-r--r--pkgs/development/compilers/ponyc/pony-stable.nix8
-rw-r--r--pkgs/development/compilers/purescript/purescript/default.nix2
-rw-r--r--pkgs/development/compilers/qbe/default.nix4
-rw-r--r--pkgs/development/compilers/rasm/default.nix4
-rw-r--r--pkgs/development/compilers/reason/default.nix4
-rw-r--r--pkgs/development/compilers/rgbds/default.nix4
-rw-r--r--pkgs/development/compilers/rust/binary.nix14
-rw-r--r--pkgs/development/compilers/rust/cargo.nix6
-rw-r--r--pkgs/development/compilers/rust/clippy.nix6
-rw-r--r--pkgs/development/compilers/rust/rls/default.nix6
-rw-r--r--pkgs/development/compilers/rust/rustc.nix8
-rw-r--r--pkgs/development/compilers/rust/rustfmt.nix6
-rw-r--r--pkgs/development/compilers/sagittarius-scheme/default.nix6
-rw-r--r--pkgs/development/compilers/sbcl/2.0.9.nix12
-rw-r--r--pkgs/development/compilers/sbcl/bootstrap.nix6
-rw-r--r--pkgs/development/compilers/sbcl/default.nix12
-rw-r--r--pkgs/development/compilers/scala/2.x.nix2
-rw-r--r--pkgs/development/compilers/scala/dotty-bare.nix4
-rw-r--r--pkgs/development/compilers/sdcc/default.nix4
-rw-r--r--pkgs/development/compilers/seexpr/default.nix4
-rw-r--r--pkgs/development/compilers/serpent/default.nix4
-rw-r--r--pkgs/development/compilers/shaderc/default.nix4
-rw-r--r--pkgs/development/compilers/smlnj/bootstrap.nix8
-rw-r--r--pkgs/development/compilers/smlnj/default.nix4
-rw-r--r--pkgs/development/compilers/solc/default.nix19
-rw-r--r--pkgs/development/compilers/souffle/default.nix6
-rw-r--r--pkgs/development/compilers/spasm-ng/default.nix4
-rw-r--r--pkgs/development/compilers/spirv-llvm-translator/default.nix4
-rw-r--r--pkgs/development/compilers/squeak/default.nix6
-rw-r--r--pkgs/development/compilers/stalin/default.nix4
-rw-r--r--pkgs/development/compilers/swi-prolog/default.nix12
-rw-r--r--pkgs/development/compilers/swift/default.nix8
-rw-r--r--pkgs/development/compilers/terra/default.nix10
-rw-r--r--pkgs/development/compilers/teyjus/default.nix6
-rw-r--r--pkgs/development/compilers/tvm/default.nix4
-rw-r--r--pkgs/development/compilers/unison/default.nix10
-rw-r--r--pkgs/development/compilers/urn/default.nix6
-rw-r--r--pkgs/development/compilers/urweb/default.nix8
-rw-r--r--pkgs/development/compilers/vala/default.nix2
-rw-r--r--pkgs/development/compilers/vlang/default.nix6
-rw-r--r--pkgs/development/compilers/vyper/default.nix2
-rw-r--r--pkgs/development/compilers/wcc/default.nix4
-rw-r--r--pkgs/development/compilers/wla-dx/default.nix4
-rw-r--r--pkgs/development/compilers/x11basic/default.nix4
-rw-r--r--pkgs/development/compilers/yap/default.nix8
-rw-r--r--pkgs/development/compilers/yasm/default.nix4
-rw-r--r--pkgs/development/compilers/z88dk/default.nix4
-rw-r--r--pkgs/development/compilers/zasm/default.nix4
-rw-r--r--pkgs/development/compilers/zig/default.nix4
-rw-r--r--pkgs/development/compilers/zulu/8.nix4
-rw-r--r--pkgs/development/compilers/zulu/default.nix4
-rw-r--r--pkgs/development/interpreters/octave/default.nix45
-rw-r--r--pkgs/development/libraries/comedilib/default.nix3
-rw-r--r--pkgs/development/libraries/cpp-utilities/default.nix3
-rw-r--r--pkgs/development/libraries/liberio/default.nix3
-rw-r--r--pkgs/development/libraries/libvirt/default.nix31
-rw-r--r--pkgs/development/libraries/nsss/default.nix4
-rw-r--r--pkgs/development/libraries/phonetisaurus/default.nix4
-rw-r--r--pkgs/development/libraries/qrupdate/default.nix3
-rw-r--r--pkgs/development/libraries/qtutilities/default.nix10
-rw-r--r--pkgs/development/libraries/skalibs/default.nix4
-rw-r--r--pkgs/development/libraries/sqlite/default.nix8
-rw-r--r--pkgs/development/libraries/tweeny/default.nix3
-rw-r--r--pkgs/development/libraries/utmps/default.nix4
-rw-r--r--pkgs/development/mobile/abootimg/default.nix4
-rw-r--r--pkgs/development/mobile/adb-sync/default.nix2
-rw-r--r--pkgs/development/mobile/flashtool/default.nix10
-rw-r--r--pkgs/development/mobile/genymotion/default.nix10
-rw-r--r--pkgs/development/mobile/titaniumenv/build-app.nix14
-rw-r--r--pkgs/development/mobile/titaniumenv/default.nix4
-rw-r--r--pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix4
-rw-r--r--pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix4
-rw-r--r--pkgs/development/mobile/xcodeenv/build-app.nix20
-rw-r--r--pkgs/development/mobile/xcodeenv/default.nix6
-rw-r--r--pkgs/development/mobile/xcodeenv/simulate-app.nix6
-rw-r--r--pkgs/development/tools/misc/sccache/default.nix16
-rw-r--r--pkgs/os-specific/linux/s6-linux-init/default.nix39
-rw-r--r--pkgs/os-specific/linux/s6-linux-utils/default.nix4
-rw-r--r--pkgs/os-specific/linux/sdnotify-wrapper/sdnotify-wrapper.c22
-rw-r--r--pkgs/servers/gotify/default.nix3
-rw-r--r--pkgs/tools/audio/bpm-tools/default.nix18
-rw-r--r--pkgs/tools/misc/execline/default.nix4
-rw-r--r--pkgs/tools/misc/execline/execlineb-wrapper.c5
-rw-r--r--pkgs/tools/misc/fdtools/default.nix1
-rw-r--r--pkgs/tools/misc/fdtools/new-skalibs.patch223
-rw-r--r--pkgs/tools/misc/grub/2.0x.nix2
-rw-r--r--pkgs/tools/misc/s6-portable-utils/default.nix4
-rw-r--r--pkgs/tools/networking/s6-dns/default.nix4
-rw-r--r--pkgs/tools/networking/s6-networking/default.nix6
-rw-r--r--pkgs/tools/system/s6-rc/default.nix4
-rw-r--r--pkgs/tools/system/s6/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix3
365 files changed, 2120 insertions, 1803 deletions
diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix
index 4d6b726d9e4..43a99fda5c5 100644
--- a/nixos/tests/chromium.nix
+++ b/nixos/tests/chromium.nix
@@ -77,7 +77,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
 
     def create_new_win():
         with machine.nested("Creating a new Chromium window"):
-            machine.execute(
+            status, _ = machine.execute(
                 ru(
                     "${xdo "new-window" ''
                       search --onlyvisible --name "startup done"
@@ -86,13 +86,14 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
                     ''}"
                 )
             )
-            machine.execute(
-                ru(
-                    "${xdo "new-window" ''
-                      key Ctrl+n
-                    ''}"
+            if status == 0:
+                machine.execute(
+                    ru(
+                        "${xdo "new-window" ''
+                          key Ctrl+n
+                        ''}"
+                    )
                 )
-            )
 
 
     def close_win():
@@ -115,7 +116,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
                     )
                 )
             for _ in range(1, 20):
-                status, out = machine.execute(
+                status, _ = machine.execute(
                     ru(
                         "${xdo "wait-for-close" ''
                           search --onlyvisible --name "new tab"
@@ -134,7 +135,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
         ret = False
         with machine.nested("Waiting for new Chromium window to appear"):
             for _ in range(1, 20):
-                status, out = machine.execute(
+                status, _ = machine.execute(
                     ru(
                         "${xdo "wait-for-window" ''
                           search --onlyvisible --name "new tab"
diff --git a/pkgs/applications/blockchains/polkadot/default.nix b/pkgs/applications/blockchains/polkadot/default.nix
index 866adeea278..84bb42fabf8 100644
--- a/pkgs/applications/blockchains/polkadot/default.nix
+++ b/pkgs/applications/blockchains/polkadot/default.nix
@@ -7,16 +7,16 @@
 }:
 rustPlatform.buildRustPackage rec {
   pname = "polkadot";
-  version = "0.8.26-1";
+  version = "0.8.27";
 
   src = fetchFromGitHub {
     owner = "paritytech";
     repo = "polkadot";
     rev = "v${version}";
-    sha256 = "17ji1gjrx3gzw4msaz9kgvm132y14wgh8z183l3mfw1cj44a6kqk";
+    sha256 = "1zkqmsclhnv14s4mxz7h49kfx8wyi3lyi0dik6jn1fh6w8zr962c";
   };
 
-  cargoSha256 = "07zwlwx02xw1y20br2c4grwv7bprhynqy7gav4qh3vw117ijpiqk";
+  cargoSha256 = "1j0pr09y5pc43a4rz1zq3h9vmd874zz6z0wd279lpm6p2m0077cs";
 
   nativeBuildInputs = [ clang ];
 
@@ -24,9 +24,10 @@ rustPlatform.buildRustPackage rec {
   PROTOC = "${protobuf}/bin/protoc";
 
   # NOTE: We don't build the WASM runtimes since this would require a more
-  # complicated rust environment setup. The resulting binary is still useful for
-  # live networks since those just use the WASM blob from the network chainspec.
-  BUILD_DUMMY_WASM_BINARY = 1;
+  # complicated rust environment setup and this is only needed for developer
+  # environments. The resulting binary is useful for end-users of live networks
+  # since those just use the WASM blob from the network chainspec.
+  SKIP_WASM_BUILD = 1;
 
   # We can't run the test suite since we didn't compile the WASM runtimes.
   doCheck = false;
diff --git a/pkgs/applications/misc/syncthingtray/default.nix b/pkgs/applications/misc/syncthingtray/default.nix
index bbe629ecb14..f5c5faf4d96 100644
--- a/pkgs/applications/misc/syncthingtray/default.nix
+++ b/pkgs/applications/misc/syncthingtray/default.nix
@@ -1,5 +1,4 @@
 { mkDerivation
-, stdenv
 , lib
 , fetchFromGitHub
 , qtbase
diff --git a/pkgs/applications/networking/browsers/chromium/common.nix b/pkgs/applications/networking/browsers/chromium/common.nix
index 7442d600085..2b7cdb9b4b7 100644
--- a/pkgs/applications/networking/browsers/chromium/common.nix
+++ b/pkgs/applications/networking/browsers/chromium/common.nix
@@ -117,7 +117,7 @@ let
   base = rec {
     name = "${packageName}-unwrapped-${version}";
     inherit (upstream-info) version;
-    inherit channel packageName buildType buildPath;
+    inherit packageName buildType buildPath;
 
     src = fetchurl {
       url = "https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${version}.tar.xz";
diff --git a/pkgs/applications/networking/gmailctl/default.nix b/pkgs/applications/networking/gmailctl/default.nix
index 1dfd1f62fb0..0042e5417df 100644
--- a/pkgs/applications/networking/gmailctl/default.nix
+++ b/pkgs/applications/networking/gmailctl/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv
+{ lib
 , buildGoModule
 , fetchFromGitHub
 }:
diff --git a/pkgs/applications/networking/mailreaders/mailnag/goa-plugin.nix b/pkgs/applications/networking/mailreaders/mailnag/goa-plugin.nix
index 4f60135cca1..1def97bd62d 100644
--- a/pkgs/applications/networking/mailreaders/mailnag/goa-plugin.nix
+++ b/pkgs/applications/networking/mailreaders/mailnag/goa-plugin.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv
+{ lib
 , fetchFromGitHub
 , python3Packages
 , gobject-introspection
diff --git a/pkgs/development/compilers/4th/default.nix b/pkgs/development/compilers/4th/default.nix
index ee3050b8ba6..7205a979e27 100644
--- a/pkgs/development/compilers/4th/default.nix
+++ b/pkgs/development/compilers/4th/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   pname = "4th";
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
     "MANDIR=${placeholder "out"}/share/man"
   ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A portable Forth compiler";
     homepage = "https://thebeez.home.xs4all.nl/4tH/index.html";
     license = licenses.lgpl3;
diff --git a/pkgs/development/compilers/abcl/default.nix b/pkgs/development/compilers/abcl/default.nix
index aa537169aaf..fff88eddd19 100644
--- a/pkgs/development/compilers/abcl/default.nix
+++ b/pkgs/development/compilers/abcl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ant, jre, jdk}:
+{lib, stdenv, fetchurl, ant, jre, jdk}:
 stdenv.mkDerivation rec {
   pname = "abcl";
   version = "1.8.0";
@@ -31,9 +31,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "A JVM-based Common Lisp implementation";
-    license = stdenv.lib.licenses.gpl3 ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3 ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     homepage = "https://common-lisp.net/project/armedbear/";
   };
 }
diff --git a/pkgs/development/compilers/acme/default.nix b/pkgs/development/compilers/acme/default.nix
index f2f2c9cf8aa..f8731f55471 100644
--- a/pkgs/development/compilers/acme/default.nix
+++ b/pkgs/development/compilers/acme/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchsvn }:
+{ lib, stdenv, fetchsvn }:
 
 stdenv.mkDerivation rec {
   pname = "acme";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
       --replace "= gcc" "?= gcc"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A multi-platform cross assembler for 6502/6510/65816 CPUs";
     homepage = "https://sourceforge.net/projects/acme-crossass/";
     license = licenses.gpl2Plus;
diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix
index 5e402b2d728..31a7346108e 100644
--- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix
+++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix
@@ -1,7 +1,7 @@
 sourcePerArch:
 
 { swingSupport ? true # not used for now
-, stdenv
+, lib, stdenv
 , fetchurl
 }:
 
@@ -43,11 +43,11 @@ let cpuName = stdenv.hostPlatform.parsed.cpu.name;
 
   passthru.home = result;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     license = licenses.gpl2Classpath;
     description = "AdoptOpenJDK, prebuilt OpenJDK binary";
     platforms = [ "x86_64-darwin" ]; # some inherit jre.meta.platforms
-    maintainers = with stdenv.lib.maintainers; [ taku0 ];
+    maintainers = with lib.maintainers; [ taku0 ];
   };
 
 }; in result
diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix
index 00945e32535..0fcad6c333f 100644
--- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix
+++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix
@@ -69,7 +69,7 @@ let result = stdenv.mkDerivation rec {
 
   passthru.home = result;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     license = licenses.gpl2Classpath;
     description = "AdoptOpenJDK, prebuilt OpenJDK binary";
     platforms = lib.mapAttrsToList (arch: _: arch + "-linux") sourcePerArch; # some inherit jre.meta.platforms
diff --git a/pkgs/development/compilers/adoptopenjdk-icedtea-web/default.nix b/pkgs/development/compilers/adoptopenjdk-icedtea-web/default.nix
index 670f7f94193..e20983380a4 100644
--- a/pkgs/development/compilers/adoptopenjdk-icedtea-web/default.nix
+++ b/pkgs/development/compilers/adoptopenjdk-icedtea-web/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cargo, rustc, autoreconfHook, jdk, glib, xulrunner, zip, pkg-config, npapi_sdk, bash, bc }:
+{ lib, stdenv, fetchFromGitHub, cargo, rustc, autoreconfHook, jdk, glib, xulrunner, zip, pkg-config, npapi_sdk, bash, bc }:
 
 stdenv.mkDerivation rec {
   pname = "adoptopenjdk-icedtea-web";
@@ -58,6 +58,6 @@ stdenv.mkDerivation rec {
       based on the NetX project.
     '';
     homepage = "https://github.com/adoptopenjdk/icedtea-web";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/aldor/default.nix b/pkgs/development/compilers/aldor/default.nix
index 09ccf9510bb..2654cc467fe 100644
--- a/pkgs/development/compilers/aldor/default.nix
+++ b/pkgs/development/compilers/aldor/default.nix
@@ -1,4 +1,4 @@
-{ fetchgit, stdenv, gmp, which, flex, bison, makeWrapper
+{ fetchgit, lib, stdenv, gmp, which, flex, bison, makeWrapper
 , autoconf, automake, libtool, jdk, perl }:
 
 stdenv.mkDerivation {
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
     broken = true;
     homepage = "http://www.aldor.org/";
     description = "Programming language with an expressive type system";
-    license = stdenv.lib.licenses.asl20;
+    license = lib.licenses.asl20;
 
     longDescription = ''
       Aldor is a programming language with an expressive type system well-suited
@@ -47,6 +47,6 @@ stdenv.mkDerivation {
       and powerful properties of functional, object-oriented and aspect-oriented styles.
     '';
 
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/aliceml/default.nix b/pkgs/development/compilers/aliceml/default.nix
index d3208b12dd6..8f560ef6198 100644
--- a/pkgs/development/compilers/aliceml/default.nix
+++ b/pkgs/development/compilers/aliceml/default.nix
@@ -1,4 +1,4 @@
-{stdenv, gcc, glibc, fetchurl, fetchgit, libtool, autoconf, automake, file, gnumake, which, zsh, m4, pkg-config, perl, gnome2, gtk2, pango, sqlite, libxml2, zlib, gmp, smlnj }:
+{lib, stdenv, gcc, glibc, fetchurl, fetchgit, libtool, autoconf, automake, file, gnumake, which, zsh, m4, pkg-config, perl, gnome2, gtk2, pango, sqlite, libxml2, zlib, gmp, smlnj }:
 
 stdenv.mkDerivation {
   name = "aliceml-1.4-7d44dc8e";
@@ -50,8 +50,8 @@ stdenv.mkDerivation {
       programming.
     '';
     homepage = "https://www.ps.uni-saarland.de/alice/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = [ stdenv.lib.maintainers.doublec ];
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.doublec ];
     broken = true;
   };
 }
diff --git a/pkgs/development/compilers/apache-flex-sdk/default.nix b/pkgs/development/compilers/apache-flex-sdk/default.nix
index 337d5a4e26d..800b1ea55e3 100644
--- a/pkgs/development/compilers/apache-flex-sdk/default.nix
+++ b/pkgs/development/compilers/apache-flex-sdk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, jre }:
+{ lib, stdenv, fetchurl, makeWrapper, jre }:
 
 let
   playerglobal_ver = "27.0";
@@ -47,7 +47,7 @@ in stdenv.mkDerivation rec {
 
   fixupPhase = ":";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Flex SDK for Adobe Flash / ActionScript";
     homepage = "https://flex.apache.org/";
     license = with licenses; [ asl20 ];
diff --git a/pkgs/development/compilers/arachne-pnr/default.nix b/pkgs/development/compilers/arachne-pnr/default.nix
index 613f3fa186a..030da03add8 100644
--- a/pkgs/development/compilers/arachne-pnr/default.nix
+++ b/pkgs/development/compilers/arachne-pnr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, icestorm }:
+{ lib, stdenv, fetchFromGitHub, icestorm }:
 
 with builtins;
 
@@ -37,8 +37,8 @@ stdenv.mkDerivation rec {
       the IceStorm [2] icepack command.
     '';
     homepage = "https://github.com/cseed/arachne-pnr";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ shell thoughtpolice ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ shell thoughtpolice ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/asn1c/default.nix b/pkgs/development/compilers/asn1c/default.nix
index 230ed36fff5..a4e822eec6d 100644
--- a/pkgs/development/compilers/asn1c/default.nix
+++ b/pkgs/development/compilers/asn1c/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl }:
+{ lib, stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
   pname = "asn1c";
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://lionet.info/asn1c/compiler.html";
     description = "Open Source ASN.1 Compiler";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/aspectj/default.nix b/pkgs/development/compilers/aspectj/default.nix
index 8fd47e937c8..24ff50f558c 100644
--- a/pkgs/development/compilers/aspectj/default.nix
+++ b/pkgs/development/compilers/aspectj/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, jre}:
+{lib, stdenv, fetchurl, jre}:
 
 stdenv.mkDerivation rec {
   pname = "aspectj";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://www.eclipse.org/aspectj/";
     description = "A seamless aspect-oriented extension to the Java programming language";
-    platforms = stdenv.lib.platforms.unix;
-    license = stdenv.lib.licenses.epl10;
+    platforms = lib.platforms.unix;
+    license = lib.licenses.epl10;
   };
 }
diff --git a/pkgs/development/compilers/ats/default.nix b/pkgs/development/compilers/ats/default.nix
index f086c36468d..35e1b1dd105 100644
--- a/pkgs/development/compilers/ats/default.nix
+++ b/pkgs/development/compilers/ats/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gmp }:
+{ lib, stdenv, fetchurl, gmp }:
 
 stdenv.mkDerivation rec {
   pname = "ats";
@@ -16,10 +16,10 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Functional programming language with dependent types";
     homepage    = "http://www.ats-lang.org";
-    license     = stdenv.lib.licenses.gpl3Plus;
+    license     = lib.licenses.gpl3Plus;
     # TODO: it looks like ATS requires gcc specifically. Someone with more knowledge
     # will need to experiment.
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    platforms   = lib.platforms.linux;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/development/compilers/ats2/default.nix b/pkgs/development/compilers/ats2/default.nix
index bbfbcdbbeb0..c75600b5341 100644
--- a/pkgs/development/compilers/ats2/default.nix
+++ b/pkgs/development/compilers/ats2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gmp
+{ lib, stdenv, fetchurl, gmp
 , withEmacsSupport ? true
 , withContrib ? true }:
 
@@ -10,14 +10,14 @@ let
     sha256 = "184m4hz2xszhcfc6w9fw9qibhmcvgjmikwfwkb345xypr59jm93d";
   };
 
-  postInstallContrib = stdenv.lib.optionalString withContrib
+  postInstallContrib = lib.optionalString withContrib
   ''
     local contribDir=$out/lib/ats2-postiats-*/ ;
     mkdir -p $contribDir ;
     tar -xzf "${contrib}" --strip-components 1 -C $contribDir ;
   '';
 
-  postInstallEmacs = stdenv.lib.optionalString withEmacsSupport
+  postInstallEmacs = lib.optionalString withEmacsSupport
   ''
     local siteLispDir=$out/share/emacs/site-lisp/ats2 ;
     mkdir -p $siteLispDir ;
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ gmp ];
 
-  setupHook = with stdenv.lib;
+  setupHook = with lib;
     let
       hookFiles =
         [ ./setup-hook.sh ]
@@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
 
   postInstall = postInstallContrib + postInstallEmacs;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Functional programming language with dependent types";
     homepage    = "http://www.ats-lang.org";
     license     = licenses.gpl3Plus;
diff --git a/pkgs/development/compilers/avian/default.nix b/pkgs/development/compilers/avian/default.nix
index 7c5db45f31b..d39aa2806a4 100644
--- a/pkgs/development/compilers/avian/default.nix
+++ b/pkgs/development/compilers/avian/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, zlib, jdk, CoreServices, Foundation }:
+{ lib, stdenv, fetchFromGitHub, zlib, jdk, CoreServices, Foundation }:
 
 stdenv.mkDerivation rec {
   pname = "avian";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ zlib jdk ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Foundation ];
+    ++ lib.optionals stdenv.isDarwin [ CoreServices Foundation ];
 
   NIX_CFLAGS_COMPILE = "-Wno-error";
 
@@ -36,8 +36,8 @@ stdenv.mkDerivation rec {
       building self-contained applications.
     '';
     homepage = "https://readytalk.github.io/avian/";
-    license = stdenv.lib.licenses.isc;
-    platforms = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.earldouglas ];
+    license = lib.licenses.isc;
+    platforms = lib.platforms.all;
+    maintainers = [ lib.maintainers.earldouglas ];
   };
 }
diff --git a/pkgs/development/compilers/avra/default.nix b/pkgs/development/compilers/avra/default.nix
index 56bf3e657be..9d360780053 100644
--- a/pkgs/development/compilers/avra/default.nix
+++ b/pkgs/development/compilers/avra/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoconf, automake }:
+{ lib, stdenv, fetchurl, autoconf, automake }:
 stdenv.mkDerivation rec {
   name = "avra-1.3.0";
 
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     automake -a
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Assembler for the Atmel AVR microcontroller family";
     homepage = "http://avra.sourceforge.net/";
     license = licenses.gpl2Plus;
diff --git a/pkgs/development/compilers/bigloo/default.nix b/pkgs/development/compilers/bigloo/default.nix
index ced7dd07a22..a4f4287523f 100644
--- a/pkgs/development/compilers/bigloo/default.nix
+++ b/pkgs/development/compilers/bigloo/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, autoconf, automake, libtool, gmp
+{ fetchurl, lib, stdenv, autoconf, automake, libtool, gmp
 , darwin
 }:
 
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoconf automake libtool ];
 
-  buildInputs = stdenv.lib.optional stdenv.isDarwin
+  buildInputs = lib.optional stdenv.isDarwin
     darwin.apple_sdk.frameworks.ApplicationServices
   ;
 
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   preConfigure =
     # For libuv on darwin
-    stdenv.lib.optionalString stdenv.isDarwin ''
+    lib.optionalString stdenv.isDarwin ''
       export LIBTOOLIZE=libtoolize
     '' +
     # Help libgc's configure.
@@ -50,9 +50,9 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Efficient Scheme compiler";
     homepage    = "http://www-sop.inria.fr/indes/fp/Bigloo/";
-    license     = stdenv.lib.licenses.gpl2Plus;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
+    license     = lib.licenses.gpl2Plus;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
 
     longDescription = ''
       Bigloo is a Scheme implementation devoted to one goal: enabling
diff --git a/pkgs/development/compilers/binaryen/default.nix b/pkgs/development/compilers/binaryen/default.nix
index 6de4e0fb304..d2d866a2804 100644
--- a/pkgs/development/compilers/binaryen/default.nix
+++ b/pkgs/development/compilers/binaryen/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, python3, fetchFromGitHub, fetchpatch, emscripten }:
+{ lib, stdenv, cmake, python3, fetchFromGitHub, fetchpatch, emscripten }:
 
 stdenv.mkDerivation rec {
   pname = "binaryen";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake python3 ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://github.com/WebAssembly/binaryen";
     description = "Compiler infrastructure and toolchain library for WebAssembly, in C++";
     platforms = platforms.all;
diff --git a/pkgs/development/compilers/bluespec/default.nix b/pkgs/development/compilers/bluespec/default.nix
index 1e9fd8505c5..defe78d7c31 100644
--- a/pkgs/development/compilers/bluespec/default.nix
+++ b/pkgs/development/compilers/bluespec/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , fetchpatch
 , autoconf
@@ -97,10 +97,10 @@ in stdenv.mkDerivation rec {
   meta = {
     description = "Toolchain for the Bluespec Hardware Definition Language";
     homepage    = "https://github.com/B-Lang-org/bsc";
-    license     = stdenv.lib.licenses.bsd3;
+    license     = lib.licenses.bsd3;
     platforms = [ "x86_64-linux" ];
     # darwin fails at https://github.com/B-Lang-org/bsc/pull/35#issuecomment-583731562
     # aarch64 fails, as GHC fails with "ghc: could not execute: opt"
-    maintainers = with stdenv.lib.maintainers; [ jcumming thoughtpolice ];
+    maintainers = with lib.maintainers; [ jcumming thoughtpolice ];
   };
 }
diff --git a/pkgs/development/compilers/bs-platform/build-bs-platform.nix b/pkgs/development/compilers/bs-platform/build-bs-platform.nix
index 18c61d0d923..c73bb72b9d0 100644
--- a/pkgs/development/compilers/bs-platform/build-bs-platform.nix
+++ b/pkgs/development/compilers/bs-platform/build-bs-platform.nix
@@ -1,12 +1,12 @@
 # This file is based on https://github.com/turboMaCk/bs-platform.nix/blob/master/build-bs-platform.nix
 # to make potential future updates simpler
 
-{ stdenv, fetchFromGitHub, ninja, runCommand, nodejs, python3,
+{ lib, stdenv, fetchFromGitHub, ninja, runCommand, nodejs, python3,
   ocaml-version, version, src,
   patches ? [],
   ocaml ? (import ./ocaml.nix {
     version = ocaml-version;
-    inherit stdenv;
+    inherit lib stdenv;
     src = "${src}/ocaml";
   }),
   custom-ninja ? (ninja.overrideAttrs (attrs: {
diff --git a/pkgs/development/compilers/bs-platform/default.nix b/pkgs/development/compilers/bs-platform/default.nix
index 6eb7d50bfc8..50274c9eca6 100644
--- a/pkgs/development/compilers/bs-platform/default.nix
+++ b/pkgs/development/compilers/bs-platform/default.nix
@@ -1,9 +1,9 @@
-{ stdenv, runCommand, fetchFromGitHub, ninja, nodejs, python3, ... }:
+{ lib, stdenv, runCommand, fetchFromGitHub, ninja, nodejs, python3, ... }:
 let
   build-bs-platform = import ./build-bs-platform.nix;
 in
 (build-bs-platform rec {
-  inherit stdenv runCommand fetchFromGitHub ninja nodejs python3;
+  inherit lib stdenv runCommand fetchFromGitHub ninja nodejs python3;
   version = "8.2.0";
   ocaml-version = "4.06.1";
 
@@ -17,7 +17,7 @@ in
     fetchSubmodules = true;
   };
 }).overrideAttrs (attrs: {
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A JavaScript backend for OCaml focused on smooth integration and clean generated code";
     homepage = "https://bucklescript.github.io";
     license = licenses.lgpl3;
diff --git a/pkgs/development/compilers/bs-platform/ocaml.nix b/pkgs/development/compilers/bs-platform/ocaml.nix
index 9aa34d02b36..d650d767a8d 100644
--- a/pkgs/development/compilers/bs-platform/ocaml.nix
+++ b/pkgs/development/compilers/bs-platform/ocaml.nix
@@ -1,4 +1,4 @@
-{ stdenv, src, version }:
+{ lib, stdenv, src, version }:
 stdenv.mkDerivation rec {
   inherit src version;
   name = "ocaml-${version}+bs";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     make -j9 world.opt
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     branch = "4.06";
     platforms = platforms.all;
   };
diff --git a/pkgs/development/compilers/bupc/default.nix b/pkgs/development/compilers/bupc/default.nix
index ecdfe8d461a..9b3a291a1a0 100644
--- a/pkgs/development/compilers/bupc/default.nix
+++ b/pkgs/development/compilers/bupc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl, coreutils }:
+{ lib, stdenv, fetchurl, perl, coreutils }:
 
 stdenv.mkDerivation rec {
   name = "berkeley_upc-2.22.0";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ coreutils ];
   buildInputs = [ perl ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A compiler for the Berkely Unified Parallel C language";
     longDescription = ''
       Unified Parallel C (UPC) is an extension of the C programming language
diff --git a/pkgs/development/compilers/cakelisp/default.nix b/pkgs/development/compilers/cakelisp/default.nix
index 500c15a2aaa..15afb9fc25e 100644
--- a/pkgs/development/compilers/cakelisp/default.nix
+++ b/pkgs/development/compilers/cakelisp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, gcc }:
+{ lib, stdenv, fetchFromGitHub, gcc }:
 
 stdenv.mkDerivation rec {
   pname = "cakelisp";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
         --replace '"/usr/bin/g++"' '"${gcc}/bin/g++"'
     substituteInPlace src/ModuleManager.cpp \
         --replace '"/usr/bin/g++"' '"${gcc}/bin/g++"'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace Build.sh --replace '--export-dynamic' '-export_dynamic'
     substituteInPlace runtime/HotReloading.cake --replace '--export-dynamic' '-export_dynamic'
     substituteInPlace Bootstrap.cake --replace '--export-dynamic' '-export_dynamic'
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
     install -Dm755 bin/cakelisp -t $out/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A performance-oriented Lisp-like language";
     homepage = "https://github.com/makuto/cakelisp";
     license = licenses.gpl3Plus;
diff --git a/pkgs/development/compilers/carp/default.nix b/pkgs/development/compilers/carp/default.nix
index f6c27436c76..0299c179775 100644
--- a/pkgs/development/compilers/carp/default.nix
+++ b/pkgs/development/compilers/carp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, makeWrapper, clang, haskellPackages }:
+{ lib, stdenv, fetchFromGitHub, makeWrapper, clang, haskellPackages }:
 
 haskellPackages.mkDerivation rec {
 
@@ -39,10 +39,10 @@ haskellPackages.mkDerivation rec {
 
   description = "A statically typed lisp, without a GC, for real-time applications";
   homepage    = "https://github.com/carp-lang/Carp";
-  license     = stdenv.lib.licenses.asl20;
-  maintainers = with stdenv.lib.maintainers; [ jluttine ];
+  license     = lib.licenses.asl20;
+  maintainers = with lib.maintainers; [ jluttine ];
 
   # Windows not (yet) supported.
-  platforms   = with stdenv.lib.platforms; unix ++ darwin;
+  platforms   = with lib.platforms; unix ++ darwin;
 
 }
diff --git a/pkgs/development/compilers/cc65/default.nix b/pkgs/development/compilers/cc65/default.nix
index 1b5011365cf..347382990d1 100644
--- a/pkgs/development/compilers/cc65/default.nix
+++ b/pkgs/development/compilers/cc65/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 }:
 
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   makeFlags = [ "PREFIX=${placeholder "out"}"];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://cc65.github.io/";
     description = "C compiler for processors of 6502 family";
     longDescription = ''
diff --git a/pkgs/development/compilers/ccl/default.nix b/pkgs/development/compilers/ccl/default.nix
index 8f292e358ae..79e7d324ec9 100644
--- a/pkgs/development/compilers/ccl/default.nix
+++ b/pkgs/development/compilers/ccl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, runCommand, bootstrap_cmds, coreutils, glibc, m4, runtimeShell }:
+{ lib, stdenv, fetchurl, runCommand, bootstrap_cmds, coreutils, glibc, m4, runtimeShell }:
 
 let
   options = rec {
@@ -101,7 +101,7 @@ stdenv.mkDerivation rec {
 
   hardeningDisable = [ "format" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Clozure Common Lisp";
     homepage    = "https://ccl.clozure.com/";
     maintainers = with maintainers; [ raskin muflax tohl ];
diff --git a/pkgs/development/compilers/chez/default.nix b/pkgs/development/compilers/chez/default.nix
index 550f754639e..c1c8eced83b 100644
--- a/pkgs/development/compilers/chez/default.nix
+++ b/pkgs/development/compilers/chez/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , coreutils, cctools
 , ncurses, libiconv, libX11, libuuid
 }:
@@ -15,12 +15,12 @@ stdenv.mkDerivation rec {
     fetchSubmodules = true;
   };
 
-  nativeBuildInputs = [ coreutils ] ++ stdenv.lib.optional stdenv.isDarwin cctools;
+  nativeBuildInputs = [ coreutils ] ++ lib.optional stdenv.isDarwin cctools;
   buildInputs = [ ncurses libiconv libX11 libuuid ];
 
   enableParallelBuilding = true;
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation";
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation";
 
   /*
   ** We patch out a very annoying 'feature' in ./configure, which
@@ -70,9 +70,9 @@ stdenv.mkDerivation rec {
   meta = {
     description  = "A powerful and incredibly fast R6RS Scheme compiler";
     homepage     = "https://cisco.github.io/ChezScheme/";
-    license      = stdenv.lib.licenses.asl20;
-    maintainers  = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms    = stdenv.lib.platforms.unix;
+    license      = lib.licenses.asl20;
+    maintainers  = with lib.maintainers; [ thoughtpolice ];
+    platforms    = lib.platforms.unix;
     badPlatforms = [ "aarch64-linux" ];
   };
 }
diff --git a/pkgs/development/compilers/chicken/4/chicken.nix b/pkgs/development/compilers/chicken/4/chicken.nix
index 50126fdac92..8ea522a81a9 100644
--- a/pkgs/development/compilers/chicken/4/chicken.nix
+++ b/pkgs/development/compilers/chicken/4/chicken.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
+{ lib, stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
 
 let
   version = "4.13.0";
@@ -8,7 +8,6 @@ let
     else if (isFreeBSD || isOpenBSD) then "bsd"
     else if isSunOS then "solaris"
     else "linux"; # Should be a sane default
-  lib = stdenv.lib;
 in
 stdenv.mkDerivation {
   pname = "chicken";
@@ -70,9 +69,9 @@ stdenv.mkDerivation {
 
   meta = {
     homepage = "http://www.call-cc.org/";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = with stdenv.lib.maintainers; [ corngood ];
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; # Maybe other Unix
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ corngood ];
+    platforms = lib.platforms.linux ++ lib.platforms.darwin; # Maybe other Unix
     description = "A portable compiler for the Scheme programming language";
     longDescription = ''
       CHICKEN is a compiler for the Scheme programming language.
diff --git a/pkgs/development/compilers/chicken/4/egg2nix.nix b/pkgs/development/compilers/chicken/4/egg2nix.nix
index 977f34692f9..2775666f14c 100644
--- a/pkgs/development/compilers/chicken/4/egg2nix.nix
+++ b/pkgs/development/compilers/chicken/4/egg2nix.nix
@@ -20,8 +20,8 @@ eggDerivation {
   meta = {
     description = "Generate nix-expression from CHICKEN scheme eggs";
     homepage = "https://github.com/the-kenny/egg2nix";
-    license = stdenv.lib.licenses.bsd3;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ corngood ];
+    license = lib.licenses.bsd3;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ corngood ];
   };
 }
diff --git a/pkgs/development/compilers/chicken/4/eggDerivation.nix b/pkgs/development/compilers/chicken/4/eggDerivation.nix
index cd340c22174..4c84ef8c42b 100644
--- a/pkgs/development/compilers/chicken/4/eggDerivation.nix
+++ b/pkgs/development/compilers/chicken/4/eggDerivation.nix
@@ -1,4 +1,4 @@
-{ stdenv, chicken, makeWrapper }:
+{ lib, stdenv, chicken, makeWrapper }:
 { name, src
 , buildInputs ? []
 , chickenInstallFlags ? []
@@ -8,7 +8,7 @@
 let
   libPath = "${chicken}/var/lib/chicken/${toString chicken.binaryVersion}/";
   overrides = import ./overrides.nix;
-  baseName = stdenv.lib.getName name;
+  baseName = lib.getName name;
   override = if builtins.hasAttr baseName overrides
    then
      builtins.getAttr baseName overrides
@@ -20,7 +20,7 @@ stdenv.mkDerivation ({
   propagatedBuildInputs = buildInputs;
   buildInputs = [ makeWrapper chicken ];
 
-  CSC_OPTIONS = stdenv.lib.concatStringsSep " " cscOptions;
+  CSC_OPTIONS = lib.concatStringsSep " " cscOptions;
 
   CHICKEN_REPOSITORY = libPath;
   CHICKEN_INSTALL_PREFIX = "$out";
@@ -28,7 +28,7 @@ stdenv.mkDerivation ({
   installPhase = ''
     runHook preInstall
 
-    chicken-install -p $out ${stdenv.lib.concatStringsSep " " chickenInstallFlags}
+    chicken-install -p $out ${lib.concatStringsSep " " chickenInstallFlags}
 
     for f in $out/bin/*
     do
diff --git a/pkgs/development/compilers/chicken/5/chicken.nix b/pkgs/development/compilers/chicken/5/chicken.nix
index 712012643f3..9f2554b7343 100644
--- a/pkgs/development/compilers/chicken/5/chicken.nix
+++ b/pkgs/development/compilers/chicken/5/chicken.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
+{ lib, stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
 
 let
   version = "5.2.0";
@@ -8,7 +8,6 @@ let
     else if (isFreeBSD || isOpenBSD) then "bsd"
     else if isSunOS then "solaris"
     else "linux"; # Should be a sane default
-  lib = stdenv.lib;
 in
 stdenv.mkDerivation {
   pname = "chicken";
@@ -51,9 +50,9 @@ stdenv.mkDerivation {
 
   meta = {
     homepage = "http://www.call-cc.org/";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = with stdenv.lib.maintainers; [ corngood ];
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; # Maybe other Unix
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ corngood ];
+    platforms = lib.platforms.linux ++ lib.platforms.darwin; # Maybe other Unix
     description = "A portable compiler for the Scheme programming language";
     longDescription = ''
       CHICKEN is a compiler for the Scheme programming language.
diff --git a/pkgs/development/compilers/chicken/5/egg2nix.nix b/pkgs/development/compilers/chicken/5/egg2nix.nix
index 0c18b8db2de..69e8d9e62c3 100644
--- a/pkgs/development/compilers/chicken/5/egg2nix.nix
+++ b/pkgs/development/compilers/chicken/5/egg2nix.nix
@@ -1,4 +1,4 @@
-{ stdenv, eggDerivation, fetchFromGitHub, chickenEggs }:
+{ lib, stdenv, eggDerivation, fetchFromGitHub, chickenEggs }:
 
 # Note: This mostly reimplements the default.nix already contained in
 # the tarball. Is there a nicer way than duplicating code?
@@ -22,8 +22,8 @@ eggDerivation {
   meta = {
     description = "Generate nix-expression from CHICKEN scheme eggs";
     homepage = "https://github.com/the-kenny/egg2nix";
-    license = stdenv.lib.licenses.bsd3;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ corngood ];
+    license = lib.licenses.bsd3;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ corngood ];
   };
 }
diff --git a/pkgs/development/compilers/chicken/5/eggDerivation.nix b/pkgs/development/compilers/chicken/5/eggDerivation.nix
index f5ed4b4b7f8..7102126206a 100644
--- a/pkgs/development/compilers/chicken/5/eggDerivation.nix
+++ b/pkgs/development/compilers/chicken/5/eggDerivation.nix
@@ -1,4 +1,4 @@
-{ stdenv, chicken, makeWrapper }:
+{ lib, stdenv, chicken, makeWrapper }:
 { name, src
 , buildInputs ? []
 , chickenInstallFlags ? []
@@ -7,7 +7,7 @@
 
 let
   overrides = import ./overrides.nix;
-  baseName = stdenv.lib.getName name;
+  baseName = lib.getName name;
   override = if builtins.hasAttr baseName overrides
    then
      builtins.getAttr baseName overrides
@@ -19,14 +19,14 @@ stdenv.mkDerivation ({
   propagatedBuildInputs = buildInputs;
   buildInputs = [ makeWrapper chicken ];
 
-  CSC_OPTIONS = stdenv.lib.concatStringsSep " " cscOptions;
+  CSC_OPTIONS = lib.concatStringsSep " " cscOptions;
 
   installPhase = ''
     runHook preInstall
 
     export CHICKEN_INSTALL_PREFIX=$out
     export CHICKEN_INSTALL_REPOSITORY=$out/lib/chicken/${toString chicken.binaryVersion}
-    chicken-install ${stdenv.lib.concatStringsSep " " chickenInstallFlags}
+    chicken-install ${lib.concatStringsSep " " chickenInstallFlags}
 
     for f in $out/bin/*
     do
diff --git a/pkgs/development/compilers/ciao/default.nix b/pkgs/development/compilers/ciao/default.nix
index be39d81f558..de8e73374c5 100644
--- a/pkgs/development/compilers/ciao/default.nix
+++ b/pkgs/development/compilers/ciao/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ lib, stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
   pname = "ciao";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     ./ciao-boot.sh install
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://ciao-lang.org/";
     description = "A general purpose, multi-paradigm programming language in the Prolog family";
     license = licenses.lgpl21;
diff --git a/pkgs/development/compilers/clasp/default.nix b/pkgs/development/compilers/clasp/default.nix
index b7da76d38f9..31a669c313e 100644
--- a/pkgs/development/compilers/clasp/default.nix
+++ b/pkgs/development/compilers/clasp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchFromGitLab
+{ lib, stdenv, fetchFromGitHub, fetchFromGitLab
 , llvmPackages
 , cmake, boehmgc, gmp, zlib, ncurses, boost, libelf
 , python, git, sbcl
@@ -72,14 +72,14 @@ stdenv.mkDerivation rec {
 
   buildInputs = with llvmPackages;
   (
-   builtins.map (x: stdenv.lib.overrideDerivation x
+   builtins.map (x: lib.overrideDerivation x
            (x: {NIX_CFLAGS_COMPILE= (x.NIX_CFLAGS_COMPILE or "") + " -frtti"; }))
    [ llvm clang clang-unwrapped clang ]) ++
   [
     gmp zlib ncurses
     boost boehmgc libelf
     (boost.override {enableStatic = true; enableShared = false;})
-    (stdenv.lib.overrideDerivation boehmgc
+    (lib.overrideDerivation boehmgc
       (x: {configureFlags = (x.configureFlags or []) ++ ["--enable-static"];}))
   ];
 
@@ -120,9 +120,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "A Common Lisp implementation based on LLVM with C++ integration";
-    license = stdenv.lib.licenses.lgpl21Plus ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.lgpl21Plus ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     # Large, long to build, a private build of clang is needed, a prerelease.
     hydraPlatforms = [];
     homepage = "https://github.com/drmeister/clasp";
diff --git a/pkgs/development/compilers/clean/default.nix b/pkgs/development/compilers/clean/default.nix
index 0dfd05030b9..f8121958e29 100644
--- a/pkgs/development/compilers/clean/default.nix
+++ b/pkgs/development/compilers/clean/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   name = "clean-3.0";
@@ -45,8 +45,8 @@ stdenv.mkDerivation {
     '';
 
     homepage = "http://wiki.clean.cs.ru.nl/Clean";
-    license = stdenv.lib.licenses.lgpl21;
-    maintainers = [ stdenv.lib.maintainers.kkallio ];
+    license = lib.licenses.lgpl21;
+    maintainers = [ lib.maintainers.kkallio ];
     platforms = [ "i686-linux" "x86_64-linux" ];
   };
 }
diff --git a/pkgs/development/compilers/closure/default.nix b/pkgs/development/compilers/closure/default.nix
index 7c0d42f1864..b5ac2e187d8 100644
--- a/pkgs/development/compilers/closure/default.nix
+++ b/pkgs/development/compilers/closure/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, jre, makeWrapper }:
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "closure-compiler";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
       --add-flags "-jar $out/share/java/closure-compiler-v${version}.jar"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A tool for making JavaScript download and run faster";
     homepage = "https://developers.google.com/closure/compiler/";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/cmdstan/default.nix b/pkgs/development/compilers/cmdstan/default.nix
index 87d3f0ef00c..df674b67db8 100644
--- a/pkgs/development/compilers/cmdstan/default.nix
+++ b/pkgs/development/compilers/cmdstan/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python, runtimeShell }:
+{ lib, stdenv, fetchurl, python, runtimeShell }:
 
 stdenv.mkDerivation {
   name = "cmdstan-2.17.1";
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
       likelihood estimation with Optimization (L-BFGS).
     '';
     homepage = "https://mc-stan.org/interfaces/cmdstan.html";
-    license = stdenv.lib.licenses.bsd3;
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.bsd3;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/cmucl/binary.nix b/pkgs/development/compilers/cmucl/binary.nix
index 480a7e522b5..b09f5f41b67 100644
--- a/pkgs/development/compilers/cmucl/binary.nix
+++ b/pkgs/development/compilers/cmucl/binary.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 
 let
   inherit (stdenv.hostPlatform) system;
@@ -36,9 +36,9 @@ stdenv.mkDerivation {
       which runs on most major Unix platforms.  It mainly conforms to the
       ANSI Common Lisp standard.
     '';
-    license = stdenv.lib.licenses.free;		# public domain
+    license = lib.licenses.free;		# public domain
     homepage = "http://www.cons.org/cmucl/";
-    maintainers = [stdenv.lib.maintainers.tohl];
-    platforms = stdenv.lib.platforms.linux;
+    maintainers = [lib.maintainers.tohl];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/colm/default.nix b/pkgs/development/compilers/colm/default.nix
index 06a56dc42ea..d7a0953a803 100644
--- a/pkgs/development/compilers/colm/default.nix
+++ b/pkgs/development/compilers/colm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, gcc, asciidoc, autoreconfHook }:
+{ lib, stdenv, fetchurl, makeWrapper, gcc, asciidoc, autoreconfHook }:
 
 stdenv.mkDerivation rec {
   pname = "colm";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
       --prefix PATH ":" ${gcc}/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A programming language for the analysis and transformation of computer languages";
     homepage = "http://www.colm.net/open-source/colm";
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/compcert/default.nix b/pkgs/development/compilers/compcert/default.nix
index 99bd09d8d9e..611efb11f44 100644
--- a/pkgs/development/compilers/compcert/default.nix
+++ b/pkgs/development/compilers/compcert/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper
+{ lib, stdenv, fetchFromGitHub, fetchpatch, makeWrapper
 , coqPackages, ocamlPackages, coq2html
 , tools ? stdenv.cc
 , version ? "3.8"
@@ -8,7 +8,7 @@ let
   ocaml-pkgs      = with ocamlPackages; [ ocaml findlib menhir ];
   ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux";
   inherit (coqPackages) coq flocq;
-  inherit (stdenv.lib) optional optionalString;
+  inherit (lib) optional optionalString;
 in
 
 let param = {
@@ -83,7 +83,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "lib" "doc" "man" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Formally verified C compiler";
     homepage    = "https://compcert.org";
     license     = licenses.inria-compcert;
diff --git a/pkgs/development/compilers/computecpp/default.nix b/pkgs/development/compilers/computecpp/default.nix
index acdcc2014f8..0f9e877201b 100644
--- a/pkgs/development/compilers/computecpp/default.nix
+++ b/pkgs/development/compilers/computecpp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchzip
 , pkg-config
 , autoPatchelfHook
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
     isClang = true;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description =
       "Accelerate Complex C++ Applications on Heterogeneous Compute Systems using Open Standards";
     homepage = "https://www.codeplay.com/products/computesuite/computecpp";
diff --git a/pkgs/development/compilers/copper/default.nix b/pkgs/development/compilers/copper/default.nix
index 67bc786e669..dd6af73547a 100644
--- a/pkgs/development/compilers/copper/default.nix
+++ b/pkgs/development/compilers/copper/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , libffi
 }:
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   installPhase = ''
     make BACKEND=elf64 install prefix=$out
   '';
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Simple imperative language, statically typed with type inference and genericity";
     homepage = "https://tibleiz.net/copper/";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/coreclr/default.nix b/pkgs/development/compilers/coreclr/default.nix
index 2a44279209c..f38a3805962 100644
--- a/pkgs/development/compilers/coreclr/default.nix
+++ b/pkgs/development/compilers/coreclr/default.nix
@@ -1,4 +1,4 @@
-{ config, stdenv
+{ config, lib, stdenv
 , fetchFromGitHub
 , fetchpatch
 , which
@@ -90,7 +90,7 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://github.com/dotnet/core/";
     description = ".NET is a general purpose development platform";
     platforms = [ "x86_64-linux" ];
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
index b449d66d3ba..489e9d28cbc 100644
--- a/pkgs/development/compilers/crystal/default.nix
+++ b/pkgs/development/compilers/crystal/default.nix
@@ -63,7 +63,7 @@ let
   commonBuildInputs = extraBuildInputs: [
     boehmgc libatomic_ops pcre libevent libyaml zlib libxml2 openssl
   ] ++ extraBuildInputs
-    ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv ];
+    ++ lib.optionals stdenv.isDarwin [ libiconv ];
 
   generic = (
     { version
diff --git a/pkgs/development/compilers/cudatoolkit/common.nix b/pkgs/development/compilers/cudatoolkit/common.nix
index 92a684a6fbf..c18eb9d534a 100644
--- a/pkgs/development/compilers/cudatoolkit/common.nix
+++ b/pkgs/development/compilers/cudatoolkit/common.nix
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     gtk2 glib fontconfig freetype unixODBC alsaLib
   ];
 
-  rpath = "${stdenv.lib.makeLibraryPath runtimeDependencies}:${stdenv.cc.cc.lib}/lib64";
+  rpath = "${lib.makeLibraryPath runtimeDependencies}:${stdenv.cc.cc.lib}/lib64";
 
   unpackPhase = ''
     sh $src --keep --noexec
@@ -232,7 +232,7 @@ stdenv.mkDerivation rec {
     majorVersion = lib.versions.majorMinor version;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A compiler for NVIDIA GPUs, math libraries, and tools";
     homepage = "https://developer.nvidia.com/cuda-toolkit";
     platforms = [ "x86_64-linux" ];
diff --git a/pkgs/development/compilers/dale/default.nix b/pkgs/development/compilers/dale/default.nix
index ef32b37ef99..addd7997d36 100644
--- a/pkgs/development/compilers/dale/default.nix
+++ b/pkgs/development/compilers/dale/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , pkg-config
@@ -27,7 +27,7 @@ stdenv.mkDerivation {
 
   checkTarget = "tests";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Lisp-flavoured C";
     longDescription = ''
       Dale is a system (no GC) programming language that uses
diff --git a/pkgs/development/compilers/dasm/default.nix b/pkgs/development/compilers/dasm/default.nix
index 627ac36329a..7f57f47f2ed 100644
--- a/pkgs/development/compilers/dasm/default.nix
+++ b/pkgs/development/compilers/dasm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ lib, stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
   pname = "dasm";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   checkTarget = "test";
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Assembler for 6502 and other 8-bit microprocessors";
     homepage = "https://dasm-assembler.github.io";
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/dev86/default.nix b/pkgs/development/compilers/dev86/default.nix
index 88b46561241..cea9ea37b4e 100644
--- a/pkgs/development/compilers/dev86/default.nix
+++ b/pkgs/development/compilers/dev86/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   pname = "dev86";
@@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Linux 8086 development environment";
     homepage = "http://v3.sk/~lkundrak/dev86/";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/dmd/default.nix b/pkgs/development/compilers/dmd/default.nix
index 4bfd6298c8f..074646f5f41 100644
--- a/pkgs/development/compilers/dmd/default.nix
+++ b/pkgs/development/compilers/dmd/default.nix
@@ -16,7 +16,7 @@ let
       name = "dmd.conf";
       text = (lib.generators.toINI {} {
         Environment = {
-          DFLAGS = ''-I@out@/include/dmd -L-L@out@/lib -fPIC ${stdenv.lib.optionalString (!targetPackages.stdenv.cc.isClang) "-L--export-dynamic"}'';
+          DFLAGS = ''-I@out@/include/dmd -L-L@out@/lib -fPIC ${lib.optionalString (!targetPackages.stdenv.cc.isClang) "-L--export-dynamic"}'';
         };
       });
   };
@@ -77,16 +77,16 @@ stdenv.mkDerivation rec {
   postPatch = ''
       substituteInPlace dmd/test/dshell/test6952.d --replace "/usr/bin/env bash" "${bash}/bin/bash"
   ''
-  + stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
+  + lib.optionalString stdenv.hostPlatform.isLinux ''
       substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" ""
   ''
-  + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+  + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)"
   '';
 
   nativeBuildInputs = [ makeWrapper unzip which gdb git ]
 
-  ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
+  ++ lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
     Foundation
   ]);
 
@@ -163,7 +163,7 @@ stdenv.mkDerivation rec {
       substitute ${dmdConfFile} "$out/bin/dmd.conf" --subst-var out
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Official reference compiler for the D language";
     homepage = "http://dlang.org/";
     # Everything is now Boost licensed, even the backend.
diff --git a/pkgs/development/compilers/dotnet/build-dotnet.nix b/pkgs/development/compilers/dotnet/build-dotnet.nix
index 1162a75d0de..56880826a19 100644
--- a/pkgs/development/compilers/dotnet/build-dotnet.nix
+++ b/pkgs/development/compilers/dotnet/build-dotnet.nix
@@ -4,7 +4,7 @@
 }:
 
 assert builtins.elem type [ "aspnetcore" "netcore" "sdk"];
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , libunwind
 , openssl
@@ -41,7 +41,7 @@ let
 in stdenv.mkDerivation rec {
   inherit pname version;
 
-  rpath = stdenv.lib.makeLibraryPath [
+  rpath = lib.makeLibraryPath [
     curl
     icu
     libunwind
@@ -70,7 +70,7 @@ in stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
-  postFixup = stdenv.lib.optionalString stdenv.isLinux ''
+  postFixup = lib.optionalString stdenv.isLinux ''
     patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet
     patchelf --set-rpath "${rpath}" $out/dotnet
     find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
@@ -82,7 +82,7 @@ in stdenv.mkDerivation rec {
     $out/bin/dotnet --info
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://dotnet.github.io/";
     description = builtins.getAttr type descriptions;
     platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
diff --git a/pkgs/development/compilers/ecl/16.1.2.nix b/pkgs/development/compilers/ecl/16.1.2.nix
index a7b2aa6be74..0789addb337 100644
--- a/pkgs/development/compilers/ecl/16.1.2.nix
+++ b/pkgs/development/compilers/ecl/16.1.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch
+{ lib, stdenv, fetchurl, fetchpatch
 , libtool, autoconf, automake
 , gmp, mpfr, libffi, makeWrapper
 , noUnicode ? false
@@ -23,7 +23,7 @@ let
   ];
   propagatedBuildInputs = [
     libffi gmp mpfr gcc
-  ] ++ stdenv.lib.optionals useBoehmgc [
+  ] ++ lib.optionals useBoehmgc [
     # replaces ecl's own gc which other packages can depend on, thus propagated
     boehmgc
   ];
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
     "--with-libffi-prefix=${libffi.dev}"
     ]
     ++
-    (stdenv.lib.optional (! noUnicode)
+    (lib.optional (! noUnicode)
       "--enable-unicode")
     ;
 
@@ -77,8 +77,8 @@ stdenv.mkDerivation {
   meta = {
     inherit (s) version;
     description = "Lisp implementation aiming to be small, fast and easy to embed";
-    license = stdenv.lib.licenses.mit ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.mit ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix
index 40f3e38e506..0b4ea9b8389 100644
--- a/pkgs/development/compilers/ecl/default.nix
+++ b/pkgs/development/compilers/ecl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl
+{lib, stdenv, fetchurl
 , libtool, autoconf, automake
 , texinfo
 , gmp, mpfr, libffi, makeWrapper
@@ -22,7 +22,7 @@ let
   propagatedBuildInputs = [
     libffi gmp mpfr gcc
     # replaces ecl's own gc which other packages can depend on, thus propagated
-  ] ++ stdenv.lib.optionals useBoehmgc [
+  ] ++ lib.optionals useBoehmgc [
     # replaces ecl's own gc which other packages can depend on, thus propagated
     boehmgc
   ];
@@ -76,7 +76,7 @@ stdenv.mkDerivation {
     "--with-libffi-prefix=${libffi.dev}"
     ]
     ++
-    (stdenv.lib.optional (! noUnicode)
+    (lib.optional (! noUnicode)
       "--enable-unicode")
     ;
 
@@ -94,8 +94,8 @@ stdenv.mkDerivation {
     inherit (s) version;
     description = "Lisp implementation aiming to be small, fast and easy to embed";
     homepage = "https://common-lisp.net/project/ecl/";
-    license = stdenv.lib.licenses.mit ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/eli/default.nix b/pkgs/development/compilers/eli/default.nix
index 61e5fd70a7c..8920e34b6ee 100644
--- a/pkgs/development/compilers/eli/default.nix
+++ b/pkgs/development/compilers/eli/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , symlinkJoin
 , makeWrapper
@@ -84,8 +84,8 @@ stdenv.mkDerivation rec {
       arbitrary special cases. Output is the C subset of C++.
     '';
     homepage = "http://eli-project.sourceforge.net/";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [ timokau ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = with lib.maintainers; [ timokau ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix
index 6c4b1bd2d30..459efde218a 100644
--- a/pkgs/development/compilers/elm/default.nix
+++ b/pkgs/development/compilers/elm/default.nix
@@ -118,7 +118,7 @@ let
 
       elm-test = patchBinwrap [elmi-to-json]
         nodePkgs.elm-test // {
-          meta = with stdenv.lib; {
+          meta = with lib; {
             description = "Runs elm-test suites from Node.js";
             homepage = "https://github.com/rtfeldman/node-test-runner";
             license = licenses.bsd3;
@@ -128,7 +128,7 @@ let
 
       elm-verify-examples = patchBinwrap [elmi-to-json]
         nodePkgs.elm-verify-examples // {
-          meta = with stdenv.lib; {
+          meta = with lib; {
             description = "Verify examples in your docs";
             homepage = "https://github.com/stoeffel/elm-verify-examples";
             license = licenses.bsd3;
@@ -153,7 +153,7 @@ let
             mkdir -p unpacked_bin
             ln -sf ${elm-instrument}/bin/elm-instrument unpacked_bin/elm-instrument
           '';
-          meta = with stdenv.lib; {
+          meta = with lib; {
             description = "Work in progress - Code coverage tooling for Elm";
             homepage = "https://github.com/zwilias/elm-coverage";
             license = licenses.bsd3;
@@ -163,7 +163,7 @@ let
 
       create-elm-app = patchNpmElm (patchBinwrap [elmi-to-json]
         nodePkgs.create-elm-app) // {
-          meta = with stdenv.lib; {
+          meta = with lib; {
             description = "Create Elm apps with no build configuration";
             homepage = "https://github.com/halfzebra/create-elm-app";
             license = licenses.mit;
@@ -173,7 +173,7 @@ let
 
       elm-review = patchBinwrap [elmRustPackages.elm-json]
         nodePkgs.elm-review // {
-          meta = with stdenv.lib; {
+          meta = with lib; {
             description = "Analyzes Elm projects, to help find mistakes before your users find them";
             homepage = "https://package.elm-lang.org/packages/jfmengels/elm-review/${nodePkgs.elm-review.version}";
             license = licenses.bsd3;
@@ -182,7 +182,7 @@ let
         };
 
       elm-language-server = nodePkgs."@elm-tooling/elm-language-server" // {
-        meta = with stdenv.lib; {
+        meta = with lib; {
           description = "Language server implementation for Elm";
           homepage = "https://github.com/elm-tooling/elm-language-server";
           license = licenses.mit;
@@ -191,7 +191,7 @@ let
       };
 
       elm-optimize-level-2 = nodePkgs."elm-optimize-level-2" // {
-        meta = with stdenv.lib; {
+        meta = with lib; {
           description = "A second level of optimization for the Javascript that the Elm Compiler produces";
           homepage = "https://github.com/mdgriffith/elm-optimize-level-2";
           license = licenses.bsd3;
diff --git a/pkgs/development/compilers/elm/packages/elm-format.nix b/pkgs/development/compilers/elm/packages/elm-format.nix
index ff944cc4b64..71386e00ef1 100644
--- a/pkgs/development/compilers/elm/packages/elm-format.nix
+++ b/pkgs/development/compilers/elm/packages/elm-format.nix
@@ -1,7 +1,7 @@
 { mkDerivation, fetchgit, ansi-terminal, ansi-wl-pprint, array, base, binary
 , bytestring, cmark, containers, directory, filepath, free, HUnit
 , indents, json, mtl, optparse-applicative, parsec, process
-, QuickCheck, quickcheck-io, split, stdenv, tasty, tasty-golden
+, QuickCheck, quickcheck-io, split, lib, stdenv, tasty, tasty-golden
 , tasty-hunit, tasty-quickcheck, text
 }:
 mkDerivation {
@@ -36,5 +36,5 @@ mkDerivation {
   doHaddock = false;
   homepage = "https://elm-lang.org";
   description = "A source code formatter for Elm";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/elm/packages/elm-instrument.nix b/pkgs/development/compilers/elm/packages/elm-instrument.nix
index 4d7efcf1083..cd13eb4de4f 100644
--- a/pkgs/development/compilers/elm/packages/elm-instrument.nix
+++ b/pkgs/development/compilers/elm/packages/elm-instrument.nix
@@ -2,7 +2,7 @@
 , bytestring, Cabal, cmark, containers, directory, elm-format
 , fetchgit, filepath, free, HUnit, indents, json, mtl
 , optparse-applicative, parsec, process, QuickCheck, quickcheck-io
-, split, stdenv, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
+, split, lib, stdenv, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
 , text
 }:
 mkDerivation {
@@ -30,5 +30,5 @@ mkDerivation {
   ];
   homepage = "https://elm-lang.org";
   description = "Instrumentation library for Elm";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/elm/packages/elm.nix b/pkgs/development/compilers/elm/packages/elm.nix
index 644a53fd619..edb2ed6ed7a 100644
--- a/pkgs/development/compilers/elm/packages/elm.nix
+++ b/pkgs/development/compilers/elm/packages/elm.nix
@@ -3,7 +3,7 @@
 , file-embed, filelock, filepath, ghc-prim, haskeline, HTTP
 , http-client, http-client-tls, http-types, language-glsl, mtl
 , network, parsec, process, raw-strings-qq, scientific, SHA
-, snap-core, snap-server, stdenv, template-haskell, time
+, snap-core, snap-server, lib, stdenv, template-haskell, time
 , unordered-containers, utf8-string, vector, zip-archive
 }:
 mkDerivation {
@@ -27,5 +27,5 @@ mkDerivation {
   ];
   homepage = "https://elm-lang.org";
   description = "The `elm` command line interface";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/elm/packages/elmi-to-json.nix b/pkgs/development/compilers/elm/packages/elmi-to-json.nix
index eaed18c5297..6788fce6a99 100644
--- a/pkgs/development/compilers/elm/packages/elmi-to-json.nix
+++ b/pkgs/development/compilers/elm/packages/elmi-to-json.nix
@@ -1,6 +1,6 @@
 { mkDerivation, aeson, base, binary, bytestring, containers
 , directory, fetchgit, filepath, ghc-prim, hpack
-, optparse-applicative, stdenv, text, unliftio
+, optparse-applicative, lib, stdenv, text, unliftio
 , unordered-containers
 }:
 mkDerivation {
@@ -23,5 +23,5 @@ mkDerivation {
   testHaskellDepends = [ base ];
   prePatch = "hpack";
   homepage = "https://github.com/stoeffel/elmi-to-json#readme";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/elm/packages/indents.nix b/pkgs/development/compilers/elm/packages/indents.nix
index 6bf7fa7890e..80f3c08d9e3 100644
--- a/pkgs/development/compilers/elm/packages/indents.nix
+++ b/pkgs/development/compilers/elm/packages/indents.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, base, concatenative, mtl, parsec, stdenv }:
+{ mkDerivation, base, concatenative, mtl, parsec, lib, stdenv }:
 mkDerivation {
   pname = "indents";
   version = "0.3.3";
@@ -7,5 +7,5 @@ mkDerivation {
   doCheck = false;
   homepage = "http://patch-tag.com/r/salazar/indents";
   description = "indentation sensitive parser-combinators for parsec";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/emscripten/default.nix b/pkgs/development/compilers/emscripten/default.nix
index ac13f955930..648ec156abe 100644
--- a/pkgs/development/compilers/emscripten/default.nix
+++ b/pkgs/development/compilers/emscripten/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
+{ lib, stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
 , jre, binaryen
 , llvmPackages_11
 , symlinkJoin, makeWrapper
@@ -101,7 +101,7 @@ stdenv.mkDerivation rec {
     popd
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://github.com/emscripten-core/emscripten";
     description = "An LLVM-to-JavaScript Compiler";
     platforms = platforms.all;
diff --git a/pkgs/development/compilers/eql/default.nix b/pkgs/development/compilers/eql/default.nix
index ce42c102115..a3fefbc1f48 100644
--- a/pkgs/development/compilers/eql/default.nix
+++ b/pkgs/development/compilers/eql/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, qt4, ecl, xorgserver, xkbcomp, xkeyboard_config }:
+{ lib, stdenv, fetchgit, qt4, ecl, xorgserver, xkbcomp, xkeyboard_config }:
 
 stdenv.mkDerivation rec {
   version = src.rev;
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
     ln -s $out/lib/eql/build-dir/libeql*.so* $out/lib
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Embedded Qt Lisp (ECL+Qt)";
     maintainers = with maintainers; [ raskin ];
     platforms = platforms.linux;
diff --git a/pkgs/development/compilers/factor-lang/default.nix b/pkgs/development/compilers/factor-lang/default.nix
index eba5b0f584c..fc5f478177c 100644
--- a/pkgs/development/compilers/factor-lang/default.nix
+++ b/pkgs/development/compilers/factor-lang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, git,
+{ lib, stdenv, fetchurl, glib, git,
   rlwrap, curl, pkg-config, perl, makeWrapper, tzdata, ncurses,
   pango, cairo, gtk2, gdk-pixbuf, gtkglext,
   mesa, xorg, openssl, unzip }:
@@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
     # out of known libraries. The side effect is that find-lib
     # will work only on the known libraries. There does not seem
     # to be a generic solution here.
-    find $(echo ${stdenv.lib.makeLibraryPath (with xorg; [
+    find $(echo ${lib.makeLibraryPath (with xorg; [
         glib libX11 pango cairo gtk2 gdk-pixbuf gtkglext
         mesa libXmu libXt libICE libSM ])} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst
 
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
 
     cp ./factor $out/bin
     wrapProgram $out/bin/factor --prefix LD_LIBRARY_PATH : \
-      "${stdenv.lib.makeLibraryPath (with xorg; [ glib
+      "${lib.makeLibraryPath (with xorg; [ glib
         libX11 pango cairo gtk2 gdk-pixbuf gtkglext
         mesa libXmu libXt libICE libSM openssl])}"
 
@@ -93,7 +93,7 @@ stdenv.mkDerivation rec {
     cp misc/fuel/*.el $out/share/emacs/site-lisp/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://factorcode.org";
     license = licenses.bsd2;
     description = "A concatenative, stack-based programming language";
diff --git a/pkgs/development/compilers/fasmg/default.nix b/pkgs/development/compilers/fasmg/default.nix
index 5233e248c07..611a2bdb8f1 100644
--- a/pkgs/development/compilers/fasmg/default.nix
+++ b/pkgs/development/compilers/fasmg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchzip
 }:
 
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
     cp docs/*.txt $doc/share/doc/fasmg
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "x86(-64) macro assembler to binary, MZ, PE, COFF, and ELF";
     homepage = "https://flatassembler.net";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/flasm/default.nix b/pkgs/development/compilers/flasm/default.nix
index 9393d4fc59f..4257feb87b9 100644
--- a/pkgs/development/compilers/flasm/default.nix
+++ b/pkgs/development/compilers/flasm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, unzip, bison, flex, gperf, zlib }:
+{ lib, stdenv, fetchzip, unzip, bison, flex, gperf, zlib }:
 
 stdenv.mkDerivation rec {
   pname = "flasm";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     install -Dm755 flasm -t $out/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Assembler and disassembler for Flash (SWF) bytecode";
     homepage = "http://flasm.sourceforge.net/";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix
index b7769e88af3..a7ec8732250 100644
--- a/pkgs/development/compilers/flutter/flutter.nix
+++ b/pkgs/development/compilers/flutter/flutter.nix
@@ -13,7 +13,7 @@
 , coreutils
 , git
 , runCommand
-, stdenv
+, lib, stdenv
 , fetchurl
 , alsaLib
 , dbus
@@ -137,7 +137,7 @@ runCommand drvName
   preferLocalBuild = true;
   allowSubstitutes = false;
   passthru = { unwrapped = flutter; };
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Flutter is Google's SDK for building mobile, web and desktop with Dart";
     longDescription = ''
       Flutter is Google’s UI toolkit for building beautiful,
diff --git a/pkgs/development/compilers/fpc/default.nix b/pkgs/development/compilers/fpc/default.nix
index 6e7ffefca21..5c829386651 100644
--- a/pkgs/development/compilers/fpc/default.nix
+++ b/pkgs/development/compilers/fpc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gawk }:
+{ lib, stdenv, fetchurl, gawk }:
 
 let startFPC = import ./binary.nix { inherit stdenv fetchurl; }; in
 
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
     bootstrap = startFPC;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Free Pascal Compiler from a source distribution";
     homepage = "https://www.freepascal.org";
     maintainers = [ maintainers.raskin ];
diff --git a/pkgs/development/compilers/fpc/lazarus.nix b/pkgs/development/compilers/fpc/lazarus.nix
index 71303305791..0b7ac647529 100644
--- a/pkgs/development/compilers/fpc/lazarus.nix
+++ b/pkgs/development/compilers/fpc/lazarus.nix
@@ -97,7 +97,7 @@ stdenv.mkDerivation rec {
       --prefix PATH ':' "${lib.makeBinPath [ fpc gdb gnumake binutils ]}"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Graphical IDE for the FreePascal language";
     homepage = "https://www.lazarus.freepascal.org";
     license = licenses.gpl2Plus ;
diff --git a/pkgs/development/compilers/fsharp/default.nix b/pkgs/development/compilers/fsharp/default.nix
index 53c9aeea3e0..19b79989dc2 100644
--- a/pkgs/development/compilers/fsharp/default.nix
+++ b/pkgs/development/compilers/fsharp/default.nix
@@ -1,6 +1,6 @@
 # Temporarily avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it
 
-{ stdenv, fetchurl, mono, pkg-config, dotnetbuildhelpers, autoconf, automake, which }:
+{ lib, stdenv, fetchurl, mono, pkg-config, dotnetbuildhelpers, autoconf, automake, which }:
 
 stdenv.mkDerivation rec {
   pname = "fsharp";
@@ -41,8 +41,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A functional CLI language";
     homepage = "https://fsharp.org/";
-    license = stdenv.lib.licenses.asl20;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ];
-    platforms = with stdenv.lib.platforms; unix;
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ thoughtpolice raskin ];
+    platforms = with lib.platforms; unix;
   };
 }
diff --git a/pkgs/development/compilers/fsharp41/default.nix b/pkgs/development/compilers/fsharp41/default.nix
index 7c1a2fd32ef..e9f9088df3a 100644
--- a/pkgs/development/compilers/fsharp41/default.nix
+++ b/pkgs/development/compilers/fsharp41/default.nix
@@ -1,6 +1,6 @@
 # Temporaririly avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it
 
-{ stdenv, fetchurl, pkg-config, autoconf, automake, which, mono, msbuild, dotnetbuildhelpers, dotnetPackages }:
+{ lib, stdenv, fetchurl, pkg-config, autoconf, automake, which, mono, msbuild, dotnetbuildhelpers, dotnetPackages }:
 
 stdenv.mkDerivation rec {
   pname = "fsharp";
@@ -119,8 +119,8 @@ EOF
   meta = {
     description = "A functional CLI language";
     homepage = "https://fsharp.org/";
-    license = stdenv.lib.licenses.asl20;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ];
-    platforms = with stdenv.lib.platforms; unix;
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ thoughtpolice raskin ];
+    platforms = with lib.platforms; unix;
   };
 }
diff --git a/pkgs/development/compilers/fstar/default.nix b/pkgs/development/compilers/fstar/default.nix
index 548abeff78d..73bf001f752 100644
--- a/pkgs/development/compilers/fstar/default.nix
+++ b/pkgs/development/compilers/fstar/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, z3, ocamlPackages, makeWrapper, installShellFiles }:
+{ lib, stdenv, fetchFromGitHub, z3, ocamlPackages, makeWrapper, installShellFiles }:
 
 stdenv.mkDerivation rec {
   pname = "fstar";
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
     installShellCompletion --zsh --name _fstar.exe .completion/zsh/__fstar.exe
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "ML-like functional programming language aimed at program verification";
     homepage = "https://www.fstar-lang.org";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/gavrasm/default.nix b/pkgs/development/compilers/gavrasm/default.nix
index 58e8b45b61a..6bd813b56cf 100644
--- a/pkgs/development/compilers/gavrasm/default.nix
+++ b/pkgs/development/compilers/gavrasm/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchzip, fpc , lang ? "en" } :
-assert stdenv.lib.assertOneOf "lang" lang ["cn" "de" "en" "fr" "tr"];
+{ lib, stdenv, fetchzip, fpc , lang ? "en" } :
+assert lib.assertOneOf "lang" lang ["cn" "de" "en" "fr" "tr"];
 stdenv.mkDerivation rec {
   pname = "gavrasm";
   version = "4.5";
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
     cp LiesMich.Txt $out/doc
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://www.avr-asm-tutorial.net/gavrasm";
     description = "AVR Assembler for ATMEL AVR-Processors";
     license = licenses.unfree;
diff --git a/pkgs/development/compilers/gcc-arm-embedded/10/default.nix b/pkgs/development/compilers/gcc-arm-embedded/10/default.nix
index b300a190e1c..943ddd100a2 100644
--- a/pkgs/development/compilers/gcc-arm-embedded/10/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/10/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , ncurses5
 , python27
@@ -39,11 +39,11 @@ stdenv.mkDerivation rec {
     find $out -type f | while read f; do
       patchelf "$f" > /dev/null 2>&1 || continue
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
-      patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
+      patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
     homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
     license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ];
diff --git a/pkgs/development/compilers/gcc-arm-embedded/6/default.nix b/pkgs/development/compilers/gcc-arm-embedded/6/default.nix
index 7d8a4b5b14d..266863d95b2 100644
--- a/pkgs/development/compilers/gcc-arm-embedded/6/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/6/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , ncurses5
 , python27
@@ -37,11 +37,11 @@ stdenv.mkDerivation rec {
     find $out -type f | while read f; do
       patchelf "$f" > /dev/null 2>&1 || continue
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
-      patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
+      patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
     homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
     license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ];
diff --git a/pkgs/development/compilers/gcc-arm-embedded/7/default.nix b/pkgs/development/compilers/gcc-arm-embedded/7/default.nix
index 633ae054d05..4f2135446f6 100644
--- a/pkgs/development/compilers/gcc-arm-embedded/7/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , ncurses5
 , python27
@@ -37,11 +37,11 @@ stdenv.mkDerivation rec {
     find $out -type f | while read f; do
       patchelf "$f" > /dev/null 2>&1 || continue
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
-      patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
+      patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
     homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
     license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ];
diff --git a/pkgs/development/compilers/gcc-arm-embedded/8/default.nix b/pkgs/development/compilers/gcc-arm-embedded/8/default.nix
index 99ec9d1b549..2d85113527c 100644
--- a/pkgs/development/compilers/gcc-arm-embedded/8/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/8/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , ncurses5
 , python27
@@ -37,11 +37,11 @@ stdenv.mkDerivation rec {
     find $out -type f | while read f; do
       patchelf "$f" > /dev/null 2>&1 || continue
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
-      patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
+      patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
     homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
     license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ];
diff --git a/pkgs/development/compilers/gcc-arm-embedded/9/default.nix b/pkgs/development/compilers/gcc-arm-embedded/9/default.nix
index c4c1ebc1d8a..944d7c7b159 100644
--- a/pkgs/development/compilers/gcc-arm-embedded/9/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/9/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , ncurses5
 , python27
@@ -39,11 +39,11 @@ stdenv.mkDerivation rec {
     find $out -type f | while read f; do
       patchelf "$f" > /dev/null 2>&1 || continue
       patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
-      patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
+      patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
     homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
     license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ];
diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix
index ecbe7c9eb4b..df718d8ba74 100644
--- a/pkgs/development/compilers/gcc/10/default.nix
+++ b/pkgs/development/compilers/gcc/10/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langAda ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
@@ -48,7 +48,7 @@ assert langAda -> gnatboot != null;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "10";
@@ -90,7 +90,7 @@ stdenv.mkDerivation ({
 
   inherit patches;
 
-  outputs = [ "out" "man" "info" ] ++ stdenv.lib.optional (!langJit) "lib";
+  outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib";
   setOutputFlags = false;
   NIX_NO_SELF_RPATH = true;
 
@@ -100,7 +100,7 @@ stdenv.mkDerivation ({
 
   # This should kill all the stdinc frameworks that gcc and friends like to
   # insert into default search paths.
-  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+  prePatch = lib.optionalString hostPlatform.isDarwin ''
     substituteInPlace gcc/config/darwin-c.c \
       --replace 'if (stdinc)' 'if (0)'
 
@@ -134,13 +134,13 @@ stdenv.mkDerivation ({
                  -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        + lib.optionalString (targetPlatform.libc == "musl")
         ''
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
     else "")
-      + stdenv.lib.optionalString targetPlatform.isAvr ''
+      + lib.optionalString targetPlatform.isAvr ''
             makeFlagsArray+=(
                'LIMITS_H_TEST=false'
             )
@@ -177,20 +177,21 @@ stdenv.mkDerivation ({
 
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
-  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+  NIX_LDFLAGS = lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform gnatboot langAda langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -262,7 +263,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -275,13 +276,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ synthetica ];
+    maintainers = with lib.maintainers; [ synthetica ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 3d2c754c6a2..69fdeefe87a 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
 , langObjCpp ? stdenv.targetPlatform.isDarwin
@@ -58,7 +58,7 @@ assert langGo -> langCC;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "4";
@@ -190,17 +190,18 @@ stdenv.mkDerivation ({
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform langJava langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -289,7 +290,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -302,13 +303,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ peti veprbl ];
+    maintainers = with lib.maintainers; [ peti veprbl ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
     badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index b3192e44cfe..4c0a144f14d 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
 , langObjCpp ? stdenv.targetPlatform.isDarwin
@@ -58,7 +58,7 @@ assert langGo -> langCC;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "4";
@@ -203,17 +203,18 @@ stdenv.mkDerivation ({
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform langJava langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -301,7 +302,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -314,13 +315,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ peti veprbl ];
+    maintainers = with lib.maintainers; [ peti veprbl ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
     badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index ed97e6a0ce8..50c920fee16 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, fetchFromGitHub, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, fetchFromGitHub, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langAda ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
@@ -61,7 +61,7 @@ assert langAda -> gnatboot != null;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "6";
@@ -148,7 +148,7 @@ stdenv.mkDerivation ({
   prePatch =
     # This should kill all the stdinc frameworks that gcc and friends like to
     # insert into default search paths.
-    stdenv.lib.optionalString hostPlatform.isDarwin ''
+    lib.optionalString hostPlatform.isDarwin ''
       substituteInPlace gcc/config/darwin-c.c \
         --replace 'if (stdinc)' 'if (0)'
 
@@ -177,7 +177,7 @@ stdenv.mkDerivation ({
                  -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        + lib.optionalString (targetPlatform.libc == "musl")
         ''
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
@@ -219,20 +219,21 @@ stdenv.mkDerivation ({
 
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
-  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+  NIX_LDFLAGS = lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform gnatboot langJava langAda langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -320,7 +321,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -333,13 +334,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ peti ];
+    maintainers = with lib.maintainers; [ peti ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 4bd776e6f8b..dc60bd7ddab 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
 , langObjCpp ? stdenv.targetPlatform.isDarwin
@@ -45,7 +45,7 @@ assert langGo -> langCC;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "7";
@@ -97,7 +97,7 @@ stdenv.mkDerivation ({
 
   inherit patches;
 
-  outputs = [ "out" "man" "info" ] ++ stdenv.lib.optional (!langJit) "lib";
+  outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib";
   setOutputFlags = false;
   NIX_NO_SELF_RPATH = true;
 
@@ -107,7 +107,7 @@ stdenv.mkDerivation ({
 
   # This should kill all the stdinc frameworks that gcc and friends like to
   # insert into default search paths.
-  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+  prePatch = lib.optionalString hostPlatform.isDarwin ''
     substituteInPlace gcc/config/darwin-c.c \
       --replace 'if (stdinc)' 'if (0)'
 
@@ -141,13 +141,13 @@ stdenv.mkDerivation ({
                  -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        + lib.optionalString (targetPlatform.libc == "musl")
         ''
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
     else "")
-      + stdenv.lib.optionalString targetPlatform.isAvr ''
+      + lib.optionalString targetPlatform.isAvr ''
         makeFlagsArray+=(
            'LIMITS_H_TEST=false'
         )
@@ -183,21 +183,22 @@ stdenv.mkDerivation ({
 
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument";
-  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+  NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument";
+  NIX_LDFLAGS = lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -272,7 +273,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -285,13 +286,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ ];
+    maintainers = with lib.maintainers; [ ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix
index d9234a75530..7b2d0d6fd72 100644
--- a/pkgs/development/compilers/gcc/8/default.nix
+++ b/pkgs/development/compilers/gcc/8/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
 , langObjCpp ? stdenv.targetPlatform.isDarwin
@@ -45,7 +45,7 @@ assert langGo -> langCC;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "8";
@@ -87,7 +87,7 @@ stdenv.mkDerivation ({
 
   inherit patches;
 
-  outputs = [ "out" "man" "info" ] ++ stdenv.lib.optional (!langJit) "lib";
+  outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib";
   setOutputFlags = false;
   NIX_NO_SELF_RPATH = true;
 
@@ -97,7 +97,7 @@ stdenv.mkDerivation ({
 
   # This should kill all the stdinc frameworks that gcc and friends like to
   # insert into default search paths.
-  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+  prePatch = lib.optionalString hostPlatform.isDarwin ''
     substituteInPlace gcc/config/darwin-c.c \
       --replace 'if (stdinc)' 'if (0)'
 
@@ -131,13 +131,13 @@ stdenv.mkDerivation ({
                  -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        + lib.optionalString (targetPlatform.libc == "musl")
         ''
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
     else "")
-      + stdenv.lib.optionalString targetPlatform.isAvr ''
+      + lib.optionalString targetPlatform.isAvr ''
             makeFlagsArray+=(
                'LIMITS_H_TEST=false'
             )
@@ -173,20 +173,21 @@ stdenv.mkDerivation ({
 
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
-  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+  NIX_LDFLAGS = lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform langGo;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -257,7 +258,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -270,13 +271,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ synthetica ];
+    maintainers = with lib.maintainers; [ synthetica ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix
index 40af21a1fa3..baa0741e80e 100644
--- a/pkgs/development/compilers/gcc/9/default.nix
+++ b/pkgs/development/compilers/gcc/9/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
+{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langAda ? false
 , langObjC ? stdenv.targetPlatform.isDarwin
@@ -54,7 +54,7 @@ assert langAda -> gnatboot != null;
 # threadsCross is just for MinGW
 assert threadsCross != null -> stdenv.targetPlatform.isWindows;
 
-with stdenv.lib;
+with lib;
 with builtins;
 
 let majorVersion = "9";
@@ -103,7 +103,7 @@ stdenv.mkDerivation ({
 
   inherit patches;
 
-  outputs = [ "out" "man" "info" ] ++ stdenv.lib.optional (!langJit) "lib";
+  outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib";
   setOutputFlags = false;
   NIX_NO_SELF_RPATH = true;
 
@@ -113,7 +113,7 @@ stdenv.mkDerivation ({
 
   # This should kill all the stdinc frameworks that gcc and friends like to
   # insert into default search paths.
-  prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
+  prePatch = lib.optionalString hostPlatform.isDarwin ''
     substituteInPlace gcc/config/darwin-c.c \
       --replace 'if (stdinc)' 'if (0)'
 
@@ -147,13 +147,13 @@ stdenv.mkDerivation ({
                  -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
            done
         ''
-        + stdenv.lib.optionalString (targetPlatform.libc == "musl")
+        + lib.optionalString (targetPlatform.libc == "musl")
         ''
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
     else "")
-      + stdenv.lib.optionalString targetPlatform.isAvr ''
+      + lib.optionalString targetPlatform.isAvr ''
           makeFlagsArray+=(
              'LIMITS_H_TEST=false'
           )
@@ -190,20 +190,21 @@ stdenv.mkDerivation ({
 
   depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
 
-  NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
+  NIX_LDFLAGS = lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
 
   preConfigure = import ../common/pre-configure.nix {
-    inherit (stdenv) lib;
+    inherit lib;
     inherit version hostPlatform gnatboot langAda langGo langJit;
   };
 
   dontDisableStatic = true;
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+  configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   configureFlags = import ../common/configure-flags.nix {
     inherit
+      lib
       stdenv
       targetPackages
       crossStageStatic libcCross
@@ -276,7 +277,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "https://gcc.gnu.org/";
-    license = stdenv.lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
+    license = lib.licenses.gpl3Plus;  # runtime support libraries are typically LGPLv3+
     description = "GNU Compiler Collection, version ${version}"
       + (if stripped then "" else " (with debugging info)");
 
@@ -289,13 +290,13 @@ stdenv.mkDerivation ({
       compiler used in the GNU system including the GNU/Linux variant.
     '';
 
-    maintainers = with stdenv.lib.maintainers; [ synthetica ];
+    maintainers = with lib.maintainers; [ synthetica ];
 
     platforms =
-      stdenv.lib.platforms.linux ++
-      stdenv.lib.platforms.freebsd ++
-      stdenv.lib.platforms.illumos ++
-      stdenv.lib.platforms.darwin;
+      lib.platforms.linux ++
+      lib.platforms.freebsd ++
+      lib.platforms.illumos ++
+      lib.platforms.darwin;
   };
 }
 
diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix
index 12d3f5d8987..3f1866713e6 100644
--- a/pkgs/development/compilers/gcc/common/configure-flags.nix
+++ b/pkgs/development/compilers/gcc/common/configure-flags.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , targetPackages
 
 , crossStageStatic, libcCross
@@ -24,8 +24,8 @@
 , langJit
 }:
 
-assert cloog != null -> stdenv.lib.versionOlder version "5";
-assert langJava -> stdenv.lib.versionOlder version "7";
+assert cloog != null -> lib.versionOlder version "5";
+assert langJava -> lib.versionOlder version "7";
 
 # Note [Windows Exception Handling]
 # sjlj (short jump long jump) exception handling makes no sense on x86_64,
@@ -171,7 +171,7 @@ let
     ++ lib.optional javaAwtGtk "--enable-java-awt=gtk"
     ++ lib.optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}"
 
-    ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; })
+    ++ (import ../common/platform-flags.nix { inherit (stdenv)  targetPlatform; inherit lib; })
     ++ lib.optionals (targetPlatform != hostPlatform) crossConfigureFlags
     ++ lib.optional (targetPlatform != hostPlatform) "--disable-bootstrap"
 
diff --git a/pkgs/development/compilers/gcc/common/extra-target-flags.nix b/pkgs/development/compilers/gcc/common/extra-target-flags.nix
index 0a5a7a1bc1c..6ced56cedc0 100644
--- a/pkgs/development/compilers/gcc/common/extra-target-flags.nix
+++ b/pkgs/development/compilers/gcc/common/extra-target-flags.nix
@@ -11,7 +11,7 @@ in
   EXTRA_FLAGS_FOR_TARGET = let
       mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([
         "-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
-      ] ++ stdenv.lib.optionals (! crossStageStatic) [
+      ] ++ lib.optionals (! crossStageStatic) [
         "-B${lib.getLib dep}${dep.libdir or "/lib"}"
       ]);
     in mkFlags libcCross langD
diff --git a/pkgs/development/compilers/gcl/2.6.13-pre.nix b/pkgs/development/compilers/gcl/2.6.13-pre.nix
index f4f63bc9b19..50efbe5d3c5 100644
--- a/pkgs/development/compilers/gcl/2.6.13-pre.nix
+++ b/pkgs/development/compilers/gcl/2.6.13-pre.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, mpfr, m4, binutils, emacs, zlib, which
+{ lib, stdenv, fetchgit, mpfr, m4, binutils, emacs, zlib, which
 , texinfo, libX11, xorgproto, libXi, gmp, readline, strace
 , libXext, libXt, libXaw, libXmu } :
 
@@ -45,7 +45,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "GNU Common Lisp compiler working via GCC";
-    maintainers = [ stdenv.lib.maintainers.raskin ];
-    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ lib.maintainers.raskin ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/gcl/default.nix b/pkgs/development/compilers/gcl/default.nix
index a8a1bf9fc1b..6d0471dacbb 100644
--- a/pkgs/development/compilers/gcl/default.nix
+++ b/pkgs/development/compilers/gcl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, mpfr, m4, binutils, emacs, zlib, which
+{ lib, stdenv, fetchurl, mpfr, m4, binutils, emacs, zlib, which
 , texinfo, libX11, xorgproto, libXi, gmp
 , libXext, libXt, libXaw, libXmu } :
 
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
 
   NIX_CFLAGS_COMPILE = "-fgnu89-inline";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "GNU Common Lisp compiler working via GCC";
     maintainers = [ maintainers.raskin ];
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/gforth/default.nix b/pkgs/development/compilers/gforth/default.nix
index d2a2a7a85e3..bdf172cb9b9 100644
--- a/pkgs/development/compilers/gforth/default.nix
+++ b/pkgs/development/compilers/gforth/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, m4 }:
+{ lib, stdenv, fetchurl, m4 }:
 
 let
   version = "0.7.3";
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
 
   buildInputs = [ m4 ];
 
-  configureFlags = stdenv.lib.optional stdenv.isDarwin [ "--build=x86_64-apple-darwin" ];
+  configureFlags = lib.optional stdenv.isDarwin [ "--build=x86_64-apple-darwin" ];
 
   postInstall = ''
     mkdir -p $out/share/emacs/site-lisp
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
   meta = {
     description = "The Forth implementation of the GNU project";
     homepage = "https://www.gnu.org/software/gforth/";
-    license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/ghc/8.10.1.nix b/pkgs/development/compilers/ghc/8.10.1.nix
index ce963e1c275..661dd5cb002 100644
--- a/pkgs/development/compilers/ghc/8.10.1.nix
+++ b/pkgs/development/compilers/ghc/8.10.1.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -35,7 +35,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -51,7 +51,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -69,32 +69,32 @@ let
     # to actually link to our new Libc. The iOS simulator is a special
     # exception because we can’t actually run simulators binaries
     # ourselves.
-  + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString dontStrip ''
+  '' + lib.optionalString dontStrip ''
     STRIP_CMD = :
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -128,7 +128,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -138,13 +138,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK dontStrip}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -164,29 +164,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -207,18 +207,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -228,7 +228,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -245,14 +245,14 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
   dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
   dontPatchELF = true;
   noAuditTmpdir = true;
 })
diff --git a/pkgs/development/compilers/ghc/8.10.2-binary.nix b/pkgs/development/compilers/ghc/8.10.2-binary.nix
index 1a1a9ca0160..02373d00b10 100644
--- a/pkgs/development/compilers/ghc/8.10.2-binary.nix
+++ b/pkgs/development/compilers/ghc/8.10.2-binary.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl, perl, gcc
 , ncurses6, gmp, glibc, libiconv, numactl
 , llvmPackages
@@ -16,12 +16,12 @@ assert stdenv.targetPlatform == stdenv.hostPlatform;
 let
   useLLVM = !stdenv.targetPlatform.isx86;
 
-  libPath = stdenv.lib.makeLibraryPath ([
+  libPath = lib.makeLibraryPath ([
     ncurses6 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isAarch64) numactl);
+  ] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv
+    ++ lib.optional (stdenv.hostPlatform.isAarch64) numactl);
 
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+  libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
     + "LD_LIBRARY_PATH";
 
   glibcDynLinker = assert stdenv.isLinux;
@@ -29,7 +29,7 @@ let
        # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
        ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
     else
-      "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+      "${lib.getLib glibc}/lib/ld-linux*";
 
 in
 
@@ -64,7 +64,7 @@ stdenv.mkDerivation rec {
     or (throw "cannot bootstrap GHC on this platform"));
 
   nativeBuildInputs = [ perl ];
-  propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+  propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ];
 
   # Cannot patchelf beforehand due to relative RPATHs that anticipate
   # the final install location/
@@ -73,7 +73,7 @@ stdenv.mkDerivation rec {
   postUnpack =
     # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
     # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
+    lib.optionalString stdenv.isDarwin ''
       export NIX_LDFLAGS+=" -no_dtrace_dof"
       # not enough room in the object files for the full path to libiconv :(
       for exe in $(find . -type f -executable); do
@@ -92,20 +92,20 @@ stdenv.mkDerivation rec {
     ''
       find . -name integer-gmp.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    '' + lib.optionalString stdenv.isDarwin ''
       find . -name base.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
     '' +
     # aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
     # FFI_LIB_DIR is a good indication of places it must be needed.
-    stdenv.lib.optionalString stdenv.hostPlatform.isAarch64 ''
+    lib.optionalString stdenv.hostPlatform.isAarch64 ''
       find . -name package.conf.in \
           -exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
     '' +
     # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
+    lib.optionalString stdenv.isLinux ''
       find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.6 libncurses.so \
+          --replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.6 libncurses.so \
           --interpreter ${glibcDynLinker} {} \;
 
       sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
@@ -117,21 +117,21 @@ stdenv.mkDerivation rec {
     # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
     # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
     # Use objcopy magic to make the change:
-    stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    lib.optionalString stdenv.hostPlatform.isMusl ''
       find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
     '';
 
   # fix for `configure: error: Your linker is affected by binutils #16177`
-  preConfigure = stdenv.lib.optionalString
+  preConfigure = lib.optionalString
     stdenv.targetPlatform.isAarch32
     "LD=ld.gold";
 
   configurePlatforms = [ ];
   configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+    "--with-gmp-libraries=${lib.getLib gmp}/lib"
+    "--with-gmp-includes=${lib.getDev gmp}/include"
+  ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
+    ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
 
   # No building is necessary, but calling make without flags ironically
   # calls install-strip ...
@@ -139,7 +139,7 @@ stdenv.mkDerivation rec {
 
   # On Linux, use patchelf to modify the executables so that they can
   # find editline/gmp.
-  postFixup = stdenv.lib.optionalString stdenv.isLinux
+  postFixup = lib.optionalString stdenv.isLinux
     (if stdenv.hostPlatform.isAarch64 then
       # Keep rpath as small as possible on aarch64 for patchelf#244.  All Elfs
       # are 2 directories deep from $out/lib, so pooling symlinks there makes
@@ -167,7 +167,7 @@ stdenv.mkDerivation rec {
           patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
         fi
       done
-    '') + stdenv.lib.optionalString stdenv.isDarwin ''
+    '') + lib.optionalString stdenv.isDarwin ''
     # not enough room in the object files for the full path to libiconv :(
     for exe in $(find "$out" -type f -executable); do
       isScript $exe && continue
@@ -179,7 +179,7 @@ stdenv.mkDerivation rec {
       substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
     done
   '' +
-  stdenv.lib.optionalString minimal ''
+  lib.optionalString minimal ''
     # Remove profiling files
     find $out -type f -name '*.p_o' -delete
     find $out -type f -name '*.p_hi' -delete
@@ -215,8 +215,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    license = stdenv.lib.licenses.bsd3;
+    license = lib.licenses.bsd3;
     platforms = ["x86_64-linux" "armv7l-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
-    maintainers = with stdenv.lib.maintainers; [ lostnet ];
+    maintainers = with lib.maintainers; [ lostnet ];
   };
 }
diff --git a/pkgs/development/compilers/ghc/8.10.2.nix b/pkgs/development/compilers/ghc/8.10.2.nix
index fac12099d5d..6e194b68faa 100644
--- a/pkgs/development/compilers/ghc/8.10.2.nix
+++ b/pkgs/development/compilers/ghc/8.10.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -35,7 +35,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -51,7 +51,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -62,30 +62,30 @@ let
     endif
     DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
     INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
-  '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  '' + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -110,7 +110,7 @@ stdenv.mkDerivation (rec {
   # https://gitlab.haskell.org/ghc/ghc/-/issues/18549
   patches = [
     ./issue-18549.patch
-  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.isDarwin [
     # Make Block.h compile with c++ compilers. Remove with the next release
     (fetchpatch {
       url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
@@ -130,7 +130,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -140,13 +140,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -166,29 +166,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -209,18 +209,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -230,7 +230,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -247,12 +247,12 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
   dontStrip = true;
   dontPatchELF = true;
   noAuditTmpdir = true;
diff --git a/pkgs/development/compilers/ghc/8.10.3.nix b/pkgs/development/compilers/ghc/8.10.3.nix
index c24b72fb43b..582817cca07 100644
--- a/pkgs/development/compilers/ghc/8.10.3.nix
+++ b/pkgs/development/compilers/ghc/8.10.3.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -35,7 +35,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -51,7 +51,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -62,30 +62,30 @@ let
     endif
     DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
     INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
-  '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  '' + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -107,7 +107,7 @@ stdenv.mkDerivation (rec {
 
   outputs = [ "out" "doc" ];
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [
+  patches = lib.optionals stdenv.isDarwin [
     # Make Block.h compile with c++ compilers. Remove with the next release
     (fetchpatch {
       url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
@@ -127,7 +127,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -137,13 +137,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -163,29 +163,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -206,18 +206,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -227,7 +227,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -244,12 +244,12 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
   dontStrip = true;
   dontPatchELF = true;
   noAuditTmpdir = true;
diff --git a/pkgs/development/compilers/ghc/8.2.2-binary.nix b/pkgs/development/compilers/ghc/8.2.2-binary.nix
index 9f546bcb541..5f83c2b2afc 100644
--- a/pkgs/development/compilers/ghc/8.2.2-binary.nix
+++ b/pkgs/development/compilers/ghc/8.2.2-binary.nix
@@ -1,4 +1,4 @@
-{ stdenv, substituteAll
+{ lib, stdenv, substituteAll
 , fetchurl, perl, gcc, llvm
 , ncurses5, gmp, glibc, libiconv
 , llvmPackages
@@ -10,11 +10,11 @@ assert stdenv.targetPlatform == stdenv.hostPlatform;
 let
   useLLVM = !stdenv.targetPlatform.isx86;
 
-  libPath = stdenv.lib.makeLibraryPath ([
+  libPath = lib.makeLibraryPath ([
     ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
+  ] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
 
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+  libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
     + "LD_LIBRARY_PATH";
 
   glibcDynLinker = assert stdenv.isLinux;
@@ -22,7 +22,7 @@ let
        # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
        ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
     else
-      "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+      "${lib.getLib glibc}/lib/ld-linux*";
 
 in
 
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
     or (throw "cannot bootstrap GHC on this platform"));
 
   nativeBuildInputs = [ perl ];
-  propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+  propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ];
 
   # Cannot patchelf beforehand due to relative RPATHs that anticipate
   # the final install location/
@@ -65,7 +65,7 @@ stdenv.mkDerivation rec {
   postUnpack =
     # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
     # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
+    lib.optionalString stdenv.isDarwin ''
       export NIX_LDFLAGS+=" -no_dtrace_dof"
       # not enough room in the object files for the full path to libiconv :(
       for exe in $(find . -type f -executable); do
@@ -97,14 +97,14 @@ stdenv.mkDerivation rec {
     ''
       find . -name integer-gmp.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    '' + lib.optionalString stdenv.isDarwin ''
       find . -name base.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
     '' +
     # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
+    lib.optionalString stdenv.isLinux ''
       find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
+          --replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
           --replace-needed libtinfo.so libtinfo.so.5 \
           --interpreter ${glibcDynLinker} {} \;
 
@@ -117,7 +117,7 @@ stdenv.mkDerivation rec {
     # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
     # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
     # Use objcopy magic to make the change:
-    stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    lib.optionalString stdenv.hostPlatform.isMusl ''
       find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
     '';
 
@@ -130,10 +130,10 @@ stdenv.mkDerivation rec {
       src = ./gcc-clang-wrapper.sh;
     };
   in
-  [ "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin            "--with-gcc=${gcc-clang-wrapper}"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+  [ "--with-gmp-libraries=${lib.getLib gmp}/lib"
+    "--with-gmp-includes=${lib.getDev gmp}/include"
+  ] ++ lib.optional stdenv.isDarwin            "--with-gcc=${gcc-clang-wrapper}"
+    ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
 
   # Stripping combined with patchelf breaks the executables (they die
   # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
@@ -145,14 +145,14 @@ stdenv.mkDerivation rec {
 
   # On Linux, use patchelf to modify the executables so that they can
   # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
+  preFixup = lib.optionalString stdenv.isLinux ''
     for p in $(find "$out" -type f -executable); do
       if isELF "$p"; then
         echo "Patchelfing $p"
         patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
       fi
     done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     # not enough room in the object files for the full path to libiconv :(
     for exe in $(find "$out" -type f -executable); do
       isScript $exe && continue
@@ -186,6 +186,6 @@ stdenv.mkDerivation rec {
     enableShared = true;
   };
 
-  meta.license = stdenv.lib.licenses.bsd3;
+  meta.license = lib.licenses.bsd3;
   meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"];
 }
diff --git a/pkgs/development/compilers/ghc/8.6.5-binary.nix b/pkgs/development/compilers/ghc/8.6.5-binary.nix
index 9234e3b1457..ca984c36957 100644
--- a/pkgs/development/compilers/ghc/8.6.5-binary.nix
+++ b/pkgs/development/compilers/ghc/8.6.5-binary.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl, perl, gcc
 , ncurses5, ncurses6, gmp, glibc, libiconv
 , llvmPackages
@@ -14,11 +14,11 @@ let
 
   ourNcurses = if useNcurses6 then ncurses6 else ncurses5;
 
-  libPath = stdenv.lib.makeLibraryPath ([
+  libPath = lib.makeLibraryPath ([
     ourNcurses gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
+  ] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
 
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+  libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
     + "LD_LIBRARY_PATH";
 
   glibcDynLinker = assert stdenv.isLinux;
@@ -26,7 +26,7 @@ let
        # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
        ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
     else
-      "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+      "${lib.getLib glibc}/lib/ld-linux*";
 
 in
 
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     or (throw "cannot bootstrap GHC on this platform"));
 
   nativeBuildInputs = [ perl ];
-  propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+  propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ];
 
   # Cannot patchelf beforehand due to relative RPATHs that anticipate
   # the final install location/
@@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
   postUnpack =
     # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
     # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
+    lib.optionalString stdenv.isDarwin ''
       export NIX_LDFLAGS+=" -no_dtrace_dof"
       # not enough room in the object files for the full path to libiconv :(
       for exe in $(find . -type f -executable); do
@@ -90,17 +90,17 @@ stdenv.mkDerivation rec {
     ''
       find . -name integer-gmp.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    '' + lib.optionalString stdenv.isDarwin ''
       find . -name base.buildinfo \
           -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
     '' +
     # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
+    lib.optionalString stdenv.isLinux ''
       find . -type f -perm -0100 \
           -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
+          --replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
           ${ # This isn't required for x86_64-linux where we use ncurses6
-             stdenv.lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
+             lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
            } \
           --interpreter ${glibcDynLinker} {} \;
 
@@ -113,16 +113,16 @@ stdenv.mkDerivation rec {
     # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
     # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
     # Use objcopy magic to make the change:
-    stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    lib.optionalString stdenv.hostPlatform.isMusl ''
       find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
     '';
 
   configurePlatforms = [ ];
   configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+    "--with-gmp-libraries=${lib.getLib gmp}/lib"
+    "--with-gmp-includes=${lib.getDev gmp}/include"
+  ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
+    ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
 
   # No building is necessary, but calling make without flags ironically
   # calls install-strip ...
@@ -130,14 +130,14 @@ stdenv.mkDerivation rec {
 
   # On Linux, use patchelf to modify the executables so that they can
   # find editline/gmp.
-  postFixup = stdenv.lib.optionalString stdenv.isLinux ''
+  postFixup = lib.optionalString stdenv.isLinux ''
     for p in $(find "$out" -type f -executable); do
       if isELF "$p"; then
         echo "Patchelfing $p"
         patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
       fi
     done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     # not enough room in the object files for the full path to libiconv :(
     for exe in $(find "$out" -type f -executable); do
       isScript $exe && continue
@@ -171,6 +171,6 @@ stdenv.mkDerivation rec {
     enableShared = true;
   };
 
-  meta.license = stdenv.lib.licenses.bsd3;
+  meta.license = lib.licenses.bsd3;
   meta.platforms = ["x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
 }
diff --git a/pkgs/development/compilers/ghc/8.6.5.nix b/pkgs/development/compilers/ghc/8.6.5.nix
index 7adacff597c..219ace5a916 100644
--- a/pkgs/development/compilers/ghc/8.6.5.nix
+++ b/pkgs/development/compilers/ghc/8.6.5.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -32,7 +32,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -48,7 +48,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -66,28 +66,28 @@ let
     # to actually link to our new Libc. The iOS simulator is a special
     # exception because we can’t actually run simulators binaries
     # ourselves.
-  + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -136,7 +136,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -146,13 +146,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -172,23 +172,23 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -209,14 +209,14 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   # See #63511 - the only unstripped file is the debug rts which isn't meant to
   # be stripped.
@@ -224,7 +224,7 @@ stdenv.mkDerivation (rec {
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -234,11 +234,11 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   ''
   # Temporary work-around for https://github.com/NixOS/nixpkgs/issues/66277
-  + stdenv.lib.optionalString hostPlatform.isAarch64 ''
+  + lib.optionalString hostPlatform.isAarch64 ''
     rm -rf "$doc/share/doc/ghc/html/libraries"
   '';
 
@@ -255,12 +255,12 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
   dontStrip = true;
   dontPatchELF = true;
   noAuditTmpdir = true;
diff --git a/pkgs/development/compilers/ghc/8.8.2.nix b/pkgs/development/compilers/ghc/8.8.2.nix
index 8663f16f023..94553e56a81 100644
--- a/pkgs/development/compilers/ghc/8.8.2.nix
+++ b/pkgs/development/compilers/ghc/8.8.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -32,7 +32,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -48,7 +48,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -66,30 +66,30 @@ let
     # to actually link to our new Libc. The iOS simulator is a special
     # exception because we can’t actually run simulators binaries
     # ourselves.
-  + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString dontStrip ''
+  '' + lib.optionalString dontStrip ''
     STRIP_CMD = :
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -123,7 +123,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -133,13 +133,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK dontStrip}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -159,29 +159,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -202,18 +202,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -223,7 +223,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -240,14 +240,14 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
   dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
   dontPatchELF = true;
   noAuditTmpdir = true;
 })
diff --git a/pkgs/development/compilers/ghc/8.8.3.nix b/pkgs/development/compilers/ghc/8.8.3.nix
index deb19bb87b5..ca4dc35ccdc 100644
--- a/pkgs/development/compilers/ghc/8.8.3.nix
+++ b/pkgs/development/compilers/ghc/8.8.3.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -35,7 +35,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -51,7 +51,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -69,32 +69,32 @@ let
     # to actually link to our new Libc. The iOS simulator is a special
     # exception because we can’t actually run simulators binaries
     # ourselves.
-  + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString dontStrip ''
+  '' + lib.optionalString dontStrip ''
     STRIP_CMD = :
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -128,7 +128,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -138,13 +138,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK dontStrip}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -164,29 +164,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -207,18 +207,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -228,7 +228,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -245,14 +245,14 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
   dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
   dontPatchELF = true;
   noAuditTmpdir = true;
 })
diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix
index c1b39a70e38..ab5f2c12e23 100644
--- a/pkgs/development/compilers/ghc/8.8.4.nix
+++ b/pkgs/development/compilers/ghc/8.8.4.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -18,7 +18,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -35,7 +35,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -51,7 +51,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -69,32 +69,32 @@ let
     # to actually link to our new Libc. The iOS simulator is a special
     # exception because we can’t actually run simulators binaries
     # ourselves.
-  + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString dontStrip ''
+  '' + lib.optionalString dontStrip ''
     STRIP_CMD = :
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -119,7 +119,7 @@ stdenv.mkDerivation (rec {
   postPatch = "patchShebangs .";
 
   # GHC is a bit confused on its cross terminology.
-  preConfigure = stdenv.lib.optionalString stdenv.isAarch64 ''
+  preConfigure = lib.optionalString stdenv.isAarch64 ''
     # Aarch64 allow backward bootstrapping since earlier versions are unstable.
     find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
       -exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
@@ -132,7 +132,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -142,13 +142,13 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK dontStrip}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -168,29 +168,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -211,18 +211,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -232,7 +232,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -249,14 +249,14 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
   dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
   dontPatchELF = true;
   noAuditTmpdir = true;
 })
diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix
index d86cce9849c..39abe9c760e 100644
--- a/pkgs/development/compilers/ghc/9.0.1.nix
+++ b/pkgs/development/compilers/ghc/9.0.1.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -19,7 +19,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+  enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
@@ -36,7 +36,7 @@
 
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -52,7 +52,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -63,30 +63,30 @@ let
     endif
     DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
     INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
-  '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  '' + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+    ++ lib.optional (!enableIntegerSimple) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -123,7 +123,7 @@ stdenv.mkDerivation (rec {
     export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -133,15 +133,15 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (stdenv.isLinux) ''
+  '' + lib.optionalString (stdenv.isLinux) ''
     export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -161,29 +161,29 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+  ] ++ lib.optionals (disableLargeAddressSpace) [
     "--disable-large-address-space"
   ];
 
@@ -204,18 +204,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -225,7 +225,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -242,12 +242,12 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     timeout = 24 * 3600;
     inherit (ghc.meta) license platforms;
   };
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
   dontStrip = true;
   dontPatchELF = true;
   noAuditTmpdir = true;
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index c203f5cf19c..3ba88763117 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -1,4 +1,4 @@
-{ stdenv, pkgsBuildTarget, targetPackages
+{ lib, stdenv, pkgsBuildTarget, targetPackages
 
 # build-tools
 , bootPkgs
@@ -22,7 +22,7 @@
 
 , # If enabled, GHC will be built with the GPL-free but slightly slower native
   # bignum backend instead of the faster but GPLed gmp backend.
-  enableNativeBignum ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms)
+  enableNativeBignum ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms)
 , gmp
 
 , # If enabled, use -fPIC when compiling static libs.
@@ -41,7 +41,7 @@
 , version ? "8.11.20200824"
 , # What flavour to build. An empty string indicates no
   # specific flavour and falls back to ghc default values.
-  ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+  ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
     (if useLLVM then "perf-cross" else "perf-cross-ncg")
 
 , # Whether to disable the large address space allocator
@@ -57,7 +57,7 @@ let
   inherit (bootPkgs) ghc;
 
   # TODO(@Ericson2314) Make unconditional
-  targetPrefix = stdenv.lib.optionalString
+  targetPrefix = lib.optionalString
     (targetPlatform != hostPlatform)
     "${targetPlatform.config}-";
 
@@ -68,33 +68,33 @@ let
     endif
     DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
     BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
-  '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+  '' + lib.optionalString (targetPlatform != hostPlatform) ''
     Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
     CrossCompilePrefix = ${targetPrefix}
     HADDOCK_DOCS = NO
     BUILD_SPHINX_HTML = NO
     BUILD_SPHINX_PDF = NO
-  '' + stdenv.lib.optionalString dontStrip ''
+  '' + lib.optionalString dontStrip ''
     STRIP_CMD = :
-  '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+  '' + lib.optionalString (!enableProfiledLibs) ''
     GhcLibWays = "v dyn"
-  '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+  '' + lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
-  libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+  libDeps = platform: lib.optional enableTerminfo ncurses
     ++ [libffi]
-    ++ stdenv.lib.optional (!enableNativeBignum) gmp
-    ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
-    ++ stdenv.lib.optional enableDwarf elfutils;
+    ++ lib.optional (!enableNativeBignum) gmp
+    ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
+    ++ lib.optional enableDwarf elfutils;
 
   toolsForTarget = [
     pkgsBuildTarget.targetPackages.stdenv.cc
-  ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+  ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
 
   targetCC = builtins.head toolsForTarget;
 
@@ -131,7 +131,7 @@ stdenv.mkDerivation (rec {
     export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
     # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
     # and more generally have a faster linker.
-    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+    export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
     export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
     export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
     export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -144,13 +144,13 @@ stdenv.mkDerivation (rec {
     echo ${src.rev} > GIT_COMMIT_ID
     ./boot
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+  '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
     sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
-  '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+  '' + lib.optionalString targetPlatform.isMusl ''
       echo "patching llvm-targets for musl targets..."
       echo "Cloning these existing '*-linux-gnu*' targets:"
       grep linux-gnu llvm-targets | sed 's/^/  /'
@@ -170,33 +170,33 @@ stdenv.mkDerivation (rec {
 
   # TODO(@Ericson2314): Always pass "--target" and always prefix.
   configurePlatforms = [ "build" "host" ]
-    ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+    ++ lib.optional (targetPlatform != hostPlatform) "target";
 
   # `--with` flags for libraries needed for RTS linker
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ stdenv.lib.optionals (libffi != null) [
+  ] ++ lib.optionals (libffi != null) [
     "--with-system-libffi"
     "--with-ffi-includes=${targetPackages.libffi.dev}/include"
     "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+  ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
     "--with-iconv-includes=${libiconv}/include"
     "--with-iconv-libraries=${libiconv}/lib"
-  ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+  ] ++ lib.optionals (targetPlatform != hostPlatform) [
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ stdenv.lib.optionals useLdGold [
+  ] ++ lib.optionals useLdGold [
     "CFLAGS=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
     "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
-  ] ++ stdenv.lib.optional disableLargeAddressSpace "--disable-large-address-space"
-    ++ stdenv.lib.optionals enableDwarf [
+  ] ++ lib.optional disableLargeAddressSpace "--disable-large-address-space"
+    ++ lib.optionals enableDwarf [
     "--enable-dwarf-unwind"
-    "--with-libdw-includes=${stdenv.lib.getDev elfutils}/include"
-    "--with-libdw-libraries=${stdenv.lib.getLib elfutils}/lib"
+    "--with-libdw-includes=${lib.getDev elfutils}/include"
+    "--with-libdw-libraries=${lib.getLib elfutils}/lib"
   ];
 
   # Make sure we never relax`$PATH` and hooks support for compatibility.
@@ -216,18 +216,18 @@ stdenv.mkDerivation (rec {
   buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
 
   propagatedBuildInputs = [ targetPackages.stdenv.cc ]
-    ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+    ++ lib.optional useLLVM llvmPackages.llvm;
 
-  depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+  depsTargetTarget = map lib.getDev (libDeps targetPlatform);
+  depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+  stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+  hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
 
   postInstall = ''
     # Install the bash completion file.
@@ -237,7 +237,7 @@ stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -254,13 +254,13 @@ stdenv.mkDerivation (rec {
   meta = {
     homepage = "http://haskell.org/ghc";
     description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+    maintainers = with lib.maintainers; [ marcweber andres peti ];
     inherit (ghc.meta) license platforms;
   };
 
   dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
 
-} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
   dontPatchELF = true;
   noAuditTmpdir = true;
 })
diff --git a/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix b/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix
index b957a6aa9e1..88630f996a9 100644
--- a/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix
+++ b/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix
@@ -55,7 +55,7 @@
         websockets yaml
       ];
       description = "Haskell to JavaScript compiler";
-      license = stdenv.lib.licenses.mit;
+      license = lib.licenses.mit;
     }) {};
 
   ghc-api-ghcjs = callPackage
@@ -76,7 +76,7 @@
       libraryToolDepends = [ alex happy ];
       homepage = "http://www.haskell.org/ghc/";
       description = "The GHC API (customized for GHCJS)";
-      license = stdenv.lib.licenses.bsd3;
+      license = lib.licenses.bsd3;
     }) {};
 
   ghci-ghcjs = callPackage
@@ -93,7 +93,7 @@
         ghc-boot-th ghc-heap template-haskell-ghcjs transformers unix
       ];
       description = "The library supporting GHC's interactive interpreter (customized for GHCJS)";
-      license = stdenv.lib.licenses.bsd3;
+      license = lib.licenses.bsd3;
     }) {};
 
   ghcjs-th = callPackage
@@ -109,7 +109,7 @@
         template-haskell-ghcjs
       ];
       homepage = "http://github.com/ghcjs";
-      license = stdenv.lib.licenses.mit;
+      license = lib.licenses.mit;
     }) {};
 
   haddock-api-ghcjs = callPackage
@@ -136,7 +136,7 @@
       testToolDepends = [ hspec-discover ];
       homepage = "http://www.haskell.org/haddock/";
       description = "A documentation-generation tool for Haskell libraries";
-      license = stdenv.lib.licenses.bsd3;
+      license = lib.licenses.bsd3;
     }) {};
 
   haddock-library-ghcjs = callPackage
@@ -160,7 +160,7 @@
       testToolDepends = [ hspec-discover ];
       homepage = "http://www.haskell.org/haddock/";
       description = "Library exposing some functionality of Haddock";
-      license = stdenv.lib.licenses.bsd3;
+      license = lib.licenses.bsd3;
     }) {};
 
   template-haskell-ghcjs = callPackage
@@ -171,7 +171,7 @@
       src = configuredSrc + /lib/template-haskell-ghcjs;
       libraryHaskellDepends = [ base ghc-boot-th pretty ];
       description = "Support library for Template Haskell (customized for GHCJS)";
-      license = stdenv.lib.licenses.bsd3;
+      license = lib.licenses.bsd3;
     }) {};
 
 }
diff --git a/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix b/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix
index 7c10ce6572f..82c37bd8617 100644
--- a/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix
+++ b/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix
@@ -25,5 +25,5 @@ mkDerivation {
   ];
   homepage = "https://github.com/ghcjs/ghcjs-base";
   description = "base library for GHCJS";
-  license = stdenv.lib.licenses.mit;
+  license = lib.licenses.mit;
 }
diff --git a/pkgs/development/compilers/gleam/default.nix b/pkgs/development/compilers/gleam/default.nix
index b2529986f6e..b9c7e7e1e3d 100644
--- a/pkgs/development/compilers/gleam/default.nix
+++ b/pkgs/development/compilers/gleam/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, rustPlatform, fetchFromGitHub, pkg-config, openssl, Security }:
+{ lib, stdenv, rustPlatform, fetchFromGitHub, pkg-config, openssl, Security }:
 
 rustPlatform.buildRustPackage rec {
   pname = "gleam";
@@ -14,11 +14,11 @@ rustPlatform.buildRustPackage rec {
   nativeBuildInputs = [ pkg-config ];
 
   buildInputs = [ openssl ] ++
-    stdenv.lib.optionals stdenv.isDarwin [ Security ];
+    lib.optionals stdenv.isDarwin [ Security ];
 
   cargoSha256 = "sha256-/l54ezS68loljKNh7AdYMIuCiyIbsMI3jqD9ktjZLfc=";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A statically typed language for the Erlang VM";
     homepage = "https://gleam.run/";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/glslang/default.nix b/pkgs/development/compilers/glslang/default.nix
index 3fb9e107356..0cfb2502a0d 100644
--- a/pkgs/development/compilers/glslang/default.nix
+++ b/pkgs/development/compilers/glslang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , bison
 , cmake
@@ -71,7 +71,7 @@ stdenv.mkDerivation rec {
     fi
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     inherit (src.meta) homepage;
     description = "Khronos reference front-end for GLSL and ESSL";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/gnatboot/default.nix b/pkgs/development/compilers/gnatboot/default.nix
index cb643d6123a..d97298d0238 100644
--- a/pkgs/development/compilers/gnatboot/default.nix
+++ b/pkgs/development/compilers/gnatboot/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "gentoo-gnatboot";
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
     langAda = true;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://gentoo.org";
     license = licenses.gpl3Plus;
     maintainers = [ maintainers.lucus16 ];
diff --git a/pkgs/development/compilers/gnu-cobol/default.nix b/pkgs/development/compilers/gnu-cobol/default.nix
index 146af98093d..e208f262ebe 100644
--- a/pkgs/development/compilers/gnu-cobol/default.nix
+++ b/pkgs/development/compilers/gnu-cobol/default.nix
@@ -1,9 +1,8 @@
-{ stdenv, fetchurl, gcc, makeWrapper
+{ lib, stdenv, fetchurl, gcc, makeWrapper
 , db, gmp, ncurses }:
 
 let
   version = "2.2";
-  lib = stdenv.lib;
 in
 stdenv.mkDerivation rec {
   pname = "gnu-cobol";
@@ -18,19 +17,19 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ db gmp ncurses ];
 
-  cflags  = stdenv.lib.concatMapStringsSep " " (p: "-L" + (lib.getLib p) + "/lib ") buildInputs;
-  ldflags = stdenv.lib.concatMapStringsSep " " (p: "-I" + (lib.getDev p) + "/include ") buildInputs;
+  cflags  = lib.concatMapStringsSep " " (p: "-L" + (lib.getLib p) + "/lib ") buildInputs;
+  ldflags = lib.concatMapStringsSep " " (p: "-I" + (lib.getDev p) + "/include ") buildInputs;
 
   cobolCCFlags = "-I$out/include ${ldflags} -L$out/lib ${cflags}";
 
-  postInstall = with stdenv.lib; ''
+  postInstall = with lib; ''
     wrapProgram "$out/bin/cobc" \
       --set COB_CC "${gcc}/bin/gcc" \
       --prefix COB_LDFLAGS " " "${cobolCCFlags}" \
       --prefix COB_CFLAGS " " "${cobolCCFlags}"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An open-source COBOL compiler";
     homepage = "https://sourceforge.net/projects/open-cobol/";
     license = licenses.gpl3;
diff --git a/pkgs/development/compilers/gnu-smalltalk/default.nix b/pkgs/development/compilers/gnu-smalltalk/default.nix
index e06c16058d1..cd33baad993 100644
--- a/pkgs/development/compilers/gnu-smalltalk/default.nix
+++ b/pkgs/development/compilers/gnu-smalltalk/default.nix
@@ -1,4 +1,4 @@
-{ config, stdenv, fetchurl, pkg-config, libtool
+{ config, lib, stdenv, fetchurl, pkg-config, libtool
 , zip, libffi, libsigsegv, readline, gmp
 , gnutls, gnome2, cairo, SDL, sqlite
 , emacsSupport ? config.emacsSupport or false, emacs ? null }:
@@ -11,7 +11,7 @@ let # The gnu-smalltalk project has a dependency to the libsigsegv library.
     # Adding --enable-static=libsigsegv to the gnu-smalltalk configuration flags
     # does not help, the error still occurs. The only solution is to build a
     # shared version of libsigsegv.
-    libsigsegv-shared = stdenv.lib.overrideDerivation libsigsegv (oldAttrs: {
+    libsigsegv-shared = lib.overrideDerivation libsigsegv (oldAttrs: {
       configureFlags = [ "--enable-shared" ];
     });
 
@@ -32,19 +32,19 @@ in stdenv.mkDerivation rec {
     libtool zip libffi libsigsegv-shared readline gmp gnutls gnome2.gtk
     cairo SDL sqlite
   ]
-  ++ stdenv.lib.optional emacsSupport emacs;
+  ++ lib.optional emacsSupport emacs;
 
-  configureFlags = stdenv.lib.optional (!emacsSupport) "--without-emacs";
+  configureFlags = lib.optional (!emacsSupport) "--without-emacs";
 
   hardeningDisable = [ "format" ];
 
-  installFlags = stdenv.lib.optional emacsSupport "lispdir=$(out)/share/emacs/site-lisp";
+  installFlags = lib.optional emacsSupport "lispdir=$(out)/share/emacs/site-lisp";
 
   # For some reason the tests fail if executated with nix-build, but pass if
   # executed within nix-shell --pure.
   doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A free implementation of the Smalltalk-80 language";
     longDescription = ''
       GNU Smalltalk is a free implementation of the Smalltalk-80 language. It
diff --git a/pkgs/development/compilers/go/1.14.nix b/pkgs/development/compilers/go/1.14.nix
index 6da01358afe..174c299b15b 100644
--- a/pkgs/development/compilers/go/1.14.nix
+++ b/pkgs/development/compilers/go/1.14.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, tzdata, iana-etc, runCommand
+{ lib, stdenv, fetchurl, tzdata, iana-etc, runCommand
 , perl, which, pkg-config, patch, procps, pcre, cacert, Security, Foundation
 , mailcap, runtimeShell
 , buildPackages
@@ -8,7 +8,7 @@
 
 let
 
-  inherit (stdenv.lib) optionals optionalString;
+  inherit (lib) optionals optionalString;
 
   goBootstrap = runCommand "go-bootstrap" {} ''
     mkdir $out
@@ -180,7 +180,7 @@ stdenv.mkDerivation rec {
     else
       null;
 
-  GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
+  GOARM = toString (lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   # Hopefully avoids test timeouts on Hydra
@@ -247,7 +247,7 @@ stdenv.mkDerivation rec {
 
   disallowedReferences = [ goBootstrap ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://golang.org/";
     description = "The Go Programming language";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/go/1.15.nix b/pkgs/development/compilers/go/1.15.nix
index 9c6232b8e8b..c3aef549e68 100644
--- a/pkgs/development/compilers/go/1.15.nix
+++ b/pkgs/development/compilers/go/1.15.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, tzdata, iana-etc, runCommand
+{ lib, stdenv, fetchurl, tzdata, iana-etc, runCommand
 , perl, which, pkg-config, patch, procps, pcre, cacert, Security, Foundation
 , mailcap, runtimeShell
 , buildPackages
@@ -8,7 +8,7 @@
 
 let
 
-  inherit (stdenv.lib) optionals optionalString;
+  inherit (lib) optionals optionalString;
 
   goBootstrap = runCommand "go-bootstrap" {} ''
     mkdir $out
@@ -183,7 +183,7 @@ stdenv.mkDerivation rec {
     else
       null;
 
-  GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
+  GOARM = toString (lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   # Hopefully avoids test timeouts on Hydra
@@ -250,7 +250,7 @@ stdenv.mkDerivation rec {
 
   disallowedReferences = [ goBootstrap ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://golang.org/";
     description = "The Go Programming language";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/go/1.4.nix b/pkgs/development/compilers/go/1.4.nix
index 032a8933db9..ec3fd97da9b 100644
--- a/pkgs/development/compilers/go/1.4.nix
+++ b/pkgs/development/compilers/go/1.4.nix
@@ -66,7 +66,7 @@ stdenv.mkDerivation rec {
            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.hostPlatform.system == "armv5tel-linux") "5";
+  GOARM = lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5";
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 0;
 
@@ -83,7 +83,7 @@ stdenv.mkDerivation rec {
     ./all.bash
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://golang.org/";
     description = "The Go Programming language";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/go/2-dev.nix b/pkgs/development/compilers/go/2-dev.nix
index c43b4d0175a..3e09f7c0fad 100644
--- a/pkgs/development/compilers/go/2-dev.nix
+++ b/pkgs/development/compilers/go/2-dev.nix
@@ -1,4 +1,4 @@
-{ pkgs, stdenv, fetchurl, fetchgit, tzdata, iana-etc, runCommand
+{ pkgs, lib, stdenv, fetchurl, fetchgit, tzdata, iana-etc, runCommand
 , perl, which, pkg-config, patch, procps, pcre, cacert, Security, Foundation
 , mailcap, runtimeShell
 , buildPackages
@@ -8,7 +8,7 @@
 
 let
 
-  inherit (stdenv.lib) optionals optionalString;
+  inherit (lib) optionals optionalString;
 
   goBootstrap = runCommand "go-bootstrap" {} ''
     mkdir $out
@@ -184,7 +184,7 @@ stdenv.mkDerivation rec {
     else
       null;
 
-  GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
+  GOARM = toString (lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
   GO386 = 387; # from Arch: don't assume sse2 on i686
   CGO_ENABLED = 1;
   # Hopefully avoids test timeouts on Hydra
@@ -251,7 +251,7 @@ stdenv.mkDerivation rec {
 
   disallowedReferences = [ goBootstrap ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://golang.org/";
     description = "The Go Programming language";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/gprolog/default.nix b/pkgs/development/compilers/gprolog/default.nix
index 0a1cc512873..59f33db68cb 100644
--- a/pkgs/development/compilers/gprolog/default.nix
+++ b/pkgs/development/compilers/gprolog/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   name = "gprolog-1.4.5";
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0z4cc42n3k6i35b8mr816iwsvrpxshw6d7dgz6s2h1hy0l7g1p5z";
   };
 
-  hardeningDisable = stdenv.lib.optional stdenv.isi686 "pic";
+  hardeningDisable = lib.optional stdenv.isi686 "pic";
 
   patchPhase = ''
     sed -i -e "s|/tmp/make.log|$TMPDIR/make.log|g" src/Pl2Wam/check_boot
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://www.gnu.org/software/gprolog/";
     description = "GNU Prolog, a free Prolog compiler with constraint solving over finite domains";
-    license = stdenv.lib.licenses.lgpl3Plus;
+    license = lib.licenses.lgpl3Plus;
 
     longDescription = ''
       GNU Prolog is a free Prolog compiler with constraint solving
@@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
       declarativity of logic programming.
     '';
 
-    maintainers = [ stdenv.lib.maintainers.peti ];
-    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
+    maintainers = [ lib.maintainers.peti ];
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/graalvm/community-edition.nix b/pkgs/development/compilers/graalvm/community-edition.nix
index 71f3b1560c6..76245a44081 100644
--- a/pkgs/development/compilers/graalvm/community-edition.nix
+++ b/pkgs/development/compilers/graalvm/community-edition.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath }:
+{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath }:
 
 let
   common = javaVersion:
@@ -111,7 +111,7 @@ let
                       "11" = "$out/lib/jli:$out/lib/server:$out/lib";
                     }.${javaVersion}
                  }:${
-            stdenv.lib.makeLibraryPath [
+            lib.makeLibraryPath [
               stdenv.cc.cc.lib # libstdc++.so.6
               zlib             # libz.so.1
             ]}"
@@ -128,7 +128,7 @@ let
 
         doInstallCheck = true;
         installCheckPhase = ''
-          echo ${stdenv.lib.escapeShellArg ''
+          echo ${lib.escapeShellArg ''
                    public class HelloWorld {
                      public static void main(String[] args) {
                        System.out.println("Hello World");
@@ -151,7 +151,7 @@ let
 
         passthru.home = graalvmXXX-ce;
 
-        meta = with stdenv.lib; {
+        meta = with lib; {
           homepage = "https://www.graalvm.org/";
           description = "High-Performance Polyglot VM";
           license = with licenses; [ upl gpl2Classpath bsd3 ];
diff --git a/pkgs/development/compilers/graalvm/default.nix b/pkgs/development/compilers/graalvm/default.nix
index 337e0f735eb..fc30e37e4b7 100644
--- a/pkgs/development/compilers/graalvm/default.nix
+++ b/pkgs/development/compilers/graalvm/default.nix
@@ -270,7 +270,7 @@ in rec {
         --prefix PATH : ${lib.makeBinPath [ python27withPackages mercurial ]} \
         --set    FINDBUGS_HOME ${findbugs}
     '';
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "https://github.com/graalvm/mx";
       description = "Command-line tool used for the development of Graal projects";
       license = licenses.gpl2;
@@ -527,7 +527,7 @@ in rec {
     enableParallelBuilding = true;
     passthru.home = graalvm8;
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "https://github.com/oracle/graal";
       description = "High-Performance Polyglot VM";
       license = licenses.gpl2;
diff --git a/pkgs/development/compilers/graalvm/enterprise-edition.nix b/pkgs/development/compilers/graalvm/enterprise-edition.nix
index 690bfdb425c..c9c5206f6da 100644
--- a/pkgs/development/compilers/graalvm/enterprise-edition.nix
+++ b/pkgs/development/compilers/graalvm/enterprise-edition.nix
@@ -1,4 +1,4 @@
-{ stdenv, requireFile, perl, unzip, glibc, zlib, bzip2, gdk-pixbuf, xorg, glib, fontconfig, freetype, cairo, pango, gtk3, gtk2, ffmpeg, libGL, atk, alsaLib, libav_0_8, setJavaClassPath }:
+{ lib, stdenv, requireFile, perl, unzip, glibc, zlib, bzip2, gdk-pixbuf, xorg, glib, fontconfig, freetype, cairo, pango, gtk3, gtk2, ffmpeg, libGL, atk, alsaLib, libav_0_8, setJavaClassPath }:
 
 let
   common = javaVersion:
@@ -124,7 +124,7 @@ let
                       "11" = "$out/lib/jli:$out/lib/server:$out/lib";
                     }.${javaVersion}
                  }:${
-            stdenv.lib.strings.makeLibraryPath [ glibc xorg.libXxf86vm xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender
+            lib.strings.makeLibraryPath [ glibc xorg.libXxf86vm xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender
                                                  glib zlib bzip2 alsaLib fontconfig freetype pango gtk3 gtk2 cairo gdk-pixbuf atk ffmpeg libGL ]}"
 
           for f in $(find $out -type f -perm -0100); do
@@ -141,7 +141,7 @@ let
 
         doInstallCheck = true;
         installCheckPhase = ''
-          echo ${stdenv.lib.escapeShellArg ''
+          echo ${lib.escapeShellArg ''
                    public class HelloWorld {
                      public static void main(String[] args) {
                        System.out.println("Hello World");
@@ -167,7 +167,7 @@ let
 
         passthru.home = graalvmXXX-ee;
 
-        meta = with stdenv.lib; {
+        meta = with lib; {
           homepage = "https://www.graalvm.org/";
           description = "High-Performance Polyglot VM";
           license = licenses.unfree;
diff --git a/pkgs/development/compilers/gwt/2.4.0.nix b/pkgs/development/compilers/gwt/2.4.0.nix
index 14bf940fadf..e10d1012034 100644
--- a/pkgs/development/compilers/gwt/2.4.0.nix
+++ b/pkgs/development/compilers/gwt/2.4.0.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip }:
+{ lib, stdenv, fetchurl, unzip }:
 
 stdenv.mkDerivation {
   name = "gwt-java-2.4.0";
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "http://www.gwtproject.org/";
     description = "A development toolkit for building and optimizing complex browser-based applications";
-    license = stdenv.lib.licenses.asl20;
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.asl20;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix
index a3110c0c1af..58451192396 100644
--- a/pkgs/development/compilers/haxe/default.nix
+++ b/pkgs/development/compilers/haxe/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, coreutils, ocamlPackages, zlib, pcre, neko }:
+{ lib, stdenv, fetchgit, coreutils, ocamlPackages, zlib, pcre, neko }:
 
 let inherit (ocamlPackages) ocaml camlp4; in
 
@@ -74,7 +74,7 @@ let
         popd > /dev/null
       '';
 
-      meta = with stdenv.lib; {
+      meta = with lib; {
         description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
         homepage = "https://haxe.org";
         license = with licenses; [ gpl2 bsd2 /*?*/ ];  # -> docs/license.txt
diff --git a/pkgs/development/compilers/hhvm/default.nix b/pkgs/development/compilers/hhvm/default.nix
index c06e94a038f..d8495977e78 100644
--- a/pkgs/development/compilers/hhvm/default.nix
+++ b/pkgs/development/compilers/hhvm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, cmake, pkg-config, boost, libunwind, libmemcached
+{ lib, stdenv, fetchgit, cmake, pkg-config, boost, libunwind, libmemcached
 , pcre, libevent, gd, curl, libxml2, icu, flex, bison, openssl, zlib, php
 , expat, libcap, oniguruma, libdwarf, libmcrypt, tbb, gperftools, glog, libkrb5
 , bzip2, openldap, readline, libelf, uwimap, binutils, cyrus_sasl, pam, libpng
@@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
     homepage    = "https://hhvm.com";
     license     = "PHP/Zend";
     platforms   = [ "x86_64-linux" ];
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    maintainers = [ lib.maintainers.thoughtpolice ];
     broken = true; # Since 2018-04-21, see https://hydra.nixos.org/build/73059373
   };
 }
diff --git a/pkgs/development/compilers/hop/default.nix b/pkgs/development/compilers/hop/default.nix
index fd3ef137ae6..8e5bd6a7df0 100644
--- a/pkgs/development/compilers/hop/default.nix
+++ b/pkgs/development/compilers/hop/default.nix
@@ -1,8 +1,8 @@
-{ stdenv, fetchurl, bigloo }:
+{ lib, stdenv, fetchurl, bigloo }:
 
 # Compute the “release” version of bigloo (before the first dash, if any)
 let bigloo-release =
-  let inherit (stdenv.lib) head splitString; in
+  let inherit (lib) head splitString; in
   head (splitString "-" (builtins.parseDrvName bigloo.name).version)
 ; in
 
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
     "--bigloolibdir=${bigloo}/lib/bigloo/${bigloo-release}/"
   ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A multi-tier programming language for the Web 2.0 and the so-called diffuse Web";
     homepage = "http://hop.inria.fr/";
     license = licenses.gpl2Plus;
diff --git a/pkgs/development/compilers/iasl/default.nix b/pkgs/development/compilers/iasl/default.nix
index d68fba1d624..fb6bd41344a 100644
--- a/pkgs/development/compilers/iasl/default.nix
+++ b/pkgs/development/compilers/iasl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, fetchpatch, bison, flex}:
+{lib, stdenv, fetchurl, fetchpatch, bison, flex}:
 
 stdenv.mkDerivation rec {
   pname = "iasl";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Intel ACPI Compiler";
     homepage = "http://www.acpica.org/";
-    license = stdenv.lib.licenses.iasl;
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.iasl;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/idris2/default.nix b/pkgs/development/compilers/idris2/default.nix
index dc124f56f6e..ec0d8fe5c72 100644
--- a/pkgs/development/compilers/idris2/default.nix
+++ b/pkgs/development/compilers/idris2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, makeWrapper
+{ lib, stdenv, fetchFromGitHub, makeWrapper
 , clang, chez
 }:
 
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   '';
 
   makeFlags = [ "PREFIX=$(out)" ]
-    ++ stdenv.lib.optional stdenv.isDarwin "OS=";
+    ++ lib.optional stdenv.isDarwin "OS=";
 
   # The name of the main executable of pkgs.chez is `scheme`
   buildFlags = [ "bootstrap-build" "SCHEME=scheme" ];
@@ -71,8 +71,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A purely functional programming language with first class types";
     homepage = "https://github.com/idris-lang/Idris2";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = with stdenv.lib.maintainers; [ wchresta ];
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ wchresta ];
     inherit (chez.meta) platforms;
   };
 }
diff --git a/pkgs/development/compilers/inform6/default.nix b/pkgs/development/compilers/inform6/default.nix
index 1d339a2b14b..f0c182f0207 100644
--- a/pkgs/development/compilers/inform6/default.nix
+++ b/pkgs/development/compilers/inform6/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl }:
+{ lib, stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
   pname = "inform6";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   makeFlags = [ "PREFIX=${placeholder "out"}" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Interactive fiction compiler and libraries";
     longDescription = ''
       Inform 6 is a C-like programming language for writing interactive fiction
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     homepage = "https://gitlab.com/DavidGriffith/inform6unix";
     changelog = "https://gitlab.com/DavidGriffith/inform6unix/-/raw/${version}/NEWS";
     license = licenses.artistic2;
-    maintainers = with stdenv.lib.maintainers; [ ddelabru ];
+    maintainers = with lib.maintainers; [ ddelabru ];
     platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/inform7/default.nix b/pkgs/development/compilers/inform7/default.nix
index 8e5f02e792d..80349b7e6da 100644
--- a/pkgs/development/compilers/inform7/default.nix
+++ b/pkgs/development/compilers/inform7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, coreutils, perl, gnutar, gzip }:
+{ lib, stdenv, fetchzip, coreutils, perl, gnutar, gzip }:
 let
   version = "6M62";
 in stdenv.mkDerivation {
@@ -21,7 +21,7 @@ in stdenv.mkDerivation {
       --replace "/usr/bin/perl" "${perl}/bin/perl"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A design system for interactive fiction";
     homepage = "http://inform7.com/";
     license = licenses.artistic2;
diff --git a/pkgs/development/compilers/intel-graphics-compiler/default.nix b/pkgs/development/compilers/intel-graphics-compiler/default.nix
index 7d0c67a1acb..ebba160fc95 100644
--- a/pkgs/development/compilers/intel-graphics-compiler/default.nix
+++ b/pkgs/development/compilers/intel-graphics-compiler/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , pkg-config
@@ -19,7 +19,7 @@ let
   };
   inherit (llvmPkgs) llvm;
   inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang clang-unwrapped spirv-llvm-translator;
-  inherit (stdenv.lib) getVersion optional optionals versionOlder versions;
+  inherit (lib) getVersion optional optionals versionOlder versions;
 in
 
 stdenv.mkDerivation rec {
@@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
     "-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
   ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage    = "https://github.com/intel/intel-graphics-compiler";
     description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
     license     = licenses.mit;
diff --git a/pkgs/development/compilers/intercal/default.nix b/pkgs/development/compilers/intercal/default.nix
index b20a0899f03..d696b6801ed 100644
--- a/pkgs/development/compilers/intercal/default.nix
+++ b/pkgs/development/compilers/intercal/default.nix
@@ -1,9 +1,9 @@
-{ stdenv, fetchurl
+{ lib, stdenv, fetchurl
 , pkg-config
 , bison, flex
 , makeWrapper }:
 
-with stdenv.lib;
+with lib;
 stdenv.mkDerivation rec {
 
   pname = "intercal";
diff --git a/pkgs/development/compilers/ios-cross-compile/9.2.nix b/pkgs/development/compilers/ios-cross-compile/9.2.nix
index e64c0c912d9..cabdbd9dcc0 100644
--- a/pkgs/development/compilers/ios-cross-compile/9.2.nix
+++ b/pkgs/development/compilers/ios-cross-compile/9.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, git, clang,
+{ lib, stdenv, git, clang,
   fetchFromGitHub, requireFile,
   openssl, xz, gnutar,
   automake, autoconf, libtool, clangStdenv } :
@@ -57,9 +57,9 @@ clangStdenv.mkDerivation rec {
   meta = {
     description =
     "Provides an iOS cross compiler from 7.1 up to iOS-${version} and ldid";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     hydraPlatforms = [];
-    maintainers = with stdenv.lib.maintainers; [ fxfactorial ];
-    license = stdenv.lib.licenses.gpl2;
+    maintainers = with lib.maintainers; [ fxfactorial ];
+    license = lib.licenses.gpl2;
   };
 }
diff --git a/pkgs/development/compilers/ispc/default.nix b/pkgs/development/compilers/ispc/default.nix
index 01e1eaca6e1..d1ac7bcd0ef 100644
--- a/pkgs/development/compilers/ispc/default.nix
+++ b/pkgs/development/compilers/ispc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , cmake, which, m4, python3, bison, flex, llvmPackages
 
   # the default test target is sse4, but that is not supported by all Hydra agents
@@ -60,7 +60,7 @@ stdenv.mkDerivation rec {
     "-DARM_ENABLED=FALSE"
   ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage    = "https://ispc.github.io/";
     description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
     license     = licenses.bsd3;
diff --git a/pkgs/development/compilers/jasmin/default.nix b/pkgs/development/compilers/jasmin/default.nix
index 7defdc5c689..c61f267bf1a 100644
--- a/pkgs/development/compilers/jasmin/default.nix
+++ b/pkgs/development/compilers/jasmin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , unzip
 , jdk8
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
     minimal-module = callPackage ./test-assemble-hello-world {};
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An assembler for the Java Virtual Machine";
     homepage = "http://jasmin.sourceforge.net/";
     downloadPage = "https://sourceforge.net/projects/jasmin/files/latest/download";
diff --git a/pkgs/development/compilers/javacard-devkit/default.nix b/pkgs/development/compilers/javacard-devkit/default.nix
index 5b691530d34..88371406387 100644
--- a/pkgs/development/compilers/javacard-devkit/default.nix
+++ b/pkgs/development/compilers/javacard-devkit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, requireFile, unzip, makeWrapper, oraclejdk8, autoPatchelfHook
+{ lib, stdenv, requireFile, unzip, makeWrapper, oraclejdk8, autoPatchelfHook
 , pcsclite
 }:
 
@@ -62,8 +62,8 @@ stdenv.mkDerivation rec {
       For more details, please refer to the documentation by Oracle
     '';
     homepage = "https://www.oracle.com/technetwork/java/embedded/javacard/overview/index.html";
-    license = stdenv.lib.licenses.unfree;
-    maintainers = [ stdenv.lib.maintainers.ekleog ];
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.ekleog ];
     platforms = [ "i686-linux" "x86_64-linux" ];
   };
 }
diff --git a/pkgs/development/compilers/jetbrains-jdk/default.nix b/pkgs/development/compilers/jetbrains-jdk/default.nix
index fd3270fa0d0..2edf93b7fc0 100644
--- a/pkgs/development/compilers/jetbrains-jdk/default.nix
+++ b/pkgs/development/compilers/jetbrains-jdk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, openjdk11, fetchFromGitHub, jetbrains }:
+{ lib, stdenv, openjdk11, fetchFromGitHub, jetbrains }:
 
 openjdk11.overrideAttrs (oldAttrs: rec {
   pname = "jetbrains-jdk";
@@ -6,11 +6,11 @@ openjdk11.overrideAttrs (oldAttrs: rec {
   src = fetchFromGitHub {
     owner = "JetBrains";
     repo = "JetBrainsRuntime";
-    rev = "jb${stdenv.lib.replaceStrings ["."] ["_"] version}";
+    rev = "jb${lib.replaceStrings ["."] ["_"] version}";
     sha256 = "1gxqi6dkyriv9j29ppan638w1ns2g9m4q1sq7arf9kwqr05zim90";
   };
   patches = [];
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An OpenJDK fork to better support Jetbrains's products.";
     longDescription = ''
      JetBrains Runtime is a runtime environment for running IntelliJ Platform
diff --git a/pkgs/development/compilers/julia/1.0.nix b/pkgs/development/compilers/julia/1.0.nix
index 0325632ad0a..77683e28628 100644
--- a/pkgs/development/compilers/julia/1.0.nix
+++ b/pkgs/development/compilers/julia/1.0.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchpatch, fetchurl, fetchzip
+{ lib, stdenv, fetchpatch, fetchurl, fetchzip
 # build tools
 , gfortran, m4, makeWrapper, patchelf, perl, which, python2
 , cmake
@@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
     pcre2.dev blas lapack openlibm openspecfun readline utf8proc
     zlib
   ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
+  ++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
   ;
 
   patches = [
@@ -121,7 +121,7 @@ stdenv.mkDerivation rec {
 
   makeFlags =
     let
-      arch = stdenv.lib.head (stdenv.lib.splitString "-" stdenv.system);
+      arch = lib.head (lib.splitString "-" stdenv.system);
       march = {
         x86_64 = stdenv.hostPlatform.platform.gcc.arch or "x86-64";
         i686 = "pentium4";
@@ -166,7 +166,7 @@ stdenv.mkDerivation rec {
       "USE_SYSTEM_ZLIB=1"
     ];
 
-  LD_LIBRARY_PATH = assert (blas.isILP64 == lapack.isILP64); (stdenv.lib.makeLibraryPath [
+  LD_LIBRARY_PATH = assert (blas.isILP64 == lapack.isILP64); (lib.makeLibraryPath [
     arpack fftw fftwSinglePrec gmp libgit2 mpfr blas lapack openlibm
     openspecfun pcre2
   ]);
@@ -204,8 +204,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "High-level performance-oriented dynamical language for technical computing";
     homepage = "https://julialang.org/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ raskin rob garrison ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ raskin rob garrison ];
     platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
   };
 }
diff --git a/pkgs/development/compilers/julia/1.3.nix b/pkgs/development/compilers/julia/1.3.nix
index 8096af0b320..4ee9be5df2d 100644
--- a/pkgs/development/compilers/julia/1.3.nix
+++ b/pkgs/development/compilers/julia/1.3.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchzip, fetchFromGitHub
+{ lib, stdenv, fetchurl, fetchzip, fetchFromGitHub
 # build tools
 , gfortran, m4, makeWrapper, patchelf, perl, which, python2
 , cmake
@@ -14,7 +14,7 @@
 
 assert (!blas.isILP64) && (!lapack.isILP64);
 
-with stdenv.lib;
+with lib;
 
 let
   majorVersion = "1";
@@ -64,7 +64,7 @@ stdenv.mkDerivation rec {
     pcre2.dev blas lapack openlibm openspecfun readline utf8proc
     zlib
   ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
+  ++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
   ;
 
   nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ];
@@ -153,8 +153,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "High-level performance-oriented dynamical language for technical computing";
     homepage = "https://julialang.org/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ raskin rob garrison ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ raskin rob garrison ];
     platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
     broken = stdenv.isi686;
   };
diff --git a/pkgs/development/compilers/julia/1.5.nix b/pkgs/development/compilers/julia/1.5.nix
index be3cfc39635..c0cf86ca7ae 100644
--- a/pkgs/development/compilers/julia/1.5.nix
+++ b/pkgs/development/compilers/julia/1.5.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchzip, fetchFromGitHub
+{ lib, stdenv, fetchurl, fetchzip, fetchFromGitHub
 # build tools
 , gfortran, m4, makeWrapper, patchelf, perl, which, python2
 , cmake
@@ -14,7 +14,7 @@
 
 assert (!blas.isILP64) && (!lapack.isILP64);
 
-with stdenv.lib;
+with lib;
 
 let
   majorVersion = "1";
@@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
     arpack fftw fftwSinglePrec libgit2 libunwind mpfr
     pcre2.dev blas lapack openlibm openspecfun readline utf8proc
     zlib
-  ] ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices];
+  ] ++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices];
 
   nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which cmake ];
 
@@ -150,8 +150,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "High-level performance-oriented dynamical language for technical computing";
     homepage = "https://julialang.org/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ raskin rob garrison ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ raskin rob garrison ];
     platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
     broken = stdenv.isi686;
   };
diff --git a/pkgs/development/compilers/jwasm/default.nix b/pkgs/development/compilers/jwasm/default.nix
index 8ce55c75795..2f1727ae0de 100644
--- a/pkgs/development/compilers/jwasm/default.nix
+++ b/pkgs/development/compilers/jwasm/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , cmake }:
 
-with stdenv.lib;
+with lib;
 stdenv.mkDerivation rec {
   pname = "jwasm";
   version = "2.13";
diff --git a/pkgs/development/compilers/kotlin/default.nix b/pkgs/development/compilers/kotlin/default.nix
index 934c9a848b9..cd613c1b33b 100644
--- a/pkgs/development/compilers/kotlin/default.nix
+++ b/pkgs/development/compilers/kotlin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, jre, unzip }:
+{ lib, stdenv, fetchurl, makeWrapper, jre, unzip }:
 
 let
   version = "1.4.21";
@@ -38,9 +38,9 @@ in stdenv.mkDerivation {
       and has external contributors.
     '';
     homepage = "https://kotlinlang.org/";
-    license = stdenv.lib.licenses.asl20;
-    maintainers = with stdenv.lib.maintainers;
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers;
       [ ];
-    platforms = stdenv.lib.platforms.all;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/ldc/generic.nix b/pkgs/development/compilers/ldc/generic.nix
index 19dc140a7e1..4261c2b6533 100644
--- a/pkgs/development/compilers/ldc/generic.nix
+++ b/pkgs/development/compilers/ldc/generic.nix
@@ -1,5 +1,5 @@
 { version, ldcSha256 }:
-{ stdenv, fetchurl, cmake, ninja, llvm_11, curl, tzdata
+{ lib, stdenv, fetchurl, cmake, ninja, llvm_11, curl, tzdata
 , libconfig, lit, gdb, unzip, darwin, bash
 , callPackage, makeWrapper, runCommand, targetPackages
 , ldcBootstrap ? callPackage ./bootstrap.nix { }
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
       # test depends on current year
       rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/ddocYear.d
   ''
-  + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+  + lib.optionalString stdenv.hostPlatform.isDarwin ''
       # https://github.com/NixOS/nixpkgs/issues/34817
       rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall
   '';
@@ -46,20 +46,20 @@ stdenv.mkDerivation rec {
     # Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow
     substituteInPlace tests/d2/dmd-testsuite/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash"
   ''
-  + stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
+  + lib.optionalString stdenv.hostPlatform.isLinux ''
       substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" ""
   ''
-  + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+  + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)"
   '';
 
   nativeBuildInputs = [
     cmake ldcBootstrap lit lit.python llvm_11 makeWrapper ninja unzip
   ]
-  ++ stdenv.lib.optionals stdenv.hostPlatform.isDarwin [
+  ++ lib.optionals stdenv.hostPlatform.isDarwin [
     darwin.apple_sdk.frameworks.Foundation
   ]
-  ++ stdenv.lib.optionals (!stdenv.hostPlatform.isDarwin) [
+  ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
     # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818
     gdb
   ];
@@ -77,7 +77,7 @@ stdenv.mkDerivation rec {
 
   makeFlags = [ "DMD=$DMD" ];
 
-  fixNames = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin  ''
+  fixNames = lib.optionalString stdenv.hostPlatform.isDarwin  ''
     fixDarwinDylibNames() {
       local flags=()
 
@@ -97,7 +97,7 @@ stdenv.mkDerivation rec {
   '';
 
   # https://github.com/ldc-developers/ldc/issues/2497#issuecomment-459633746
-  additionalExceptions = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin
+  additionalExceptions = lib.optionalString stdenv.hostPlatform.isDarwin
     "|druntime-test-shared";
 
   checkPhase = ''
@@ -126,7 +126,7 @@ stdenv.mkDerivation rec {
         --set-default CC "${targetPackages.stdenv.cc}/bin/cc"
    '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "The LLVM-based D compiler";
     homepage = "https://github.com/ldc-developers/ldc";
     # from https://github.com/ldc-developers/ldc/blob/master/LICENSE
diff --git a/pkgs/development/compilers/llvm/10/clang/default.nix b/pkgs/development/compilers/llvm/10/clang/default.nix
index d01d1a2a53d..35b7ab313d8 100644
--- a/pkgs/development/compilers/llvm/10/clang/default.nix
+++ b/pkgs/development/compilers/llvm/10/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -19,8 +19,8 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 lld ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm ];
 
@@ -28,7 +28,7 @@ let
       "-DCMAKE_CXX_FLAGS=-std=c++14"
       "-DCLANGD_BUILD_XPC=OFF"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
@@ -49,9 +49,9 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace tools/extra/clangd/CMakeLists.txt \
         --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
     '';
@@ -90,10 +90,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/10/compiler-rt.nix b/pkgs/development/compilers/llvm/10/compiler-rt.nix
index 568bdff67c0..37515b5039d 100644
--- a/pkgs/development/compilers/llvm/10/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/10/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   src = fetch pname "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation rec {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -53,8 +53,8 @@ stdenv.mkDerivation rec {
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
     ./find-darwin-sdk-version.patch # don't test for macOS being >= 10.15
-  ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
@@ -62,13 +62,13 @@ stdenv.mkDerivation rec {
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -78,9 +78,9 @@ stdenv.mkDerivation rec {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/10/default.nix b/pkgs/development/compilers/llvm/10/default.nix
index 3d2cb3544b9..f939eb52122 100644
--- a/pkgs/development/compilers/llvm/10/default.nix
+++ b/pkgs/development/compilers/llvm/10/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -26,7 +26,7 @@ let
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -101,15 +101,15 @@ let
       extraPackages = [
         targetLlvmLibraries.libcxxabi
         targetLlvmLibraries.compiler-rt
-      ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
+      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
       ];
       extraBuildCommands = ''
         echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
         echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
         echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
         echo "-fno-exceptions" >> $out/nix-support/cc-cflags
       '' + mkExtraBuildCommands cc;
     };
@@ -161,12 +161,12 @@ let
 
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
       }));
 
@@ -175,12 +175,12 @@ let
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
     libcxx = callPackage ./libc++ ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
     libcxxabi = callPackage ./libc++abi.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
         libunwind = libraries.libunwind;
       }));
@@ -188,7 +188,7 @@ let
     openmp = callPackage ./openmp.nix {};
 
     libunwind = callPackage ./libunwind.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
diff --git a/pkgs/development/compilers/llvm/10/libc++/default.nix b/pkgs/development/compilers/llvm/10/libc++/default.nix
index 9b501aff1ab..a3fb0927345 100644
--- a/pkgs/development/compilers/llvm/10/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/10/libc++/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+  patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
 
   preConfigure = ''
     # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
@@ -22,8 +22,8 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ];
 
@@ -31,13 +31,13 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
+  ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
+    ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
+    ++ lib.optional stdenv.hostPlatform.isWasm [
       "-DLIBCXX_ENABLE_THREADS=OFF"
       "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
       "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
+    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
 
   passthru = {
     isLLVM = true;
@@ -46,7 +46,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/10/libc++abi.nix b/pkgs/development/compilers/llvm/10/libc++abi.nix
index 7335d06e4fe..61f778fbc55 100644
--- a/pkgs/development/compilers/llvm/10/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/10/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -9,15 +9,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "0yqs722y76cwvmfsq0lb917r9m3fci7bf5z3yzl71yz9n88ghzm9";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
 
-  cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+  cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ stdenv.lib.optionals (!enableShared) [
+  ] ++ lib.optionals (!enableShared) [
     "-DLIBCXXABI_ENABLE_SHARED=OFF"
   ];
 
@@ -27,11 +27,11 @@ stdenv.mkDerivation {
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
+  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
     patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch}
   '';
 
@@ -52,7 +52,7 @@ stdenv.mkDerivation {
       install -d -m 755 $out/include $out/lib
       install -m 644 lib/libc++abi.a $out/lib
       install -m 644 ../include/cxxabi.h $out/include
-    '' + stdenv.lib.optionalString enableShared ''
+    '' + lib.optionalString enableShared ''
       install -m 644 lib/libc++abi.so.1.0 $out/lib
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
@@ -61,8 +61,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/10/libunwind.nix b/pkgs/development/compilers/llvm/10/libunwind.nix
index 8088ae97303..f0f45780a22 100644
--- a/pkgs/development/compilers/llvm/10/libunwind.nix
+++ b/pkgs/development/compilers/llvm/10/libunwind.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, fetchpatch
+{ lib, stdenv, version, fetch, cmake, fetchpatch
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -10,5 +10,5 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
-  cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+  cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
 }
diff --git a/pkgs/development/compilers/llvm/10/lld.nix b/pkgs/development/compilers/llvm/10/lld.nix
index a0cb9c117a8..a94c1b5b0dd 100644
--- a/pkgs/development/compilers/llvm/10/lld.nix
+++ b/pkgs/development/compilers/llvm/10/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/10/lldb.nix b/pkgs/development/compilers/llvm/10/lldb.nix
index fc5edadd0a4..e7dd48a23ce 100644
--- a/pkgs/development/compilers/llvm/10/lldb.nix
+++ b/pkgs/development/compilers/llvm/10/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , zlib
@@ -25,7 +25,7 @@ stdenv.mkDerivation (rec {
   patches = [ ./lldb-procfs.patch ];
 
   nativeBuildInputs = [ cmake python3 which swig lit ]
-    ++ stdenv.lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
+    ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
 
   buildInputs = [
     ncurses
@@ -34,7 +34,7 @@ stdenv.mkDerivation (rec {
     libxml2
     llvm
   ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [
+  ++ lib.optionals stdenv.isDarwin [
     darwin.libobjc
     darwin.apple_sdk.libs.xpc
     darwin.apple_sdk.frameworks.Foundation
@@ -49,11 +49,11 @@ stdenv.mkDerivation (rec {
     "-DLLVM_ENABLE_RTTI=OFF"
     "-DClang_DIR=${clang-unwrapped}/lib/cmake"
     "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
-  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.isDarwin [
     "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
-  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
+  ] ++ lib.optionals (!stdenv.isDarwin) [
     "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
-  ] ++ stdenv.lib.optionals enableManpages [
+  ] ++ lib.optionals enableManpages [
     "-DLLVM_ENABLE_SPHINX=ON"
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
@@ -67,13 +67,13 @@ stdenv.mkDerivation (rec {
     ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage = "https://lldb.llvm.org";
     license = licenses.ncsa;
     platforms = platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "lldb-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/10/llvm.nix b/pkgs/development/compilers/llvm/10/llvm.nix
index 7e6c7c02526..e951375a833 100644
--- a/pkgs/development/compilers/llvm/10/llvm.nix
+++ b/pkgs/development/compilers/llvm/10/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , python3
@@ -22,10 +22,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
+  shortVersion = with lib;
     concatStringsSep "." (take 1 (splitString "." release_version));
 
 in stdenv.mkDerivation (rec {
@@ -158,11 +158,11 @@ in stdenv.mkDerivation (rec {
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/10/openmp.nix b/pkgs/development/compilers/llvm/10/openmp.nix
index e3c1e66376a..2fa695d2d51 100644
--- a/pkgs/development/compilers/llvm/10/openmp.nix
+++ b/pkgs/development/compilers/llvm/10/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/11/clang/default.nix b/pkgs/development/compilers/llvm/11/clang/default.nix
index 24d6da97bf1..3a3e384ad98 100644
--- a/pkgs/development/compilers/llvm/11/clang/default.nix
+++ b/pkgs/development/compilers/llvm/11/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -20,15 +20,15 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 lld ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm ];
 
     cmakeFlags = [
       "-DCMAKE_CXX_FLAGS=-std=c++14"
       "-DCLANGD_BUILD_XPC=OFF"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
@@ -48,9 +48,9 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace tools/extra/clangd/CMakeLists.txt \
         --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
     '';
@@ -89,10 +89,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/11/compiler-rt.nix b/pkgs/development/compilers/llvm/11/compiler-rt.nix
index 3f8c092fce2..091f327550b 100644
--- a/pkgs/development/compilers/llvm/11/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/11/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   src = fetch pname "1z470r8c5aahdwkmflglx998n0i77j8b1c69d7cir1kf27qy6yq8";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation rec {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (stdenv.isDarwin) [
+  ] ++ lib.optionals (stdenv.isDarwin) [
     "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
   ];
 
@@ -50,8 +50,8 @@ stdenv.mkDerivation rec {
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
     ./compiler-rt-X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
-  ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
@@ -59,15 +59,15 @@ stdenv.mkDerivation rec {
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)'
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -77,9 +77,9 @@ stdenv.mkDerivation rec {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix
index b354bd6b44a..2ebde3d107a 100644
--- a/pkgs/development/compilers/llvm/11/default.nix
+++ b/pkgs/development/compilers/llvm/11/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -8,7 +8,7 @@
 let
   release_version = "11.0.1";
   candidate = ""; # empty or "rcN"
-  dash-candidate = stdenv.lib.optionalString (candidate != "") "-${candidate}";
+  dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
   version = "${release_version}${dash-candidate}"; # differentiating these (variables) is important for RCs
   targetConfig = stdenv.targetPlatform.config;
 
@@ -19,7 +19,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "1j8n6n4l54k2lrdxh266y1fl4z8vy5dc76wsf0csk5n3ikfi38ic";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -28,7 +28,7 @@ let
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -103,15 +103,15 @@ let
       extraPackages = [
         targetLlvmLibraries.libcxxabi
         targetLlvmLibraries.compiler-rt
-      ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
+      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
       ];
       extraBuildCommands = ''
         echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
         echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
         echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
         echo "-fno-exceptions" >> $out/nix-support/cc-cflags
       '' + mkExtraBuildCommands cc;
     };
@@ -163,12 +163,12 @@ let
 
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
       }));
 
@@ -177,12 +177,12 @@ let
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
     libcxx = callPackage ./libc++ ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
     libcxxabi = callPackage ./libc++abi.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
         libunwind = libraries.libunwind;
       }));
@@ -190,7 +190,7 @@ let
     openmp = callPackage ./openmp.nix {};
 
     libunwind = callPackage ./libunwind.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
diff --git a/pkgs/development/compilers/llvm/11/libc++/default.nix b/pkgs/development/compilers/llvm/11/libc++/default.nix
index d0b581c0460..7a34977afe2 100644
--- a/pkgs/development/compilers/llvm/11/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/11/libc++/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
     mv llvm-* llvm
   '';
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+  patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
 
   preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
     patchShebangs utils/cat_files.py
@@ -28,13 +28,13 @@ stdenv.mkDerivation {
 
   cmakeFlags = [
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
+  ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
+    ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
+    ++ lib.optional stdenv.hostPlatform.isWasm [
       "-DLIBCXX_ENABLE_THREADS=OFF"
       "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
       "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
+    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
 
   passthru = {
     isLLVM = true;
@@ -43,7 +43,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/11/libc++abi.nix b/pkgs/development/compilers/llvm/11/libc++abi.nix
index e87622b23b2..22e4ac4abe4 100644
--- a/pkgs/development/compilers/llvm/11/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/11/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -9,15 +9,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "0gv8pxq95gvsybldj21hdfkmm0r5cn1z7jhd72l231n0lmb70saa";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
 
-  cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+  cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ stdenv.lib.optionals (!enableShared) [
+  ] ++ lib.optionals (!enableShared) [
     "-DLIBCXXABI_ENABLE_SHARED=OFF"
   ];
 
@@ -28,11 +28,11 @@ stdenv.mkDerivation {
     mv libcxx-* libcxx
     unpackFile ${llvm.src}
     mv llvm-* llvm
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d libcxx -i ${../libcxx-0001-musl-hacks.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
+  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
     patch -p1 -d llvm -i ${./libcxxabi-wasm.patch}
   '';
 
@@ -53,7 +53,7 @@ stdenv.mkDerivation {
       install -d -m 755 $out/include $out/lib
       install -m 644 lib/libc++abi.a $out/lib
       install -m 644 ../include/cxxabi.h $out/include
-    '' + stdenv.lib.optionalString enableShared ''
+    '' + lib.optionalString enableShared ''
       install -m 644 lib/libc++abi.so.1.0 $out/lib
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
@@ -62,8 +62,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/11/libunwind.nix b/pkgs/development/compilers/llvm/11/libunwind.nix
index 5708b00c08a..1b5fe0f5788 100644
--- a/pkgs/development/compilers/llvm/11/libunwind.nix
+++ b/pkgs/development/compilers/llvm/11/libunwind.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, fetchpatch
+{ lib, stdenv, version, fetch, cmake, fetchpatch
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -10,5 +10,5 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
-  cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+  cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
 }
diff --git a/pkgs/development/compilers/llvm/11/lld.nix b/pkgs/development/compilers/llvm/11/lld.nix
index af02a5d4750..cead886f49b 100644
--- a/pkgs/development/compilers/llvm/11/lld.nix
+++ b/pkgs/development/compilers/llvm/11/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/11/lldb.nix b/pkgs/development/compilers/llvm/11/lldb.nix
index 28bb75470a9..fcc73cfdeb6 100644
--- a/pkgs/development/compilers/llvm/11/lldb.nix
+++ b/pkgs/development/compilers/llvm/11/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , zlib
@@ -25,7 +25,7 @@ stdenv.mkDerivation (rec {
   patches = [ ./lldb-procfs.patch ];
 
   nativeBuildInputs = [ cmake python3 which swig lit ]
-    ++ stdenv.lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
+    ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
 
   buildInputs = [
     ncurses
@@ -34,7 +34,7 @@ stdenv.mkDerivation (rec {
     libxml2
     llvm
   ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [
+  ++ lib.optionals stdenv.isDarwin [
     darwin.libobjc
     darwin.apple_sdk.libs.xpc
     darwin.apple_sdk.frameworks.Foundation
@@ -49,11 +49,11 @@ stdenv.mkDerivation (rec {
     "-DLLVM_ENABLE_RTTI=OFF"
     "-DClang_DIR=${clang-unwrapped}/lib/cmake"
     "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
-  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.isDarwin [
     "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
-  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
+  ] ++ lib.optionals (!stdenv.isDarwin) [
     "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
-  ] ++ stdenv.lib.optionals enableManpages [
+  ] ++ lib.optionals enableManpages [
     "-DLLVM_ENABLE_SPHINX=ON"
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
@@ -67,13 +67,13 @@ stdenv.mkDerivation (rec {
     ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage = "https://lldb.llvm.org";
     license = licenses.ncsa;
     platforms = platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "lldb-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/11/llvm.nix b/pkgs/development/compilers/llvm/11/llvm.nix
index 442e1ee3a6d..002d6f82a8e 100644
--- a/pkgs/development/compilers/llvm/11/llvm.nix
+++ b/pkgs/development/compilers/llvm/11/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , python3
@@ -22,10 +22,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
+  shortVersion = with lib;
     concatStringsSep "." (take 1 (splitString "." release_version));
 
 in stdenv.mkDerivation (rec {
@@ -160,11 +160,11 @@ in stdenv.mkDerivation (rec {
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill primeos ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/11/openmp.nix b/pkgs/development/compilers/llvm/11/openmp.nix
index 55a4ceb7e6e..b19d369a42e 100644
--- a/pkgs/development/compilers/llvm/11/openmp.nix
+++ b/pkgs/development/compilers/llvm/11/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/5/clang/default.nix b/pkgs/development/compilers/llvm/5/clang/default.nix
index a097e9167cd..21961f4f041 100644
--- a/pkgs/development/compilers/llvm/5/clang/default.nix
+++ b/pkgs/development/compilers/llvm/5/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -19,15 +19,15 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm ];
 
     cmakeFlags = [
       "-DCMAKE_CXX_FLAGS=-std=c++11"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
@@ -44,7 +44,7 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
     '';
 
@@ -80,10 +80,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/5/compiler-rt.nix b/pkgs/development/compilers/llvm/5/compiler-rt.nix
index e973be0a087..909c6b19053 100644
--- a/pkgs/development/compilers/llvm/5/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/5/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -53,19 +53,19 @@ stdenv.mkDerivation {
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
     ../7/compiler-rt-glibc.patch
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ] ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  postPatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -75,9 +75,9 @@ stdenv.mkDerivation {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix
index 36495249d16..80bb3af2786 100644
--- a/pkgs/development/compilers/llvm/5/default.nix
+++ b/pkgs/development/compilers/llvm/5/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -25,7 +25,7 @@ let
       ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -75,7 +75,7 @@ let
     lldb = callPackage ./lldb.nix {};
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
diff --git a/pkgs/development/compilers/llvm/5/libc++/default.nix b/pkgs/development/compilers/llvm/5/libc++/default.nix
index 687a613e074..164836e1a4c 100644
--- a/pkgs/development/compilers/llvm/5/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/5/libc++/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+  patches = lib.optionals stdenv.hostPlatform.isMusl [
     ../../libcxx-0001-musl-hacks.patch
   ];
 
@@ -26,8 +26,8 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional stdenv.hostPlatform.isMusl python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ];
 
@@ -35,7 +35,7 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
+  ] ++ lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
 
   passthru = {
     isLLVM = true;
@@ -44,7 +44,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/5/libc++abi.nix b/pkgs/development/compilers/llvm/5/libc++abi.nix
index 96d6e78e01e..8fc9ef9fded 100644
--- a/pkgs/development/compilers/llvm/5/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/5/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
@@ -7,15 +7,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "12lp799rskr4fc2xr64qn4jfkjnfd8b1aymvsxyn4k9ar7r9pgqv";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
 
   postUnpack = ''
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
   '';
 
@@ -44,8 +44,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/5/lld.nix b/pkgs/development/compilers/llvm/5/lld.nix
index 5f43f8235e1..244960cf41b 100644
--- a/pkgs/development/compilers/llvm/5/lld.nix
+++ b/pkgs/development/compilers/llvm/5/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , llvm
@@ -24,8 +24,8 @@ stdenv.mkDerivation {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
     badPlatforms = [ "x86_64-darwin" ];
   };
 }
diff --git a/pkgs/development/compilers/llvm/5/lldb.nix b/pkgs/development/compilers/llvm/5/lldb.nix
index 258535a7566..61a9e60391c 100644
--- a/pkgs/development/compilers/llvm/5/lldb.nix
+++ b/pkgs/development/compilers/llvm/5/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , fetchpatch
 , cmake
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
+    ++ lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
   CXXFLAGS = "-fno-rtti";
   hardeningDisable = [ "format" ];
@@ -56,7 +56,7 @@ stdenv.mkDerivation {
     cp ../docs/lldb.1 $out/share/man/man1/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage    = "https://llvm.org/";
     license     = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix
index 2c2867c9937..c91e9420435 100644
--- a/pkgs/development/compilers/llvm/5/llvm.nix
+++ b/pkgs/development/compilers/llvm/5/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , fetchpatch
 , cmake
@@ -17,7 +17,7 @@
 
 let
   # Used when creating a versioned symlinks of libLLVM.dylib
-  versionSuffixes = with stdenv.lib;
+  versionSuffixes = with lib;
     let parts = splitVersion release_version; in
     imap (i: _: concatStringsSep "." (take i parts)) parts;
 in
@@ -35,10 +35,10 @@ stdenv.mkDerivation ({
   '';
 
   outputs = [ "out" "python" ]
-    ++ stdenv.lib.optional enableSharedLibraries "lib";
+    ++ lib.optional enableSharedLibraries "lib";
 
   nativeBuildInputs = [ cmake python3 ]
-    ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
+    ++ lib.optional enableManpages python3.pkgs.sphinx;
 
   buildInputs = [ libxml2 libffi ];
 
@@ -58,13 +58,13 @@ stdenv.mkDerivation ({
     #  stripLen = 1;
     #})
   ];
-  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  postPatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/modules/AddLLVM.cmake \
       --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
       --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
   ''
   # Patch llvm-config to return correct library path based on --link-{shared,static}.
-  + stdenv.lib.optionalString (enableSharedLibraries) ''
+  + lib.optionalString (enableSharedLibraries) ''
     substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
     patch -p1 < ./llvm-outputs.patch
   '' + ''
@@ -72,9 +72,9 @@ stdenv.mkDerivation ({
     substituteInPlace unittests/Support/CMakeLists.txt \
       --replace "Path.cpp" ""
     rm unittests/Support/Path.cpp
-  '' + stdenv.lib.optionalString stdenv.isAarch64 ''
+  '' + lib.optionalString stdenv.isAarch64 ''
     patch -p0 < ${../aarch64.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -i ${../TLI-musl.patch}
     substituteInPlace unittests/Support/CMakeLists.txt \
       --replace "add_subdirectory(DynamicLibrary)" ""
@@ -98,18 +98,18 @@ stdenv.mkDerivation ({
     "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
     "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}"
   ]
-  ++ stdenv.lib.optional enableSharedLibraries
+  ++ lib.optional enableSharedLibraries
     "-DLLVM_LINK_LLVM_DYLIB=ON"
-  ++ stdenv.lib.optionals enableManpages [
+  ++ lib.optionals enableManpages [
     "-DLLVM_BUILD_DOCS=ON"
     "-DLLVM_ENABLE_SPHINX=ON"
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
   ]
-  ++ stdenv.lib.optional (!isDarwin)
+  ++ lib.optional (!isDarwin)
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-  ++ stdenv.lib.optionals (isDarwin) [
+  ++ lib.optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DCAN_TARGET_i386=false"
   ];
@@ -126,18 +126,18 @@ stdenv.mkDerivation ({
     mkdir -p $python/share
     mv $out/share/opt-viewer $python/share/opt-viewer
   ''
-  + stdenv.lib.optionalString enableSharedLibraries ''
+  + lib.optionalString enableSharedLibraries ''
     moveToOutput "lib/libLLVM-*" "$lib"
     moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
     moveToOutput "lib/libLTO${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
   ''
-  + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+  + lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLTO.dylib" "$lib/lib/libLTO.dylib"
-    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+    ${lib.concatMapStringsSep "\n" (v: ''
       ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
     '') versionSuffixes}
   '';
@@ -150,11 +150,11 @@ stdenv.mkDerivation ({
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/5/openmp.nix b/pkgs/development/compilers/llvm/5/openmp.nix
index 452f5a3cfe5..1af40922996 100644
--- a/pkgs/development/compilers/llvm/5/openmp.nix
+++ b/pkgs/development/compilers/llvm/5/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/6/clang/default.nix b/pkgs/development/compilers/llvm/6/clang/default.nix
index 63a79ffba8a..41202dd3f5d 100644
--- a/pkgs/development/compilers/llvm/6/clang/default.nix
+++ b/pkgs/development/compilers/llvm/6/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
 , fixDarwinDylibNames
 , enableManpages ? false
 }:
@@ -19,15 +19,15 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm ];
 
     cmakeFlags = [
       "-DCMAKE_CXX_FLAGS=-std=c++11"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
@@ -44,7 +44,7 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
     '';
 
@@ -80,10 +80,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/6/compiler-rt.nix b/pkgs/development/compilers/llvm/6/compiler-rt.nix
index df61824e908..6e47ffe8aca 100644
--- a/pkgs/development/compilers/llvm/6/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/6/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetch "compiler-rt" "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -53,21 +53,21 @@ stdenv.mkDerivation {
   patches = [
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
     ../7/compiler-rt-glibc.patch
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ] ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -77,9 +77,9 @@ stdenv.mkDerivation {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix
index 4c2e87ec5e1..f39fb9b60da 100644
--- a/pkgs/development/compilers/llvm/6/default.nix
+++ b/pkgs/development/compilers/llvm/6/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "1w8ml7fyn4vyxmy59n2qm4r1k1kgwgwkaldp6m45fdv4g0kkfbhd";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -25,7 +25,7 @@ let
       ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -75,7 +75,7 @@ let
     lldb = callPackage ./lldb.nix {};
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
diff --git a/pkgs/development/compilers/llvm/6/libc++/default.nix b/pkgs/development/compilers/llvm/6/libc++/default.nix
index 129d06fe515..ac489db54fc 100644
--- a/pkgs/development/compilers/llvm/6/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/6/libc++/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+  patches = lib.optionals stdenv.hostPlatform.isMusl [
     ../../libcxx-0001-musl-hacks.patch
   ];
 
@@ -26,8 +26,8 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional stdenv.hostPlatform.isMusl python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ];
 
@@ -35,7 +35,7 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
+  ] ++ lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
 
   passthru = {
     isLLVM = true;
@@ -44,7 +44,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/6/libc++abi.nix b/pkgs/development/compilers/llvm/6/libc++abi.nix
index 246bc6153e5..6e99f2d287a 100644
--- a/pkgs/development/compilers/llvm/6/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/6/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
@@ -7,15 +7,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "0prqvdj317qrc8nddaq1hh2ag9algkd9wbkj3y4mr5588k12x7r0";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
 
   postUnpack = ''
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
   '';
 
@@ -44,8 +44,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/6/lld.nix b/pkgs/development/compilers/llvm/6/lld.nix
index da1acf3f5f3..b8038524805 100644
--- a/pkgs/development/compilers/llvm/6/lld.nix
+++ b/pkgs/development/compilers/llvm/6/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/6/lldb.nix b/pkgs/development/compilers/llvm/6/lldb.nix
index 0a138618574..7c6f8b1bd97 100644
--- a/pkgs/development/compilers/llvm/6/lldb.nix
+++ b/pkgs/development/compilers/llvm/6/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , fetchpatch
 , cmake
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
+    ++ lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
   CXXFLAGS = "-fno-rtti";
   hardeningDisable = [ "format" ];
@@ -56,7 +56,7 @@ stdenv.mkDerivation {
     cp ../docs/lldb.1 $out/share/man/man1/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage    = "https://llvm.org/";
     license     = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/6/llvm.nix b/pkgs/development/compilers/llvm/6/llvm.nix
index 07aaf1e9218..7d429e3ecf3 100644
--- a/pkgs/development/compilers/llvm/6/llvm.nix
+++ b/pkgs/development/compilers/llvm/6/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , python3
@@ -17,10 +17,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a versioned symlinks of libLLVM.dylib
-  versionSuffixes = with stdenv.lib;
+  versionSuffixes = with lib;
     let parts = splitVersion release_version; in
     imap (i: _: concatStringsSep "." (take i parts)) parts;
 in
@@ -136,7 +136,7 @@ stdenv.mkDerivation ({
   + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+    ${lib.concatMapStringsSep "\n" (v: ''
       ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
     '') versionSuffixes}
   '';
@@ -149,11 +149,11 @@ stdenv.mkDerivation ({
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/6/openmp.nix b/pkgs/development/compilers/llvm/6/openmp.nix
index d6b00bb01ae..420bfe8c3bb 100644
--- a/pkgs/development/compilers/llvm/6/openmp.nix
+++ b/pkgs/development/compilers/llvm/6/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/7/clang/default.nix b/pkgs/development/compilers/llvm/7/clang/default.nix
index 0b1fdd53de9..4ab13441e36 100644
--- a/pkgs/development/compilers/llvm/7/clang/default.nix
+++ b/pkgs/development/compilers/llvm/7/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -20,21 +20,21 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm lld ];
 
     cmakeFlags = [
       "-DCMAKE_CXX_FLAGS=-std=c++11"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
       "-DSPHINX_OUTPUT_HTML=OFF"
       "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-    ] ++ stdenv.lib.optionals enablePolly [
+    ] ++ lib.optionals enablePolly [
       "-DWITH_POLLY=ON"
       "-DLINK_POLLY_INTO_TOOLS=ON"
     ];
@@ -52,9 +52,9 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace tools/extra/clangd/CMakeLists.txt \
         --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
     '';
@@ -91,10 +91,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/7/compiler-rt.nix b/pkgs/development/compilers/llvm/7/compiler-rt.nix
index bae9cf5fa0e..6320a3405d2 100644
--- a/pkgs/development/compilers/llvm/7/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/7/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -55,22 +55,22 @@ stdenv.mkDerivation {
     ./compiler-rt-glibc.patch
 
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
-  ] ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ] ++ lib.optional (useLLVM) ./crtbegin-and-end.patch
+    ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -80,9 +80,9 @@ stdenv.mkDerivation {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix
index 3dd067ae607..393a1f59472 100644
--- a/pkgs/development/compilers/llvm/7/default.nix
+++ b/pkgs/development/compilers/llvm/7/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "0lb4kdh7j2fhfz8kd6iv5df7m3pikiryk1vvwsf87spc90n09q0w";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -25,7 +25,7 @@ let
       ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -103,9 +103,9 @@ let
       extraBuildCommands = ''
         echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
         echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
         echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
         echo "-fno-exceptions" >> $out/nix-support/cc-cflags
       '' + mkExtraBuildCommands cc;
     };
@@ -157,7 +157,7 @@ let
 
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
@@ -172,12 +172,12 @@ let
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
     libcxx = callPackage ./libc++ ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
     libcxxabi = callPackage ./libc++abi.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
         libunwind = libraries.libunwind;
       }));
diff --git a/pkgs/development/compilers/llvm/7/libc++/default.nix b/pkgs/development/compilers/llvm/7/libc++/default.nix
index 27315672607..fb50c4e24d7 100644
--- a/pkgs/development/compilers/llvm/7/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/7/libc++/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+  patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
 
   prePatch = ''
     substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
@@ -27,8 +27,8 @@ stdenv.mkDerivation {
   '';
 
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional stdenv.hostPlatform.isMusl python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ] ;
 
@@ -36,8 +36,8 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"
-  ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" ;
+  ] ++ lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" ;
 
   passthru = {
     isLLVM = true;
@@ -46,7 +46,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/7/libc++abi.nix b/pkgs/development/compilers/llvm/7/libc++abi.nix
index 4c46aeaa191..61879be91da 100644
--- a/pkgs/development/compilers/llvm/7/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/7/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, llvm, version
+{ lib, stdenv, cmake, fetch, libcxx, llvm, version
 , standalone ? false
   # on musl the shared objects don't build
 , enableShared ? !stdenv.hostPlatform.isStatic
@@ -16,15 +16,15 @@ stdenv.mkDerivation {
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     cmakeFlagsArray=($cmakeFlagsArray -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*) )
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
   '';
 
   cmakeFlags =
-     stdenv.lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
-     stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
+     lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
+     lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
 
   installPhase = if stdenv.isDarwin
     then ''
@@ -42,17 +42,17 @@ stdenv.mkDerivation {
     else ''
       install -d -m 755 $out/include $out/lib
       install -m 644 lib/libc++abi.a $out/lib
-      ${stdenv.lib.optionalString enableShared "install -m 644 lib/libc++abi.so.1.0 $out/lib"}
+      ${lib.optionalString enableShared "install -m 644 lib/libc++abi.so.1.0 $out/lib"}
       install -m 644 ../include/cxxabi.h $out/include
-      ${stdenv.lib.optionalString enableShared "ln -s libc++abi.so.1.0 $out/lib/libc++abi.so"}
-      ${stdenv.lib.optionalString enableShared "ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1"}
+      ${lib.optionalString enableShared "ln -s libc++abi.so.1.0 $out/lib/libc++abi.so"}
+      ${lib.optionalString enableShared "ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1"}
     '';
 
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.unix;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/llvm/7/lld.nix b/pkgs/development/compilers/llvm/7/lld.nix
index 5e0568b6a09..f4c58abef8a 100644
--- a/pkgs/development/compilers/llvm/7/lld.nix
+++ b/pkgs/development/compilers/llvm/7/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/7/lldb.nix b/pkgs/development/compilers/llvm/7/lldb.nix
index d1508c46d0c..3fa5b411f63 100644
--- a/pkgs/development/compilers/llvm/7/lldb.nix
+++ b/pkgs/development/compilers/llvm/7/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , zlib
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake perl python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
+    ++ lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
 
   postPatch = ''
@@ -50,14 +50,14 @@ stdenv.mkDerivation {
   CXXFLAGS = "-fno-rtti";
   hardeningDisable = [ "format" ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-I${libxml2.dev}/include/libxml2";
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-I${libxml2.dev}/include/libxml2";
 
   postInstall = ''
     mkdir -p $out/share/man/man1
     cp ../docs/lldb.1 $out/share/man/man1/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage    = "https://llvm.org/";
     license     = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/7/llvm.nix b/pkgs/development/compilers/llvm/7/llvm.nix
index 69114c7ca23..2d6f0d18722 100644
--- a/pkgs/development/compilers/llvm/7/llvm.nix
+++ b/pkgs/development/compilers/llvm/7/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , fetchpatch
 , cmake
@@ -23,10 +23,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a versioned symlinks of libLLVM.dylib
-  versionSuffixes = with stdenv.lib;
+  versionSuffixes = with lib;
     let parts = splitVersion release_version; in
     imap (i: _: concatStringsSep "." (take i parts)) parts;
 
@@ -158,7 +158,7 @@ in stdenv.mkDerivation ({
   + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
       --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
-    ${stdenv.lib.concatMapStringsSep "\n" (v: ''
+    ${lib.concatMapStringsSep "\n" (v: ''
       ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
     '') versionSuffixes}
   '';
@@ -171,11 +171,11 @@ in stdenv.mkDerivation ({
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/7/openmp.nix b/pkgs/development/compilers/llvm/7/openmp.nix
index e36b236fd02..9977ed3dd41 100644
--- a/pkgs/development/compilers/llvm/7/openmp.nix
+++ b/pkgs/development/compilers/llvm/7/openmp.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , llvm
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/8/clang/default.nix b/pkgs/development/compilers/llvm/8/clang/default.nix
index 0c00ce62715..8f44ffc0615 100644
--- a/pkgs/development/compilers/llvm/8/clang/default.nix
+++ b/pkgs/development/compilers/llvm/8/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -20,8 +20,8 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm lld ];
 
@@ -29,13 +29,13 @@ let
       "-DCMAKE_CXX_FLAGS=-std=c++11"
       "-DCLANGD_BUILD_XPC=OFF"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
       "-DSPHINX_OUTPUT_HTML=OFF"
       "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-    ] ++ stdenv.lib.optionals enablePolly [
+    ] ++ lib.optionals enablePolly [
       "-DWITH_POLLY=ON"
       "-DLINK_POLLY_INTO_TOOLS=ON"
     ];
@@ -62,9 +62,9 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace tools/extra/clangd/CMakeLists.txt \
         --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
     '';
@@ -101,10 +101,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/8/compiler-rt.nix b/pkgs/development/compilers/llvm/8/compiler-rt.nix
index 280204c6e35..2e49ef17346 100644
--- a/pkgs/development/compilers/llvm/8/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/8/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -53,22 +53,22 @@ stdenv.mkDerivation {
   patches = [
     ../7/compiler-rt-glibc.patch
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
-  ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional (useLLVM) ./crtbegin-and-end.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional (useLLVM) ./crtbegin-and-end.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -78,9 +78,9 @@ stdenv.mkDerivation {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix
index 6e80737f32a..4dc0b8dd3c4 100644
--- a/pkgs/development/compilers/llvm/8/default.nix
+++ b/pkgs/development/compilers/llvm/8/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "1qf3097bc5ia8p6cpmbx985rjr3yaah5s8fc0nv7pw742yv7jw8q";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -25,7 +25,7 @@ let
       ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -100,15 +100,15 @@ let
       extraPackages = [
         targetLlvmLibraries.libcxxabi
         targetLlvmLibraries.compiler-rt
-      ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
+      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
       ];
       extraBuildCommands = ''
         echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
         echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
         echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
         echo "-fno-exceptions" >> $out/nix-support/cc-cflags
       '' + mkExtraBuildCommands cc;
     };
@@ -160,12 +160,12 @@ let
 
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
       }));
 
@@ -174,12 +174,12 @@ let
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
     libcxx = callPackage ./libc++ ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
     libcxxabi = callPackage ./libc++abi.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
         libunwind = libraries.libunwind;
       }));
@@ -187,7 +187,7 @@ let
     openmp = callPackage ./openmp.nix {};
 
     libunwind = callPackage ./libunwind.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
diff --git a/pkgs/development/compilers/llvm/8/libc++/default.nix b/pkgs/development/compilers/llvm/8/libc++/default.nix
index 7a3a33bfd7d..70e4d9e1a65 100644
--- a/pkgs/development/compilers/llvm/8/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/8/libc++/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+  patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
 
   prePatch = ''
     substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
@@ -26,8 +26,8 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ];
 
@@ -35,13 +35,13 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
+  ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
+    ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
+    ++ lib.optional stdenv.hostPlatform.isWasm [
       "-DLIBCXX_ENABLE_THREADS=OFF"
       "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
       "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
+    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
 
   passthru = {
     isLLVM = true;
@@ -50,7 +50,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/8/libc++abi.nix b/pkgs/development/compilers/llvm/8/libc++abi.nix
index 50a38dfa967..5a74981eba8 100644
--- a/pkgs/development/compilers/llvm/8/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/8/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -9,15 +9,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "1vznz8n1z1h8af0ga451m98lc2hjnv4fyzl71napsvjhvk4g6nxp";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
 
-  cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+  cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ stdenv.lib.optionals (!enableShared) [
+  ] ++ lib.optionals (!enableShared) [
     "-DLIBCXXABI_ENABLE_SHARED=OFF"
   ];
 
@@ -27,11 +27,11 @@ stdenv.mkDerivation {
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
+  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
     patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch}
   '';
 
@@ -52,7 +52,7 @@ stdenv.mkDerivation {
       install -d -m 755 $out/include $out/lib
       install -m 644 lib/libc++abi.a $out/lib
       install -m 644 ../include/cxxabi.h $out/include
-    '' + stdenv.lib.optionalString enableShared ''
+    '' + lib.optionalString enableShared ''
       install -m 644 lib/libc++abi.so.1.0 $out/lib
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
@@ -61,8 +61,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/8/libunwind.nix b/pkgs/development/compilers/llvm/8/libunwind.nix
index 6e765865282..d1bd54fbd34 100644
--- a/pkgs/development/compilers/llvm/8/libunwind.nix
+++ b/pkgs/development/compilers/llvm/8/libunwind.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, fetchpatch
+{ lib, stdenv, version, fetch, cmake, fetchpatch
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -21,5 +21,5 @@ stdenv.mkDerivation {
     })
   ];
 
-  cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+  cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
 }
diff --git a/pkgs/development/compilers/llvm/8/lld.nix b/pkgs/development/compilers/llvm/8/lld.nix
index f890591b377..8009beb7bc1 100644
--- a/pkgs/development/compilers/llvm/8/lld.nix
+++ b/pkgs/development/compilers/llvm/8/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/8/lldb.nix b/pkgs/development/compilers/llvm/8/lldb.nix
index a22d27f9b29..83c171d2a57 100644
--- a/pkgs/development/compilers/llvm/8/lldb.nix
+++ b/pkgs/development/compilers/llvm/8/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , zlib
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake python3 which swig ];
   buildInputs = [ ncurses zlib libedit libxml2 llvm ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
+    ++ lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
 
   CXXFLAGS = "-fno-rtti";
   hardeningDisable = [ "format" ];
@@ -50,7 +50,7 @@ stdenv.mkDerivation {
     ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage    = "https://llvm.org/";
     license     = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/8/llvm.nix b/pkgs/development/compilers/llvm/8/llvm.nix
index e3ca31313ce..9c2c3416aea 100644
--- a/pkgs/development/compilers/llvm/8/llvm.nix
+++ b/pkgs/development/compilers/llvm/8/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , fetchpatch
 , cmake
@@ -23,10 +23,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
+  shortVersion = with lib;
     concatStringsSep "." (take 1 (splitVersion release_version));
 
 in stdenv.mkDerivation ({
@@ -155,11 +155,11 @@ in stdenv.mkDerivation ({
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/8/openmp.nix b/pkgs/development/compilers/llvm/8/openmp.nix
index 4eb43600dd6..ad2cd93fdb6 100644
--- a/pkgs/development/compilers/llvm/8/openmp.nix
+++ b/pkgs/development/compilers/llvm/8/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/9/clang/default.nix b/pkgs/development/compilers/llvm/9/clang/default.nix
index b880d843d59..87b29163f43 100644
--- a/pkgs/development/compilers/llvm/9/clang/default.nix
+++ b/pkgs/development/compilers/llvm/9/clang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
+{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
 , fixDarwinDylibNames
 , enableManpages ? false
 , enablePolly ? false # TODO: get this info from llvm (passthru?)
@@ -20,8 +20,8 @@ let
     '';
 
     nativeBuildInputs = [ cmake python3 ]
-      ++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
-      ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
     buildInputs = [ libxml2 llvm lld ];
 
@@ -29,13 +29,13 @@ let
       "-DCMAKE_CXX_FLAGS=-std=c++11"
       "-DCLANGD_BUILD_XPC=OFF"
       "-DLLVM_ENABLE_RTTI=ON"
-    ] ++ stdenv.lib.optionals enableManpages [
+    ] ++ lib.optionals enableManpages [
       "-DCLANG_INCLUDE_DOCS=ON"
       "-DLLVM_ENABLE_SPHINX=ON"
       "-DSPHINX_OUTPUT_MAN=ON"
       "-DSPHINX_OUTPUT_HTML=OFF"
       "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-    ] ++ stdenv.lib.optionals enablePolly [
+    ] ++ lib.optionals enablePolly [
       "-DWITH_POLLY=ON"
       "-DLINK_POLLY_INTO_TOOLS=ON"
     ];
@@ -55,9 +55,9 @@ let
 
       # Patch for standalone doc building
       sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
       sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
-    '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+    '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
       substituteInPlace tools/extra/clangd/CMakeLists.txt \
         --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
     '';
@@ -96,10 +96,10 @@ let
     meta = {
       description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
       homepage    = "https://llvm.org/";
-      license     = stdenv.lib.licenses.ncsa;
-      platforms   = stdenv.lib.platforms.all;
+      license     = lib.licenses.ncsa;
+      platforms   = lib.platforms.all;
     };
-  } // stdenv.lib.optionalAttrs enableManpages {
+  } // lib.optionalAttrs enableManpages {
     pname = "clang-manpages";
 
     buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/9/compiler-rt.nix b/pkgs/development/compilers/llvm/9/compiler-rt.nix
index 709d0c13477..2ab9dc8ffa2 100644
--- a/pkgs/development/compilers/llvm/9/compiler-rt.nix
+++ b/pkgs/development/compilers/llvm/9/compiler-rt.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
+{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
 
 let
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   src = fetch pname "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
 
   nativeBuildInputs = [ cmake python3 llvm ];
-  buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
+  buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
 
   NIX_CFLAGS_COMPILE = [
     "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@@ -24,24 +24,24 @@ stdenv.mkDerivation rec {
     "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
     "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
     "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
     "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
     "-DCOMPILER_RT_BUILD_XRAY=OFF"
     "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
-  ] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
+  ] ++ lib.optionals (useLLVM || bareMetal) [
     "-DCMAKE_C_COMPILER_WORKS=ON"
     "-DCMAKE_CXX_COMPILER_WORKS=ON"
     "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
     "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
-  ] ++ stdenv.lib.optionals (useLLVM) [
+  ] ++ lib.optionals (useLLVM) [
     "-DCOMPILER_RT_BUILD_BUILTINS=ON"
     "-DCMAKE_C_FLAGS=-nodefaultlibs"
     #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
     "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
-  ] ++ stdenv.lib.optionals (bareMetal) [
+  ] ++ lib.optionals (bareMetal) [
     "-DCOMPILER_RT_OS_DIR=baremetal"
-  ] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
     # The compiler-rt build infrastructure sniffs supported platforms on Darwin
     # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
     # when it tries to use libc++ and libc++api for i386.
@@ -53,21 +53,21 @@ stdenv.mkDerivation rec {
   patches = [
     ../7/compiler-rt-glibc.patch
     ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
-  ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
-    ++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
+  ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
+    ++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
 
   # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
   # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
   # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
   # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
   # a flag and turn the flag off during the stdenv build.
-  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
     substituteInPlace cmake/builtin-config-ix.cmake \
       --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
@@ -77,9 +77,9 @@ stdenv.mkDerivation rec {
   '';
 
   # Hack around weird upsream RPATH bug
-  postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
     ln -s "$out/lib"/*/* "$out/lib"
-  '' + stdenv.lib.optionalString (useLLVM) ''
+  '' + lib.optionalString (useLLVM) ''
     ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
     ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
     ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix
index 6f5bdb8e8cc..e381b192766 100644
--- a/pkgs/development/compilers/llvm/9/default.nix
+++ b/pkgs/development/compilers/llvm/9/default.nix
@@ -1,4 +1,4 @@
-{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
 , buildPackages
 , buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
 
   clang-tools-extra_src = fetch "clang-tools-extra" "01vgzd4k1q93nfs8gyl83mjlc4x0qsgfqw32lacbjzdxg0mdfvxj";
 
-  tools = stdenv.lib.makeExtensible (tools: let
+  tools = lib.makeExtensible (tools: let
     callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
     mkExtraBuildCommands = cc: ''
       rsrc="$out/resource-root"
@@ -25,7 +25,7 @@ let
       ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
       ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
       echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
-    '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
+    '' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
       echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
     '';
   in {
@@ -100,15 +100,15 @@ let
       extraPackages = [
         targetLlvmLibraries.libcxxabi
         targetLlvmLibraries.compiler-rt
-      ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
+      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
         targetLlvmLibraries.libunwind
       ];
       extraBuildCommands = ''
         echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
         echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+      '' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
         echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
-      '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
+      '' + lib.optionalString stdenv.targetPlatform.isWasm ''
         echo "-fno-exceptions" >> $out/nix-support/cc-cflags
       '' + mkExtraBuildCommands cc;
     };
@@ -160,12 +160,12 @@ let
 
   });
 
-  libraries = stdenv.lib.makeExtensible (libraries: let
+  libraries = lib.makeExtensible (libraries: let
     callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
   in {
 
     compiler-rt = callPackage ./compiler-rt.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
       }));
 
@@ -174,12 +174,12 @@ let
     libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
 
     libcxx = callPackage ./libc++ ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
     libcxxabi = callPackage ./libc++abi.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
         libunwind = libraries.libunwind;
       }));
@@ -187,7 +187,7 @@ let
     openmp = callPackage ./openmp.nix {};
 
     libunwind = callPackage ./libunwind.nix ({} //
-      (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
+      (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
         stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
       }));
 
diff --git a/pkgs/development/compilers/llvm/9/libc++/default.nix b/pkgs/development/compilers/llvm/9/libc++/default.nix
index c70130d36a4..6ea1e28e7b4 100644
--- a/pkgs/development/compilers/llvm/9/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/9/libc++/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
   '';
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
+  patches = lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch;
 
   preConfigure = ''
     # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
@@ -22,8 +22,8 @@ stdenv.mkDerivation {
     patchShebangs utils/cat_files.py
   '';
   nativeBuildInputs = [ cmake ]
-    ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
-    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
 
   buildInputs = [ libcxxabi ];
 
@@ -31,13 +31,13 @@ stdenv.mkDerivation {
     "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
     "-DLIBCXX_LIBCPPABI_VERSION=2"
     "-DLIBCXX_CXX_ABI=libcxxabi"
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
-    ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
-    ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
+  ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
+    ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
+    ++ lib.optional stdenv.hostPlatform.isWasm [
       "-DLIBCXX_ENABLE_THREADS=OFF"
       "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
       "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
-    ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
+    ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
 
   passthru = {
     isLLVM = true;
@@ -46,7 +46,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxx.llvm.org/";
     description = "A new implementation of the C++ standard library, targeting C++11";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/9/libc++abi.nix b/pkgs/development/compilers/llvm/9/libc++abi.nix
index 13f033091be..e8e08f84801 100644
--- a/pkgs/development/compilers/llvm/9/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/9/libc++abi.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
+{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -9,15 +9,15 @@ stdenv.mkDerivation {
   src = fetch "libcxxabi" "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8";
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
+  buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
 
-  cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
+  cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
-  ] ++ stdenv.lib.optionals (!enableShared) [
+  ] ++ lib.optionals (!enableShared) [
     "-DLIBCXXABI_ENABLE_SHARED=OFF"
   ];
 
@@ -27,11 +27,11 @@ stdenv.mkDerivation {
     unpackFile ${libcxx.src}
     unpackFile ${llvm.src}
     cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     export TRIPLE=x86_64-apple-darwin
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
+  '' + lib.optionalString stdenv.hostPlatform.isWasm ''
     patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch}
   '';
 
@@ -52,7 +52,7 @@ stdenv.mkDerivation {
       install -d -m 755 $out/include $out/lib
       install -m 644 lib/libc++abi.a $out/lib
       install -m 644 ../include/cxxabi.h $out/include
-    '' + stdenv.lib.optionalString enableShared ''
+    '' + lib.optionalString enableShared ''
       install -m 644 lib/libc++abi.so.1.0 $out/lib
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
       ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
@@ -61,8 +61,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://libcxxabi.llvm.org/";
     description = "A new implementation of low level support for a standard C++ library";
-    license = with stdenv.lib.licenses; [ ncsa mit ];
-    maintainers = with stdenv.lib.maintainers; [ vlstill ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ ncsa mit ];
+    maintainers = with lib.maintainers; [ vlstill ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/9/libunwind.nix b/pkgs/development/compilers/llvm/9/libunwind.nix
index 86756c53829..4c4c85512e3 100644
--- a/pkgs/development/compilers/llvm/9/libunwind.nix
+++ b/pkgs/development/compilers/llvm/9/libunwind.nix
@@ -1,4 +1,4 @@
-{ stdenv, version, fetch, cmake, fetchpatch
+{ lib, stdenv, version, fetch, cmake, fetchpatch
 , enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
@@ -10,5 +10,5 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
-  cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+  cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
 }
diff --git a/pkgs/development/compilers/llvm/9/lld.nix b/pkgs/development/compilers/llvm/9/lld.nix
index a2b17a97cdc..8b12642d2a7 100644
--- a/pkgs/development/compilers/llvm/9/lld.nix
+++ b/pkgs/development/compilers/llvm/9/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , libxml2
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "The LLVM Linker";
     homepage    = "https://lld.llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/9/lldb.nix b/pkgs/development/compilers/llvm/9/lldb.nix
index 9c43287b166..8da5c0bef68 100644
--- a/pkgs/development/compilers/llvm/9/lldb.nix
+++ b/pkgs/development/compilers/llvm/9/lldb.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , zlib
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
     libxml2
     llvm
   ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [
+  ++ lib.optionals stdenv.isDarwin [
     darwin.libobjc
     darwin.apple_sdk.libs.xpc
     darwin.apple_sdk.frameworks.Foundation
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A next-generation high-performance debugger";
     homepage = "https://llvm.org/";
     license = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/9/llvm.nix b/pkgs/development/compilers/llvm/9/llvm.nix
index c46e54debe9..207dc242b91 100644
--- a/pkgs/development/compilers/llvm/9/llvm.nix
+++ b/pkgs/development/compilers/llvm/9/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetch
 , cmake
 , python3
@@ -22,10 +22,10 @@
 }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (lib) optional optionals optionalString;
 
   # Used when creating a version-suffixed symlink of libLLVM.dylib
-  shortVersion = with stdenv.lib;
+  shortVersion = with lib;
     concatStringsSep "." (take 1 (splitString "." release_version));
 
 in stdenv.mkDerivation (rec {
@@ -163,11 +163,11 @@ in stdenv.mkDerivation (rec {
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies";
     homepage    = "https://llvm.org/";
-    license     = stdenv.lib.licenses.ncsa;
-    maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.ncsa;
+    maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
+    platforms   = lib.platforms.all;
   };
-} // stdenv.lib.optionalAttrs enableManpages {
+} // lib.optionalAttrs enableManpages {
   pname = "llvm-manpages";
 
   buildPhase = ''
diff --git a/pkgs/development/compilers/llvm/9/openmp.nix b/pkgs/development/compilers/llvm/9/openmp.nix
index 9fdcf9e6cff..35997c9dda4 100644
--- a/pkgs/development/compilers/llvm/9/openmp.nix
+++ b/pkgs/development/compilers/llvm/9/openmp.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Components required to build an executable OpenMP program";
     homepage    = "https://openmp.llvm.org/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/llvm/rocm/clang.nix b/pkgs/development/compilers/llvm/rocm/clang.nix
index 6bb23b77543..789d4c055eb 100644
--- a/pkgs/development/compilers/llvm/rocm/clang.nix
+++ b/pkgs/development/compilers/llvm/rocm/clang.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , python
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
     #undef CLANG_REPOSITORY
   '';
 
-  postUnpack = stdenv.lib.optionalString (!(isNull clang-tools-extra_src)) ''
+  postUnpack = lib.optionalString (!(isNull clang-tools-extra_src)) ''
     ln -s ${clang-tools-extra_src} $sourceRoot/tools/extra
   '';
 
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
     echo "$VCSVersion" > lib/Basic/VCSVersion.inc
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "ROCm fork of the clang C/C++/Objective-C/Objective-C++ LLVM compiler frontend";
     homepage = "https://llvm.org/";
     license = with licenses; [ ncsa ];
diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix
index 36b42cef392..ffa1aff9537 100644
--- a/pkgs/development/compilers/llvm/rocm/default.nix
+++ b/pkgs/development/compilers/llvm/rocm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, callPackage, wrapCCWith }:
+{ lib, stdenv, fetchFromGitHub, callPackage, wrapCCWith }:
 
 let
   version = "4.0.0";
diff --git a/pkgs/development/compilers/llvm/rocm/lld.nix b/pkgs/development/compilers/llvm/rocm/lld.nix
index 34a094bf379..2a05331f7a0 100644
--- a/pkgs/development/compilers/llvm/rocm/lld.nix
+++ b/pkgs/development/compilers/llvm/rocm/lld.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , cmake
 , libxml2
 , llvm
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
       --replace "\''${_IMPORT_PREFIX}/bin/lld" "$out/bin/lld"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "ROCm fork of the LLVM Linker";
     homepage = "https://github.com/RadeonOpenCompute/llvm-project";
     license = licenses.ncsa;
diff --git a/pkgs/development/compilers/llvm/rocm/llvm.nix b/pkgs/development/compilers/llvm/rocm/llvm.nix
index 909284a3e91..d6fe211c475 100644
--- a/pkgs/development/compilers/llvm/rocm/llvm.nix
+++ b/pkgs/development/compilers/llvm/rocm/llvm.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , python3
@@ -26,7 +26,7 @@ in stdenv.mkDerivation rec {
   pname = "rocm-llvm";
 
   outputs = [ "out" "python" ]
-    ++ stdenv.lib.optional enableSharedLibraries "lib";
+    ++ lib.optional enableSharedLibraries "lib";
 
   nativeBuildInputs = [ cmake python3 ];
 
@@ -44,10 +44,10 @@ in stdenv.mkDerivation rec {
     "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
   ]
   ++
-  stdenv.lib.optional
+  lib.optional
     enableSharedLibraries
     "-DLLVM_LINK_LLVM_DYLIB=ON"
-  ++ stdenv.lib.optionals enableManpages [
+  ++ lib.optionals enableManpages [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
     "-DLLVM_BUILD_DOCS=ON"
     "-DLLVM_ENABLE_SPHINX=ON"
@@ -78,7 +78,7 @@ in stdenv.mkDerivation rec {
   postInstall = ''
     moveToOutput share/opt-viewer "$python"
   ''
-  + stdenv.lib.optionalString enableSharedLibraries ''
+  + lib.optionalString enableSharedLibraries ''
     moveToOutput "lib/libLLVM-*" "$lib"
     moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
     substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
@@ -87,7 +87,7 @@ in stdenv.mkDerivation rec {
 
   passthru.src = src;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "ROCm fork of the LLVM compiler infrastructure";
     homepage = "https://github.com/RadeonOpenCompute/llvm-project";
     license = with licenses; [ ncsa ];
diff --git a/pkgs/development/compilers/lobster/default.nix b/pkgs/development/compilers/lobster/default.nix
index 728049448e6..b65d640b475 100644
--- a/pkgs/development/compilers/lobster/default.nix
+++ b/pkgs/development/compilers/lobster/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , unstableGitUpdater
 , cmake
@@ -51,7 +51,7 @@ stdenv.mkDerivation rec {
     updateScript = unstableGitUpdater { };
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://strlen.com/lobster";
     description = "The Lobster programming language";
     longDescription = ''
diff --git a/pkgs/development/compilers/mcpp/default.nix b/pkgs/development/compilers/mcpp/default.nix
index 023bae48b3e..efb5972e542 100644
--- a/pkgs/development/compilers/mcpp/default.nix
+++ b/pkgs/development/compilers/mcpp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch }:
+{ lib, stdenv, fetchurl, fetchpatch }:
 
 stdenv.mkDerivation rec {
   pname = "mcpp";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://mcpp.sourceforge.net/";
     description = "A portable c preprocessor";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/mercury/default.nix b/pkgs/development/compilers/mercury/default.nix
index d7029733381..e063c4c0921 100644
--- a/pkgs/development/compilers/mercury/default.nix
+++ b/pkgs/development/compilers/mercury/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gcc, flex, bison, texinfo, jdk, erlang, makeWrapper
+{ lib, stdenv, fetchurl, gcc, flex, bison, texinfo, jdk, erlang, makeWrapper
 , readline }:
 
 stdenv.mkDerivation rec {
@@ -55,8 +55,8 @@ stdenv.mkDerivation rec {
       trade-offs.
     '';
     homepage    = "http://mercurylang.org";
-    license     = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+    license     = lib.licenses.gpl2;
+    platforms = lib.platforms.linux ++ lib.platforms.darwin;
     maintainers = [ ];
   };
 }
diff --git a/pkgs/development/compilers/meta-environment/meta-build-env/default.nix b/pkgs/development/compilers/meta-environment/meta-build-env/default.nix
index a5c7054c3a6..34d8f98970e 100644
--- a/pkgs/development/compilers/meta-environment/meta-build-env/default.nix
+++ b/pkgs/development/compilers/meta-environment/meta-build-env/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}: stdenv.mkDerivation {
+{lib, stdenv, fetchurl}: stdenv.mkDerivation {
   name = "meta-build-env-0.1";
   src = fetchurl {
     url = "http://www.meta-environment.org/releases/meta-build-env-0.1.tar.gz";
@@ -6,6 +6,6 @@
   };
 
   meta = {
-    platforms = stdenv.lib.platforms.unix;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/mezzo/default.nix b/pkgs/development/compilers/mezzo/default.nix
index a90076c9ecc..4c535be4d49 100644
--- a/pkgs/development/compilers/mezzo/default.nix
+++ b/pkgs/development/compilers/mezzo/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, menhir, yojson, ulex, pprint, fix, functory }:
+{ lib, stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, menhir, yojson, ulex, pprint, fix, functory }:
 
-if stdenv.lib.versionAtLeast ocaml.version "4.06"
+if lib.versionAtLeast ocaml.version "4.06"
 then throw "mezzo is not available for OCaml ${ocaml.version}"
 else
 
 let
-  check-ocaml-version = with stdenv.lib; versionAtLeast (getVersion ocaml);
+  check-ocaml-version = with lib; versionAtLeast (getVersion ocaml);
 in
 
 assert check-ocaml-version "4";
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   buildInputs = [ ocaml findlib ocamlbuild yojson menhir ulex pprint fix functory ];
 
   # Sets warning 3 as non-fatal
-  prePatch = stdenv.lib.optionalString (check-ocaml-version "4.02") ''
+  prePatch = lib.optionalString (check-ocaml-version "4.02") ''
     substituteInPlace myocamlbuild.pre.ml \
     --replace '@1..3' '@1..2+3'
   '';
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
     cp mezzo $out/bin/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://protz.github.io/mezzo/";
     description = "A programming language in the ML tradition, which places strong emphasis on the control of aliasing and access to mutable memory";
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/microscheme/default.nix b/pkgs/development/compilers/microscheme/default.nix
index ba3e388c399..ee2de8518f3 100644
--- a/pkgs/development/compilers/microscheme/default.nix
+++ b/pkgs/development/compilers/microscheme/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, vim, makeWrapper }:
+{ lib, stdenv, fetchzip, vim, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "microscheme";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     make install PREFIX=$out
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://microscheme.org";
     description = "A Scheme subset for Atmel microcontrollers";
     longDescription = ''
diff --git a/pkgs/development/compilers/miranda/default.nix b/pkgs/development/compilers/miranda/default.nix
index 55d3976858b..298cb5e21ea 100644
--- a/pkgs/development/compilers/miranda/default.nix
+++ b/pkgs/development/compilers/miranda/default.nix
@@ -64,7 +64,7 @@ stdenv.mkDerivation rec {
     patchShebangs quotehostinfo
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Compiler for Miranda -- a pure, non-strict, polymorphic, higher order functional programming language";
     homepage = "https://www.cs.kent.ac.uk/people/staff/dat/miranda/";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/mit-scheme/default.nix b/pkgs/development/compilers/mit-scheme/default.nix
index a3b320c384f..8cf709c10ae 100644
--- a/pkgs/development/compilers/mit-scheme/default.nix
+++ b/pkgs/development/compilers/mit-scheme/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, makeWrapper, gnum4, texinfo, texLive, automake,
+{ fetchurl, lib, stdenv, makeWrapper, gnum4, texinfo, texLive, automake,
   enableX11 ? false, xlibsWrapper ? null }:
 
 let
@@ -63,7 +63,7 @@ stdenv.mkDerivation {
   # XXX: The `check' target doesn't exist.
   doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "MIT/GNU Scheme, a native code Scheme compiler";
 
     longDescription =
diff --git a/pkgs/development/compilers/mkcl/default.nix b/pkgs/development/compilers/mkcl/default.nix
index baaf978d298..3656f1e0dd8 100644
--- a/pkgs/development/compilers/mkcl/default.nix
+++ b/pkgs/development/compilers/mkcl/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, makeWrapper, gmp, gcc }:
+{ lib, stdenv, fetchFromGitHub, makeWrapper, gmp, gcc }:
 
-with stdenv.lib; stdenv.mkDerivation rec {
+with lib; stdenv.mkDerivation rec {
   pname = "mkcl";
   version = "1.1.11";
 
diff --git a/pkgs/development/compilers/mlkit/default.nix b/pkgs/development/compilers/mlkit/default.nix
index 8ce19c1be3d..5fc134f5ab2 100644
--- a/pkgs/development/compilers/mlkit/default.nix
+++ b/pkgs/development/compilers/mlkit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, mlton }:
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, mlton }:
 
 stdenv.mkDerivation rec {
   pname = "mlkit";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   buildFlags = ["mlkit" "mlkit_libs"];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Standard ML Compiler and Toolkit";
     homepage = "https://elsman.com/mlkit/";
     license = licenses.gpl2Plus;
diff --git a/pkgs/development/compilers/mlton/20130715.nix b/pkgs/development/compilers/mlton/20130715.nix
index 52bb0a0775c..98b4aeda551 100644
--- a/pkgs/development/compilers/mlton/20130715.nix
+++ b/pkgs/development/compilers/mlton/20130715.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, patchelf, gmp }:
+{ lib, stdenv, fetchurl, patchelf, gmp }:
 
 let
   version = "20130715";
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
   sourceRoot = "${pname}-${version}";
 
   buildInputs = [ gmp ];
-  nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf;
+  nativeBuildInputs = lib.optional stdenv.isLinux patchelf;
 
   makeFlags = [ "all-no-docs" ];
 
@@ -61,9 +61,9 @@ stdenv.mkDerivation rec {
     done
 
     substituteInPlace $(pwd)/../${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $(pwd)/../${usr_prefix}/lib/mlton
-  '' + stdenv.lib.optionalString stdenv.cc.isClang ''
+  '' + lib.optionalString stdenv.cc.isClang ''
     sed -i "s_	patch -s -p0 <gdtoa.hide-public-fns.patch_	patch -s -p0 <gdtoa.hide-public-fns.patch\n\tsed -i 's|printf(emptyfmt|printf(\"\"|g' ./gdtoa/arithchk.c_" ./runtime/Makefile
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     sed -i 's|XCFLAGS += -I/usr/local/include -I/sw/include -I/opt/local/include||' ./runtime/Makefile
   '';
 
@@ -79,13 +79,13 @@ stdenv.mkDerivation rec {
     # So the builder runs the binary compiler with gmp.
     export LD_LIBRARY_PATH=${gmp.out}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
 
-  '' + stdenv.lib.optionalString stdenv.isLinux ''
+  '' + lib.optionalString stdenv.isLinux ''
     # Patch ELF interpreter.
     patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
     for e in mllex mlyacc ; do
       patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/bin/$e
     done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     # Patch libgmp linking
     install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
     install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mlyacc
diff --git a/pkgs/development/compilers/mlton/20180207-binary.nix b/pkgs/development/compilers/mlton/20180207-binary.nix
index 2b4998f91c9..4846b58bf26 100644
--- a/pkgs/development/compilers/mlton/20180207-binary.nix
+++ b/pkgs/development/compilers/mlton/20180207-binary.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, patchelf, gmp }:
+{ lib, stdenv, fetchurl, patchelf, gmp }:
 let
   dynamic-linker = stdenv.cc.bintools.dynamicLinker;
 in
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     throw "Architecture not supported";
 
   buildInputs = [ gmp ];
-  nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf;
+  nativeBuildInputs = lib.optional stdenv.isLinux patchelf;
 
   buildPhase = ''
     make update \
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
     make install PREFIX=$out
   '';
 
-  postFixup = stdenv.lib.optionalString stdenv.isLinux ''
+  postFixup = lib.optionalString stdenv.isLinux ''
     patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile
     patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile
 
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
       patchelf --set-interpreter ${dynamic-linker} $out/bin/$e
       patchelf --set-rpath ${gmp}/lib $out/bin/$e
     done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     install_name_tool -change \
       /opt/local/lib/libgmp.10.dylib \
       ${gmp}/lib/libgmp.10.dylib \
diff --git a/pkgs/development/compilers/mono/generic.nix b/pkgs/development/compilers/mono/generic.nix
index 40d85be5a24..901848c693a 100644
--- a/pkgs/development/compilers/mono/generic.nix
+++ b/pkgs/development/compilers/mono/generic.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, bison, pkg-config, glib, gettext, perl, libgdiplus, libX11, callPackage, ncurses, zlib, withLLVM ? false, cacert, Foundation, libobjc, python3, version, sha256, autoconf, libtool, automake, cmake, which
+{ lib, stdenv, fetchurl, bison, pkg-config, glib, gettext, perl, libgdiplus, libX11, callPackage, ncurses, zlib, withLLVM ? false, cacert, Foundation, libobjc, python3, version, sha256, autoconf, libtool, automake, cmake, which
 , gnumake42
 , enableParallelBuilding ? true
 , srcArchiveSuffix ? "tar.bz2"
@@ -21,14 +21,14 @@ stdenv.mkDerivation rec {
   buildInputs =
     [ glib gettext perl libgdiplus libX11 ncurses zlib python3 autoconf libtool
     ]
-    ++ (stdenv.lib.optionals stdenv.isDarwin [ Foundation libobjc ]);
+    ++ (lib.optionals stdenv.isDarwin [ Foundation libobjc ]);
 
   configureFlags = [
     "--x-includes=${libX11.dev}/include"
     "--x-libraries=${libX11.out}/lib"
     "--with-libgdiplus=${libgdiplus}/lib/libgdiplus.so"
   ]
-  ++ stdenv.lib.optionals withLLVM [
+  ++ lib.optionals withLLVM [
     "--enable-llvm"
     "--with-llvm=${llvm}"
   ];
@@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
   preBuild = ''
     makeFlagsArray=(INSTALL=`type -tp install`)
     substituteInPlace mcs/class/corlib/System/Environment.cs --replace /usr/share "$out/share"
-  '' + stdenv.lib.optionalString withLLVM ''
+  '' + lib.optionalString withLLVM ''
     substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")"
   '';
 
@@ -75,7 +75,7 @@ stdenv.mkDerivation rec {
 
   inherit enableParallelBuilding;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://mono-project.com/";
     description = "Cross platform, open source .NET development framework";
     platforms = with platforms; darwin ++ linux;
diff --git a/pkgs/development/compilers/mono/llvm.nix b/pkgs/development/compilers/mono/llvm.nix
index 0a0f232227d..c69a4021677 100644
--- a/pkgs/development/compilers/mono/llvm.nix
+++ b/pkgs/development/compilers/mono/llvm.nix
@@ -39,13 +39,13 @@ stdenv.mkDerivation {
   cmakeFlags = with stdenv; [
     "-DLLVM_ENABLE_FFI=ON"
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-  ] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
+  ] ++ lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
 
   meta = {
     description = "Collection of modular and reusable compiler and toolchain technologies - Mono build";
     homepage    = "http://llvm.org/";
-    license     = stdenv.lib.licenses.bsd3;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/compilers/mosml/default.nix b/pkgs/development/compilers/mosml/default.nix
index 3d94303cbaa..ec8fa793cfd 100644
--- a/pkgs/development/compilers/mosml/default.nix
+++ b/pkgs/development/compilers/mosml/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gmp, perl }:
+{ lib, stdenv, fetchurl, gmp, perl }:
 
 stdenv.mkDerivation rec {
   pname = "mosml";
@@ -6,7 +6,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ gmp perl ];
 
-  makeFlags = [ "PREFIX=$(out)" ] ++ stdenv.lib.optionals stdenv.isDarwin [ "CC=cc" ];
+  makeFlags = [ "PREFIX=$(out)" ] ++ lib.optionals stdenv.isDarwin [ "CC=cc" ];
 
   src = fetchurl {
     url = "https://github.com/kfl/mosml/archive/ver-${version}.tar.gz";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   setSourceRoot = ''export sourceRoot="$(echo */src)"'';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A light-weight implementation of Standard ML";
     longDescription = ''
       Moscow ML is a light-weight implementation of Standard ML (SML), a strict
diff --git a/pkgs/development/compilers/mozart/binary.nix b/pkgs/development/compilers/mozart/binary.nix
index 66d642dbbbd..8366fd77a47 100644
--- a/pkgs/development/compilers/mozart/binary.nix
+++ b/pkgs/development/compilers/mozart/binary.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper
+{ lib, stdenv, fetchurl, makeWrapper
 , boost, gmp
 , tcl-8_5, tk-8_5
 , emacs
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
 
   src = binaries.${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}");
 
-  libPath = stdenv.lib.makeLibraryPath
+  libPath = lib.makeLibraryPath
     [ stdenv.cc.cc
       boost
       gmp
@@ -51,8 +51,8 @@ stdenv.mkDerivation {
 
     wrapProgram $out/bin/ozemulator --set OZHOME $out
 
-    ${stdenv.lib.optionalString (emacs != null) ''
-      wrapProgram $out/bin/oz --suffix PATH ":" ${stdenv.lib.makeBinPath [ emacs ]}
+    ${lib.optionalString (emacs != null) ''
+      wrapProgram $out/bin/oz --suffix PATH ":" ${lib.makeBinPath [ emacs ]}
     ''}
 
     sed -i $out/share/applications/oz.desktop \
@@ -63,7 +63,7 @@ stdenv.mkDerivation {
     patchShebangs $out
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://www.mozart-oz.org/";
     description = "Multiplatform implementation of the Oz programming language";
     longDescription = ''
diff --git a/pkgs/development/compilers/mruby/default.nix b/pkgs/development/compilers/mruby/default.nix
index eee4f2c64eb..25d35adff94 100644
--- a/pkgs/development/compilers/mruby/default.nix
+++ b/pkgs/development/compilers/mruby/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, ruby, bison, rake, fetchFromGitHub }:
+{ lib, stdenv, ruby, bison, rake, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
   pname = "mruby";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An embeddable implementation of the Ruby language";
     homepage = "https://mruby.org";
     maintainers = [ maintainers.nicknovitski ];
diff --git a/pkgs/development/compilers/nasm/default.nix b/pkgs/development/compilers/nasm/default.nix
index 89217db6818..ce053e87130 100644
--- a/pkgs/development/compilers/nasm/default.nix
+++ b/pkgs/development/compilers/nasm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl }:
+{ lib, stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
   pname = "nasm";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     make test
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.nasm.us/";
     description = "An 80x86 and x86-64 assembler designed for portability and modularity";
     platforms = platforms.unix;
diff --git a/pkgs/development/compilers/neko/default.nix b/pkgs/development/compilers/neko/default.nix
index b31a2daa1f8..8b157fb4ca0 100644
--- a/pkgs/development/compilers/neko/default.nix
+++ b/pkgs/development/compilers/neko/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, boehmgc, zlib, sqlite, pcre, cmake, pkg-config
+{ lib, stdenv, fetchurl, boehmgc, zlib, sqlite, pcre, cmake, pkg-config
 , git, apacheHttpd, apr, aprutil, libmysqlclient, mbedtls, openssl, pkgs, gtk2, libpthreadstubs
 }:
 
@@ -15,8 +15,8 @@ stdenv.mkDerivation rec {
   buildInputs =
     [ boehmgc zlib sqlite pcre apacheHttpd apr aprutil
       libmysqlclient mbedtls openssl libpthreadstubs ]
-      ++ stdenv.lib.optional stdenv.isLinux gtk2
-      ++ stdenv.lib.optionals stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security
+      ++ lib.optional stdenv.isLinux gtk2
+      ++ lib.optionals stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security
                                                 pkgs.darwin.apple_sdk.frameworks.Carbon];
   cmakeFlags = [ "-DRUN_LDCONFIG=OFF" ];
 
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   dontPatchELF = true;
   dontStrip = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A high-level dynamically typed programming language";
     homepage = "https://nekovm.org";
     license = licenses.lgpl21;
diff --git a/pkgs/development/compilers/obliv-c/default.nix b/pkgs/development/compilers/obliv-c/default.nix
index cdd0cf375bc..8a647a31c7c 100644
--- a/pkgs/development/compilers/obliv-c/default.nix
+++ b/pkgs/development/compilers/obliv-c/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, libgcrypt, fetchFromGitHub, ocamlPackages, perl }:
+{ lib, stdenv, libgcrypt, fetchFromGitHub, ocamlPackages, perl }:
 stdenv.mkDerivation rec {
   pname = "obliv-c";
   version = "0.0pre20180624";
@@ -35,8 +35,8 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "A GCC wrapper that makes it easy to embed secure computation protocols inside regular C programs";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.bsd3;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/ocaml/3.08.0.nix b/pkgs/development/compilers/ocaml/3.08.0.nix
index cd621c131ff..5762bed41a4 100644
--- a/pkgs/development/compilers/ocaml/3.08.0.nix
+++ b/pkgs/development/compilers/ocaml/3.08.0.nix
@@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
   checkTarget = ["opt.opt"];
 
   meta = {
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/ocaml/3.10.0.nix b/pkgs/development/compilers/ocaml/3.10.0.nix
index 8f26790020c..e3778457fd3 100644
--- a/pkgs/development/compilers/ocaml/3.10.0.nix
+++ b/pkgs/development/compilers/ocaml/3.10.0.nix
@@ -26,9 +26,9 @@ stdenv.mkDerivation (rec {
 
   meta = {
     homepage = "http://caml.inria.fr/ocaml";
-    license = with stdenv.lib.licenses; [ qpl lgpl2 ];
+    license = with lib.licenses; [ qpl lgpl2 ];
     description = "Most popular variant of the Caml language";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 
 })
diff --git a/pkgs/development/compilers/ocaml/3.11.2.nix b/pkgs/development/compilers/ocaml/3.11.2.nix
index 8c9a6ef07fa..642b0d91b7f 100644
--- a/pkgs/development/compilers/ocaml/3.11.2.nix
+++ b/pkgs/development/compilers/ocaml/3.11.2.nix
@@ -3,7 +3,7 @@
 let
    useX11 = stdenv.isi686 || stdenv.isx86_64;
    useNativeCompilers = stdenv.isi686 || stdenv.isx86_64 || stdenv.isMips;
-   inherit (stdenv.lib) optionals optionalString;
+   inherit (lib) optionals optionalString;
 in
 
 stdenv.mkDerivation rec {
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
     ln -sv $out/lib/ocaml/caml $out/include/caml
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://caml.inria.fr/ocaml";
     license = with licenses; [
       qpl /* compiler */
diff --git a/pkgs/development/compilers/ocaml/3.12.1.nix b/pkgs/development/compilers/ocaml/3.12.1.nix
index f90d61744f5..781b5be0982 100644
--- a/pkgs/development/compilers/ocaml/3.12.1.nix
+++ b/pkgs/development/compilers/ocaml/3.12.1.nix
@@ -3,7 +3,7 @@
 let
    useX11 = !stdenv.isAarch32 && !stdenv.isMips;
    useNativeCompilers = !stdenv.isMips;
-   inherit (stdenv.lib) optionals optionalString;
+   inherit (lib) optionals optionalString;
 in
 
 stdenv.mkDerivation rec {
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
     nativeCompilers = useNativeCompilers;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://caml.inria.fr/ocaml";
     branch = "3.12";
     license = with licenses; [
diff --git a/pkgs/development/compilers/ocaml/4.00.1.nix b/pkgs/development/compilers/ocaml/4.00.1.nix
index 81a8e0034fe..93e08740ddd 100644
--- a/pkgs/development/compilers/ocaml/4.00.1.nix
+++ b/pkgs/development/compilers/ocaml/4.00.1.nix
@@ -1,9 +1,9 @@
-{ stdenv, fetchurl, ncurses, xlibsWrapper }:
+{ lib, stdenv, fetchurl, ncurses, xlibsWrapper }:
 
 let
    useX11 = !stdenv.isAarch32 && !stdenv.isMips;
    useNativeCompilers = !stdenv.isMips;
-   inherit (stdenv.lib) optional optionals optionalString;
+   inherit (lib) optional optionals optionalString;
 in
 
 stdenv.mkDerivation rec {
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     nativeCompilers = useNativeCompilers;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://caml.inria.fr/ocaml";
     branch = "4.00";
     license = with licenses; [
diff --git a/pkgs/development/compilers/ocaml/ber-metaocaml.nix b/pkgs/development/compilers/ocaml/ber-metaocaml.nix
index a6ddcd8ce8f..d3ab0d6e1c6 100644
--- a/pkgs/development/compilers/ocaml/ber-metaocaml.nix
+++ b/pkgs/development/compilers/ocaml/ber-metaocaml.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ lib, stdenv, fetchurl
 , ncurses
 , libX11, xorgproto, buildEnv
 }:
@@ -6,7 +6,7 @@
 let
    useX11 = stdenv.isi686 || stdenv.isx86_64;
    x11deps = [ libX11 xorgproto ];
-   inherit (stdenv.lib) optionals;
+   inherit (lib) optionals;
 
    baseOcamlBranch  = "4.07";
    baseOcamlVersion = "${baseOcamlBranch}.1";
@@ -78,7 +78,7 @@ stdenv.mkDerivation rec {
     nativeCompilers = true;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description     = "Multi-Stage Programming extension for OCaml";
     homepage        = "http://okmij.org/ftp/ML/MetaOCaml.html";
     license         = with licenses; [ /* compiler */ qpl /* library */ lgpl2 ];
diff --git a/pkgs/development/compilers/ocaml/generic.nix b/pkgs/development/compilers/ocaml/generic.nix
index 79aab1ffe83..d4a6b6250b5 100644
--- a/pkgs/development/compilers/ocaml/generic.nix
+++ b/pkgs/development/compilers/ocaml/generic.nix
@@ -6,17 +6,17 @@ let
   safeX11 = stdenv: !(stdenv.isAarch32 || stdenv.isMips);
 in
 
-{ stdenv, fetchurl, ncurses, buildEnv, libunwind
-, libX11, xorgproto, useX11 ? safeX11 stdenv && !stdenv.lib.versionAtLeast version "4.09"
+{ lib, stdenv, fetchurl, ncurses, buildEnv, libunwind
+, libX11, xorgproto, useX11 ? safeX11 stdenv && !lib.versionAtLeast version "4.09"
 , aflSupport ? false
 , flambdaSupport ? false
 , spaceTimeSupport ? false
 }:
 
 assert useX11 -> !stdenv.isAarch32 && !stdenv.isMips;
-assert aflSupport -> stdenv.lib.versionAtLeast version "4.05";
-assert flambdaSupport -> stdenv.lib.versionAtLeast version "4.03";
-assert spaceTimeSupport -> stdenv.lib.versionAtLeast version "4.04";
+assert aflSupport -> lib.versionAtLeast version "4.05";
+assert flambdaSupport -> lib.versionAtLeast version "4.03";
+assert spaceTimeSupport -> lib.versionAtLeast version "4.04";
 
 let
   src = args.src or (fetchurl {
@@ -27,7 +27,7 @@ in
 
 let
    useNativeCompilers = !stdenv.isMips;
-   inherit (stdenv.lib) optional optionals optionalString;
+   inherit (lib) optional optionals optionalString;
    name = "ocaml${optionalString aflSupport "+afl"}${optionalString spaceTimeSupport "+spacetime"}${optionalString flambdaSupport "+flambda"}-${version}";
 in
 
@@ -47,7 +47,7 @@ stdenv.mkDerivation (args // {
   prefixKey = "-prefix ";
   configureFlags =
     let flags = new: old:
-      if stdenv.lib.versionAtLeast version "4.08"
+      if lib.versionAtLeast version "4.08"
       then new else old
     ; in
     optionals useX11 (flags
@@ -59,11 +59,11 @@ stdenv.mkDerivation (args // {
   ;
 
   buildFlags = [ "world" ] ++ optionals useNativeCompilers [ "bootstrap" "world.opt" ];
-  buildInputs = optional (!stdenv.lib.versionAtLeast version "4.07") ncurses
+  buildInputs = optional (!lib.versionAtLeast version "4.07") ncurses
     ++ optionals useX11 [ libX11 xorgproto ];
   propagatedBuildInputs = optional spaceTimeSupport libunwind;
   installTargets = [ "install" ] ++ optional useNativeCompilers "installopt";
-  preConfigure = optionalString (!stdenv.lib.versionAtLeast version "4.04") ''
+  preConfigure = optionalString (!lib.versionAtLeast version "4.04") ''
     CAT=$(type -tp cat)
     sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
   '';
@@ -76,7 +76,7 @@ stdenv.mkDerivation (args // {
     nativeCompilers = useNativeCompilers;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://caml.inria.fr/ocaml";
     branch = versionNoPatch;
     license = with licenses; [
@@ -105,7 +105,7 @@ stdenv.mkDerivation (args // {
       '';
 
     platforms = with platforms; linux ++ darwin;
-    broken = stdenv.isAarch64 && !stdenv.lib.versionAtLeast version "4.06";
+    broken = stdenv.isAarch64 && !lib.versionAtLeast version "4.06";
   };
 
 })
diff --git a/pkgs/development/compilers/ocaml/metaocaml-3.09.nix b/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
index 8459f26367e..e13f3006be5 100644
--- a/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
+++ b/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xlibsWrapper, ncurses }:
+{ lib, stdenv, fetchurl, xlibsWrapper, ncurses }:
 
 stdenv.mkDerivation ({
 
@@ -26,7 +26,7 @@ stdenv.mkDerivation ({
 
   meta = {
     homepage = "http://www.metaocaml.org/";
-    license = with stdenv.lib.licenses; [ qpl lgpl2 ];
+    license = with lib.licenses; [ qpl lgpl2 ];
     description = "A compiled, type-safe, multi-stage programming language";
     broken = true;
   };
diff --git a/pkgs/development/compilers/opa/default.nix b/pkgs/development/compilers/opa/default.nix
index 864bb8e1b26..5e648c9de4a 100644
--- a/pkgs/development/compilers/opa/default.nix
+++ b/pkgs/development/compilers/opa/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, which, perl, jdk
+{ lib, stdenv, fetchFromGitHub, which, perl, jdk
 , ocamlPackages, openssl
 , coreutils, zlib, ncurses, makeWrapper
 , gcc, binutils, gnumake, nodejs
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   # Paths so the opa compiler code generation will use the same programs as were
   # used to build opa.
-  codeGeneratorPaths = stdenv.lib.makeBinPath [ ocamlPackages.ocaml gcc binutils gnumake nodejs ];
+  codeGeneratorPaths = lib.makeBinPath [ ocamlPackages.ocaml gcc binutils gnumake nodejs ];
 
   preConfigure = ''
     patchShebangs .
@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
     ocaml findlib ssl cryptokit camlzip ulex ocamlgraph camlp4
   ]);
 
-  NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
+  NIX_LDFLAGS = lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
 
   postInstall = ''
     # Have compiler use same tools for code generation as used to build it.
@@ -71,8 +71,8 @@ stdenv.mkDerivation rec {
       Opa is concise, simple, concurrent, dynamically distributed, and secure.
     '';
     homepage = "http://opalang.org/";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.kkallio ];
-    platforms = with stdenv.lib.platforms; unix;
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.kkallio ];
+    platforms = with lib.platforms; unix;
   };
 }
diff --git a/pkgs/development/compilers/opendylan/bin.nix b/pkgs/development/compilers/opendylan/bin.nix
index 7636b251e62..9687f1b1a66 100644
--- a/pkgs/development/compilers/opendylan/bin.nix
+++ b/pkgs/development/compilers/opendylan/bin.nix
@@ -1,6 +1,6 @@
 # Binaries provided by Open Dylan to be used to bootstrap from source.
 # The binaries can also be used as is.
-{stdenv, fetchurl, patchelf, boehmgc, gnused, gcc, makeWrapper}:
+{lib, stdenv, fetchurl, patchelf, boehmgc, gnused, gcc, makeWrapper}:
 
 stdenv.mkDerivation {
   name = "opendylan-2013.2";
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://opendylan.org";
     description = "A multi-paradigm functional and object-oriented programming language";
-    license = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/opendylan/default.nix b/pkgs/development/compilers/opendylan/default.nix
index 5abc40cc3bb..45b2454259f 100644
--- a/pkgs/development/compilers/opendylan/default.nix
+++ b/pkgs/development/compilers/opendylan/default.nix
@@ -1,5 +1,5 @@
 # Build Open Dylan from source using the binary builds to bootstrap.
-{stdenv, fetchgit, boehmgc, mps, gnused, opendylan-bootstrap, autoconf, automake, perl, makeWrapper, gcc }:
+{lib, stdenv, fetchgit, boehmgc, mps, gnused, opendylan-bootstrap, autoconf, automake, perl, makeWrapper, gcc }:
 
 stdenv.mkDerivation {
   name = "opendylan-2016.1pre";
@@ -34,7 +34,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://opendylan.org";
     description = "A multi-paradigm functional and object-oriented programming language";
-    license = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix
index fc896f43d28..18440a718d1 100644
--- a/pkgs/development/compilers/openjdk/11.nix
+++ b/pkgs/development/compilers/openjdk/11.nix
@@ -136,7 +136,7 @@ let
 
     disallowedReferences = [ openjdk11-bootstrap ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "http://openjdk.java.net/";
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
diff --git a/pkgs/development/compilers/openjdk/12.nix b/pkgs/development/compilers/openjdk/12.nix
index 75f114e9fbf..0b3a4db6c48 100644
--- a/pkgs/development/compilers/openjdk/12.nix
+++ b/pkgs/development/compilers/openjdk/12.nix
@@ -140,7 +140,7 @@ let
 
     disallowedReferences = [ openjdk11 ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "http://openjdk.java.net/";
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
diff --git a/pkgs/development/compilers/openjdk/13.nix b/pkgs/development/compilers/openjdk/13.nix
index ee99cb93a1a..7c6fe633c49 100644
--- a/pkgs/development/compilers/openjdk/13.nix
+++ b/pkgs/development/compilers/openjdk/13.nix
@@ -140,7 +140,7 @@ let
 
     disallowedReferences = [ openjdk13-bootstrap ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "http://openjdk.java.net/";
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
diff --git a/pkgs/development/compilers/openjdk/14.nix b/pkgs/development/compilers/openjdk/14.nix
index 6faff92c508..bda6444a8f9 100644
--- a/pkgs/development/compilers/openjdk/14.nix
+++ b/pkgs/development/compilers/openjdk/14.nix
@@ -141,7 +141,7 @@ let
 
     disallowedReferences = [ openjdk14-bootstrap ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "https://openjdk.java.net/";
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix
index 0b659b95aa8..64654351886 100644
--- a/pkgs/development/compilers/openjdk/darwin/11.nix
+++ b/pkgs/development/compilers/openjdk/darwin/11.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
+{ lib, stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
 let
   jce-policies = fetchurl {
     # Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK!
@@ -52,7 +52,7 @@ let
       home = jdk;
     };
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       license = licenses.gpl2;
       platforms = platforms.darwin;
     };
diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix
index 8afaf90f943..4df180c1f5a 100644
--- a/pkgs/development/compilers/openjdk/darwin/8.nix
+++ b/pkgs/development/compilers/openjdk/darwin/8.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
+{ lib, stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
 let
   jce-policies = fetchurl {
     # Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK!
@@ -56,7 +56,7 @@ let
       home = jdk;
     };
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       license = licenses.gpl2;
       platforms = platforms.darwin;
     };
diff --git a/pkgs/development/compilers/openjdk/darwin/default.nix b/pkgs/development/compilers/openjdk/darwin/default.nix
index f10ede2506a..8885db4115e 100644
--- a/pkgs/development/compilers/openjdk/darwin/default.nix
+++ b/pkgs/development/compilers/openjdk/darwin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
+{ lib, stdenv, fetchurl, unzip, setJavaClassPath, freetype }:
 let
   jce-policies = fetchurl {
     # Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK!
@@ -52,7 +52,7 @@ let
       home = jdk;
     };
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       license = licenses.gpl2;
       platforms = platforms.darwin;
     };
diff --git a/pkgs/development/compilers/openjdk/default.nix b/pkgs/development/compilers/openjdk/default.nix
index 3888d6d6982..ddd523ad787 100644
--- a/pkgs/development/compilers/openjdk/default.nix
+++ b/pkgs/development/compilers/openjdk/default.nix
@@ -141,7 +141,7 @@ let
 
     disallowedReferences = [ openjdk15-bootstrap ];
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "https://openjdk.java.net/";
       license = licenses.gpl2;
       description = "The open-source Java Development Kit";
diff --git a/pkgs/development/compilers/openjdk/openjfx/11.nix b/pkgs/development/compilers/openjdk/openjfx/11.nix
index 30762d7811a..8688831cdaa 100644
--- a/pkgs/development/compilers/openjdk/openjfx/11.nix
+++ b/pkgs/development/compilers/openjdk/openjfx/11.nix
@@ -103,7 +103,7 @@ in makePackage {
 
   passthru.deps = deps;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://openjdk.java.net/projects/openjfx/";
     license = licenses.gpl2;
     description = "The next-generation Java client toolkit";
diff --git a/pkgs/development/compilers/openjdk/openjfx/15.nix b/pkgs/development/compilers/openjdk/openjfx/15.nix
index d491250bd93..21801b8ba3a 100644
--- a/pkgs/development/compilers/openjdk/openjfx/15.nix
+++ b/pkgs/development/compilers/openjdk/openjfx/15.nix
@@ -107,7 +107,7 @@ in makePackage {
 
   passthru.deps = deps;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://openjdk.java.net/projects/openjfx/";
     license = licenses.gpl2;
     description = "The next-generation Java client toolkit";
diff --git a/pkgs/development/compilers/openspin/default.nix b/pkgs/development/compilers/openspin/default.nix
index fe10f43abd5..abf5623b582 100644
--- a/pkgs/development/compilers/openspin/default.nix
+++ b/pkgs/development/compilers/openspin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ lib, stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation {
   pname = "openspin";
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
     mv build/openspin $out/bin/openspin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Compiler for SPIN/PASM languages for Parallax Propeller MCU";
     homepage = "https://github.com/parallaxinc/OpenSpin";
     license = licenses.mit;
diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
index 17030cf5bf1..c44d7fc116f 100644
--- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix
@@ -6,7 +6,7 @@
 }:
 
 { swingSupport ? true
-, stdenv
+, lib, stdenv
 , requireFile
 , makeWrapper
 , unzip
@@ -85,7 +85,7 @@ let result = stdenv.mkDerivation rec {
     };
 
   nativeBuildInputs = [ file ]
-    ++ stdenv.lib.optional installjce unzip;
+    ++ lib.optional installjce unzip;
 
   buildInputs = [ makeWrapper ];
 
@@ -149,7 +149,7 @@ let result = stdenv.mkDerivation rec {
   '';
 
   postFixup = ''
-    rpath+="''${rpath:+:}${stdenv.lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}"
+    rpath+="''${rpath:+:}${lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}"
 
     # set all the dynamic linkers
     find $out -type f -perm -0100 \
@@ -174,7 +174,7 @@ let result = stdenv.mkDerivation rec {
     [stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg_3 libxslt libGL xorg.libXxf86vm alsaLib fontconfig freetype pango gtk2 cairo gdk-pixbuf atk] ++
     (if swingSupport then [xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt xorg.libXrender stdenv.cc.cc] else []);
 
-  rpath = stdenv.lib.strings.makeLibraryPath libraries;
+  rpath = lib.strings.makeLibraryPath libraries;
 
   passthru.mozillaPlugin = if installjdk then "/jre/lib/${architecture}/plugins" else "/lib/${architecture}/plugins";
 
@@ -184,7 +184,7 @@ let result = stdenv.mkDerivation rec {
 
   passthru.architecture = architecture;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     license = licenses.unfree;
     platforms = [ "i686-linux" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]; # some inherit jre.meta.platforms
   };
diff --git a/pkgs/development/compilers/oraclejdk/jdk11-linux.nix b/pkgs/development/compilers/oraclejdk/jdk11-linux.nix
index b73270e8dd8..7e0e5cae7ca 100644
--- a/pkgs/development/compilers/oraclejdk/jdk11-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk11-linux.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , requireFile
 , xorg
 , zlib
@@ -30,7 +30,7 @@ let result = stdenv.mkDerivation rec {
   '';
 
   postFixup = ''
-    rpath="$out/lib/jli:$out/lib/server:$out/lib:${stdenv.lib.strings.makeLibraryPath [ zlib xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender freetype alsaLib]}"
+    rpath="$out/lib/jli:$out/lib/server:$out/lib:${lib.strings.makeLibraryPath [ zlib xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender freetype alsaLib]}"
 
     for f in $(find $out -name "*.so") $(find $out -type f -perm -0100); do
       patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$f" || true
@@ -47,7 +47,7 @@ let result = stdenv.mkDerivation rec {
 
   dontStrip = true; # See: https://github.com/NixOS/patchelf/issues/10
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     license = licenses.unfree;
     platforms = [ "x86_64-linux" ];
   };
diff --git a/pkgs/development/compilers/oraclejdk/jdk14-linux.nix b/pkgs/development/compilers/oraclejdk/jdk14-linux.nix
index 427c7cedad1..b1655cd8b8f 100644
--- a/pkgs/development/compilers/oraclejdk/jdk14-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk14-linux.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , requireFile
 , xorg
 , zlib
@@ -30,7 +30,7 @@ let result = stdenv.mkDerivation rec {
   '';
 
   postFixup = ''
-    rpath="$out/lib/jli:$out/lib/server:$out/lib:${stdenv.lib.strings.makeLibraryPath [ stdenv.cc.cc zlib xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender freetype alsaLib]}"
+    rpath="$out/lib/jli:$out/lib/server:$out/lib:${lib.strings.makeLibraryPath [ stdenv.cc.cc zlib xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender freetype alsaLib]}"
 
     for f in $(find $out -name "*.so") $(find $out -type f -perm -0100); do
       patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$f" || true
@@ -47,7 +47,7 @@ let result = stdenv.mkDerivation rec {
 
   dontStrip = true; # See: https://github.com/NixOS/patchelf/issues/10
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     license = licenses.unfree;
     platforms = [ "x86_64-linux" ];
   };
diff --git a/pkgs/development/compilers/orc/default.nix b/pkgs/development/compilers/orc/default.nix
index 210aa786cdd..40c89d0cc59 100644
--- a/pkgs/development/compilers/orc/default.nix
+++ b/pkgs/development/compilers/orc/default.nix
@@ -1,8 +1,8 @@
-{ stdenv, fetchurl, meson, ninja
+{ lib, stdenv, fetchurl, meson, ninja
 , gtk-doc ? null, file, docbook_xsl
 , buildDevDoc ? gtk-doc != null
 }: let
-  inherit (stdenv.lib) optional optionals;
+  inherit (lib) optional optionals;
 in stdenv.mkDerivation rec {
   pname = "orc";
   version = "0.4.32";
@@ -27,7 +27,7 @@ in stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "The Oil Runtime Compiler";
     homepage = "https://gstreamer.freedesktop.org/projects/orc.html";
     # The source code implementing the Marsenne Twister algorithm is licensed
diff --git a/pkgs/development/compilers/osl/default.nix b/pkgs/development/compilers/osl/default.nix
index b1f9dae4fcd..a4111f71998 100644
--- a/pkgs/development/compilers/osl/default.nix
+++ b/pkgs/development/compilers/osl/default.nix
@@ -1,4 +1,4 @@
-{ clangStdenv, stdenv, fetchFromGitHub, cmake, zlib, openexr,
+{ clangStdenv, lib, stdenv, fetchFromGitHub, cmake, zlib, openexr,
 openimageio, llvm, boost165, flex, bison, partio, pugixml,
 util-linux, python
 }:
@@ -29,7 +29,7 @@ in clangStdenv.mkDerivation rec {
      python # CMake doesn't check this?
   ];
   # TODO: How important is partio? CMake doesn't seem to find it
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Advanced shading language for production GI renderers";
     homepage = "http://opensource.imageworks.com/?p=osl";
     maintainers = with maintainers; [ hodapp ];
diff --git a/pkgs/development/compilers/owl-lisp/default.nix b/pkgs/development/compilers/owl-lisp/default.nix
index 93713af99b4..1d8ba03e72f 100644
--- a/pkgs/development/compilers/owl-lisp/default.nix
+++ b/pkgs/development/compilers/owl-lisp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, coreutils, which }:
+{ lib, stdenv, fetchFromGitLab, coreutils, which }:
 
 stdenv.mkDerivation rec {
   pname = "owl-lisp";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   # tests are run as part of the compilation process
   doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A functional Scheme for world domination";
     homepage    = "https://gitlab.com/owl-lisp/owl";
     license     = licenses.mit;
diff --git a/pkgs/development/compilers/pakcs/curry-base.nix b/pkgs/development/compilers/pakcs/curry-base.nix
index b34a2146383..660a4f2de40 100644
--- a/pkgs/development/compilers/pakcs/curry-base.nix
+++ b/pkgs/development/compilers/pakcs/curry-base.nix
@@ -1,5 +1,5 @@
 { mkDerivation, base, Cabal, containers, directory, extra, filepath
-, mtl, parsec, pretty, stdenv, time, transformers
+, mtl, parsec, pretty, lib, stdenv, time, transformers
 }:
 mkDerivation {
   pname = "curry-base";
@@ -12,5 +12,5 @@ mkDerivation {
   testHaskellDepends = [ base Cabal filepath mtl ];
   homepage = "http://curry-language.org";
   description = "Functions for manipulating Curry programs";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/pakcs/curry-frontend.nix b/pkgs/development/compilers/pakcs/curry-frontend.nix
index b169578c7c3..8fd1645ee70 100644
--- a/pkgs/development/compilers/pakcs/curry-frontend.nix
+++ b/pkgs/development/compilers/pakcs/curry-frontend.nix
@@ -1,6 +1,6 @@
 { mkDerivation, base, bytestring, Cabal, containers, curry-base
 , directory, extra, file-embed, filepath, mtl, network-uri, pretty
-, process, set-extra, stdenv, template-haskell, transformers
+, process, set-extra, lib, stdenv, template-haskell, transformers
 }:
 mkDerivation {
   pname = "curry-frontend";
@@ -22,5 +22,5 @@ mkDerivation {
   testHaskellDepends = [ base Cabal curry-base filepath ];
   homepage = "http://curry-language.org";
   description = "Compile the functional logic language Curry to several intermediate formats";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/development/compilers/pakcs/default.nix b/pkgs/development/compilers/pakcs/default.nix
index 9f876ea914a..98fab9eb210 100644
--- a/pkgs/development/compilers/pakcs/default.nix
+++ b/pkgs/development/compilers/pakcs/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper
+{ lib, stdenv, fetchurl, makeWrapper
 , haskellPackages, haskell
 , which, swiProlog, rlwrap, tk
 , curl, git, unzip, gnutar, coreutils, sqlite }:
@@ -74,10 +74,10 @@ in stdenv.mkDerivation {
 
     # List of dependencies from currytools/cpm/src/CPM/Main.curry
     wrapProgram $out/pakcs/bin/cypm \
-      --prefix PATH ":" "${stdenv.lib.makeBinPath [ curl git unzip gnutar coreutils sqlite ]}"
+      --prefix PATH ":" "${lib.makeBinPath [ curl git unzip gnutar coreutils sqlite ]}"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://www.informatik.uni-kiel.de/~pakcs/";
     description = "An implementation of the multi-paradigm declarative language Curry";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/pforth/default.nix b/pkgs/development/compilers/pforth/default.nix
index ce228c2f1cb..44c6ea0a16a 100644
--- a/pkgs/development/compilers/pforth/default.nix
+++ b/pkgs/development/compilers/pforth/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchpatch }:
+{ lib, stdenv, fetchFromGitHub, fetchpatch }:
 
 stdenv.mkDerivation {
   version = "28";
@@ -29,8 +29,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Portable ANSI style Forth written in ANSI C";
     homepage = "http://www.softsynth.com/pforth/";
-    license = stdenv.lib.licenses.publicDomain;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ yrashk ];
+    license = lib.licenses.publicDomain;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ yrashk ];
   };
 }
diff --git a/pkgs/development/compilers/picat/default.nix b/pkgs/development/compilers/picat/default.nix
index 960b5ce1c2c..159dec05e29 100644
--- a/pkgs/development/compilers/picat/default.nix
+++ b/pkgs/development/compilers/picat/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, zlib }:
+{ lib, stdenv, fetchurl, zlib }:
 
 let
   ARCH = {
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   buildPhase = "cd emu && make -j $NIX_BUILD_CORES -f Makefile.$ARCH";
   installPhase = "mkdir -p $out/bin && cp picat $out/bin/picat";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Logic-based programming langage";
     homepage    = "http://picat-lang.org/";
     license     = licenses.mpl20;
diff --git a/pkgs/development/compilers/polyml/5.6.nix b/pkgs/development/compilers/polyml/5.6.nix
index 714adfb0e4c..7858e3f6dc1 100644
--- a/pkgs/development/compilers/polyml/5.6.nix
+++ b/pkgs/development/compilers/polyml/5.6.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, autoreconfHook}:
+{lib, stdenv, fetchurl, autoreconfHook}:
 
 let
   version = "5.6";
@@ -8,11 +8,11 @@ stdenv.mkDerivation {
   pname = "polyml";
   inherit version;
 
-  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  prePatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure.ac --replace stdc++ c++
   '';
 
-  buildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook;
+  buildInputs = lib.optional stdenv.isDarwin autoreconfHook;
 
   src = fetchurl {
     url = "mirror://sourceforge/polyml/polyml.${version}.tar.gz";
@@ -25,10 +25,10 @@ stdenv.mkDerivation {
       Poly/ML is a full implementation of Standard ML.
     '';
     homepage = "https://www.polyml.org/";
-    license = stdenv.lib.licenses.lgpl21;
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.lgpl21;
+    platforms = with lib.platforms; linux;
     maintainers = [ #Add your name here!
-      stdenv.lib.maintainers.maggesi
+      lib.maintainers.maggesi
     ];
   };
 }
diff --git a/pkgs/development/compilers/polyml/5.7.nix b/pkgs/development/compilers/polyml/5.7.nix
index ce8c033e4be..5ac6990383c 100644
--- a/pkgs/development/compilers/polyml/5.7.nix
+++ b/pkgs/development/compilers/polyml/5.7.nix
@@ -1,10 +1,10 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, gmp, libffi }:
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, gmp, libffi }:
 
 stdenv.mkDerivation rec {
   pname = "polyml";
   version = "5.7.1";
 
-  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  prePatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure.ac --replace stdc++ c++
   '';
 
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ libffi gmp ];
 
-  nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook;
+  nativeBuildInputs = lib.optional stdenv.isDarwin autoreconfHook;
 
   configureFlags = [
     "--enable-shared"
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     sha256 = "0j0wv3ijfrjkfngy7dswm4k1dchk3jak9chl5735dl8yrl8mq755";
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Standard ML compiler and interpreter";
     longDescription = ''
       Poly/ML is a full implementation of Standard ML.
diff --git a/pkgs/development/compilers/polyml/default.nix b/pkgs/development/compilers/polyml/default.nix
index 7b15a988e38..d2a15033422 100644
--- a/pkgs/development/compilers/polyml/default.nix
+++ b/pkgs/development/compilers/polyml/default.nix
@@ -1,16 +1,16 @@
-{ stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, gmp, libffi }:
+{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, gmp, libffi }:
 
 stdenv.mkDerivation rec {
   pname = "polyml";
   version = "5.8.1";
 
-  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  prePatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure.ac --replace stdc++ c++
   '';
 
   buildInputs = [ libffi gmp ];
 
-  nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook;
+  nativeBuildInputs = lib.optional stdenv.isDarwin autoreconfHook;
 
   configureFlags = [
     "--enable-shared"
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
     sha256 = "0gcx2fjiwsiazlyfhm7zlrd563blc4fy9w2mspib9divbavaxin6";
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Standard ML compiler and interpreter";
     longDescription = ''
       Poly/ML is a full implementation of Standard ML.
diff --git a/pkgs/development/compilers/ponyc/default.nix b/pkgs/development/compilers/ponyc/default.nix
index df80fe2fdb6..e34ed4b157d 100644
--- a/pkgs/development/compilers/ponyc/default.nix
+++ b/pkgs/development/compilers/ponyc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchurl, makeWrapper, pcre2, coreutils, which, libressl, libxml2, cmake, z3, substituteAll,
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, pcre2, coreutils, which, libressl, libxml2, cmake, z3, substituteAll,
   cc ? stdenv.cc, lto ? !stdenv.isDarwin }:
 
 stdenv.mkDerivation (rec {
@@ -80,8 +80,8 @@ stdenv.mkDerivation (rec {
     "PONYC_VERSION=${version}"
     "prefix=${placeholder "out"}"
   ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ "bits=64" ]
-    ++ stdenv.lib.optionals (stdenv.isDarwin && (!lto)) [ "lto=no" ];
+    ++ lib.optionals stdenv.isDarwin [ "bits=64" ]
+    ++ lib.optionals (stdenv.isDarwin && (!lto)) [ "lto=no" ];
 
   doCheck = true;
 
@@ -89,20 +89,20 @@ stdenv.mkDerivation (rec {
 
   installPhase = ''
     make config=release prefix=$out ''
-    + stdenv.lib.optionalString stdenv.isDarwin '' bits=64 ''
-    + stdenv.lib.optionalString (stdenv.isDarwin && (!lto)) '' lto=no ''
+    + lib.optionalString stdenv.isDarwin '' bits=64 ''
+    + lib.optionalString (stdenv.isDarwin && (!lto)) '' lto=no ''
     + '' install
 
     wrapProgram $out/bin/ponyc \
       --prefix PATH ":" "${stdenv.cc}/bin" \
       --set-default CC "$CC" \
-      --prefix PONYPATH : "${stdenv.lib.makeLibraryPath [ pcre2 libressl (placeholder "out") ]}"
+      --prefix PONYPATH : "${lib.makeLibraryPath [ pcre2 libressl (placeholder "out") ]}"
   '';
 
   # Stripping breaks linking for ponyc
   dontStrip = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pony is an Object-oriented, actor-model, capabilities-secure, high performance programming language";
     homepage = "https://www.ponylang.org";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/ponyc/pony-corral.nix b/pkgs/development/compilers/ponyc/pony-corral.nix
index 7cf3000e9db..5da1ec77016 100644
--- a/pkgs/development/compilers/ponyc/pony-corral.nix
+++ b/pkgs/development/compilers/ponyc/pony-corral.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ponyc }:
+{ lib, stdenv, fetchFromGitHub, ponyc }:
 
 stdenv.mkDerivation ( rec {
   pname = "corral";
@@ -15,7 +15,7 @@ stdenv.mkDerivation ( rec {
 
   installFlags = [ "prefix=${placeholder "out"}" "install" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Corral is a dependency management tool for ponylang (ponyc)";
     homepage = "https://www.ponylang.io";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/ponyc/pony-stable.nix b/pkgs/development/compilers/ponyc/pony-stable.nix
index 3c1b2a0f91b..8e581050897 100644
--- a/pkgs/development/compilers/ponyc/pony-stable.nix
+++ b/pkgs/development/compilers/ponyc/pony-stable.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, ponyc }:
+{lib, stdenv, fetchFromGitHub, ponyc }:
 
 stdenv.mkDerivation rec {
   pname = "pony-stable";
@@ -18,8 +18,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A simple dependency manager for the Pony language";
     homepage = "https://www.ponylang.org";
-    license = stdenv.lib.licenses.bsd2;
-    maintainers = with stdenv.lib.maintainers; [ dipinhora kamilchm patternspandemic ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.bsd2;
+    maintainers = with lib.maintainers; [ dipinhora kamilchm patternspandemic ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix
index 8dd19ecf858..741d0ec7d1c 100644
--- a/pkgs/development/compilers/purescript/purescript/default.nix
+++ b/pkgs/development/compilers/purescript/purescript/default.nix
@@ -55,7 +55,7 @@ in stdenv.mkDerivation rec {
     minimal-module = pkgs.callPackage ./test-minimal-module {};
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A strongly-typed functional programming language that compiles to JavaScript";
     homepage = "https://www.purescript.org/";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix
index 436b03e499c..9ebcb2242dd 100644
--- a/pkgs/development/compilers/qbe/default.nix
+++ b/pkgs/development/compilers/qbe/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchgit
 , unstableGitUpdater
 }:
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   passthru.updateScript = unstableGitUpdater { };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://c9x.me/compile/";
     description = "A small compiler backend written in C";
     maintainers = with maintainers; [ fgaz ];
diff --git a/pkgs/development/compilers/rasm/default.nix b/pkgs/development/compilers/rasm/default.nix
index 37e07a230ae..c2415899f6b 100644
--- a/pkgs/development/compilers/rasm/default.nix
+++ b/pkgs/development/compilers/rasm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip }:
+{ lib, stdenv, fetchurl, unzip }:
 
 stdenv.mkDerivation rec {
   pname = "rasm";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     install -Dt $out/bin rasm
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://www.roudoudou.com/rasm/";
     description = "Z80 assembler";
     # use -n option to display all licenses
diff --git a/pkgs/development/compilers/reason/default.nix b/pkgs/development/compilers/reason/default.nix
index 435813ee5e7..2807ddb6b5f 100644
--- a/pkgs/development/compilers/reason/default.nix
+++ b/pkgs/development/compilers/reason/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, makeWrapper, fetchFromGitHub, ocaml, findlib, dune_2
+{ lib, stdenv, makeWrapper, fetchFromGitHub, ocaml, findlib, dune_2
 , fix, menhir, merlin-extend, ppx_tools_versioned, utop, cppo
 }:
 
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
       --prefix OCAMLPATH : "$OCAMLPATH:$OCAMLFIND_DESTDIR"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://reasonml.github.io/";
     description = "Facebook's friendly syntax to OCaml";
     license = licenses.mit;
diff --git a/pkgs/development/compilers/rgbds/default.nix b/pkgs/development/compilers/rgbds/default.nix
index 4c8a4cfd4ef..6bc74971c4e 100644
--- a/pkgs/development/compilers/rgbds/default.nix
+++ b/pkgs/development/compilers/rgbds/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, bison, flex, pkg-config, libpng}:
+{lib, stdenv, fetchFromGitHub, bison, flex, pkg-config, libpng}:
 
 # TODO: byacc is the recommended parser generator but due to https://github.com/rednex/rgbds/issues/333
 # it does not work for the moment. We should switch back to byacc as soon as the fix is integrated
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ bison flex pkg-config libpng ];
   installFlags = [ "PREFIX=\${out}" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://rednex.github.io/rgbds/";
     description = "A free assembler/linker package for the Game Boy and Game Boy Color";
     license = licenses.mit;
diff --git a/pkgs/development/compilers/rust/binary.nix b/pkgs/development/compilers/rust/binary.nix
index b84e390e0b0..770cc3415f2 100644
--- a/pkgs/development/compilers/rust/binary.nix
+++ b/pkgs/development/compilers/rust/binary.nix
@@ -1,4 +1,4 @@
-{ stdenv, makeWrapper, bash, curl, darwin, zlib
+{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib
 , version
 , src
 , platform
@@ -6,7 +6,7 @@
 }:
 
 let
-  inherit (stdenv.lib) optionalString;
+  inherit (lib) optionalString;
   inherit (darwin.apple_sdk.frameworks) Security;
 
   bootstrapping = versionType == "bootstrap";
@@ -24,7 +24,7 @@ rec {
     inherit version;
     inherit src;
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "http://www.rust-lang.org/";
       description = "A safe, concurrent, practical language";
       maintainers = with maintainers; [ qknight ];
@@ -32,7 +32,7 @@ rec {
     };
 
     buildInputs = [ bash ]
-      ++ stdenv.lib.optional stdenv.isDarwin Security;
+      ++ lib.optional stdenv.isDarwin Security;
 
     postPatch = ''
       patchShebangs .
@@ -46,7 +46,7 @@ rec {
         patchelf \
           --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
           "$out/bin/rustc"
-        '' + optionalString (stdenv.lib.versionAtLeast version "1.46")
+        '' + optionalString (lib.versionAtLeast version "1.46")
         # rustc bootstrap needs libz starting from 1.46
         ''
           ln -s ${zlib}/lib/libz.so.1 $out/lib/libz.so.1
@@ -76,7 +76,7 @@ rec {
     inherit version;
     inherit src;
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       homepage = "http://www.rust-lang.org/";
       description = "A safe, concurrent, practical language";
       maintainers = with maintainers; [ qknight ];
@@ -84,7 +84,7 @@ rec {
     };
 
     buildInputs = [ makeWrapper bash ]
-      ++ stdenv.lib.optional stdenv.isDarwin Security;
+      ++ lib.optional stdenv.isDarwin Security;
 
     postPatch = ''
       patchShebangs .
diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix
index 40acb925d10..3a7f29e3229 100644
--- a/pkgs/development/compilers/rust/cargo.nix
+++ b/pkgs/development/compilers/rust/cargo.nix
@@ -1,4 +1,4 @@
-{ stdenv, file, curl, pkg-config, python3, openssl, cmake, zlib
+{ lib, stdenv, file, curl, pkg-config, python3, openssl, cmake, zlib
 , installShellFiles, makeWrapper, libiconv, cacert, rustPlatform, rustc
 , CoreFoundation, Security
 }:
@@ -18,7 +18,7 @@ rustPlatform.buildRustPackage {
 
   nativeBuildInputs = [ pkg-config cmake installShellFiles makeWrapper ];
   buildInputs = [ cacert file curl python3 openssl zlib ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Security libiconv ];
+    ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security libiconv ];
 
   # cargo uses git-rs which is made for a version of libgit2 from recent master that
   # is not compatible with the current version in nixpkgs.
@@ -54,7 +54,7 @@ rustPlatform.buildRustPackage {
   # Disable check phase as there are failures (4 tests fail)
   doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://crates.io";
     description = "Downloads your Rust project's dependencies and builds your project";
     maintainers = with maintainers; [ retrry ];
diff --git a/pkgs/development/compilers/rust/clippy.nix b/pkgs/development/compilers/rust/clippy.nix
index 0546ad9bac1..a3597e9febf 100644
--- a/pkgs/development/compilers/rust/clippy.nix
+++ b/pkgs/development/compilers/rust/clippy.nix
@@ -10,7 +10,7 @@ rustPlatform.buildRustPackage {
   # changes hash of vendor directory otherwise
   dontUpdateAutotoolsGnuConfigScripts = true;
 
-  buildInputs = [ rustc rustc.llvm ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security ];
+  buildInputs = [ rustc rustc.llvm ] ++ lib.optionals stdenv.isDarwin [ Security ];
 
   # fixes: error: the option `Z` is only accepted on the nightly compiler
   RUSTC_BOOTSTRAP = 1;
@@ -20,11 +20,11 @@ rustPlatform.buildRustPackage {
   #   (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm)
   doCheck = false;
 
-  preFixup = stdenv.lib.optionalString stdenv.isDarwin ''
+  preFixup = lib.optionalString stdenv.isDarwin ''
     install_name_tool -add_rpath "${rustc}/lib" $out/bin/clippy-driver
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://rust-lang.github.io/rust-clippy/";
     description = "A bunch of lints to catch common mistakes and improve your Rust code";
     maintainers = with maintainers; [ basvandijk ];
diff --git a/pkgs/development/compilers/rust/rls/default.nix b/pkgs/development/compilers/rust/rls/default.nix
index c57b28aee51..ee860d78258 100644
--- a/pkgs/development/compilers/rust/rls/default.nix
+++ b/pkgs/development/compilers/rust/rls/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, makeWrapper, fetchFromGitHub, rustPlatform
+{ lib, stdenv, makeWrapper, fetchFromGitHub, rustPlatform
 , openssh, openssl, pkg-config, cmake, zlib, curl, libiconv
 , CoreFoundation, Security }:
 
@@ -30,7 +30,7 @@ rustPlatform.buildRustPackage {
 
   nativeBuildInputs = [ pkg-config cmake ];
   buildInputs = [ openssh openssl curl zlib libiconv makeWrapper rustPlatform.rust.rustc.llvm ]
-    ++ (stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Security ]);
+    ++ (lib.optionals stdenv.isDarwin [ CoreFoundation Security ]);
 
   doCheck = true;
 
@@ -44,7 +44,7 @@ rustPlatform.buildRustPackage {
     wrapProgram $out/bin/rls --set-default RUST_SRC_PATH ${rustPlatform.rustLibSrc}
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Rust Language Server - provides information about Rust programs to IDEs and other tools";
     homepage = "https://github.com/rust-lang/rls/";
     license = with licenses; [ asl20 /* or */ mit ];
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index a5c24a5fc69..e27c190acd7 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -1,4 +1,4 @@
-{ stdenv, removeReferencesTo, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget
+{ lib, stdenv, removeReferencesTo, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget
 , llvmShared, llvmSharedForBuild, llvmSharedForHost, llvmSharedForTarget
 , fetchurl, file, python3
 , darwin, cmake, rust, rustPlatform
@@ -12,7 +12,7 @@
 }:
 
 let
-  inherit (stdenv.lib) optionals optional optionalString concatStringsSep;
+  inherit (lib) optionals optional optionalString concatStringsSep;
   inherit (darwin.apple_sdk.frameworks) Security;
 in stdenv.mkDerivation rec {
   pname = "rustc";
@@ -143,7 +143,7 @@ in stdenv.mkDerivation rec {
   outputs = [ "out" "man" "doc" ];
   setOutputFlags = false;
 
-  postInstall = stdenv.lib.optionalString enableRustcDev ''
+  postInstall = lib.optionalString enableRustcDev ''
     # install rustc-dev components. Necessary to build rls, clippy...
     python x.py dist rustc-dev
     tar xf build/dist/rustc-dev*tar.gz
@@ -172,7 +172,7 @@ in stdenv.mkDerivation rec {
 
   passthru.llvm = llvmShared;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.rust-lang.org/";
     description = "A safe, concurrent, practical language";
     maintainers = with maintainers; [ madjar cstrahan globin havvy ];
diff --git a/pkgs/development/compilers/rust/rustfmt.nix b/pkgs/development/compilers/rust/rustfmt.nix
index 6215c936c6d..b3191c242fe 100644
--- a/pkgs/development/compilers/rust/rustfmt.nix
+++ b/pkgs/development/compilers/rust/rustfmt.nix
@@ -1,4 +1,4 @@
-{ stdenv, rustPlatform, Security }:
+{ lib, stdenv, rustPlatform, Security }:
 
 rustPlatform.buildRustPackage rec {
   pname = "rustfmt";
@@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
   # changes hash of vendor directory otherwise
   dontUpdateAutotoolsGnuConfigScripts = true;
 
-  buildInputs = stdenv.lib.optional stdenv.isDarwin Security;
+  buildInputs = lib.optional stdenv.isDarwin Security;
 
   # As of 1.0.0 and rustc 1.30 rustfmt requires a nightly compiler
   RUSTC_BOOTSTRAP = 1;
@@ -21,7 +21,7 @@ rustPlatform.buildRustPackage rec {
   CFG_RELEASE = "${rustPlatform.rust.rustc.version}-nightly";
   CFG_RELEASE_CHANNEL = "nightly";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A tool for formatting Rust code according to style guidelines";
     homepage = "https://github.com/rust-lang-nursery/rustfmt";
     license = with licenses; [ mit asl20 ];
diff --git a/pkgs/development/compilers/sagittarius-scheme/default.nix b/pkgs/development/compilers/sagittarius-scheme/default.nix
index ff40c622f1e..b421fe5d2ef 100644
--- a/pkgs/development/compilers/sagittarius-scheme/default.nix
+++ b/pkgs/development/compilers/sagittarius-scheme/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , cmake
 , pkg-config
@@ -29,9 +29,9 @@ stdenv.mkDerivation rec {
            '';
   nativeBuildInputs = [ pkg-config cmake ];
 
-  buildInputs = [ libffi boehmgc openssl zlib ] ++ stdenv.lib.optional odbcSupport libiodbc;
+  buildInputs = [ libffi boehmgc openssl zlib ] ++ lib.optional odbcSupport libiodbc;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An R6RS/R7RS Scheme system";
     longDescription = ''
       Sagittarius Scheme is a free Scheme implementation supporting
diff --git a/pkgs/development/compilers/sbcl/2.0.9.nix b/pkgs/development/compilers/sbcl/2.0.9.nix
index 148ecccf131..ada098ec182 100644
--- a/pkgs/development/compilers/sbcl/2.0.9.nix
+++ b/pkgs/development/compilers/sbcl/2.0.9.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, writeText, sbclBootstrap
+{ lib, stdenv, fetchurl, writeText, sbclBootstrap
 , sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit"
 , threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system)
 , disableImmobileSpace ? false
@@ -70,17 +70,17 @@ stdenv.mkDerivation rec {
     export HOME=$PWD/test-home
   '';
 
-  enableFeatures = with stdenv.lib;
+  enableFeatures = with lib;
     optional threadSupport "sb-thread" ++
     optional stdenv.isAarch32 "arm";
 
-  disableFeatures = with stdenv.lib;
+  disableFeatures = with lib;
     optional (!threadSupport) "sb-thread" ++
     optionals disableImmobileSpace [ "immobile-space" "immobile-code" "compact-instance-header" ];
 
   buildPhase = ''
     sh make.sh --prefix=$out --xc-host="${sbclBootstrapHost}" ${
-                  stdenv.lib.concatStringsSep " "
+                  lib.concatStringsSep " "
                     (builtins.map (x: "--with-${x}") enableFeatures ++
                      builtins.map (x: "--without-${x}") disableFeatures)
                 }
@@ -90,7 +90,7 @@ stdenv.mkDerivation rec {
   installPhase = ''
     INSTALL_ROOT=$out sh install.sh
   ''
-  + stdenv.lib.optionalString (!purgeNixReferences) ''
+  + lib.optionalString (!purgeNixReferences) ''
     cp -r src $out/lib/sbcl
     cp -r contrib $out/lib/sbcl
     cat >$out/lib/sbcl/sbclrc <<EOF
@@ -100,7 +100,7 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
-  setupHook = stdenv.lib.optional purgeNixReferences (writeText "setupHook.sh" ''
+  setupHook = lib.optional purgeNixReferences (writeText "setupHook.sh" ''
     addEnvHooks "$targetOffset" _setSbclHome
     _setSbclHome() {
       export SBCL_HOME='@out@/lib/sbcl/'
diff --git a/pkgs/development/compilers/sbcl/bootstrap.nix b/pkgs/development/compilers/sbcl/bootstrap.nix
index 81afe64ed53..cb42235bc8e 100644
--- a/pkgs/development/compilers/sbcl/bootstrap.nix
+++ b/pkgs/development/compilers/sbcl/bootstrap.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper }:
+{ lib, stdenv, fetchurl, makeWrapper }:
 
 let
   options = rec {
@@ -65,11 +65,11 @@ stdenv.mkDerivation rec {
       --add-flags "--core $out/share/sbcl/sbcl.core"
   '';
 
-  postFixup = stdenv.lib.optionalString (!stdenv.isAarch32 && stdenv.isLinux) ''
+  postFixup = lib.optionalString (!stdenv.isAarch32 && stdenv.isLinux) ''
     patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $out/share/sbcl/sbcl
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Lisp compiler";
     homepage = "http://www.sbcl.org";
     license = licenses.publicDomain; # and FreeBSD
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 3c7fca3c4b0..df80bb8af1d 100644
--- a/pkgs/development/compilers/sbcl/default.nix
+++ b/pkgs/development/compilers/sbcl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, writeText, sbclBootstrap
+{ lib, stdenv, fetchurl, writeText, sbclBootstrap
 , sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit"
 , threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system)
 , disableImmobileSpace ? false
@@ -70,17 +70,17 @@ stdenv.mkDerivation rec {
     export HOME=$PWD/test-home
   '';
 
-  enableFeatures = with stdenv.lib;
+  enableFeatures = with lib;
     optional threadSupport "sb-thread" ++
     optional stdenv.isAarch32 "arm";
 
-  disableFeatures = with stdenv.lib;
+  disableFeatures = with lib;
     optional (!threadSupport) "sb-thread" ++
     optionals disableImmobileSpace [ "immobile-space" "immobile-code" "compact-instance-header" ];
 
   buildPhase = ''
     sh make.sh --prefix=$out --xc-host="${sbclBootstrapHost}" ${
-                  stdenv.lib.concatStringsSep " "
+                  lib.concatStringsSep " "
                     (builtins.map (x: "--with-${x}") enableFeatures ++
                      builtins.map (x: "--without-${x}") disableFeatures)
                 }
@@ -90,7 +90,7 @@ stdenv.mkDerivation rec {
   installPhase = ''
     INSTALL_ROOT=$out sh install.sh
   ''
-  + stdenv.lib.optionalString (!purgeNixReferences) ''
+  + lib.optionalString (!purgeNixReferences) ''
     cp -r src $out/lib/sbcl
     cp -r contrib $out/lib/sbcl
     cat >$out/lib/sbcl/sbclrc <<EOF
@@ -100,7 +100,7 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
-  setupHook = stdenv.lib.optional purgeNixReferences (writeText "setupHook.sh" ''
+  setupHook = lib.optional purgeNixReferences (writeText "setupHook.sh" ''
     addEnvHooks "$targetOffset" _setSbclHome
     _setSbclHome() {
       export SBCL_HOME='@out@/lib/sbcl/'
diff --git a/pkgs/development/compilers/scala/2.x.nix b/pkgs/development/compilers/scala/2.x.nix
index 5b4c3a610f1..a747206dff8 100644
--- a/pkgs/development/compilers/scala/2.x.nix
+++ b/pkgs/development/compilers/scala/2.x.nix
@@ -75,7 +75,7 @@ stdenv.mkDerivation rec {
       #!${stdenv.shell}
       set -o errexit
       PATH=${
-        stdenv.lib.makeBinPath [
+        lib.makeBinPath [
           common-updater-scripts
           coreutils
           git
diff --git a/pkgs/development/compilers/scala/dotty-bare.nix b/pkgs/development/compilers/scala/dotty-bare.nix
index cefa4537c36..b173de58049 100644
--- a/pkgs/development/compilers/scala/dotty-bare.nix
+++ b/pkgs/development/compilers/scala/dotty-bare.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, jre, ncurses }:
+{ lib, stdenv, fetchurl, makeWrapper, jre, ncurses }:
 
 stdenv.mkDerivation rec {
   version = "0.26.0-RC1";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
         done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Research platform for new language concepts and compiler technologies for Scala";
     longDescription = ''
        Dotty is a platform to try out new language concepts and compiler technologies for Scala.
diff --git a/pkgs/development/compilers/sdcc/default.nix b/pkgs/development/compilers/sdcc/default.nix
index 3d3d43a55e5..500c0b4d395 100644
--- a/pkgs/development/compilers/sdcc/default.nix
+++ b/pkgs/development/compilers/sdcc/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, autoconf, bison, boost, flex, texinfo, zlib, gputils ? null
+{ lib, stdenv, fetchurl, autoconf, bison, boost, flex, texinfo, zlib, gputils ? null
 , excludePorts ? [] }:
 
-with stdenv.lib;
+with lib;
 
 let
   # choices: mcs51 z80 z180 r2k r3ka gbz80 tlcs90 ds390 ds400 pic14 pic16 hc08 s08 stm8
diff --git a/pkgs/development/compilers/seexpr/default.nix b/pkgs/development/compilers/seexpr/default.nix
index 4bf89973d7e..7fc1fc7b1b6 100644
--- a/pkgs/development/compilers/seexpr/default.nix
+++ b/pkgs/development/compilers/seexpr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, libpng, zlib, qt4,
+{ lib, stdenv, fetchFromGitHub, cmake, libpng, zlib, qt4,
 bison, flex, libGLU, pythonPackages
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ libGLU libpng zlib qt4 pythonPackages.pyqt4 bison flex ];
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Embeddable expression evaluation engine from Disney Animation";
     homepage = "https://www.disneyanimation.com/technology/seexpr.html";
     maintainers = with maintainers; [ hodapp ];
diff --git a/pkgs/development/compilers/serpent/default.nix b/pkgs/development/compilers/serpent/default.nix
index 2459127f425..775a78a9734 100644
--- a/pkgs/development/compilers/serpent/default.nix
+++ b/pkgs/development/compilers/serpent/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ... }:
+{ lib, stdenv, fetchFromGitHub, ... }:
 
 stdenv.mkDerivation {
   pname = "serpent";
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
     mv serpent $out/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Compiler for the Serpent language for Ethereum";
     longDescription = ''
       Serpent is one of the high-level programming languages used to
diff --git a/pkgs/development/compilers/shaderc/default.nix b/pkgs/development/compilers/shaderc/default.nix
index 23532cc8446..678ab3adb06 100644
--- a/pkgs/development/compilers/shaderc/default.nix
+++ b/pkgs/development/compilers/shaderc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, python3 }:
+{ lib, stdenv, fetchFromGitHub, cmake, python3 }:
 # Like many google projects, shaderc doesn't gracefully support separately compiled dependencies, so we can't easily use
 # the versions of glslang and spirv-tools used by vulkan-loader. Exact revisions are taken from
 # https://github.com/google/shaderc/blob/known-good/known_good.json
@@ -50,7 +50,7 @@ in stdenv.mkDerivation rec {
 
   cmakeFlags = [ "-DSHADERC_SKIP_TESTS=ON" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     inherit (src.meta) homepage;
     description = "A collection of tools, libraries and tests for shader compilation";
     license = [ licenses.asl20 ];
diff --git a/pkgs/development/compilers/smlnj/bootstrap.nix b/pkgs/development/compilers/smlnj/bootstrap.nix
index 55d96266ac9..113b22768d9 100644
--- a/pkgs/development/compilers/smlnj/bootstrap.nix
+++ b/pkgs/development/compilers/smlnj/bootstrap.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cpio, rsync, xar, makeWrapper }:
+{ lib, stdenv, fetchurl, cpio, rsync, xar, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "smlnj-bootstrap";
@@ -36,8 +36,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Compiler for the Standard ML '97 programming language";
     homepage    = "http://www.smlnj.org";
-    license     = stdenv.lib.licenses.free;
-    platforms   = stdenv.lib.platforms.darwin;
-    maintainers = [ stdenv.lib.maintainers.jwiegley ];
+    license     = lib.licenses.free;
+    platforms   = lib.platforms.darwin;
+    maintainers = [ lib.maintainers.jwiegley ];
   };
 }
diff --git a/pkgs/development/compilers/smlnj/default.nix b/pkgs/development/compilers/smlnj/default.nix
index 18562bc487a..3e987e8ccda 100644
--- a/pkgs/development/compilers/smlnj/default.nix
+++ b/pkgs/development/compilers/smlnj/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 let
   version = "110.95";
   baseurl = "http://smlnj.cs.uchicago.edu/dist/working/${version}";
@@ -79,7 +79,7 @@ in stdenv.mkDerivation {
     done
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Standard ML of New Jersey, a compiler";
     homepage    = "http://smlnj.org";
     license     = licenses.bsd3;
diff --git a/pkgs/development/compilers/solc/default.nix b/pkgs/development/compilers/solc/default.nix
index 0f0af33e700..546697d8efe 100644
--- a/pkgs/development/compilers/solc/default.nix
+++ b/pkgs/development/compilers/solc/default.nix
@@ -1,13 +1,12 @@
-{ gccStdenv, fetchzip, boost, cmake, ncurses, python3, coreutils
+{ lib, gccStdenv, fetchzip, boost, cmake, ncurses, python3, coreutils
 , z3Support ? true, z3 ? null, cvc4Support ? true, cvc4 ? null
 , cln ? null, gmp ? null
 }:
 
 # compiling source/libsmtutil/CVC4Interface.cpp breaks on clang on Darwin,
 # general commandline tests fail at abiencoderv2_no_warning/ on clang on NixOS
-let stdenv = gccStdenv; in
 
-assert z3Support -> z3 != null && stdenv.lib.versionAtLeast z3.version "4.6.0";
+assert z3Support -> z3 != null && lib.versionAtLeast z3.version "4.6.0";
 assert cvc4Support -> cvc4 != null && cln != null && gmp != null;
 
 let
@@ -18,7 +17,7 @@ let
     sha256 = "0qnx5y6c90fphl9mj9d20j2dfgy6s5yr5l0xnzid0vh71zrp6jwv";
   };
 in
-stdenv.mkDerivation rec {
+gccStdenv.mkDerivation rec {
 
   pname = "solc";
   version = "0.7.4";
@@ -36,20 +35,20 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DBoost_USE_STATIC_LIBS=OFF"
-  ] ++ stdenv.lib.optionals (!z3Support) [
+  ] ++ lib.optionals (!z3Support) [
     "-DUSE_Z3=OFF"
-  ] ++ stdenv.lib.optionals (!cvc4Support) [
+  ] ++ lib.optionals (!cvc4Support) [
     "-DUSE_CVC4=OFF"
   ];
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ boost ]
-    ++ stdenv.lib.optionals z3Support [ z3 ]
-    ++ stdenv.lib.optionals cvc4Support [ cvc4 cln gmp ];
+    ++ lib.optionals z3Support [ z3 ]
+    ++ lib.optionals cvc4Support [ cvc4 cln gmp ];
   checkInputs = [ ncurses python3 ];
 
   # Test fails on darwin for unclear reason
-  doCheck = stdenv.hostPlatform.isLinux;
+  doCheck = gccStdenv.hostPlatform.isLinux;
 
   checkPhase = ''
     while IFS= read -r -d ''' dir
@@ -68,7 +67,7 @@ stdenv.mkDerivation rec {
     popd
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Compiler for Ethereum smart contract language Solidity";
     homepage = "https://github.com/ethereum/solidity";
     license = licenses.gpl3;
diff --git a/pkgs/development/compilers/souffle/default.nix b/pkgs/development/compilers/souffle/default.nix
index ba13cd7b4b2..e57062642ba 100644
--- a/pkgs/development/compilers/souffle/default.nix
+++ b/pkgs/development/compilers/souffle/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , perl, ncurses, zlib, sqlite, libffi
 , autoreconfHook, mcpp, bison, flex, doxygen, graphviz
 , makeWrapper
@@ -6,7 +6,7 @@
 
 
 let
-  toolsPath = stdenv.lib.makeBinPath [ mcpp ];
+  toolsPath = lib.makeBinPath [ mcpp ];
 in
 stdenv.mkDerivation rec {
   pname = "souffle";
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A translator of declarative Datalog programs into the C++ language";
     homepage    = "https://souffle-lang.github.io/";
     platforms   = platforms.unix;
diff --git a/pkgs/development/compilers/spasm-ng/default.nix b/pkgs/development/compilers/spasm-ng/default.nix
index 8eb0ddb59ef..bd31719731e 100644
--- a/pkgs/development/compilers/spasm-ng/default.nix
+++ b/pkgs/development/compilers/spasm-ng/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, gcc, gmp, openssl, zlib }:
+{ lib, stdenv, fetchFromGitHub, gcc, gmp, openssl, zlib }:
 
 stdenv.mkDerivation rec {
   pname = "spasm-ng";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     install -Dm755 spasm -t $out/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage    = "https://github.com/alberthdev/spasm-ng";
     description = "Z80 assembler with extra features to support development for TI calculators";
     license     = licenses.gpl2Plus;
diff --git a/pkgs/development/compilers/spirv-llvm-translator/default.nix b/pkgs/development/compilers/spirv-llvm-translator/default.nix
index 73af5f0c985..324e0b07ad8 100644
--- a/pkgs/development/compilers/spirv-llvm-translator/default.nix
+++ b/pkgs/development/compilers/spirv-llvm-translator/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   # FIXME: CMake tries to run "/llvm-lit" which of course doesn't exist
   doCheck = false;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage    = "https://github.com/KhronosGroup/SPIRV-LLVM-Translator";
     description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR";
     license     = licenses.ncsa;
diff --git a/pkgs/development/compilers/squeak/default.nix b/pkgs/development/compilers/squeak/default.nix
index f62e86461f9..7d531181d1d 100644
--- a/pkgs/development/compilers/squeak/default.nix
+++ b/pkgs/development/compilers/squeak/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, coreutils, dbus, freetype, glib, gnused
+{ lib, stdenv, fetchurl, cmake, coreutils, dbus, freetype, glib, gnused
 , libpthreadstubs, pango, pkg-config, libpulseaudio, which }:
 
 stdenv.mkDerivation rec {
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   postPatch = ''
     for i in squeak.in squeak.sh.in; do
       substituteInPlace unix/cmake/$i --replace "PATH=" \
-        "PATH=${stdenv.lib.makeBinPath [ coreutils gnused which ]} #"
+        "PATH=${lib.makeBinPath [ coreutils gnused which ]} #"
     done
   '';
 
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
 
   hardeningDisable = [ "format" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Smalltalk programming language and environment";
     longDescription = ''
       Squeak is a full-featured implementation of the Smalltalk programming
diff --git a/pkgs/development/compilers/stalin/default.nix b/pkgs/development/compilers/stalin/default.nix
index e37b207b4f2..40ab4abf885 100644
--- a/pkgs/development/compilers/stalin/default.nix
+++ b/pkgs/development/compilers/stalin/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, ncompress, libX11 }:
+{ fetchurl, lib, stdenv, ncompress, libX11 }:
 
 stdenv.mkDerivation rec {
   name = "stalin-0.11";
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     homepage = "http://www.ece.purdue.edu/~qobi/software.html";
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
     description = "An optimizing Scheme compiler";
 
     maintainers = [ ];
diff --git a/pkgs/development/compilers/swi-prolog/default.nix b/pkgs/development/compilers/swi-prolog/default.nix
index 66d2add98b1..ce666852e38 100644
--- a/pkgs/development/compilers/swi-prolog/default.nix
+++ b/pkgs/development/compilers/swi-prolog/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, jdk, gmp, readline, openssl, unixODBC, zlib
+{ lib, stdenv, fetchFromGitHub, jdk, gmp, readline, openssl, unixODBC, zlib
 , libarchive, db, pcre, libedit, libossp_uuid, libXpm
 , libSM, libXt, freetype, pkg-config, fontconfig
 , cmake, libyaml, Security
@@ -31,9 +31,9 @@ stdenv.mkDerivation {
   buildInputs = [ gmp readline openssl
     libarchive libyaml db pcre libedit libossp_uuid
     zlib ]
-  ++ stdenv.lib.optionals (withGui && !stdenv.isDarwin) [ libXpm libX11 libXext libXft libXinerama libjpeg ]
+  ++ lib.optionals (withGui && !stdenv.isDarwin) [ libXpm libX11 libXext libXft libXinerama libjpeg ]
   ++ extraLibraries
-  ++ stdenv.lib.optional stdenv.isDarwin Security;
+  ++ lib.optional stdenv.isDarwin Security;
 
   hardeningDisable = [ "format" ];
 
@@ -46,9 +46,9 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://www.swi-prolog.org";
     description = "A Prolog compiler and interpreter";
-    license = stdenv.lib.licenses.bsd2;
+    license = lib.licenses.bsd2;
 
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.optionals (!withGui) stdenv.lib.platforms.darwin;
-    maintainers = [ stdenv.lib.maintainers.meditans ];
+    platforms = lib.platforms.linux ++ lib.optionals (!withGui) lib.platforms.darwin;
+    maintainers = [ lib.maintainers.meditans ];
   };
 }
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index 6b873810764..bf181d07f28 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , cmake
 , coreutils
 , glibc
@@ -121,7 +121,7 @@ let
 
   cmakeFlags = [
     "-DGLIBC_INCLUDE_PATH=${stdenv.cc.libc.dev}/include"
-    "-DC_INCLUDE_DIRS=${stdenv.lib.makeSearchPathOutput "dev" "include" devInputs}:${libxml2.dev}/include/libxml2"
+    "-DC_INCLUDE_DIRS=${lib.makeSearchPathOutput "dev" "include" devInputs}:${libxml2.dev}/include/libxml2"
     "-DGCC_INSTALL_PREFIX=${gccForLibs}"
   ];
 
@@ -282,7 +282,7 @@ stdenv.mkDerivation {
       installable_package=$INSTALLABLE_PACKAGE \
       install_prefix=$out \
       install_destdir=$SWIFT_INSTALL_DIR \
-      extra_cmake_options="${stdenv.lib.concatStringsSep "," cmakeFlags}"
+      extra_cmake_options="${lib.concatStringsSep "," cmakeFlags}"
   '';
 
   doCheck = true;
@@ -323,7 +323,7 @@ stdenv.mkDerivation {
   # Hack to avoid build and install directories in RPATHs.
   preFixup = ''rm -rf $SWIFT_BUILD_ROOT $SWIFT_INSTALL_DIR'';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "The Swift Programming Language";
     homepage = "https://github.com/apple/swift";
     maintainers = with maintainers; [ dtzWill ];
diff --git a/pkgs/development/compilers/terra/default.nix b/pkgs/development/compilers/terra/default.nix
index e8478828c1b..bd50ea9caaa 100644
--- a/pkgs/development/compilers/terra/default.nix
+++ b/pkgs/development/compilers/terra/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchFromGitHub
+{ lib, stdenv, fetchurl, fetchFromGitHub
 , llvmPackages, ncurses, lua
 }:
 
@@ -34,13 +34,13 @@ stdenv.mkDerivation rec {
       --replace '-lcurses' '-lncurses'
 
     substituteInPlace src/terralib.lua \
-      --subst-var-by NIX_LIBC_INCLUDE ${stdenv.lib.getDev stdenv.cc.libc}/include
+      --subst-var-by NIX_LIBC_INCLUDE ${lib.getDev stdenv.cc.libc}/include
   '';
 
   preBuild = ''
     cat >Makefile.inc<<EOF
-    CLANG = ${stdenv.lib.getBin llvmPackages.clang-unwrapped}/bin/clang
-    LLVM_CONFIG = ${stdenv.lib.getBin llvmPackages.llvm}/bin/llvm-config
+    CLANG = ${lib.getBin llvmPackages.clang-unwrapped}/bin/clang
+    LLVM_CONFIG = ${lib.getBin llvmPackages.llvm}/bin/llvm-config
     EOF
 
     mkdir -p build
@@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
     cp -rv release/include/terra $dev/include
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A low-level counterpart to Lua";
     homepage    = "http://terralang.org/";
     platforms   = platforms.x86_64;
diff --git a/pkgs/development/compilers/teyjus/default.nix b/pkgs/development/compilers/teyjus/default.nix
index 6768d0c1cbe..74ba1866b55 100644
--- a/pkgs/development/compilers/teyjus/default.nix
+++ b/pkgs/development/compilers/teyjus/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, omake, ocaml, flex, bison }:
+{ lib, stdenv, fetchurl, omake, ocaml, flex, bison }:
 
 let
   version = "2.1";
@@ -25,10 +25,10 @@ stdenv.mkDerivation {
 
   installPhase = "mkdir -p $out/bin && cp tj* $out/bin";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "An efficient implementation of the Lambda Prolog language";
     homepage = "https://github.com/teyjus/teyjus";
-    license = stdenv.lib.licenses.gpl3;
+    license = lib.licenses.gpl3;
     maintainers = [ maintainers.bcdarwin ];
     platforms = platforms.linux;
   };
diff --git a/pkgs/development/compilers/tvm/default.nix b/pkgs/development/compilers/tvm/default.nix
index 01c44718f11..2bb8b9d5be3 100644
--- a/pkgs/development/compilers/tvm/default.nix
+++ b/pkgs/development/compilers/tvm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake }:
+{ lib, stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   pname = "tvm";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   # not mangle the legitimate use of the opt/ folder.
   dontFixCmake = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://tvm.apache.org/";
     description = "An End to End Deep Learning Compiler Stack for CPUs, GPUs and accelerators";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/unison/default.nix b/pkgs/development/compilers/unison/default.nix
index 7ae16a77a26..433e07c68b0 100644
--- a/pkgs/development/compilers/unison/default.nix
+++ b/pkgs/development/compilers/unison/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoPatchelfHook
+{ lib, stdenv, fetchurl, autoPatchelfHook
 , ncurses5, zlib, gmp
 , makeWrapper
 , less
@@ -25,16 +25,16 @@ stdenv.mkDerivation rec {
   dontBuild = true;
   dontConfigure = true;
 
-  nativeBuildInputs = [ makeWrapper ] ++ (stdenv.lib.optional (!stdenv.isDarwin) autoPatchelfHook);
-  buildInputs = stdenv.lib.optionals (!stdenv.isDarwin) [ ncurses5 zlib gmp ];
+  nativeBuildInputs = [ makeWrapper ] ++ (lib.optional (!stdenv.isDarwin) autoPatchelfHook);
+  buildInputs = lib.optionals (!stdenv.isDarwin) [ ncurses5 zlib gmp ];
 
   installPhase = ''
     mkdir -p $out/bin
     mv ucm $out/bin
-    wrapProgram $out/bin/ucm --prefix PATH ":" "${stdenv.lib.makeBinPath [ less ]}";
+    wrapProgram $out/bin/ucm --prefix PATH ":" "${lib.makeBinPath [ less ]}";
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Modern, statically-typed purely functional language";
     homepage = "https://unisonweb.org/";
     license = with licenses; [ mit bsd3 ];
diff --git a/pkgs/development/compilers/urn/default.nix b/pkgs/development/compilers/urn/default.nix
index 812792a125e..f7e338cf43f 100644
--- a/pkgs/development/compilers/urn/default.nix
+++ b/pkgs/development/compilers/urn/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, buildEnv, makeWrapper, lua, luajit, readline
+{ lib, stdenv, fetchFromGitLab, buildEnv, makeWrapper, lua, luajit, readline
 , useLuaJit ? false
 , extraLibraries ? []
 }:
@@ -17,7 +17,7 @@ let
               [ lua ];
   };
 
-  inherit (stdenv.lib) optionalString concatMapStringsSep;
+  inherit (lib) optionalString concatMapStringsSep;
 in
 
 stdenv.mkDerivation {
@@ -48,7 +48,7 @@ stdenv.mkDerivation {
       --prefix LD_LIBRARY_PATH : ${urn-rt}/lib/
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://urn-lang.com";
     description = "Yet another Lisp variant which compiles to Lua";
     license = licenses.bsd3;
diff --git a/pkgs/development/compilers/urweb/default.nix b/pkgs/development/compilers/urweb/default.nix
index ac324167f97..e2d9d1f226e 100644
--- a/pkgs/development/compilers/urweb/default.nix
+++ b/pkgs/development/compilers/urweb/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, file, openssl, mlton
+{ lib, stdenv, fetchurl, file, openssl, mlton
 , libmysqlclient, postgresql, sqlite, gcc, icu
 }:
 
@@ -39,8 +39,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Advanced purely-functional web programming language";
     homepage    = "http://www.impredicative.com/ur/";
-    license     = stdenv.lib.licenses.bsd3;
-    platforms   = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice stdenv.lib.maintainers.sheganinans ];
+    license     = lib.licenses.bsd3;
+    platforms   = lib.platforms.linux ++ lib.platforms.darwin;
+    maintainers = [ lib.maintainers.thoughtpolice lib.maintainers.sheganinans ];
   };
 }
diff --git a/pkgs/development/compilers/vala/default.nix b/pkgs/development/compilers/vala/default.nix
index 47a11489917..222ad903ec1 100644
--- a/pkgs/development/compilers/vala/default.nix
+++ b/pkgs/development/compilers/vala/default.nix
@@ -92,7 +92,7 @@ let
     #  };
     # };
 
-    meta = with stdenv.lib; {
+    meta = with lib; {
       description = "Compiler for GObject type system";
       homepage = "https://wiki.gnome.org/Projects/Vala";
       license = licenses.lgpl21Plus;
diff --git a/pkgs/development/compilers/vlang/default.nix b/pkgs/development/compilers/vlang/default.nix
index fba11a06a6e..f53d6d4c382 100644
--- a/pkgs/development/compilers/vlang/default.nix
+++ b/pkgs/development/compilers/vlang/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, glfw, freetype, openssl, upx ? null }:
+{ lib, stdenv, fetchFromGitHub, glfw, freetype, openssl, upx ? null }:
 
 assert stdenv.hostPlatform.isUnix -> upx != null;
 
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
   propagatedBuildInputs = [ glfw freetype openssl ]
-    ++ stdenv.lib.optional stdenv.hostPlatform.isUnix upx;
+    ++ lib.optional stdenv.hostPlatform.isUnix upx;
 
   buildPhase = ''
     runHook preBuild
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://vlang.io/";
     description = "Simple, fast, safe, compiled language for developing maintainable software";
     license = licenses.mit;
diff --git a/pkgs/development/compilers/vyper/default.nix b/pkgs/development/compilers/vyper/default.nix
index 3a584ab2018..79702c01bee 100644
--- a/pkgs/development/compilers/vyper/default.nix
+++ b/pkgs/development/compilers/vyper/default.nix
@@ -45,7 +45,7 @@ buildPythonPackage rec {
     $out/bin/vyper "${sample-contract}"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Pythonic Smart Contract Language for the EVM";
     homepage = "https://github.com/vyperlang/vyper";
     license = licenses.asl20;
diff --git a/pkgs/development/compilers/wcc/default.nix b/pkgs/development/compilers/wcc/default.nix
index b6030da49d3..644e9ad646a 100644
--- a/pkgs/development/compilers/wcc/default.nix
+++ b/pkgs/development/compilers/wcc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, capstone, libbfd, libelf, libiberty, readline }:
+{ lib, stdenv, fetchFromGitHub, capstone, libbfd, libelf, libiberty, readline }:
 
 stdenv.mkDerivation {
   pname = "wcc-unstable";
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://github.com/endrazine/wcc";
     description = "Witchcraft compiler collection: tools to convert and script ELF files";
     license = licenses.mit;
diff --git a/pkgs/development/compilers/wla-dx/default.nix b/pkgs/development/compilers/wla-dx/default.nix
index 0cebbfa520f..b80b460d4de 100644
--- a/pkgs/development/compilers/wla-dx/default.nix
+++ b/pkgs/development/compilers/wla-dx/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, cmake}:
+{lib, stdenv, fetchFromGitHub, cmake}:
 
 stdenv.mkDerivation rec {
   pname = "wla-dx";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.villehelin.com/wla.html";
     description = "Yet Another GB-Z80/Z80/6502/65C02/6510/65816/HUC6280/SPC-700 Multi Platform Cross Assembler Package";
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/x11basic/default.nix b/pkgs/development/compilers/x11basic/default.nix
index 9bf6b3d2874..e48bbc90d61 100644
--- a/pkgs/development/compilers/x11basic/default.nix
+++ b/pkgs/development/compilers/x11basic/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , automake, autoconf, readline
 , libX11, bluez, SDL2
 }:
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
     cp -r ../examples $out/share/.
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://x11-basic.sourceforge.net/";
     description = "A Basic interpreter and compiler with graphics capabilities";
     license = licenses.gpl2;
diff --git a/pkgs/development/compilers/yap/default.nix b/pkgs/development/compilers/yap/default.nix
index 100fb236c83..da10125c243 100644
--- a/pkgs/development/compilers/yap/default.nix
+++ b/pkgs/development/compilers/yap/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, readline, gmp, zlib }:
+{ lib, stdenv, fetchurl, readline, gmp, zlib }:
 
 stdenv.mkDerivation rec {
   version = "6.3.3";
@@ -18,10 +18,10 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://www.dcc.fc.up.pt/~vsc/Yap/";
     description = "A ISO-compatible high-performance Prolog compiler";
-    license = stdenv.lib.licenses.artistic2;
+    license = lib.licenses.artistic2;
 
-    maintainers = [ stdenv.lib.maintainers.peti ];
-    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ lib.maintainers.peti ];
+    platforms = lib.platforms.linux;
     broken = !stdenv.is64bit;   # the linux 32 bit build fails.
   };
 }
diff --git a/pkgs/development/compilers/yasm/default.nix b/pkgs/development/compilers/yasm/default.nix
index 923a11c1466..48c251d828a 100644
--- a/pkgs/development/compilers/yasm/default.nix
+++ b/pkgs/development/compilers/yasm/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
   name = "yasm-1.3.0";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "0gv0slmm0qpq91za3v2v9glff3il594x5xsrbgab7xcmnh0ndkix";
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "http://www.tortall.net/projects/yasm/";
     description = "Complete rewrite of the NASM assembler";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/z88dk/default.nix b/pkgs/development/compilers/z88dk/default.nix
index 0fb73d42b7e..026a205cd26 100644
--- a/pkgs/development/compilers/z88dk/default.nix
+++ b/pkgs/development/compilers/z88dk/default.nix
@@ -1,4 +1,4 @@
-{ fetchFromGitHub, stdenv, makeWrapper, unzip, libxml2, m4, uthash, which }:
+{ fetchFromGitHub, lib, stdenv, makeWrapper, unzip, libxml2, m4, uthash, which }:
 
 stdenv.mkDerivation rec {
   pname = "z88dk";
@@ -49,7 +49,7 @@ stdenv.mkDerivation rec {
 
   installTargets = [ "libs" "install" ];
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.z88dk.org";
     description = "z80 Development Kit";
     license = licenses.clArtistic;
diff --git a/pkgs/development/compilers/zasm/default.nix b/pkgs/development/compilers/zasm/default.nix
index 174092496ba..97c7aa3c2ac 100644
--- a/pkgs/development/compilers/zasm/default.nix
+++ b/pkgs/development/compilers/zasm/default.nix
@@ -1,4 +1,4 @@
-{ fetchFromGitHub, zlib, stdenv }:
+{ fetchFromGitHub, zlib, lib, stdenv }:
 let
   libs-src = fetchFromGitHub {
     owner = "megatokio";
@@ -33,7 +33,7 @@ stdenv.mkDerivation {
     mv zasm $out/bin
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Z80 / 8080 assembler (for unix-style OS)";
     homepage = "https://k1.spdns.de/Develop/Projects/zasm/Distributions/";
     license = licenses.bsd2;
diff --git a/pkgs/development/compilers/zig/default.nix b/pkgs/development/compilers/zig/default.nix
index 1a5cba37d47..bd96010e8bf 100644
--- a/pkgs/development/compilers/zig/default.nix
+++ b/pkgs/development/compilers/zig/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2, zlib, substituteAll }:
+{ lib, stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2, zlib, substituteAll }:
 
 llvmPackages.stdenv.mkDerivation rec {
   version = "0.7.1";
@@ -32,7 +32,7 @@ llvmPackages.stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description =
       "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
     homepage = "https://ziglang.org/";
diff --git a/pkgs/development/compilers/zulu/8.nix b/pkgs/development/compilers/zulu/8.nix
index bea32475f9a..e81cc412428 100644
--- a/pkgs/development/compilers/zulu/8.nix
+++ b/pkgs/development/compilers/zulu/8.nix
@@ -62,13 +62,13 @@ in stdenv.mkDerivation {
     EOF
   '';
 
-  rpath = stdenv.lib.strings.makeLibraryPath libraries;
+  rpath = lib.strings.makeLibraryPath libraries;
 
   passthru = {
     home = zulu;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.azul.com/products/zulu/";
     license = licenses.gpl2;
     description = "Certified builds of OpenJDK";
diff --git a/pkgs/development/compilers/zulu/default.nix b/pkgs/development/compilers/zulu/default.nix
index 73e7bd7d338..63b95465c27 100644
--- a/pkgs/development/compilers/zulu/default.nix
+++ b/pkgs/development/compilers/zulu/default.nix
@@ -59,13 +59,13 @@ in stdenv.mkDerivation {
     EOF
   '';
 
-  rpath = stdenv.lib.strings.makeLibraryPath libraries;
+  rpath = lib.strings.makeLibraryPath libraries;
 
   passthru = {
     home = zulu;
   };
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.azul.com/products/zulu/";
     license = licenses.gpl2;
     description = "Certified builds of OpenJDK";
diff --git a/pkgs/development/interpreters/octave/default.nix b/pkgs/development/interpreters/octave/default.nix
index 7dedf79c340..6ad25d24eae 100644
--- a/pkgs/development/interpreters/octave/default.nix
+++ b/pkgs/development/interpreters/octave/default.nix
@@ -1,4 +1,5 @@
 { stdenv
+, lib
 # Note: either stdenv.mkDerivation or, for octaveFull, the qt-5 mkDerivation
 # with wrapQtAppsHook (comes from libsForQt5.callPackage)
 , mkDerivation
@@ -124,21 +125,21 @@ in mkDerivation rec {
     libwebp
     gl2ps
   ]
-  ++ stdenv.lib.optionals enableQt [
+  ++ lib.optionals enableQt [
     qtbase
     qtsvg
     qscintilla
   ]
-  ++ stdenv.lib.optionals (ghostscript != null) [ ghostscript ]
-  ++ stdenv.lib.optionals (hdf5 != null) [ hdf5 ]
-  ++ stdenv.lib.optionals (glpk != null) [ glpk ]
-  ++ stdenv.lib.optionals (suitesparse != null) [ suitesparse' ]
-  ++ stdenv.lib.optionals (enableJava) [ jdk ]
-  ++ stdenv.lib.optionals (sundials != null) [ sundials ]
-  ++ stdenv.lib.optionals (gnuplot != null) [ gnuplot ]
-  ++ stdenv.lib.optionals (python != null) [ python ]
-  ++ stdenv.lib.optionals (!stdenv.isDarwin) [ libGL libGLU libX11 ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [
+  ++ lib.optionals (ghostscript != null) [ ghostscript ]
+  ++ lib.optionals (hdf5 != null) [ hdf5 ]
+  ++ lib.optionals (glpk != null) [ glpk ]
+  ++ lib.optionals (suitesparse != null) [ suitesparse' ]
+  ++ lib.optionals (enableJava) [ jdk ]
+  ++ lib.optionals (sundials != null) [ sundials ]
+  ++ lib.optionals (gnuplot != null) [ gnuplot ]
+  ++ lib.optionals (python != null) [ python ]
+  ++ lib.optionals (!stdenv.isDarwin) [ libGL libGLU libX11 ]
+  ++ lib.optionals stdenv.isDarwin [
     libiconv
     darwin.apple_sdk.frameworks.Accelerate
     darwin.apple_sdk.frameworks.Cocoa
@@ -152,9 +153,9 @@ in mkDerivation rec {
     fftwSinglePrec
     texinfo
   ]
-  ++ stdenv.lib.optionals (sundials != null) [ sundials ]
-  ++ stdenv.lib.optionals enableJIT [ llvm ]
-  ++ stdenv.lib.optionals enableQt [
+  ++ lib.optionals (sundials != null) [ sundials ]
+  ++ lib.optionals enableJIT [ llvm ]
+  ++ lib.optionals enableQt [
     qtscript
     qttools
   ]
@@ -172,11 +173,11 @@ in mkDerivation rec {
     "--with-lapack=lapack"
     (if use64BitIdx then "--enable-64" else "--disable-64")
   ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ "--enable-link-all-dependencies" ]
-    ++ stdenv.lib.optionals enableReadline [ "--enable-readline" ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ "--with-x=no" ]
-    ++ stdenv.lib.optionals enableQt [ "--with-qt=5" ]
-    ++ stdenv.lib.optionals enableJIT [ "--enable-jit" ]
+    ++ lib.optionals stdenv.isDarwin [ "--enable-link-all-dependencies" ]
+    ++ lib.optionals enableReadline [ "--enable-readline" ]
+    ++ lib.optionals stdenv.isDarwin [ "--with-x=no" ]
+    ++ lib.optionals enableQt [ "--with-qt=5" ]
+    ++ lib.optionals enableJIT [ "--enable-jit" ]
   ;
 
   # Keep a copy of the octave tests detailed results in the output
@@ -198,13 +199,13 @@ in mkDerivation rec {
 
   meta = {
     homepage = "https://www.gnu.org/software/octave/";
-    license = stdenv.lib.licenses.gpl3Plus;
-    maintainers = with stdenv.lib.maintainers; [ raskin doronbehar ];
+    license = lib.licenses.gpl3Plus;
+    maintainers = with lib.maintainers; [ raskin doronbehar ];
     description = "Scientific Pragramming Language";
     # https://savannah.gnu.org/bugs/?func=detailitem&item_id=56425 is the best attempt to fix JIT
     broken = enableJIT;
     platforms = if overridePlatforms == null then
-      (with stdenv.lib; platforms.linux ++ platforms.darwin)
+      (lib.platforms.linux ++ lib.platforms.darwin)
     else overridePlatforms;
   };
 }
diff --git a/pkgs/development/libraries/comedilib/default.nix b/pkgs/development/libraries/comedilib/default.nix
index e42f02407d4..fef22dea06a 100644
--- a/pkgs/development/libraries/comedilib/default.nix
+++ b/pkgs/development/libraries/comedilib/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ stdenv
+, lib
 , fetchFromGitHub
 , autoreconfHook
 , flex
diff --git a/pkgs/development/libraries/cpp-utilities/default.nix b/pkgs/development/libraries/cpp-utilities/default.nix
index 38879342f7a..cec6feded13 100644
--- a/pkgs/development/libraries/cpp-utilities/default.nix
+++ b/pkgs/development/libraries/cpp-utilities/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ stdenv
+, lib
 , fetchFromGitHub
 , fetchpatch
 , cmake
diff --git a/pkgs/development/libraries/liberio/default.nix b/pkgs/development/libraries/liberio/default.nix
index 7a40c1a83da..743455b836d 100644
--- a/pkgs/development/libraries/liberio/default.nix
+++ b/pkgs/development/libraries/liberio/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ stdenv
+, lib
 , fetchFromGitHub
 , autoreconfHook
 , systemd
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index 60113d492a7..b162ab50810 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -2,7 +2,7 @@
 , makeWrapper, autoreconfHook, fetchpatch
 , coreutils, libxml2, gnutls, perl, python2, attr, glib, docutils
 , iproute, readline, lvm2, util-linux, systemd, libpciaccess, gettext
-, libtasn1, iptables-nftables-compat, libgcrypt, yajl, pmutils, libcap_ng, libapparmor
+, libtasn1, iptables, ebtables, libgcrypt, yajl, pmutils, libcap_ng, libapparmor
 , dnsmasq, libnl, libpcap, libxslt, xhtml1, numad, numactl, perlPackages
 , curl, libiconv, gmp, zfs, parted, bridge-utils, dmidecode, dbus, libtirpc, rpcsvc-proto, darwin
 , meson, ninja, audit, cmake, bash-completion, pkg-config
@@ -16,6 +16,19 @@ with lib;
 # if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
 let
   buildFromTarball = stdenv.isDarwin;
+  # libvirt hardcodes the binary name 'ebtables', but in nixpkgs the ebtables
+  # binary we want to use is named 'ebtables-legacy'.
+  # Create a derivation to alias the binary name so that libvirt can find the right one, and use that below.
+  ebtables-compat = stdenv.mkDerivation {
+    pname = "ebtables-compat";
+    version = ebtables.version;
+    src = null;
+    buildInputs = [ ebtables ];
+    buildCommand = ''
+      mkdir -p $out/bin
+      ln -sf ${ebtables}/bin/ebtables-legacy $out/bin/ebtables
+    '';
+  };
 in stdenv.mkDerivation rec {
   pname = "libvirt";
   version = "6.8.0";
@@ -72,7 +85,7 @@ in stdenv.mkDerivation rec {
       sed -i meson.build -e "s|conf.set_quoted('${var}',.*|conf.set_quoted('${var}','${value}')|"
     '';
   in ''
-    PATH=${lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute iptables-nftables-compat lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$PATH
+    PATH=${lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute iptables ebtables-compat lvm2 systemd numad ] ++ optionals enableIscsi [ openiscsi ])}:$PATH
     # the path to qemu-kvm will be stored in VM's .xml and .save files
     # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations
     substituteInPlace src/lxc/lxc_conf.c \
@@ -115,15 +128,15 @@ in stdenv.mkDerivation rec {
   ];
 
   postInstall = let
-    # iptables-nftables-compat for an 'ebtables' binary
-    binPath = [ iptables-nftables-compat iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ] ++ optionals enableIscsi [ openiscsi ];
+    # Keep the legacy iptables binary for now for backwards compatibility (comment on #109332)
+    binPath = [ iptables ebtables-compat iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ] ++ optionals enableIscsi [ openiscsi ];
   in ''
     substituteInPlace $out/libexec/libvirt-guests.sh \
-      --replace 'ON_BOOT=start'       'ON_BOOT=''${ON_BOOT:-start}' \
-      --replace 'ON_SHUTDOWN=suspend' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
-      --replace "$out/bin"            '${gettext}/bin' \
-      --replace 'lock/subsys'         'lock' \
-      --replace 'gettext.sh'          'gettext.sh
+      --replace 'ON_BOOT="start"'       'ON_BOOT=''${ON_BOOT:-start}' \
+      --replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
+      --replace "$out/bin"              '${gettext}/bin' \
+      --replace 'lock/subsys'           'lock' \
+      --replace 'gettext.sh'            'gettext.sh
   # Added in nixpkgs:
   gettext() { "${gettext}/bin/gettext" "$@"; }
   '
diff --git a/pkgs/development/libraries/nsss/default.nix b/pkgs/development/libraries/nsss/default.nix
index 3e3530215bf..4e71c4d65e6 100644
--- a/pkgs/development/libraries/nsss/default.nix
+++ b/pkgs/development/libraries/nsss/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "nsss";
-  version = "0.0.2.2";
-  sha256 = "0am195wabv63n545ykqnch9gs8cs1g5zw35k2ddxb9dnamhxfi9k";
+  version = "0.1.0.0";
+  sha256 = "15rxbwf16wm1la079yr2xn4bccjgd7m8dh6r7bpr6s57cj93i2mq";
 
   description = "An implementation of a subset of the pwd.h, group.h and shadow.h family of functions.";
 
diff --git a/pkgs/development/libraries/phonetisaurus/default.nix b/pkgs/development/libraries/phonetisaurus/default.nix
index abacfdc1cce..9ba00833d62 100644
--- a/pkgs/development/libraries/phonetisaurus/default.nix
+++ b/pkgs/development/libraries/phonetisaurus/default.nix
@@ -7,12 +7,12 @@
 
 stdenv.mkDerivation rec {
   pname = "phonetisaurus";
-  version = "2020-07-31";
+  version = "0.9.1";
 
   src = fetchFromGitHub {
     owner = "AdolfVonKleist";
     repo = pname;
-    rev = "2831870697de5b4fbcb56a6e1b975e0e1ea10deb";
+    rev = version;
     sha256 = "1b18s5zz0l0fhqh9n9jnmgjz2hzprwzf6hx5a12zibmmam3qyriv";
   };
 
diff --git a/pkgs/development/libraries/qrupdate/default.nix b/pkgs/development/libraries/qrupdate/default.nix
index 3e4109b1bf0..ad7e88d4647 100644
--- a/pkgs/development/libraries/qrupdate/default.nix
+++ b/pkgs/development/libraries/qrupdate/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ stdenv
+, lib
 , fetchurl
 , gfortran
 , blas
diff --git a/pkgs/development/libraries/qtutilities/default.nix b/pkgs/development/libraries/qtutilities/default.nix
index c44e8f4fd87..831c51fa234 100644
--- a/pkgs/development/libraries/qtutilities/default.nix
+++ b/pkgs/development/libraries/qtutilities/default.nix
@@ -1,4 +1,12 @@
-{ lib, stdenv, fetchFromGitHub, cpp-utilities, qttools, qtbase, cmake, pkg-config }:
+{ stdenv
+, lib
+, fetchFromGitHub
+, cpp-utilities
+, qttools
+, qtbase
+, cmake
+, pkg-config
+}:
 
 stdenv.mkDerivation rec {
   pname = "qtutilities";
diff --git a/pkgs/development/libraries/skalibs/default.nix b/pkgs/development/libraries/skalibs/default.nix
index a691107f9a1..1efac7fc5e4 100644
--- a/pkgs/development/libraries/skalibs/default.nix
+++ b/pkgs/development/libraries/skalibs/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "skalibs";
-  version = "2.9.3.0";
-  sha256 = "0i1vg3bh0w3bpj7cv0kzs6q9v2dd8wa2by8h8j39fh1qkl20f6ph";
+  version = "2.10.0.1";
+  sha256 = "1chwjzlh13jbrldk77h3i4qjqv8hjpvvd3papcb8j46mvj7sxysg";
 
   description = "A set of general-purpose C programming libraries";
 
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index d2a1ed905ea..bf1b8b7aa3b 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -1,4 +1,6 @@
-{ lib, stdenv, fetchurl, zlib, interactive ? false, readline ? null, ncurses ? null }:
+{ lib, stdenv, fetchurl, zlib, interactive ? false, readline ? null, ncurses ? null
+, python3Packages
+}:
 
 assert interactive -> readline != null && ncurses != null;
 
@@ -73,6 +75,10 @@ stdenv.mkDerivation rec {
 
   doCheck = false; # fails to link against tcl
 
+  passthru.tests = {
+    inherit (python3Packages) sqlalchemy;
+  };
+
   meta = {
     description = "A self-contained, serverless, zero-configuration, transactional SQL database engine";
     downloadPage = "https://sqlite.org/download.html";
diff --git a/pkgs/development/libraries/tweeny/default.nix b/pkgs/development/libraries/tweeny/default.nix
index c1737f6f017..8340e47fbf9 100644
--- a/pkgs/development/libraries/tweeny/default.nix
+++ b/pkgs/development/libraries/tweeny/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv
+{ stdenv
+, lib
 , fetchFromGitHub
 , cmake
 }:
diff --git a/pkgs/development/libraries/utmps/default.nix b/pkgs/development/libraries/utmps/default.nix
index 16b4cd563b2..107c23dcb59 100644
--- a/pkgs/development/libraries/utmps/default.nix
+++ b/pkgs/development/libraries/utmps/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "utmps";
-  version = "0.0.3.2";
-  sha256 = "0zri5pqnva48bm8za4ic5mx0ymv70y4ga16bjh4i5pscs40sj5dh";
+  version = "0.1.0.0";
+  sha256 = "09p0k2sgxr7jlsbrn66fzvzf9zxvpjp85y79xk10hxjglypszyml";
 
   description = "A secure utmpx and wtmp implementation";
 
diff --git a/pkgs/development/mobile/abootimg/default.nix b/pkgs/development/mobile/abootimg/default.nix
index d2e43d10608..bec022f08c7 100644
--- a/pkgs/development/mobile/abootimg/default.nix
+++ b/pkgs/development/mobile/abootimg/default.nix
@@ -28,10 +28,10 @@ stdenv.mkDerivation {
     install -D -m444 ./debian/abootimg.1 $out/share/man/man1/abootimg.1;
 
     install -D -m 755 abootimg-pack-initrd $out/bin
-    wrapProgram $out/bin/abootimg-pack-initrd --prefix PATH : ${stdenv.lib.makeBinPath [ coreutils cpio findutils gzip ]}
+    wrapProgram $out/bin/abootimg-pack-initrd --prefix PATH : ${lib.makeBinPath [ coreutils cpio findutils gzip ]}
 
     install -D -m 755 abootimg-unpack-initrd $out/bin
-    wrapProgram $out/bin/abootimg-unpack-initrd --prefix PATH : ${stdenv.lib.makeBinPath [ cpio gzip ]}
+    wrapProgram $out/bin/abootimg-unpack-initrd --prefix PATH : ${lib.makeBinPath [ cpio gzip ]}
   '';
 
   meta = with lib; {
diff --git a/pkgs/development/mobile/adb-sync/default.nix b/pkgs/development/mobile/adb-sync/default.nix
index fc37eefc212..c88ac5dbca5 100644
--- a/pkgs/development/mobile/adb-sync/default.nix
+++ b/pkgs/development/mobile/adb-sync/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   dontBuild = true;
 
   installPhase = let
-    dependencies = stdenv.lib.makeBinPath [ platform-tools socat go-mtpfs adbfs-rootless ];
+    dependencies = lib.makeBinPath [ platform-tools socat go-mtpfs adbfs-rootless ];
   in ''
     runHook preInstall
 
diff --git a/pkgs/development/mobile/flashtool/default.nix b/pkgs/development/mobile/flashtool/default.nix
index 84c42c895ce..e00ff3acce0 100644
--- a/pkgs/development/mobile/flashtool/default.nix
+++ b/pkgs/development/mobile/flashtool/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, requireFile, p7zip, jre, libusb1, platform-tools, gtk2, glib, libXtst }:
+{ stdenv, lib, requireFile, p7zip, jre, libusb1, platform-tools, gtk2, glib, libXtst }:
 
 # TODO:
 #
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
     sed -i \
       -e 's|$(uname -m)|i686|' \
       -e 's|export JAVA_HOME=.*|export JAVA_HOME=${jre}|' \
-      -e 's|export LD_LIBRARY_PATH=.*|export LD_LIBRARY_PATH=${stdenv.lib.makeLibraryPath [ libXtst glib gtk2 ]}:./x10flasher_lib/linux/lib32|' \
+      -e 's|export LD_LIBRARY_PATH=.*|export LD_LIBRARY_PATH=${lib.makeLibraryPath [ libXtst glib gtk2 ]}:./x10flasher_lib/linux/lib32|' \
       FlashTool FlashToolConsole
   '';
 
@@ -51,12 +51,12 @@ stdenv.mkDerivation rec {
     mv * $out/
   '';
 
-  meta = {
+  meta = with lib; {
     homepage = "http://www.flashtool.net/";
     description = "S1 flashing software for Sony phones from X10 to Xperia Z Ultra";
-    license = stdenv.lib.licenses.unfreeRedistributableFirmware;
+    license = licenses.unfreeRedistributableFirmware;
     platforms = [ "i686-linux" ];
-    hydraPlatforms = stdenv.lib.platforms.none;
+    hydraPlatforms = platforms.none;
     broken = true;
   };
 }
diff --git a/pkgs/development/mobile/genymotion/default.nix b/pkgs/development/mobile/genymotion/default.nix
index 72a376d39a8..b4431506515 100644
--- a/pkgs/development/mobile/genymotion/default.nix
+++ b/pkgs/development/mobile/genymotion/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, which, zlib, libGL, glib, xorg, libxkbcommon
+{ stdenv, lib, fetchurl, makeWrapper, which, zlib, libGL, glib, xorg, libxkbcommon
 , xdg_utils
 # For glewinfo
 , libXmu, libXi, libXext }:
@@ -7,7 +7,7 @@ let
   packages = [
     stdenv.cc.cc zlib glib xorg.libX11 libxkbcommon libXmu libXi libXext libGL
   ];
-  libPath = stdenv.lib.makeLibraryPath packages;
+  libPath = lib.makeLibraryPath packages;
 in
 stdenv.mkDerivation rec {
   pname = "genymotion";
@@ -66,7 +66,7 @@ stdenv.mkDerivation rec {
     rm $out/libexec/genymotion/libxkbcommon*
   '';
 
-  meta = {
+  meta = with lib; {
     description = "Fast and easy Android emulation";
     longDescription = ''
       Genymotion is a relatively fast Android emulator which comes with
@@ -74,8 +74,8 @@ stdenv.mkDerivation rec {
       suitable for application testing.
      '';
     homepage = "https://www.genymotion.com/";
-    license = stdenv.lib.licenses.unfree;
+    license = licenses.unfree;
     platforms = ["x86_64-linux"];
-    maintainers = [ stdenv.lib.maintainers.puffnfresh ];
+    maintainers = [ maintainers.puffnfresh ];
   };
 }
diff --git a/pkgs/development/mobile/titaniumenv/build-app.nix b/pkgs/development/mobile/titaniumenv/build-app.nix
index a7e158bd3bb..82a264e702d 100644
--- a/pkgs/development/mobile/titaniumenv/build-app.nix
+++ b/pkgs/development/mobile/titaniumenv/build-app.nix
@@ -1,4 +1,4 @@
-{stdenv, composeAndroidPackages, composeXcodeWrapper, titaniumsdk, titanium, alloy, jdk, python, nodejs, which, file}:
+{stdenv, lib, composeAndroidPackages, composeXcodeWrapper, titaniumsdk, titanium, alloy, jdk, python, nodejs, which, file}:
 { name, src, preBuild ? "", target, tiVersion ? null
 , release ? false, androidKeyStore ? null, androidKeyAlias ? null, androidKeyStorePassword ? null
 , iosMobileProvisioningProfile ? null, iosCertificateName ? null, iosCertificate ? null, iosCertificatePassword ? null, iosVersion ? "12.1", iosBuildStore ? false
@@ -34,14 +34,14 @@ let
   extraArgs = removeAttrs args [ "name" "preRebuild" "androidsdkArgs" "xcodewrapperArgs" ];
 in
 stdenv.mkDerivation ({
-  name = stdenv.lib.replaceChars [" "] [""] name;
+  name = lib.replaceChars [" "] [""] name;
 
   buildInputs = [ nodejs titanium alloy python which file jdk ];
 
   buildPhase = ''
     ${preBuild}
 
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
+    ${lib.optionalString stdenv.isDarwin ''
       # Hack that provides a writable alloy package on macOS. Without it the build fails because of a file permission error.
       alloy=$(dirname $(type -p alloy))/..
       cp -rv $alloy/* alloy
@@ -51,7 +51,7 @@ stdenv.mkDerivation ({
 
     export HOME=${if target == "iphone" then "/Users/$(whoami)" else "$TMPDIR"}
 
-    ${stdenv.lib.optionalString (tiVersion != null) ''
+    ${lib.optionalString (tiVersion != null) ''
       # Replace titanium version by the provided one
       sed -i -e "s|<sdk-version>[0-9a-zA-Z\.]*</sdk-version>|<sdk-version>${tiVersion}</sdk-version>|" tiapp.xml
     ''}
@@ -76,7 +76,7 @@ stdenv.mkDerivation ({
       export GRADLE_USER_HOME=$TMPDIR/gradle
 
       ${if release then ''
-        ${stdenv.lib.optionalString stdenv.isDarwin ''
+        ${lib.optionalString stdenv.isDarwin ''
           # Signing the app does not work with OpenJDK on macOS, use host SDK instead
           export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
         ''}
@@ -171,7 +171,7 @@ stdenv.mkDerivation ({
         mkdir -p $out/nix-support
         echo "file binary-dist \"$(echo $out/*.ipa)\"" > $out/nix-support/hydra-build-products
 
-        ${stdenv.lib.optionalString enableWirelessDistribution ''
+        ${lib.optionalString enableWirelessDistribution ''
           appname="$(basename $out/*.ipa .ipa)"
           bundleId=$(grep '<id>[a-zA-Z0-9.]*</id>' tiapp.xml | sed -e 's|<id>||' -e 's|</id>||' -e 's/ //g')
           version=$(grep '<version>[a-zA-Z0-9.]*</version>' tiapp.xml | sed -e 's|<version>||' -e 's|</version>||' -e 's/ //g')
@@ -184,5 +184,5 @@ stdenv.mkDerivation ({
     else throw "Target: ${target} is not supported!"}
   '';
 
-  failureHook = stdenv.lib.optionalString (release && target == "iphone") deleteKeychain;
+  failureHook = lib.optionalString (release && target == "iphone") deleteKeychain;
 } // extraArgs)
diff --git a/pkgs/development/mobile/titaniumenv/default.nix b/pkgs/development/mobile/titaniumenv/default.nix
index 44ec91d7e59..151502a5d16 100644
--- a/pkgs/development/mobile/titaniumenv/default.nix
+++ b/pkgs/development/mobile/titaniumenv/default.nix
@@ -8,11 +8,11 @@ rec {
       else throw "Titanium version not supported: "+tiVersion;
     in
     import titaniumSdkFile {
-      inherit (pkgs) stdenv fetchurl unzip makeWrapper;
+      inherit (pkgs) stdenv lib fetchurl unzip makeWrapper;
     };
 
   buildApp = import ./build-app.nix {
-    inherit (pkgs) stdenv python which file jdk nodejs;
+    inherit (pkgs) stdenv lib python which file jdk nodejs;
     inherit (pkgs.nodePackages) alloy titanium;
     inherit (androidenv) composeAndroidPackages;
     inherit (xcodeenv) composeXcodeWrapper;
diff --git a/pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix b/pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix
index 2af53a63b58..0742247893c 100644
--- a/pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix
+++ b/pkgs/development/mobile/titaniumenv/titaniumsdk-8.2.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, unzip, makeWrapper}:
+{stdenv, lib, fetchurl, unzip, makeWrapper}:
 
 let
   # Gradle is a build system that bootstraps itself. This is what it actually
@@ -87,7 +87,7 @@ stdenv.mkDerivation {
     # Patch maven central repository with our own local directory. This prevents the builder from downloading Maven artifacts
     sed -i -e 's|mavenCentral()|maven { url "${fakeMavenRepo}" }|' android/templates/build/proguard.gradle
 
-    ${stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") ''
+    ${lib.optionalString (stdenv.system == "x86_64-darwin") ''
       # Patch the strip frameworks script in the iPhone build template to not let
       # it skip the strip phase. This is caused by an assumption on the file
       # permissions in which Nix deviates from the standard.
diff --git a/pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix b/pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix
index b995a566f52..965a385ac56 100644
--- a/pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix
+++ b/pkgs/development/mobile/titaniumenv/titaniumsdk-8.3.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, unzip, makeWrapper}:
+{stdenv, lib, fetchurl, unzip, makeWrapper}:
 
 let
   # Gradle is a build system that bootstraps itself. This is what it actually
@@ -87,7 +87,7 @@ stdenv.mkDerivation {
     # Patch maven central repository with our own local directory. This prevents the builder from downloading Maven artifacts
     sed -i -e 's|mavenCentral()|maven { url "${fakeMavenRepo}" }|' android/templates/build/proguard.gradle
 
-    ${stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") ''
+    ${lib.optionalString (stdenv.system == "x86_64-darwin") ''
       # Patch the strip frameworks script in the iPhone build template to not let
       # it skip the strip phase. This is caused by an assumption on the file
       # permissions in which Nix deviates from the standard.
diff --git a/pkgs/development/mobile/xcodeenv/build-app.nix b/pkgs/development/mobile/xcodeenv/build-app.nix
index adf64f9561c..ae8416c8d76 100644
--- a/pkgs/development/mobile/xcodeenv/build-app.nix
+++ b/pkgs/development/mobile/xcodeenv/build-app.nix
@@ -1,4 +1,4 @@
-{stdenv, composeXcodeWrapper}:
+{stdenv, lib, composeXcodeWrapper}:
 { name
 , src
 , sdkVersion ? "13.1"
@@ -53,13 +53,13 @@ let
   extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs);
 in
 stdenv.mkDerivation ({
-  name = stdenv.lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
+  name = lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
   buildPhase = ''
     # Be sure that the Xcode wrapper has priority over everything else.
     # When using buildInputs this does not seem to be the case.
     export PATH=${xcodewrapper}/bin:$PATH
 
-    ${stdenv.lib.optionalString release ''
+    ${lib.optionalString release ''
       export HOME=/Users/$(whoami)
       keychainName="$(basename $out)"
 
@@ -91,10 +91,10 @@ stdenv.mkDerivation ({
     # Do the building
     export LD=/usr/bin/clang # To avoid problem with -isysroot parameter that is unrecognized by the stock ld. Comparison with an impure build shows that it uses clang instead. Ugly, but it works
 
-    xcodebuild -target ${_target} -configuration ${_configuration} ${stdenv.lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags}
+    xcodebuild -target ${_target} -configuration ${_configuration} ${lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags}
 
-    ${stdenv.lib.optionalString release ''
-      ${stdenv.lib.optionalString generateIPA ''
+    ${lib.optionalString release ''
+      ${lib.optionalString generateIPA ''
         # Create export plist file
         cat > "${name}.plist" <<EOF
         <?xml version="1.0" encoding="UTF-8"?>
@@ -112,7 +112,7 @@ stdenv.mkDerivation ({
             <string>manual</string>
             <key>method</key>
             <string>${signMethod}</string>
-            ${stdenv.lib.optionalString (signMethod == "enterprise" || signMethod == "ad-hoc") ''
+            ${lib.optionalString (signMethod == "enterprise" || signMethod == "ad-hoc") ''
               <key>compileBitcode</key>
               <false/>
             ''}
@@ -127,14 +127,14 @@ stdenv.mkDerivation ({
         mkdir -p $out/nix-support
         echo "file binary-dist \"$(echo $out/*.ipa)\"" > $out/nix-support/hydra-build-products
 
-        ${stdenv.lib.optionalString enableWirelessDistribution ''
+        ${lib.optionalString enableWirelessDistribution ''
           # Add another hacky build product that enables wireless adhoc installations
           appname="$(basename "$(echo $out/*.ipa)" .ipa)"
           sed -e "s|@INSTALL_URL@|${installURL}?bundleId=${bundleId}\&amp;version=${appVersion}\&amp;title=$appname|" ${./install.html.template} > $out/''${appname}.html
           echo "doc install \"$out/''${appname}.html\"" >> $out/nix-support/hydra-build-products
         ''}
       ''}
-      ${stdenv.lib.optionalString generateXCArchive ''
+      ${lib.optionalString generateXCArchive ''
         mkdir -p $out
         mv "${name}.xcarchive" $out
       ''}
@@ -144,7 +144,7 @@ stdenv.mkDerivation ({
     ''}
   '';
 
-  failureHook = stdenv.lib.optionalString release deleteKeychain;
+  failureHook = lib.optionalString release deleteKeychain;
 
   installPhase = "true";
 } // extraArgs)
diff --git a/pkgs/development/mobile/xcodeenv/default.nix b/pkgs/development/mobile/xcodeenv/default.nix
index 47686e6d69e..90642ca7d9a 100644
--- a/pkgs/development/mobile/xcodeenv/default.nix
+++ b/pkgs/development/mobile/xcodeenv/default.nix
@@ -1,4 +1,4 @@
-{stdenv}:
+{ stdenv, lib }:
 
 rec {
   composeXcodeWrapper = import ./compose-xcodewrapper.nix {
@@ -6,10 +6,10 @@ rec {
   };
 
   buildApp = import ./build-app.nix {
-    inherit stdenv composeXcodeWrapper;
+    inherit stdenv lib composeXcodeWrapper;
   };
 
   simulateApp = import ./simulate-app.nix {
-    inherit stdenv composeXcodeWrapper;
+    inherit stdenv lib composeXcodeWrapper;
   };
 }
diff --git a/pkgs/development/mobile/xcodeenv/simulate-app.nix b/pkgs/development/mobile/xcodeenv/simulate-app.nix
index 1a55f8366a3..ea0502eb981 100644
--- a/pkgs/development/mobile/xcodeenv/simulate-app.nix
+++ b/pkgs/development/mobile/xcodeenv/simulate-app.nix
@@ -1,4 +1,4 @@
-{stdenv, composeXcodeWrapper}:
+{stdenv, lib, composeXcodeWrapper}:
 {name, app ? null, bundleId ? null, ...}@args:
 
 assert app != null -> bundleId != null;
@@ -9,7 +9,7 @@ let
   xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
 in
 stdenv.mkDerivation {
-  name = stdenv.lib.replaceChars [" "] [""] name;
+  name = lib.replaceChars [" "] [""] name;
   buildCommand = ''
     mkdir -p $out/bin
     cat > $out/bin/run-test-simulator << "EOF"
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
     # Open the simulator instance
     open -a "$(readlink "${xcodewrapper}/bin/Simulator")" --args -CurrentDeviceUDID $udid
 
-    ${stdenv.lib.optionalString (app != null) ''
+    ${lib.optionalString (app != null) ''
       # Copy the app and restore the write permissions
       appTmpDir=$(mktemp -d -t appTmpDir)
       cp -r "$(echo ${app}/*.app)" "$appTmpDir"
diff --git a/pkgs/development/tools/misc/sccache/default.nix b/pkgs/development/tools/misc/sccache/default.nix
index 9c4fa708910..c68a1c1547c 100644
--- a/pkgs/development/tools/misc/sccache/default.nix
+++ b/pkgs/development/tools/misc/sccache/default.nix
@@ -1,4 +1,14 @@
-{ stdenv, fetchFromGitHub, cargo, rustc, rustPlatform, pkg-config, glib, openssl, darwin }:
+{ stdenv
+, lib
+, fetchFromGitHub
+, cargo
+, rustc
+, rustPlatform
+, pkg-config
+, glib
+, openssl
+, darwin
+}:
 
 rustPlatform.buildRustPackage rec {
   version = "0.2.14";
@@ -18,12 +28,12 @@ rustPlatform.buildRustPackage rec {
   ];
   buildInputs = [
     openssl
-  ] ++ stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
+  ] ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
   # Tests fail because of client server setup which is not possible inside the pure environment,
   # see https://github.com/mozilla/sccache/issues/460
   checkPhase = null;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Ccache with Cloud Storage";
     homepage = "https://github.com/mozilla/sccache";
     maintainers = with maintainers; [ doronbehar ];
diff --git a/pkgs/os-specific/linux/s6-linux-init/default.nix b/pkgs/os-specific/linux/s6-linux-init/default.nix
new file mode 100644
index 00000000000..2fb6c9441ed
--- /dev/null
+++ b/pkgs/os-specific/linux/s6-linux-init/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, skawarePackages }:
+
+with skawarePackages;
+
+buildPackage {
+  pname = "s6-linux-init";
+  version = "1.0.6.0";
+  sha256 = "0kzif3dqhm7h4h7c6npzdbcy7w756222g8ysw116fgb8j385dr6w";
+
+  description = "A set of minimalistic tools used to create a s6-based init system, including a /sbin/init binary, on a Linux kernel";
+  platforms = lib.platforms.linux;
+
+  outputs = [ "bin" "dev" "doc" "out" ];
+
+  configureFlags = [
+    "--bindir=\${bin}/bin"
+    "--includedir=\${dev}/include"
+    "--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
+    "--with-include=${skalibs.dev}/include"
+    "--with-include=${execline.dev}/include"
+    "--with-include=${s6.dev}/include"
+    "--with-lib=${skalibs.lib}/lib"
+    "--with-lib=${s6.out}/lib"
+    "--with-lib=${execline.lib}/lib"
+    "--with-dynlib=${skalibs.lib}/lib"
+    "--with-dynlib=${execline.lib}/lib"
+    "--with-dynlib=${s6.out}/lib"
+  ];
+
+  postInstall = ''
+    # remove all s6 executables from build directory
+    rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable)
+    rm libs6_linux_init.* libhpr.*
+    rm -rf skel
+
+    mv doc $doc/share/doc/s6-linux-init/html
+  '';
+
+}
diff --git a/pkgs/os-specific/linux/s6-linux-utils/default.nix b/pkgs/os-specific/linux/s6-linux-utils/default.nix
index 42ffea0029a..209f596d273 100644
--- a/pkgs/os-specific/linux/s6-linux-utils/default.nix
+++ b/pkgs/os-specific/linux/s6-linux-utils/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "s6-linux-utils";
-  version = "2.5.1.3";
-  sha256 = "0wbv02zxaami88xbj2zg63kspz05bbplswg0c6ncb5g9khf52wa4";
+  version = "2.5.1.4";
+  sha256 = "02gxzc9igid2kf2rvm3v6kc9806mpjmdq7cpanv4cml0ip68vbfq";
 
   description = "A set of minimalistic Linux-specific system utilities";
   platforms = lib.platforms.linux;
diff --git a/pkgs/os-specific/linux/sdnotify-wrapper/sdnotify-wrapper.c b/pkgs/os-specific/linux/sdnotify-wrapper/sdnotify-wrapper.c
index 0d1ae96068a..bb71a732bf9 100644
--- a/pkgs/os-specific/linux/sdnotify-wrapper/sdnotify-wrapper.c
+++ b/pkgs/os-specific/linux/sdnotify-wrapper/sdnotify-wrapper.c
@@ -1,5 +1,5 @@
 /*
-   Copyright: (C)2015-2017 Laurent Bercot.  http://skarnet.org/
+   Copyright: (C)2015-2020 Laurent Bercot.  http://skarnet.org/
    ISC license. See http://opensource.org/licenses/ISC
 
    Build-time requirements: skalibs.  http://skarnet.org/software/skalibs/
@@ -53,20 +53,24 @@
 #include <sys/types.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+
 #include <skalibs/uint64.h>
 #include <skalibs/types.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/strerr2.h>
-#include <skalibs/env.h>
 #include <skalibs/allreadwrite.h>
 #include <skalibs/tai.h>
 #include <skalibs/iopause.h>
 #include <skalibs/djbunix.h>
-#include <skalibs/webipc.h>
+//#include <skalibs/webipc.h>
+// svanderburg: This header no longer exists, but socket.h provides the functions this module needs
+#include <skalibs/socket.h>
+#include <skalibs/exec.h>
 
 #define USAGE "sdnotify-wrapper [ -d fd ] [ -f ] [ -t timeout ] [ -k ] prog..."
 #define dieusage() strerr_dieusage(100, USAGE)
@@ -123,9 +127,9 @@ static inline int run_child (int fd, unsigned int timeout, pid_t pid, char const
   return 0 ;
 }
 
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
 {
-  char const *s = env_get2(envp, VAR) ;
+  char const *s = getenv(VAR) ;
   unsigned int fd = 1 ;
   unsigned int timeout = 0 ;
   int df = 1, keep = 0 ;
@@ -134,7 +138,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
     subgetopt_t l = SUBGETOPT_ZERO ;
     for (;;)
     {
-      register int opt = subgetopt_r(argc, argv, "d:ft:k", &l) ;
+      int opt = subgetopt_r(argc, argv, "d:ft:k", &l) ;
       if (opt == -1) break ;
       switch (opt)
       {
@@ -149,7 +153,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
   }
   if (!argc) dieusage() ;
 
-  if (!s) xpathexec_run(argv[0], argv, envp) ;
+  if (!s) xexec(argv) ;
   else
   {
     pid_t parent = getpid() ;
@@ -166,7 +170,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
     }
     close(p[0]) ;
     if (fd_move((int)fd, p[1]) < 0) strerr_diefu1sys(111, "move descriptor") ;
-    if (keep) xpathexec_run(argv[0], argv, envp) ;
-    else xpathexec_r(argv, envp, env_len(envp), VAR, sizeof(VAR)) ;
+    if (keep) xexec(argv) ;
+    else xmexec_m(argv, VAR, sizeof(VAR)) ;
   }
 }
diff --git a/pkgs/servers/gotify/default.nix b/pkgs/servers/gotify/default.nix
index 7b9b8124366..d0a3d9c10a2 100644
--- a/pkgs/servers/gotify/default.nix
+++ b/pkgs/servers/gotify/default.nix
@@ -1,6 +1,5 @@
-{ stdenv
+{ lib
 , buildGoPackage
-, lib
 , fetchFromGitHub
 , buildGoModule
 , sqlite
diff --git a/pkgs/tools/audio/bpm-tools/default.nix b/pkgs/tools/audio/bpm-tools/default.nix
index 7967577dda5..6e7236b1008 100644
--- a/pkgs/tools/audio/bpm-tools/default.nix
+++ b/pkgs/tools/audio/bpm-tools/default.nix
@@ -1,12 +1,12 @@
-{
-  lib, stdenv,
-  fetchurl,
-  gnuplot,
-  sox,
-  flac,
-  id3v2,
-  vorbis-tools,
-  makeWrapper
+{ stdenv
+, lib
+, fetchurl
+, gnuplot
+, sox
+, flac
+, id3v2
+, vorbis-tools
+, makeWrapper
 }:
 
 let
diff --git a/pkgs/tools/misc/execline/default.nix b/pkgs/tools/misc/execline/default.nix
index bf7853c1173..887671b4899 100644
--- a/pkgs/tools/misc/execline/default.nix
+++ b/pkgs/tools/misc/execline/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "execline";
-  version = "2.6.1.1";
-  sha256 = "0mmsnai3bkyhng0cxdz6bf7d6b7kbsxs4p39m63215lz6kq0hhrr";
+  version = "2.7.0.0";
+  sha256 = "0kl74yix60msgw8k3shhp9ymm80n91yxxqckixj5qbbhmylpnpqd";
 
   description = "A small scripting language, to be used in place of a shell in non-interactive scripts";
 
diff --git a/pkgs/tools/misc/execline/execlineb-wrapper.c b/pkgs/tools/misc/execline/execlineb-wrapper.c
index d31a76ca26e..c8e91813b77 100644
--- a/pkgs/tools/misc/execline/execlineb-wrapper.c
+++ b/pkgs/tools/misc/execline/execlineb-wrapper.c
@@ -12,6 +12,7 @@
 #include <skalibs/djbunix.h>
 #include <skalibs/strerr2.h>
 #include <skalibs/env.h>
+#include <skalibs/exec.h>
 
 #define dienomem() strerr_diefu1sys(111, "stralloc_catb")
 
@@ -41,10 +42,10 @@ int main(int argc, char const* argv[], char const *const *envp)
   }
 
   // exec into execlineb and append path_modif to the environment
-  xpathexec_r_name(
+  xmexec_aem(
     EXECLINEB_PATH(),
     argv,
-    envp, env_len(envp),
+    envp,
     path_modif.s, path_modif.len
   );
 }
diff --git a/pkgs/tools/misc/fdtools/default.nix b/pkgs/tools/misc/fdtools/default.nix
index 6e0cb66749f..d096f903bd1 100644
--- a/pkgs/tools/misc/fdtools/default.nix
+++ b/pkgs/tools/misc/fdtools/default.nix
@@ -13,6 +13,7 @@ in stdenv.mkDerivation {
     inherit sha256;
   };
 
+  patches = [ ./new-skalibs.patch ];
   outputs = [ "bin" "lib" "dev" "doc" "out" ];
 
   buildInputs = [ skawarePackages.skalibs ];
diff --git a/pkgs/tools/misc/fdtools/new-skalibs.patch b/pkgs/tools/misc/fdtools/new-skalibs.patch
new file mode 100644
index 00000000000..76c5396f8a8
--- /dev/null
+++ b/pkgs/tools/misc/fdtools/new-skalibs.patch
@@ -0,0 +1,223 @@
+diff -Naur misc/fdtools-2020.05.04/src/check_exit_exec.c misc-new/fdtools-2020.05.04/src/check_exit_exec.c
+--- misc/fdtools-2020.05.04/src/check_exit_exec.c	2015-03-16 04:55:56.000000000 +0100
++++ misc-new/fdtools-2020.05.04/src/check_exit_exec.c	2021-01-22 10:50:25.529955213 +0100
+@@ -2,6 +2,7 @@
+ #include <unistd.h>
+ #include <errno.h>
+ 
++#include <skalibs/exec.h>
+ #include <skalibs/stddjb.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+@@ -14,7 +15,7 @@
+ 
+   if (str_equal(arg, ":")) {
+     ++argv;
+-    pathexec0((char const**)argv);
++    mexec0((char const**)argv);
+     DIE1(exec, argv[0]);
+   }
+ }
+diff -Naur misc/fdtools-2020.05.04/src/grabconsole.c misc-new/fdtools-2020.05.04/src/grabconsole.c
+--- misc/fdtools-2020.05.04/src/grabconsole.c	2020-04-24 06:01:22.000000000 +0200
++++ misc-new/fdtools-2020.05.04/src/grabconsole.c	2021-01-22 10:43:27.887754936 +0100
+@@ -4,6 +4,7 @@
+ #include <errno.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+@@ -26,6 +27,6 @@
+   if (fd_grabconsole(fd)!=0) DIE0(tioccons);
+ 
+   argv+=2;
+-  pathexec0((char const**)argv);
++  mexec0((char const**)argv);
+   DIE1(exec, argv[0]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/pipecycle.c misc-new/fdtools-2020.05.04/src/pipecycle.c
+--- misc/fdtools-2020.05.04/src/pipecycle.c	2015-03-16 04:55:56.000000000 +0100
++++ misc-new/fdtools-2020.05.04/src/pipecycle.c	2021-01-22 10:47:58.033220790 +0100
+@@ -4,6 +4,7 @@
+ #include <unistd.h>
+ #include <signal.h>
+ 
++#include <skalibs/exec.h>
+ #include <skalibs/stddjb.h>
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+@@ -56,7 +57,7 @@
+       if (fd_shuffle(2, current, wanted)!=0) DIE0(dup);
+     }
+     read(start[0], &j, 1);
+-    pathexec(args);
++    mexec(args);
+     DIE1(exec, args[0]);
+   }
+ 
+diff -Naur misc/fdtools-2020.05.04/src/recvfd.c misc-new/fdtools-2020.05.04/src/recvfd.c
+--- misc/fdtools-2020.05.04/src/recvfd.c	2020-04-28 09:35:05.000000000 +0200
++++ misc-new/fdtools-2020.05.04/src/recvfd.c	2021-01-22 10:47:14.180994779 +0100
+@@ -7,6 +7,7 @@
+ #include <limits.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+ #include "fdtools.h"
+@@ -69,9 +70,9 @@
+       named_fd=duped;
+     }
+     buf[int_fmt(buf, named_fd)]='\0';
+-    if (pathexec_env(argv[i]+1, buf)==0) DIE0(alloc);
++    if (env_mexec(argv[i]+1, buf)==0) DIE0(alloc);
+   }
+   argv+=nfds+1;
+-  pathexec0((char const**)argv);
++  mexec0((char const**)argv);
+   DIE1(exec, argv[0]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/sendfd.c misc-new/fdtools-2020.05.04/src/sendfd.c
+--- misc/fdtools-2020.05.04/src/sendfd.c	2015-03-16 06:48:39.000000000 +0100
++++ misc-new/fdtools-2020.05.04/src/sendfd.c	2021-01-22 10:43:07.207634214 +0100
+@@ -7,6 +7,7 @@
+ #include <limits.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+ #include "fdtools.h"
+@@ -40,6 +41,6 @@
+   argv+=nfds;
+   if (*argv==NULL) _exit(0);
+   ++argv;
+-  pathexec0((char const**)argv);
++  mexec0((char const**)argv);
+   DIE1(exec, argv[0]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/setstate.c misc-new/fdtools-2020.05.04/src/setstate.c
+--- misc/fdtools-2020.05.04/src/setstate.c	2020-05-04 10:04:21.000000000 +0200
++++ misc-new/fdtools-2020.05.04/src/setstate.c	2021-01-22 10:45:05.084304318 +0100
+@@ -8,6 +8,7 @@
+ #include <errno.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/intattr.h"
+ #include "prjlibs-c/diewarn.h"
+@@ -167,6 +168,6 @@
+   }
+ 
+   argv+=2;
+-  pathexec_run(argv[0], (char const**)argv, (char const**)environ);
++  mexec_ae(argv[0], (char const**)argv, (char const**)environ);
+   DIE1(exec, argv[0]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/statfile.c misc-new/fdtools-2020.05.04/src/statfile.c
+--- misc/fdtools-2020.05.04/src/statfile.c	2015-03-22 00:33:44.000000000 +0100
++++ misc-new/fdtools-2020.05.04/src/statfile.c	2021-01-22 10:48:23.673351183 +0100
+@@ -6,6 +6,7 @@
+ #include <errno.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/warn.h"
+@@ -15,7 +16,7 @@
+ char const* PROG="statfile";
+ 
+ static void set(char const* const var, char const* const val) {
+-  if (pathexec_env(var, val)==0) DIE0(alloc);
++  if (env_mexec(var, val)==0) DIE0(alloc);
+ }
+ 
+ static void set64n(char const* const var, time_t t, unsigned int nsec) {
+@@ -178,6 +179,6 @@
+   }
+ 
+   argv+=3;
+-  pathexec((char const**)argv);
++  mexec((char const**)argv);
+   DIE1(exec, argv[0]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/vc-get-linux.c misc-new/fdtools-2020.05.04/src/vc-get-linux.c
+--- misc/fdtools-2020.05.04/src/vc-get-linux.c	2020-04-28 07:04:49.000000000 +0200
++++ misc-new/fdtools-2020.05.04/src/vc-get-linux.c	2021-01-22 10:47:34.649100757 +0100
+@@ -10,6 +10,7 @@
+ #include <sys/sysmacros.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+@@ -38,7 +39,7 @@
+       errno=0;
+       if (ioctl(fd, VT_OPENQRY, &vtnum)<0 || vtnum==-1) DIE0(vt_qry);
+       bufnum[ulong_fmt(bufnum, vtnum)]='\0';
+-      if (pathexec_env("TTY", buf)==0) DIE0(alloc);
++      if (env_mexec("TTY", buf)==0) DIE0(alloc);
+     }
+     fd_close(fd);
+ 
+@@ -50,12 +51,12 @@
+       if (fstat(fd, &statbuf)!=0) DIE1(stat, buf);
+       buf[ulong_fmt(buf, minor(statbuf.st_rdev))]='\0';
+     }
+-    if (pathexec_env("VCNUM", buf)==0) DIE0(alloc);
++    if (env_mexec("VCNUM", buf)==0) DIE0(alloc);
+ 
+     buf[ulong_fmt(buf, fd)]='\0';
+-    if (pathexec_env("VCFD", buf)==0) DIE0(alloc);
++    if (env_mexec("VCFD", buf)==0) DIE0(alloc);
+   }
+ 
+-  pathexec((char const**)argv+2);
++  mexec((char const**)argv+2);
+   DIE1(exec, argv[2]);
+ }
+diff -Naur misc/fdtools-2020.05.04/src/vc-lock-linux.c misc-new/fdtools-2020.05.04/src/vc-lock-linux.c
+--- misc/fdtools-2020.05.04/src/vc-lock-linux.c	2015-03-20 05:59:42.000000000 +0100
++++ misc-new/fdtools-2020.05.04/src/vc-lock-linux.c	2021-01-22 10:48:36.857417751 +0100
+@@ -8,6 +8,7 @@
+ #include <sys/ioctl.h>
+ #include <sys/vt.h>
+ 
++#include <skalibs/exec.h>
+ #include <skalibs/stddjb.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+@@ -79,7 +80,7 @@
+       WARN0(fork);
+     } else if (pid==0) {
+       sigprocmask(SIG_SETMASK, &old_set, NULLP);
+-      pathexec((char const**)argv);
++      mexec((char const**)argv);
+       DIE1(exec, *argv);
+     } else {
+       int status;
+diff -Naur misc/fdtools-2020.05.04/src/vc-switch-linux.c misc-new/fdtools-2020.05.04/src/vc-switch-linux.c
+--- misc/fdtools-2020.05.04/src/vc-switch-linux.c	2020-04-28 07:14:04.000000000 +0200
++++ misc-new/fdtools-2020.05.04/src/vc-switch-linux.c	2021-01-22 10:42:41.259480648 +0100
+@@ -10,6 +10,7 @@
+ #include <sys/sysmacros.h>
+ 
+ #include <skalibs/stddjb.h>
++#include <skalibs/exec.h>
+ #include "prjlibs-c/constants.h"
+ #include "prjlibs-c/diewarn.h"
+ #include "prjlibs-c/types.h"
+@@ -36,6 +37,6 @@
+   if (ioctl(fd, VT_ACTIVATE, ttyno)<0) DIE0(vt_act);
+   if (!scan) fd_close(fd);
+ 
+-  pathexec0((char const**)argv+3);
++  mexec0((char const**)argv+3);
+   DIE1(exec, argv[3]);
+ }
diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix
index a94275d7e35..bc933312afc 100644
--- a/pkgs/tools/misc/grub/2.0x.nix
+++ b/pkgs/tools/misc/grub/2.0x.nix
@@ -3,7 +3,7 @@
 , fuse # only needed for grub-mount
 , zfs ? null
 , efiSupport ? false
-, zfsSupport ? true
+, zfsSupport ? false
 , xenSupport ? false
 }:
 
diff --git a/pkgs/tools/misc/s6-portable-utils/default.nix b/pkgs/tools/misc/s6-portable-utils/default.nix
index fee6ae14bbd..731f6c48785 100644
--- a/pkgs/tools/misc/s6-portable-utils/default.nix
+++ b/pkgs/tools/misc/s6-portable-utils/default.nix
@@ -7,8 +7,8 @@ let
 
 in buildPackage {
   pname = pname;
-  version = "2.2.3.0";
-  sha256 = "063zwifigg2b3wsixdcz4h9yvr6fkqssvx0iyfsprjfmm1yapfi9";
+  version = "2.2.3.1";
+  sha256 = "1ks1ch5v3p2z8y8wp5fmzzgjrqn2l5sj1sgfp8vv6wy8psd8mrj3";
 
   description = "A set of tiny general Unix utilities optimized for simplicity and small size";
 
diff --git a/pkgs/tools/networking/s6-dns/default.nix b/pkgs/tools/networking/s6-dns/default.nix
index 739fdc2e2fc..5036b1a87ea 100644
--- a/pkgs/tools/networking/s6-dns/default.nix
+++ b/pkgs/tools/networking/s6-dns/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "s6-dns";
-  version = "2.3.2.0";
-  sha256 = "09hyb1xv9glqq0yy7wy8hiwvlr78kwv552pags8ancgamag15di7";
+  version = "2.3.5.0";
+  sha256 = "0h5p5dbkkdadahrp4pqhc3x9ds758i6djy49k5zrn7mm5k4722wz";
 
   description = "A suite of DNS client programs and libraries for Unix systems";
 
diff --git a/pkgs/tools/networking/s6-networking/default.nix b/pkgs/tools/networking/s6-networking/default.nix
index f8c479d5ce2..3f10b850ca7 100644
--- a/pkgs/tools/networking/s6-networking/default.nix
+++ b/pkgs/tools/networking/s6-networking/default.nix
@@ -20,8 +20,8 @@ assert sslSupportEnabled -> sslLibs ? ${sslSupport};
 
 buildPackage {
   pname = "s6-networking";
-  version = "2.3.1.2";
-  sha256 = "1029bgwfmv903y5ji93j75m7p2jgchdxya1khxzb42q2z7yxnlyr";
+  version = "2.4.0.0";
+  sha256 = "1yqykwfl5jnkxgr6skfj5kzd896pknij0hi5m7lj0r18jpfs5zgq";
 
   description = "A suite of small networking utilities for Unix systems";
 
@@ -59,7 +59,7 @@ buildPackage {
     # remove all s6 executables from build directory
     rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable)
     rm minidentd
-    rm libs6net.* libstls.*
+    rm libs6net.* libstls.* libs6tls.*
 
     mv doc $doc/share/doc/s6-networking/html
   '';
diff --git a/pkgs/tools/system/s6-rc/default.nix b/pkgs/tools/system/s6-rc/default.nix
index 8b17ea583f2..30467926f5d 100644
--- a/pkgs/tools/system/s6-rc/default.nix
+++ b/pkgs/tools/system/s6-rc/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "s6-rc";
-  version = "0.5.2.0";
-  sha256 = "1qpygkajalaziszhwfv5rr6hc27q05z8dayyv7im06z6vndimchs";
+  version = "0.5.2.1";
+  sha256 = "02pszbi440wagx2qp8aqj9mv5wm2qisw9lkq7mbnbnxxw9azlhi8";
 
   description = "A service manager for s6-based systems";
   platforms = lib.platforms.linux;
diff --git a/pkgs/tools/system/s6/default.nix b/pkgs/tools/system/s6/default.nix
index a0419c2d2ad..75aadbeda8d 100644
--- a/pkgs/tools/system/s6/default.nix
+++ b/pkgs/tools/system/s6/default.nix
@@ -4,8 +4,8 @@ with skawarePackages;
 
 buildPackage {
   pname = "s6";
-  version = "2.9.2.0";
-  sha256 = "1pfxx50shncg2s47ic4kp02jh1cxfjq75j3mnxjagyzzz0mbfg9n";
+  version = "2.10.0.0";
+  sha256 = "0xzqrd0m3wjklmw1w3gjw5dcdxnhgvxv2r5wd6m2ismw2jprr9k0";
 
   description = "skarnet.org's small & secure supervision software suite";
 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index a88cd898637..02ef97ba850 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7543,6 +7543,8 @@ in
 
   s6-dns = skawarePackages.s6-dns;
 
+  s6-linux-init = skawarePackages.s6-linux-init;
+
   s6-linux-utils = skawarePackages.s6-linux-utils;
 
   s6-networking = skawarePackages.s6-networking;
@@ -16464,6 +16466,7 @@ in
 
     s6 = callPackage ../tools/system/s6 { };
     s6-dns = callPackage ../tools/networking/s6-dns { };
+    s6-linux-init = callPackage ../os-specific/linux/s6-linux-init { };
     s6-linux-utils = callPackage ../os-specific/linux/s6-linux-utils { };
     s6-networking = callPackage ../tools/networking/s6-networking { };
     s6-portable-utils = callPackage ../tools/misc/s6-portable-utils { };