summary refs log tree commit diff
path: root/pkgs/applications/science
diff options
context:
space:
mode:
authorBen Siraphob <bensiraphob@gmail.com>2021-01-15 20:21:58 +0700
committerBen Siraphob <bensiraphob@gmail.com>2021-01-16 17:58:11 +0700
commitbadf51221db8fae81bf9948c39eaf8342dfd5597 (patch)
tree34eeb35ca97f0b081da465e9ddd6c120a9d2b7df /pkgs/applications/science
parenta9bb54359eeedf2594fdf191de5b673fd1dd102d (diff)
downloadnixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar.gz
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar.bz2
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar.lz
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar.xz
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.tar.zst
nixpkgs-badf51221db8fae81bf9948c39eaf8342dfd5597.zip
treewide: stdenv.lib -> lib
Diffstat (limited to 'pkgs/applications/science')
-rw-r--r--pkgs/applications/science/astronomy/astrolabe-generator/default.nix4
-rw-r--r--pkgs/applications/science/astronomy/celestia/default.nix8
-rw-r--r--pkgs/applications/science/astronomy/gildas/default.nix14
-rw-r--r--pkgs/applications/science/astronomy/gravit/default.nix8
-rw-r--r--pkgs/applications/science/astronomy/openspace/default.nix6
-rw-r--r--pkgs/applications/science/astronomy/xplanet/default.nix2
-rw-r--r--pkgs/applications/science/biology/ants/default.nix2
-rw-r--r--pkgs/applications/science/biology/bayescan/default.nix4
-rw-r--r--pkgs/applications/science/biology/cmtk/default.nix2
-rw-r--r--pkgs/applications/science/biology/conglomerate/default.nix2
-rw-r--r--pkgs/applications/science/biology/emboss/default.nix4
-rw-r--r--pkgs/applications/science/biology/iv/default.nix8
-rw-r--r--pkgs/applications/science/biology/messer-slim/default.nix8
-rw-r--r--pkgs/applications/science/biology/minc-widgets/default.nix2
-rw-r--r--pkgs/applications/science/biology/muscle/default.nix2
-rw-r--r--pkgs/applications/science/biology/neuron/default.nix10
-rw-r--r--pkgs/applications/science/biology/obitools/obitools3.nix4
-rw-r--r--pkgs/applications/science/biology/plink-ng/default.nix6
-rwxr-xr-xpkgs/applications/science/biology/poretools/default.nix6
-rw-r--r--pkgs/applications/science/biology/quast/default.nix4
-rw-r--r--pkgs/applications/science/biology/raxml/default.nix2
-rw-r--r--pkgs/applications/science/biology/samtools/default.nix2
-rw-r--r--pkgs/applications/science/biology/stacks/default.nix8
-rw-r--r--pkgs/applications/science/chemistry/avogadro/default.nix4
-rw-r--r--pkgs/applications/science/chemistry/gwyddion/default.nix16
-rw-r--r--pkgs/applications/science/chemistry/marvin/default.nix4
-rw-r--r--pkgs/applications/science/chemistry/quantum-espresso/default.nix2
-rw-r--r--pkgs/applications/science/chemistry/siesta/default.nix2
-rw-r--r--pkgs/applications/science/electronics/adms/default.nix8
-rw-r--r--pkgs/applications/science/electronics/archimedes/default.nix6
-rw-r--r--pkgs/applications/science/electronics/bitscope/common.nix2
-rw-r--r--pkgs/applications/science/electronics/caneda/default.nix8
-rw-r--r--pkgs/applications/science/electronics/eagle/eagle.nix2
-rw-r--r--pkgs/applications/science/electronics/eagle/eagle7.nix2
-rw-r--r--pkgs/applications/science/electronics/fritzing/default.nix8
-rw-r--r--pkgs/applications/science/electronics/gtkwave/default.nix8
-rw-r--r--pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix4
-rw-r--r--pkgs/applications/science/electronics/kicad/base.nix12
-rw-r--r--pkgs/applications/science/electronics/kicad/default.nix18
-rw-r--r--pkgs/applications/science/electronics/kicad/libraries.nix6
-rw-r--r--pkgs/applications/science/electronics/qfsm/default.nix6
-rw-r--r--pkgs/applications/science/electronics/qucs/default.nix8
-rw-r--r--pkgs/applications/science/electronics/tkgate/1.x.nix12
-rw-r--r--pkgs/applications/science/electronics/verilog/default.nix2
-rw-r--r--pkgs/applications/science/electronics/vhd2vl/default.nix2
-rw-r--r--pkgs/applications/science/electronics/xcircuit/default.nix2
-rw-r--r--pkgs/applications/science/electronics/xoscope/default.nix8
-rw-r--r--pkgs/applications/science/geometry/tetgen/1.4.nix6
-rw-r--r--pkgs/applications/science/geometry/tetgen/default.nix6
-rw-r--r--pkgs/applications/science/logic/abella/default.nix8
-rw-r--r--pkgs/applications/science/logic/aiger/default.nix8
-rw-r--r--pkgs/applications/science/logic/avy/default.nix10
-rw-r--r--pkgs/applications/science/logic/boolector/default.nix4
-rw-r--r--pkgs/applications/science/logic/btor2tools/default.nix2
-rw-r--r--pkgs/applications/science/logic/coq/default.nix2
-rw-r--r--pkgs/applications/science/logic/cryptoverif/default.nix8
-rw-r--r--pkgs/applications/science/logic/ekrhyper/default.nix8
-rw-r--r--pkgs/applications/science/logic/gappa/default.nix8
-rw-r--r--pkgs/applications/science/logic/isabelle/default.nix2
-rw-r--r--pkgs/applications/science/logic/jonprl/default.nix8
-rw-r--r--pkgs/applications/science/logic/lci/default.nix8
-rw-r--r--pkgs/applications/science/logic/lean/default.nix2
-rw-r--r--pkgs/applications/science/logic/leo3/binary.nix8
-rw-r--r--pkgs/applications/science/logic/logisim/default.nix12
-rw-r--r--pkgs/applications/science/logic/ltl2ba/default.nix8
-rw-r--r--pkgs/applications/science/logic/mcy/default.nix8
-rw-r--r--pkgs/applications/science/logic/monosat/default.nix4
-rw-r--r--pkgs/applications/science/logic/ott/default.nix8
-rw-r--r--pkgs/applications/science/logic/otter/default.nix10
-rw-r--r--pkgs/applications/science/logic/petrinizer/default.nix6
-rw-r--r--pkgs/applications/science/logic/petrinizer/sbv-7.13.nix4
-rw-r--r--pkgs/applications/science/logic/petrinizer/z3.nix4
-rw-r--r--pkgs/applications/science/logic/picosat/default.nix10
-rw-r--r--pkgs/applications/science/logic/potassco/clingcon.nix6
-rw-r--r--pkgs/applications/science/logic/potassco/clingo.nix8
-rw-r--r--pkgs/applications/science/logic/prover9/default.nix4
-rw-r--r--pkgs/applications/science/logic/proverif/default.nix8
-rw-r--r--pkgs/applications/science/logic/redprl/default.nix8
-rw-r--r--pkgs/applications/science/logic/sad/default.nix6
-rw-r--r--pkgs/applications/science/logic/satallax/default.nix12
-rw-r--r--pkgs/applications/science/logic/saw-tools/default.nix10
-rw-r--r--pkgs/applications/science/logic/statverif/default.nix8
-rw-r--r--pkgs/applications/science/logic/symbiyosys/default.nix8
-rw-r--r--pkgs/applications/science/logic/tlaplus/default.nix8
-rw-r--r--pkgs/applications/science/logic/tlaplus/tlaps.nix6
-rw-r--r--pkgs/applications/science/logic/tlaplus/toolbox.nix2
-rw-r--r--pkgs/applications/science/logic/twelf/default.nix8
-rw-r--r--pkgs/applications/science/logic/verifast/default.nix8
-rw-r--r--pkgs/applications/science/logic/workcraft/default.nix8
-rw-r--r--pkgs/applications/science/logic/yices/default.nix2
-rw-r--r--pkgs/applications/science/logic/z3/4.4.0.nix8
-rw-r--r--pkgs/applications/science/logic/z3/default.nix10
-rw-r--r--pkgs/applications/science/logic/z3/tptp.nix4
-rw-r--r--pkgs/applications/science/machine-learning/sc2-headless/default.nix2
-rw-r--r--pkgs/applications/science/math/LiE/default.nix6
-rw-r--r--pkgs/applications/science/math/R/default.nix10
-rw-r--r--pkgs/applications/science/math/bcal/default.nix4
-rw-r--r--pkgs/applications/science/math/cplex/default.nix18
-rw-r--r--pkgs/applications/science/math/csdp/default.nix2
-rw-r--r--pkgs/applications/science/math/ecm/default.nix10
-rw-r--r--pkgs/applications/science/math/eukleides/default.nix8
-rw-r--r--pkgs/applications/science/math/fricas/default.nix8
-rw-r--r--pkgs/applications/science/math/geogebra/geogebra6.nix6
-rw-r--r--pkgs/applications/science/math/gfan/default.nix10
-rw-r--r--pkgs/applications/science/math/giac/default.nix12
-rw-r--r--pkgs/applications/science/math/ginac/default.nix2
-rw-r--r--pkgs/applications/science/math/glsurf/default.nix4
-rw-r--r--pkgs/applications/science/math/gmsh/default.nix4
-rw-r--r--pkgs/applications/science/math/gurobi/default.nix2
-rw-r--r--pkgs/applications/science/math/mathematica/10.nix14
-rw-r--r--pkgs/applications/science/math/mathematica/11.nix14
-rw-r--r--pkgs/applications/science/math/mathematica/9.nix12
-rw-r--r--pkgs/applications/science/math/mathematica/default.nix12
-rw-r--r--pkgs/applications/science/math/maxima/default.nix18
-rw-r--r--pkgs/applications/science/math/msieve/default.nix8
-rw-r--r--pkgs/applications/science/math/palp/default.nix4
-rw-r--r--pkgs/applications/science/math/pari/default.nix10
-rw-r--r--pkgs/applications/science/math/pcalc/default.nix8
-rw-r--r--pkgs/applications/science/math/perseus/default.nix8
-rw-r--r--pkgs/applications/science/math/polymake/default.nix8
-rw-r--r--pkgs/applications/science/math/pspp/default.nix8
-rw-r--r--pkgs/applications/science/math/ratpoints/default.nix10
-rw-r--r--pkgs/applications/science/math/ripser/default.nix12
-rw-r--r--pkgs/applications/science/math/sage/sage.nix2
-rw-r--r--pkgs/applications/science/math/scilab/default.nix8
-rw-r--r--pkgs/applications/science/math/scotch/default.nix10
-rw-r--r--pkgs/applications/science/math/weka/default.nix10
-rw-r--r--pkgs/applications/science/math/yacas/default.nix12
-rw-r--r--pkgs/applications/science/medicine/aliza/default.nix6
-rw-r--r--pkgs/applications/science/medicine/dcmtk/default.nix4
-rw-r--r--pkgs/applications/science/misc/boinc/default.nix6
-rw-r--r--pkgs/applications/science/misc/cytoscape/default.nix8
-rw-r--r--pkgs/applications/science/misc/fityk/default.nix6
-rw-r--r--pkgs/applications/science/misc/foldingathome/client.nix8
-rw-r--r--pkgs/applications/science/misc/foldingathome/control.nix8
-rw-r--r--pkgs/applications/science/misc/foldingathome/viewer.nix8
-rw-r--r--pkgs/applications/science/misc/golly/beta.nix8
-rw-r--r--pkgs/applications/science/misc/golly/default.nix8
-rw-r--r--pkgs/applications/science/misc/megam/default.nix6
-rw-r--r--pkgs/applications/science/misc/openmodelica/default.nix4
-rw-r--r--pkgs/applications/science/misc/openmodelica/fakegit.nix10
-rw-r--r--pkgs/applications/science/misc/openmvg/default.nix8
-rw-r--r--pkgs/applications/science/misc/root/5.nix10
-rw-r--r--pkgs/applications/science/misc/root/default.nix6
-rw-r--r--pkgs/applications/science/misc/simgrid/default.nix4
-rw-r--r--pkgs/applications/science/misc/tulip/default.nix6
-rw-r--r--pkgs/applications/science/misc/vite/default.nix8
-rw-r--r--pkgs/applications/science/molecular-dynamics/gromacs/default.nix2
-rw-r--r--pkgs/applications/science/molecular-dynamics/lammps/default.nix4
-rw-r--r--pkgs/applications/science/physics/sacrifice/default.nix10
-rw-r--r--pkgs/applications/science/physics/xfitter/default.nix4
-rw-r--r--pkgs/applications/science/programming/fdr/default.nix2
-rw-r--r--pkgs/applications/science/programming/plm/default.nix2
-rw-r--r--pkgs/applications/science/robotics/yarp/default.nix8
154 files changed, 522 insertions, 522 deletions
diff --git a/pkgs/applications/science/astronomy/astrolabe-generator/default.nix b/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
index 4a6bdd9d1e9..3802f2bada8 100644
--- a/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
+++ b/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, jre, makeWrapper, unzip }:
+{ lib, stdenv, fetchurl, jre, makeWrapper, unzip }:
 
 stdenv.mkDerivation rec {
   pname = "astrolabe-generator";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
       --add-flags "-jar $out/share/java/AstrolabeGenerator-${version}.jar"
   '';
 
-  meta = with stdenv.lib;{
+  meta = with lib;{
     homepage = "https://www.astrolabeproject.com";
     description = "A Java-based tool for generating EPS files for constructing astrolabes and related tools";
     license = licenses.gpl3;
diff --git a/pkgs/applications/science/astronomy/celestia/default.nix b/pkgs/applications/science/astronomy/celestia/default.nix
index 340641917e4..cbdd29b418d 100644
--- a/pkgs/applications/science/astronomy/celestia/default.nix
+++ b/pkgs/applications/science/astronomy/celestia/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, freeglut, gtk2, gtkglext, libjpeg_turbo, libtheora, libXmu
+{ lib, stdenv, fetchurl, freeglut, gtk2, gtkglext, libjpeg_turbo, libtheora, libXmu
 , lua, libGLU, libGL, pkgconfig, perl, autoreconfHook
 }:
 
@@ -67,9 +67,9 @@ stdenv.mkDerivation {
   meta = {
     description = "Free space simulation";
     homepage = "https://celestia.space/";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
 
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.peti ];
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/applications/science/astronomy/gildas/default.nix b/pkgs/applications/science/astronomy/gildas/default.nix
index e84a542f1a6..2174d38d8b4 100644
--- a/pkgs/applications/science/astronomy/gildas/default.nix
+++ b/pkgs/applications/science/astronomy/gildas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gtk2-x11 , pkgconfig , python3 , gfortran , lesstif
+{ lib, stdenv, fetchurl, gtk2-x11 , pkgconfig , python3 , gfortran , lesstif
 , cfitsio , getopt , perl , groff , which, darwin, ncurses
 }:
 
@@ -22,13 +22,13 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig groff perl getopt gfortran which ];
 
   buildInputs = [ gtk2-x11 lesstif cfitsio python3Env ncurses ]
-    ++ stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation ]);
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation ]);
 
   patches = [ ./wrapper.patch ./clang.patch ./aarch64.patch ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks");
+  NIX_LDFLAGS = lib.optionalString stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks");
 
   configurePhase=''
     substituteInPlace admin/wrapper.sh --replace '%%OUT%%' $out
@@ -62,9 +62,9 @@ stdenv.mkDerivation rec {
       few parts in C/C++ (mainly keyboard interaction,
       plotting, widgets).'';
     homepage = "http://www.iram.fr/IRAMFR/GILDAS/gildas.html";
-    license = stdenv.lib.licenses.free;
-    maintainers = [ stdenv.lib.maintainers.bzizou stdenv.lib.maintainers.smaret ];
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.free;
+    maintainers = [ lib.maintainers.bzizou lib.maintainers.smaret ];
+    platforms = lib.platforms.all;
   };
 
 }
diff --git a/pkgs/applications/science/astronomy/gravit/default.nix b/pkgs/applications/science/astronomy/gravit/default.nix
index 0a98563ed0e..baf9ed7fc18 100644
--- a/pkgs/applications/science/astronomy/gravit/default.nix
+++ b/pkgs/applications/science/astronomy/gravit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, SDL, SDL_ttf, SDL_image, libSM, libICE, libGLU, libGL, libpng, lua5, autoconf, automake }:
+{ lib, stdenv, fetchurl, SDL, SDL_ttf, SDL_image, libSM, libICE, libGLU, libGL, libpng, lua5, autoconf, automake }:
 
 stdenv.mkDerivation rec {
   name = "gravit-0.5.1";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://gravit.slowchop.com";
     description = "Beautiful OpenGL-based gravity simulator";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
 
     longDescription = ''
       Gravit is a gravity simulator which runs under Linux, Windows and
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
       view in 3D and zoom in and out.
     '';
 
-    platforms = stdenv.lib.platforms.mesaPlatforms;
-    hydraPlatforms = stdenv.lib.platforms.linux; # darwin times out
+    platforms = lib.platforms.mesaPlatforms;
+    hydraPlatforms = lib.platforms.linux; # darwin times out
   };
 }
diff --git a/pkgs/applications/science/astronomy/openspace/default.nix b/pkgs/applications/science/astronomy/openspace/default.nix
index ca8651aa9e6..17c721ac869 100644
--- a/pkgs/applications/science/astronomy/openspace/default.nix
+++ b/pkgs/applications/science/astronomy/openspace/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchurl, makeWrapper, cmake
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, cmake
 , curl, boost, gdal, glew, soil
 , libX11, libXi, libXxf86vm, libXcursor, libXrandr, libXinerama }:
 
@@ -83,8 +83,8 @@ stdenv.mkDerivation rec {
       WARNING: This build is not very usable for now.
     '';
     homepage  = "https://www.openspaceproject.com/";
-    license   = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.linux;
+    license   = lib.licenses.mit;
+    platforms = lib.platforms.linux;
     broken = true; # fails to build
   };
 }
diff --git a/pkgs/applications/science/astronomy/xplanet/default.nix b/pkgs/applications/science/astronomy/xplanet/default.nix
index 63a1feab42f..305eb158d13 100644
--- a/pkgs/applications/science/astronomy/xplanet/default.nix
+++ b/pkgs/applications/science/astronomy/xplanet/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
 
   meta = with lib; {
     description = "Renders an image of the earth or other planets into the X root window";
diff --git a/pkgs/applications/science/biology/ants/default.nix b/pkgs/applications/science/biology/ants/default.nix
index 7aa41bdf6f0..bdcd82ed432 100644
--- a/pkgs/applications/science/biology/ants/default.nix
+++ b/pkgs/applications/science/biology/ants/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   ];
 
   nativeBuildInputs = [ cmake makeWrapper ];
-  buildInputs = [ itk4 vtk_7 ] ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ];
+  buildInputs = [ itk4 vtk_7 ] ++ lib.optional stdenv.isDarwin [ Cocoa ];
 
   cmakeFlags = [ "-DANTS_SUPERBUILD=FALSE" "-DUSE_VTK=TRUE" ];
 
diff --git a/pkgs/applications/science/biology/bayescan/default.nix b/pkgs/applications/science/biology/bayescan/default.nix
index 7c4f198b842..043ee3ca52d 100644
--- a/pkgs/applications/science/biology/bayescan/default.nix
+++ b/pkgs/applications/science/biology/bayescan/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ unzip ];
-  buildInputs = stdenv.lib.optional stdenv.cc.isClang llvmPackages.openmp;
+  buildInputs = lib.optional stdenv.cc.isClang llvmPackages.openmp;
 
   # Disable FORTIFY_SOURCE or the binary fails with "buffer overflow"
   hardeningDisable = [ "fortify" ];
@@ -34,6 +34,6 @@ stdenv.mkDerivation rec {
     homepage = "http://cmpg.unibe.ch/software/BayeScan";
     license = licenses.gpl3;
     maintainers = [ maintainers.bzizou ];
-    platforms = stdenv.lib.platforms.all;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/biology/cmtk/default.nix b/pkgs/applications/science/biology/cmtk/default.nix
index ea4f55ba475..f147c0422e4 100644
--- a/pkgs/applications/science/biology/cmtk/default.nix
+++ b/pkgs/applications/science/biology/cmtk/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   nativeBuildInputs = [ cmake ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
 
   meta = with lib; {
     description     = "Computational Morphometry Toolkit ";
diff --git a/pkgs/applications/science/biology/conglomerate/default.nix b/pkgs/applications/science/biology/conglomerate/default.nix
index 592ab2cd663..fe1c1f5511d 100644
--- a/pkgs/applications/science/biology/conglomerate/default.nix
+++ b/pkgs/applications/science/biology/conglomerate/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   postFixup = ''
     for p in $out/bin/*; do
-      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${stdenv.lib.makeBinPath [ coreutils minc_tools ]}";
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${lib.makeBinPath [ coreutils minc_tools ]}";
     done
   '';
 
diff --git a/pkgs/applications/science/biology/emboss/default.nix b/pkgs/applications/science/biology/emboss/default.nix
index 2eeb17520f2..5cbcd46ee07 100644
--- a/pkgs/applications/science/biology/emboss/default.nix
+++ b/pkgs/applications/science/biology/emboss/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, readline, perl, libharu, libX11, libpng, libXt, zlib}:
+{lib, stdenv, fetchurl, readline, perl, libharu, libX11, libpng, libXt, zlib}:
 
 stdenv.mkDerivation {
   name = "emboss-6.6.0";
@@ -22,7 +22,7 @@ stdenv.mkDerivation {
     user community, including libraries. The software automatically copes with
     data in a variety of formats and even allows transparent retrieval of
     sequence data from the web.'';
-    license     = stdenv.lib.licenses.gpl2;
+    license     = lib.licenses.gpl2;
     homepage    = "http://emboss.sourceforge.net/";
   };
 }
diff --git a/pkgs/applications/science/biology/iv/default.nix b/pkgs/applications/science/biology/iv/default.nix
index 82fe3694008..72cf9c86e65 100644
--- a/pkgs/applications/science/biology/iv/default.nix
+++ b/pkgs/applications/science/biology/iv/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, neuron-version
+{ lib, stdenv, fetchurl, neuron-version
 , libX11, libXext, patchelf
 }:
 
@@ -15,15 +15,15 @@ stdenv.mkDerivation rec
     postInstall = ''
       for dir in $out/*; do # */
         if [ -d $dir/lib ]; then
-	  mv $dir/* $out # */
+    mv $dir/* $out # */
           rmdir $dir
           break
         fi
       done
-    '' + stdenv.lib.optionalString stdenv.isLinux ''
+    '' + lib.optionalString stdenv.isLinux ''
       patchelf --add-needed ${libX11}/lib/libX11.so $out/lib/libIVhines.so
     '';
-    meta = with stdenv.lib;
+    meta = with lib;
       { description = "InterViews graphical library for Neuron";
         license     = licenses.bsd3;
         homepage    = "http://www.neuron.yale.edu/neuron";
diff --git a/pkgs/applications/science/biology/messer-slim/default.nix b/pkgs/applications/science/biology/messer-slim/default.nix
index 876cc8ebaa7..687a2a985f2 100644
--- a/pkgs/applications/science/biology/messer-slim/default.nix
+++ b/pkgs/applications/science/biology/messer-slim/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, gcc, gcc-unwrapped }:
+{ lib, stdenv, fetchurl, cmake, gcc, gcc-unwrapped }:
 
 stdenv.mkDerivation rec {
   version = "3.2.1";
@@ -17,8 +17,8 @@ stdenv.mkDerivation rec {
   meta = {
      description = "An evolutionary simulation framework";
      homepage = "https://messerlab.org/slim/";
-     license = with stdenv.lib.licenses; [ gpl3 ];
-     maintainers = with stdenv.lib.maintainers; [ bzizou ];
-     platforms = stdenv.lib.platforms.all;
+     license = with lib.licenses; [ gpl3 ];
+     maintainers = with lib.maintainers; [ bzizou ];
+     platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/biology/minc-widgets/default.nix b/pkgs/applications/science/biology/minc-widgets/default.nix
index 3af227d70a5..e8aef4138b0 100644
--- a/pkgs/applications/science/biology/minc-widgets/default.nix
+++ b/pkgs/applications/science/biology/minc-widgets/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
 
   postFixup = ''
     for p in $out/bin/*; do
-      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${stdenv.lib.makeBinPath [ coreutils minc_tools ]}";
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${lib.makeBinPath [ coreutils minc_tools ]}";
     done
   '';
 
diff --git a/pkgs/applications/science/biology/muscle/default.nix b/pkgs/applications/science/biology/muscle/default.nix
index e7c1040e593..f4f6d0c46e0 100644
--- a/pkgs/applications/science/biology/muscle/default.nix
+++ b/pkgs/applications/science/biology/muscle/default.nix
@@ -30,6 +30,6 @@ stdenv.mkDerivation rec {
     maintainers = [ maintainers.unode ];
     # NOTE: Supposed to be compatible with darwin/intel & PPC but currently fails.
     # Anyone with access to these platforms is welcome to give it a try
-    platforms   = stdenv.lib.platforms.linux;
+    platforms   = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/biology/neuron/default.nix b/pkgs/applications/science/biology/neuron/default.nix
index 048a9a5644d..3dbc39684c2 100644
--- a/pkgs/applications/science/biology/neuron/default.nix
+++ b/pkgs/applications/science/biology/neuron/default.nix
@@ -24,16 +24,16 @@ stdenv.mkDerivation rec {
     sha256 = "0f26v3qvzblcdjg7isq0m9j2q8q7x3vhmkfllv8lsr3gyj44lljf";
   };
 
-  patches = (stdenv.lib.optional (stdenv.isDarwin) [ ./neuron-carbon-disable.patch ]);
+  patches = (lib.optional (stdenv.isDarwin) [ ./neuron-carbon-disable.patch ]);
 
   # With LLVM 3.8 and above, clang (really libc++) gets upset if you attempt to redefine these...
-  postPatch = stdenv.lib.optionalString stdenv.cc.isClang ''
+  postPatch = lib.optionalString stdenv.cc.isClang ''
     substituteInPlace src/gnu/neuron_gnu_builtin.h \
       --replace 'double abs(double arg);' "" \
       --replace 'float abs(float arg);' "" \
       --replace 'short abs(short arg);' "" \
       --replace 'long abs(long arg);' ""
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     # we are darwin, but we don't have all the quirks the source wants to compensate for
     substituteInPlace src/nrnpython/setup.py.in --replace 'readline="edit"' 'readline="readline"'
     for f in src/nrnpython/*.[ch] ; do
@@ -51,14 +51,14 @@ stdenv.mkDerivation rec {
     export prefix="''${prefix} --exec-prefix=''${out}"
   '';
 
-  configureFlags = with stdenv.lib;
+  configureFlags = with lib;
                     [ "--with-readline=${readline}" "--with-iv=${iv}" ]
                     ++  optionals (python != null)  [ "--with-nrnpython=${python.interpreter}" ]
                     ++ (if mpi != null then ["--with-mpi" "--with-paranrn"]
                         else ["--without-mpi"]);
 
 
-  postInstall = stdenv.lib.optionals (python != null) [ ''
+  postInstall = lib.optionals (python != null) [ ''
     ## standardise python neuron install dir if any
     if [[ -d $out/lib/python ]]; then
         mkdir -p ''${out}/${python.sitePackages}
diff --git a/pkgs/applications/science/biology/obitools/obitools3.nix b/pkgs/applications/science/biology/obitools/obitools3.nix
index 7ecee60c4b1..55a9612c62d 100644
--- a/pkgs/applications/science/biology/obitools/obitools3.nix
+++ b/pkgs/applications/science/biology/obitools/obitools3.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python3Packages, cmake, python3 }:
+{ lib, stdenv, fetchurl, python3Packages, cmake, python3 }:
 
 let
   pythonPackages = python3Packages;
@@ -26,7 +26,7 @@ pythonPackages.buildPythonApplication rec {
 
   doCheck = true;
 
-  meta = with stdenv.lib ; {
+  meta = with lib ; {
     description = "Management of analyses and data in DNA metabarcoding";
     homepage = "https://git.metabarcoding.org/obitools/obitools3";
     license = licenses.cecill20;
diff --git a/pkgs/applications/science/biology/plink-ng/default.nix b/pkgs/applications/science/biology/plink-ng/default.nix
index 0a31ff6ba4f..26c3e7ba66b 100644
--- a/pkgs/applications/science/biology/plink-ng/default.nix
+++ b/pkgs/applications/science/biology/plink-ng/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, zlib, blas, lapack, darwin}:
+{ lib, stdenv, fetchFromGitHub, zlib, blas, lapack, darwin}:
 
 stdenv.mkDerivation rec {
   pname = "plink-ng";
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A comprehensive update to the PLINK association analysis toolset";
     homepage = "https://www.cog-genomics.org/plink2";
-    license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/biology/poretools/default.nix b/pkgs/applications/science/biology/poretools/default.nix
index a9f3fdb2467..454843e2f32 100755
--- a/pkgs/applications/science/biology/poretools/default.nix
+++ b/pkgs/applications/science/biology/poretools/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, pythonPackages, fetchFromGitHub }:
+{ lib, stdenv, pythonPackages, fetchFromGitHub }:
 
 pythonPackages.buildPythonPackage rec {
   pname = "poretools";
@@ -15,8 +15,8 @@ pythonPackages.buildPythonPackage rec {
 
   meta = {
     description = "a toolkit for working with nanopore sequencing data from Oxford Nanopore";
-    license = stdenv.lib.licenses.mit;
+    license = lib.licenses.mit;
     homepage = "https://poretools.readthedocs.io/en/latest/";
-    maintainers = [stdenv.lib.maintainers.rybern];
+    maintainers = [lib.maintainers.rybern];
   };
 }
diff --git a/pkgs/applications/science/biology/quast/default.nix b/pkgs/applications/science/biology/quast/default.nix
index e3c3ea23c2c..553fb1de539 100644
--- a/pkgs/applications/science/biology/quast/default.nix
+++ b/pkgs/applications/science/biology/quast/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python3Packages, zlib, bash, coreutils }:
+{ lib, stdenv, fetchurl, python3Packages, zlib, bash, coreutils }:
 
 let
   pythonPackages = python3Packages;
@@ -48,7 +48,7 @@ pythonPackages.buildPythonApplication rec {
   # Tests need to download data files, so manual run after packaging is needed
   doCheck = false;
 
-  meta = with stdenv.lib ; {
+  meta = with lib ; {
     description = "Evaluates genome assemblies by computing various metrics";
     homepage = "https://github.com/ablab/quast";
     license = licenses.gpl2;
diff --git a/pkgs/applications/science/biology/raxml/default.nix b/pkgs/applications/science/biology/raxml/default.nix
index e4019295ece..4f9b5aca1b2 100644
--- a/pkgs/applications/science/biology/raxml/default.nix
+++ b/pkgs/applications/science/biology/raxml/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
     sha256 = "1jqjzhch0rips0vp04prvb8vmc20c5pdmsqn8knadcf91yy859fh";
   };
 
-  buildInputs = stdenv.lib.optionals mpi [ pkgs.openmpi ];
+  buildInputs = lib.optionals mpi [ pkgs.openmpi ];
 
   # TODO darwin, AVX and AVX2 makefile targets
   buildPhase = if mpi then ''
diff --git a/pkgs/applications/science/biology/samtools/default.nix b/pkgs/applications/science/biology/samtools/default.nix
index 7dd78ee2e63..20d9565bce4 100644
--- a/pkgs/applications/science/biology/samtools/default.nix
+++ b/pkgs/applications/science/biology/samtools/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ zlib ncurses htslib ];
 
   configureFlags = [ "--with-htslib=${htslib}" ]
-    ++ stdenv.lib.optional (ncurses == null) "--without-curses";
+    ++ lib.optional (ncurses == null) "--without-curses";
 
   preCheck = ''
     patchShebangs test/
diff --git a/pkgs/applications/science/biology/stacks/default.nix b/pkgs/applications/science/biology/stacks/default.nix
index 12c86516242..c208d80d576 100644
--- a/pkgs/applications/science/biology/stacks/default.nix
+++ b/pkgs/applications/science/biology/stacks/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, zlib }:
-    
+{ lib, stdenv, fetchurl, zlib }:
+
 stdenv.mkDerivation rec {
   pname = "stacks";
   version = "2.53";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Software pipeline for building loci from short-read sequences";
     homepage = "http://catchenlab.life.illinois.edu/stacks/";
-    maintainers = [ stdenv.lib.maintainers.bzizou ];
-    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.bzizou ];
+    license = lib.licenses.gpl3;
   };
 }
diff --git a/pkgs/applications/science/chemistry/avogadro/default.nix b/pkgs/applications/science/chemistry/avogadro/default.nix
index 96dea10333b..14ceb91b06c 100644
--- a/pkgs/applications/science/chemistry/avogadro/default.nix
+++ b/pkgs/applications/science/chemistry/avogadro/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, qt4, zlib, eigen, openbabel, pkgconfig, libGLU, libGL, libX11, doxygen }:
+{ lib, stdenv, fetchurl, cmake, qt4, zlib, eigen, openbabel, pkgconfig, libGLU, libGL, libX11, doxygen }:
 
 stdenv.mkDerivation rec {
   name = "avogadro-1.1.1";
@@ -24,6 +24,6 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Molecule editor and visualizer";
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.mesaPlatforms;
+    platforms = lib.platforms.mesaPlatforms;
   };
 }
diff --git a/pkgs/applications/science/chemistry/gwyddion/default.nix b/pkgs/applications/science/chemistry/gwyddion/default.nix
index bdebfc72e47..8d9ea7a3917 100644
--- a/pkgs/applications/science/chemistry/gwyddion/default.nix
+++ b/pkgs/applications/science/chemistry/gwyddion/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gtk2, pkg-config, fftw, file,
+{ lib, stdenv, fetchurl, gtk2, pkg-config, fftw, file,
   pythonSupport ? false, pythonPackages ? null,
   gnome2 ? null,
   openexrSupport ? true, openexr ? null,
@@ -40,10 +40,10 @@ stdenv.mkDerivation rec {
     url = "mirror://sourceforge/gwyddion/gwyddion-${version}.tar.xz";
     sha256 = "0z83p3ifdkv5dds8s6fqqbycql1zmgppdc7ygqmm12z5zlrl9p12";
   };
-  
+
   nativeBuildInputs = [ pkg-config file ];
-  
-  buildInputs = with stdenv.lib;
+
+  buildInputs = with lib;
     [ gtk2 fftw ] ++
     optional openglSupport gnome2.gtkglext ++
     optional openexrSupport openexr ++
@@ -57,7 +57,7 @@ stdenv.mkDerivation rec {
     optional libuniqueSupport libunique ++
     optional libzipSupport libzip;
 
-  propagatedBuildInputs = with stdenv.lib;
+  propagatedBuildInputs = with lib;
     optionals pythonSupport [ pygtk pygobject2 python gnome2.gtksourceview ];
 
   # This patch corrects problems with python support, but should apply cleanly
@@ -79,8 +79,8 @@ stdenv.mkDerivation rec {
       analysis of profilometry data or thickness maps from imaging
       spectrophotometry.
     '';
-    license = stdenv.lib.licenses.gpl2;
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
-    maintainers = [ stdenv.lib.maintainers.cge ];
+    license = lib.licenses.gpl2;
+    platforms = with lib.platforms; linux ++ darwin;
+    maintainers = [ lib.maintainers.cge ];
   };
 }
diff --git a/pkgs/applications/science/chemistry/marvin/default.nix b/pkgs/applications/science/chemistry/marvin/default.nix
index ddab526ebe7..666731106ac 100644
--- a/pkgs/applications/science/chemistry/marvin/default.nix
+++ b/pkgs/applications/science/chemistry/marvin/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, dpkg, makeWrapper, coreutils, gawk, gnugrep, gnused, jre }:
+{ lib, stdenv, fetchurl, dpkg, makeWrapper, coreutils, gawk, gnugrep, gnused, jre }:
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   pname = "marvin";
diff --git a/pkgs/applications/science/chemistry/quantum-espresso/default.nix b/pkgs/applications/science/chemistry/quantum-espresso/default.nix
index 717ff1dba82..c7b1f901046 100644
--- a/pkgs/applications/science/chemistry/quantum-espresso/default.nix
+++ b/pkgs/applications/science/chemistry/quantum-espresso/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs = [ fftw blas lapack gfortran ]
-    ++ (stdenv.lib.optionals (mpi != null) [ mpi ]);
+    ++ (lib.optionals (mpi != null) [ mpi ]);
 
 configureFlags = if (mpi != null) then [ "LD=${mpi}/bin/mpif90" ] else [ "LD=${gfortran}/bin/gfortran" ];
 
diff --git a/pkgs/applications/science/chemistry/siesta/default.nix b/pkgs/applications/science/chemistry/siesta/default.nix
index cb4667adcab..0df953f7106 100644
--- a/pkgs/applications/science/chemistry/siesta/default.nix
+++ b/pkgs/applications/science/chemistry/siesta/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
   };
 
   buildInputs = [ blas lapack gfortran ]
-    ++ (stdenv.lib.optionals (mpi != null) [ mpi scalapack ]);
+    ++ (lib.optionals (mpi != null) [ mpi scalapack ]);
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/applications/science/electronics/adms/default.nix b/pkgs/applications/science/electronics/adms/default.nix
index 0fcf4d25e2d..7b7e2a1af63 100644
--- a/pkgs/applications/science/electronics/adms/default.nix
+++ b/pkgs/applications/science/electronics/adms/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, flex, bison, gperf,
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, flex, bison, gperf,
   libxml2, perl, perlPackages, gd }:
 
 stdenv.mkDerivation rec {
@@ -19,8 +19,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "automatic device model synthesizer";
     homepage = "https://github.com/Qucs/adms";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = with stdenv.lib.maintainers; [disassembler];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [disassembler];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/archimedes/default.nix b/pkgs/applications/science/electronics/archimedes/default.nix
index 1377231c152..731f2db56af 100644
--- a/pkgs/applications/science/electronics/archimedes/default.nix
+++ b/pkgs/applications/science/electronics/archimedes/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
   name = "archimedes-2.0.1";
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "GNU package for semiconductor device simulations";
     homepage = "https://www.gnu.org/software/archimedes";
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/bitscope/common.nix b/pkgs/applications/science/electronics/bitscope/common.nix
index 8aade9dd2c8..49415ea0484 100644
--- a/pkgs/applications/science/electronics/bitscope/common.nix
+++ b/pkgs/applications/science/electronics/bitscope/common.nix
@@ -15,7 +15,7 @@
 let
   wrapBinary = libPaths: binaryName: ''
     wrapProgram "$out/bin/${binaryName}" \
-      --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath libPaths}"
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libPaths}"
   '';
   pkg = stdenv.mkDerivation (rec {
     inherit (attrs) version src;
diff --git a/pkgs/applications/science/electronics/caneda/default.nix b/pkgs/applications/science/electronics/caneda/default.nix
index 5cf9ab1ae6f..14c654bd697 100644
--- a/pkgs/applications/science/electronics/caneda/default.nix
+++ b/pkgs/applications/science/electronics/caneda/default.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, stdenv, fetchFromGitHub, cmake, qtbase, qttools, qtsvg, qwt }:
+{ mkDerivation, lib, stdenv, fetchFromGitHub, cmake, qtbase, qttools, qtsvg, qwt }:
 
 mkDerivation rec {
   pname = "caneda";
@@ -17,8 +17,8 @@ mkDerivation rec {
   meta = {
     description = "Open source EDA software focused on easy of use and portability";
     homepage = "http://caneda.org";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/eagle/eagle.nix b/pkgs/applications/science/electronics/eagle/eagle.nix
index 130146e0d9a..58873b8a770 100644
--- a/pkgs/applications/science/electronics/eagle/eagle.nix
+++ b/pkgs/applications/science/electronics/eagle/eagle.nix
@@ -5,7 +5,7 @@
 }:
 
 let
-  libPath = stdenv.lib.makeLibraryPath
+  libPath = lib.makeLibraryPath
     [ libXrender libXrandr libXcursor libX11 libXext libXi libxcb
       libGL glib nss nspr expat alsaLib
       qtbase qtdeclarative qtsvg qtlocation qtwebchannel qtwebengine
diff --git a/pkgs/applications/science/electronics/eagle/eagle7.nix b/pkgs/applications/science/electronics/eagle/eagle7.nix
index d826d2d2c24..2804fc3c8d7 100644
--- a/pkgs/applications/science/electronics/eagle/eagle7.nix
+++ b/pkgs/applications/science/electronics/eagle/eagle7.nix
@@ -5,7 +5,7 @@
 
 let
 
-  libPath = stdenv.lib.makeLibraryPath
+  libPath = lib.makeLibraryPath
     [ zlib freetype fontconfig openssl libXrender libXrandr libXcursor libX11
       libXext libXi libxcb cups
     ];
diff --git a/pkgs/applications/science/electronics/fritzing/default.nix b/pkgs/applications/science/electronics/fritzing/default.nix
index f8a0adea482..91d6f5e77ab 100644
--- a/pkgs/applications/science/electronics/fritzing/default.nix
+++ b/pkgs/applications/science/electronics/fritzing/default.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, stdenv, fetchpatch, fetchFromGitHub, qmake, pkgconfig
+{ mkDerivation, lib, stdenv, fetchpatch, fetchFromGitHub, qmake, pkgconfig
 , qtbase, qtsvg, qttools, qtserialport, boost, libgit2
 }:
 
@@ -79,8 +79,8 @@ mkDerivation rec {
   meta = {
     description = "An open source prototyping tool for Arduino-based projects";
     homepage = "https://fritzing.org/";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.robberer ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.robberer ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/gtkwave/default.nix b/pkgs/applications/science/electronics/gtkwave/default.nix
index ad5e9e55c57..aeca4326756 100644
--- a/pkgs/applications/science/electronics/gtkwave/default.nix
+++ b/pkgs/applications/science/electronics/gtkwave/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, gtk3, gperf, pkgconfig, bzip2, tcl, tk, wrapGAppsHook, judy, xz }:
+{ lib, stdenv, fetchurl, glib, gtk3, gperf, pkgconfig, bzip2, tcl, tk, wrapGAppsHook, judy, xz }:
 
 stdenv.mkDerivation rec {
   pname = "gtkwave";
@@ -22,8 +22,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "VCD/Waveform viewer for Unix and Win32";
     homepage    = "http://gtkwave.sourceforge.net";
-    license     = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms   = stdenv.lib.platforms.linux;
+    license     = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix b/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix
index 47f901c0ba5..c16f6bf122b 100644
--- a/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix
+++ b/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix
@@ -24,9 +24,9 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake ninja pkgconfig ];
   buildInputs = [ qtbase qtsvg boost rapidjson igraph spdlog fmt graphviz wrapQtAppsHook ]
     ++ (with python3Packages; [ python pybind11 ])
-    ++ stdenv.lib.optional stdenv.cc.isClang llvmPackages.openmp;
+    ++ lib.optional stdenv.cc.isClang llvmPackages.openmp;
 
-  cmakeFlags = with stdenv.lib.versions; [
+  cmakeFlags = with lib.versions; [
     "-DHAL_VERSION_RETURN=${version}"
     "-DHAL_VERSION_MAJOR=${major version}"
     "-DHAL_VERSION_MINOR=${minor version}"
diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix
index 7f11f483a9d..c2da57d1833 100644
--- a/pkgs/applications/science/electronics/kicad/base.nix
+++ b/pkgs/applications/science/electronics/kicad/base.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitLab
 , cmake
 , libGLU
@@ -43,11 +43,11 @@
 , gtk3
 }:
 
-assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
-assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE))
+assert lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
+assert lib.asserts.assertMsg (!(withOCC && withOCE))
   "Only one of OCC and OCE may be enabled";
 let
-  inherit (stdenv.lib) optional optionals;
+  inherit (lib) optional optionals;
 in
 stdenv.mkDerivation rec {
   pname = "kicad-base";
@@ -140,7 +140,7 @@ stdenv.mkDerivation rec {
       the libraries are passed via an env var in the wrapper, default.nix
     '';
     homepage = "https://www.kicad-pcb.org/";
-    license = stdenv.lib.licenses.agpl3;
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.agpl3;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix
index 48a5779d207..88bb7978881 100644
--- a/pkgs/applications/science/electronics/kicad/default.nix
+++ b/pkgs/applications/science/electronics/kicad/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitLab
 , gnome3
 , wxGTK30
@@ -70,13 +70,13 @@
 # }
 
 assert withNgspice -> libngspice != null;
-assert stdenv.lib.assertMsg (!ngspiceSupport)
+assert lib.assertMsg (!ngspiceSupport)
   "`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
-assert stdenv.lib.assertMsg (!oceSupport)
+assert lib.assertMsg (!oceSupport)
   "`oceSupport` was renamed to `withOCE` for the sake of consistency with other kicad nix arguments.";
-assert stdenv.lib.assertMsg (!scriptingSupport)
+assert lib.assertMsg (!scriptingSupport)
   "`scriptingSupport` was renamed to `withScripting` for the sake of consistency with other kicad nix arguments.";
-assert stdenv.lib.assertMsg (!withOCCT)
+assert lib.assertMsg (!withOCCT)
   "`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
 let
   baseName = if (stable) then "kicad" else "kicad-unstable";
@@ -151,7 +151,7 @@ let
   python = python3;
   wxPython = python.pkgs.wxPython_4_0;
 
-  inherit (stdenv.lib) concatStringsSep flatten optionalString optionals;
+  inherit (lib) concatStringsSep flatten optionalString optionals;
 in
 stdenv.mkDerivation rec {
 
@@ -251,11 +251,11 @@ stdenv.mkDerivation rec {
       KiCad is an open source software suite for Electronic Design Automation.
       The Programs handle Schematic Capture, and PCB Layout with Gerber output.
     '';
-    license = stdenv.lib.licenses.agpl3;
+    license = lib.licenses.agpl3;
     # berce seems inactive...
-    maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ];
+    maintainers = with lib.maintainers; [ evils kiwi berce ];
     # kicad is cross platform
-    platforms = stdenv.lib.platforms.all;
+    platforms = lib.platforms.all;
     # despite that, nipkgs' wxGTK for darwin is "wxmac"
     # and wxPython_4_0 does not account for this
     # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix
index b045a7d1068..e98f2e49576 100644
--- a/pkgs/applications/science/electronics/kicad/libraries.nix
+++ b/pkgs/applications/science/electronics/kicad/libraries.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , cmake
 , gettext
 , libSrc
@@ -15,8 +15,8 @@ let
       nativeBuildInputs = [ cmake ];
 
       meta = rec {
-        license = stdenv.lib.licenses.cc-by-sa-40;
-        platforms = stdenv.lib.platforms.all;
+        license = lib.licenses.cc-by-sa-40;
+        platforms = lib.platforms.all;
         # the 3d models are a ~1 GiB download and occupy ~5 GiB in store.
         # this would exceed the hydra output limit
         hydraPlatforms = if (name == "packages3d") then [ ] else platforms;
diff --git a/pkgs/applications/science/electronics/qfsm/default.nix b/pkgs/applications/science/electronics/qfsm/default.nix
index a50609e84a8..de79abc3e51 100644
--- a/pkgs/applications/science/electronics/qfsm/default.nix
+++ b/pkgs/applications/science/electronics/qfsm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, qt4, cmake, graphviz, pkg-config }:
+{ lib, stdenv, fetchurl, qt4, cmake, graphviz, pkg-config }:
 
 stdenv.mkDerivation rec {
   name = "qfsm-0.54.0";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Graphical editor for finite state machines";
     homepage = "http://qfsm.sourceforge.net/";
-    license = stdenv.lib.licenses.gpl3Plus;
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl3Plus;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/electronics/qucs/default.nix b/pkgs/applications/science/electronics/qucs/default.nix
index 9b143f1c3f1..a5f2cf394b4 100644
--- a/pkgs/applications/science/electronics/qucs/default.nix
+++ b/pkgs/applications/science/electronics/qucs/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, flex, bison, qt4, libX11, cmake, gperf, adms }:
+{lib, stdenv, fetchFromGitHub, flex, bison, qt4, libX11, cmake, gperf, adms }:
 
 stdenv.mkDerivation rec {
   version = "0.0.19";
@@ -23,8 +23,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Integrated circuit simulator";
     homepage = "http://qucs.sourceforge.net";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/tkgate/1.x.nix b/pkgs/applications/science/electronics/tkgate/1.x.nix
index e6f91261603..9bb04a3189e 100644
--- a/pkgs/applications/science/electronics/tkgate/1.x.nix
+++ b/pkgs/applications/science/electronics/tkgate/1.x.nix
@@ -1,8 +1,8 @@
-{ stdenv, fetchurl, tcl, tk, libX11, glibc, which, yacc, flex, imake, xorgproto, gccmakedep }:
+{ lib, stdenv, fetchurl, tcl, tk, libX11, glibc, which, yacc, flex, imake, xorgproto, gccmakedep }:
 
 let
-  libiconvInc = stdenv.lib.optionalString stdenv.isLinux "${glibc.dev}/include";
-  libiconvLib = stdenv.lib.optionalString stdenv.isLinux "${glibc.out}/lib";
+  libiconvInc = lib.optionalString stdenv.isLinux "${glibc.dev}/include";
+  libiconvLib = lib.optionalString stdenv.isLinux "${glibc.out}/lib";
 in
 stdenv.mkDerivation rec {
   name = "tkgate-1.8.7";
@@ -35,8 +35,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Event driven digital circuit simulator with a TCL/TK-based graphical editor";
     homepage = "http://www.tkgate.org/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.peti ];
-    hydraPlatforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.peti ];
+    hydraPlatforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/electronics/verilog/default.nix b/pkgs/applications/science/electronics/verilog/default.nix
index 081ca65f315..dd76e9364c5 100644
--- a/pkgs/applications/science/electronics/verilog/default.nix
+++ b/pkgs/applications/science/electronics/verilog/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
   src = fetchFromGitHub {
     owner  = "steveicarus";
     repo   = pname;
-    rev    = "v${stdenv.lib.replaceStrings ["."] ["_"] version}";
+    rev    = "v${lib.replaceStrings ["."] ["_"] version}";
     sha256 = "0nzcyi6l2zv9wxzsv9i963p3igyjds0n55x0ph561mc3pfbc7aqp";
   };
 
diff --git a/pkgs/applications/science/electronics/vhd2vl/default.nix b/pkgs/applications/science/electronics/vhd2vl/default.nix
index 4014f53f649..adce3055107 100644
--- a/pkgs/applications/science/electronics/vhd2vl/default.nix
+++ b/pkgs/applications/science/electronics/vhd2vl/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     sha256 = "17va2pil4938j8c93anhy45zzgnvq3k71a7glj02synfrsv6fs8n";
   };
 
-  patches = stdenv.lib.optionals (!stdenv.isAarch64) [
+  patches = lib.optionals (!stdenv.isAarch64) [
     # fix build with verilog 11.0 - https://github.com/ldoolitt/vhd2vl/pull/15
     # for some strange reason, this is not needed for aarch64
     (fetchpatch {
diff --git a/pkgs/applications/science/electronics/xcircuit/default.nix b/pkgs/applications/science/electronics/xcircuit/default.nix
index d7bdf5c67c0..013f5a098bc 100644
--- a/pkgs/applications/science/electronics/xcircuit/default.nix
+++ b/pkgs/applications/science/electronics/xcircuit/default.nix
@@ -4,7 +4,7 @@
 let
   version = "3.10.12";
   name = "xcircuit-${version}";
-  inherit (stdenv.lib) getBin;
+  inherit (lib) getBin;
 
 in stdenv.mkDerivation {
   inherit name version;
diff --git a/pkgs/applications/science/electronics/xoscope/default.nix b/pkgs/applications/science/electronics/xoscope/default.nix
index f8a68f31f46..26fbadc6159 100644
--- a/pkgs/applications/science/electronics/xoscope/default.nix
+++ b/pkgs/applications/science/electronics/xoscope/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gtk2, pkgconfig}:
+{lib, stdenv, fetchurl, gtk2, pkgconfig}:
 
 stdenv.mkDerivation rec {
   name = "xoscope-2.0";
@@ -17,8 +17,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Oscilloscope through the sound card";
     homepage = "http://xoscope.sourceforge.net";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/science/geometry/tetgen/1.4.nix b/pkgs/applications/science/geometry/tetgen/1.4.nix
index 9dd25473683..245d4c12bfe 100644
--- a/pkgs/applications/science/geometry/tetgen/1.4.nix
+++ b/pkgs/applications/science/geometry/tetgen/1.4.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
   name = "tetgen-1.4.3";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator";
     homepage = "http://tetgen.org/";
-    license = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/geometry/tetgen/default.nix b/pkgs/applications/science/geometry/tetgen/default.nix
index d12e8e35844..c921c05c58e 100644
--- a/pkgs/applications/science/geometry/tetgen/default.nix
+++ b/pkgs/applications/science/geometry/tetgen/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}: 
+{lib, stdenv, fetchurl}:
 
 let version = "1.5.1"; in
 stdenv.mkDerivation {
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
     inherit version;
     description = "Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator";
     homepage = "http://tetgen.org/";
-    license = stdenv.lib.licenses.agpl3Plus;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.agpl3Plus;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/logic/abella/default.nix b/pkgs/applications/science/logic/abella/default.nix
index 3d9a2e9bd67..14ceb53f9bb 100644
--- a/pkgs/applications/science/logic/abella/default.nix
+++ b/pkgs/applications/science/logic/abella/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, rsync, ocamlPackages }:
+{ lib, stdenv, fetchurl, rsync, ocamlPackages }:
 
 stdenv.mkDerivation rec {
   pname = "abella";
@@ -31,8 +31,8 @@ stdenv.mkDerivation rec {
       objects with binding.
     '';
     homepage = "http://abella-prover.org/";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = with stdenv.lib.maintainers; [ bcdarwin ciil ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [ bcdarwin ciil ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/aiger/default.nix b/pkgs/applications/science/logic/aiger/default.nix
index aa5a59ed298..15c45466b13 100644
--- a/pkgs/applications/science/logic/aiger/default.nix
+++ b/pkgs/applications/science/logic/aiger/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, picosat }:
+{ lib, stdenv, fetchurl, picosat }:
 
 stdenv.mkDerivation rec {
   pname = "aiger";
@@ -48,8 +48,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "And-Inverter Graph (AIG) utilities";
     homepage    = "http://fmv.jku.at/aiger/";
-    license     = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms   = stdenv.lib.platforms.unix;
+    license     = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/avy/default.nix b/pkgs/applications/science/logic/avy/default.nix
index 6f8120c7b8e..fe2f30a55a3 100644
--- a/pkgs/applications/science/logic/avy/default.nix
+++ b/pkgs/applications/science/logic/avy/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, cmake, zlib, boost }:
+{ lib, stdenv, fetchgit, cmake, zlib, boost }:
 
 stdenv.mkDerivation rec {
   pname = "avy";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ zlib boost.out boost.dev ];
   NIX_CFLAGS_COMPILE = toString ([ "-Wno-narrowing" ]
     # Squelch endless stream of warnings on same few things
-    ++ stdenv.lib.optionals stdenv.cc.isClang [
+    ++ lib.optionals stdenv.cc.isClang [
       "-Wno-empty-body"
       "-Wno-tautological-compare"
       "-Wc++11-compat-deprecated-writable-strings"
@@ -40,9 +40,9 @@ stdenv.mkDerivation rec {
   meta = {
     description = "AIGER model checking for Property Directed Reachability";
     homepage    = "https://arieg.bitbucket.io/avy/";
-    license     = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms   = stdenv.lib.platforms.linux;
+    license     = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.linux;
     # See pkgs/applications/science/logic/glucose/default.nix
     # (The error is different due to glucose-fenv.patch, but the same)
     badPlatforms = [ "aarch64-linux" ];
diff --git a/pkgs/applications/science/logic/boolector/default.nix b/pkgs/applications/science/logic/boolector/default.nix
index 2898ce4e1f6..6916379bdea 100644
--- a/pkgs/applications/science/logic/boolector/default.nix
+++ b/pkgs/applications/science/logic/boolector/default.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
     in
       # tests modelgen and modelgensmt2 spawn boolector in another processes and
       # macOS strips DYLD_LIBRARY_PATH, hardcode it for testing
-      stdenv.lib.optionalString stdenv.isDarwin ''
+      lib.optionalString stdenv.isDarwin ''
         cp -r bin bin.back
         install_name_tool -change libboolector.dylib $(pwd)/lib/libboolector.dylib bin/boolector
       '' + ''
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
         patchShebangs ..
       '';
 
-  postCheck = stdenv.lib.optionalString stdenv.isDarwin ''
+  postCheck = lib.optionalString stdenv.isDarwin ''
     rm -rf bin
     mv bin.back bin
   '';
diff --git a/pkgs/applications/science/logic/btor2tools/default.nix b/pkgs/applications/science/logic/btor2tools/default.nix
index 355274d1e1c..992d8b1de58 100644
--- a/pkgs/applications/science/logic/btor2tools/default.nix
+++ b/pkgs/applications/science/logic/btor2tools/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0mfqmkgvyw8fa2c09kww107dmk180ch1hp98r5kv41vnc04iqb0s";
   };
 
-  nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+  nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   installPhase = ''
     mkdir -p $out $dev/include/btor2parser/ $lib/lib
diff --git a/pkgs/applications/science/logic/coq/default.nix b/pkgs/applications/science/logic/coq/default.nix
index fae17a5e09f..54842dd4769 100644
--- a/pkgs/applications/science/logic/coq/default.nix
+++ b/pkgs/applications/science/logic/coq/default.nix
@@ -49,7 +49,7 @@ let
     args.version;
   version = fetched.version;
   coq-version = args.coq-version or (if version != "dev" then versions.majorMinor version else "dev");
-  versionAtLeast = v: (coq-version == "dev") || (stdenv.lib.versionAtLeast coq-version v);
+  versionAtLeast = v: (coq-version == "dev") || (lib.versionAtLeast coq-version v);
   ideFlags = optionalString (buildIde && !versionAtLeast "8.10")
     "-lablgtkdir ${ocamlPackages.lablgtk}/lib/ocaml/*/site-lib/lablgtk2 -coqide opt";
   csdpPatch = if csdp != null then ''
diff --git a/pkgs/applications/science/logic/cryptoverif/default.nix b/pkgs/applications/science/logic/cryptoverif/default.nix
index 78861786def..4c9ce3e9595 100644
--- a/pkgs/applications/science/logic/cryptoverif/default.nix
+++ b/pkgs/applications/science/logic/cryptoverif/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml }:
+{ lib, stdenv, fetchurl, ocaml }:
 
 stdenv.mkDerivation rec {
   pname = "cryptoverif";
@@ -30,8 +30,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Cryptographic protocol verifier in the computational model";
     homepage    = "https://prosecco.gforge.inria.fr/personal/bblanche/cryptoverif/";
-    license     = stdenv.lib.licenses.cecill-b;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.cecill-b;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/ekrhyper/default.nix b/pkgs/applications/science/logic/ekrhyper/default.nix
index e1eb9a2dcc3..38cc0f06088 100644
--- a/pkgs/applications/science/logic/ekrhyper/default.nix
+++ b/pkgs/applications/science/logic/ekrhyper/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ocaml, perl}:
+{lib, stdenv, fetchurl, ocaml, perl}:
 let
   s = # Generated upstream information
   rec {
@@ -25,8 +25,8 @@ stdenv.mkDerivation {
   meta = {
     inherit (s) version;
     description = "Automated first-order theorem prover";
-    license = stdenv.lib.licenses.gpl2 ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2 ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/logic/gappa/default.nix b/pkgs/applications/science/logic/gappa/default.nix
index 2ca1bcd3098..73f34f60fc4 100644
--- a/pkgs/applications/science/logic/gappa/default.nix
+++ b/pkgs/applications/science/logic/gappa/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gmp, mpfr, boost }:
+{ lib, stdenv, fetchurl, gmp, mpfr, boost }:
 
 stdenv.mkDerivation {
   name = "gappa-1.3.5";
@@ -16,8 +16,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "http://gappa.gforge.inria.fr/";
     description = "Verifying and formally proving properties on numerical programs dealing with floating-point or fixed-point arithmetic";
-    license = with stdenv.lib.licenses; [ cecill20 gpl2 ];
-    maintainers = with stdenv.lib.maintainers; [ vbgl ];
-    platforms = stdenv.lib.platforms.all;
+    license = with lib.licenses; [ cecill20 gpl2 ];
+    maintainers = with lib.maintainers; [ vbgl ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/logic/isabelle/default.nix b/pkgs/applications/science/logic/isabelle/default.nix
index 9472d4b9b29..6c22c949483 100644
--- a/pkgs/applications/science/logic/isabelle/default.nix
+++ b/pkgs/applications/science/logic/isabelle/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     };
 
   buildInputs = [ perl polyml z3 ]
-             ++ stdenv.lib.optionals (!stdenv.isDarwin) [ nettools java ];
+             ++ lib.optionals (!stdenv.isDarwin) [ nettools java ];
 
   sourceRoot = dirname;
 
diff --git a/pkgs/applications/science/logic/jonprl/default.nix b/pkgs/applications/science/logic/jonprl/default.nix
index 3ee05a478bc..379a9a48354 100644
--- a/pkgs/applications/science/logic/jonprl/default.nix
+++ b/pkgs/applications/science/logic/jonprl/default.nix
@@ -1,4 +1,4 @@
-{ fetchgit, stdenv, smlnj, which }:
+{ fetchgit, lib, stdenv, smlnj, which }:
 
 stdenv.mkDerivation rec {
   pname = "jonprl";
@@ -27,9 +27,9 @@ stdenv.mkDerivation rec {
       Inspired by Nuprl
     '';
     homepage = "https://github.com/jonsterling/JonPRL";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ puffnfresh ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ puffnfresh ];
+    platforms = lib.platforms.linux;
     broken = true;
   };
 }
diff --git a/pkgs/applications/science/logic/lci/default.nix b/pkgs/applications/science/logic/lci/default.nix
index 4775384a3dd..a0897135fbb 100644
--- a/pkgs/applications/science/logic/lci/default.nix
+++ b/pkgs/applications/science/logic/lci/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, readline}: 
+{lib, stdenv, fetchurl, readline}:
 stdenv.mkDerivation rec {
   version = "0.6";
   pname = "lci";
@@ -9,8 +9,8 @@ stdenv.mkDerivation rec {
   buildInputs = [readline];
   meta = {
     description = ''Lambda calculus interpreter'';
-    maintainers = with stdenv.lib.maintainers; [raskin];
-    platforms = with stdenv.lib.platforms; linux;
-    license = stdenv.lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [raskin];
+    platforms = with lib.platforms; linux;
+    license = lib.licenses.gpl3;
   };
 }
diff --git a/pkgs/applications/science/logic/lean/default.nix b/pkgs/applications/science/logic/lean/default.nix
index 5bf33a8a359..53423549a72 100644
--- a/pkgs/applications/science/logic/lean/default.nix
+++ b/pkgs/applications/science/logic/lean/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
 
   postPatch = "patchShebangs .";
 
-  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+  postInstall = lib.optionalString stdenv.isDarwin ''
     substituteInPlace $out/bin/leanpkg \
       --replace "greadlink" "${coreutils}/bin/readlink"
   '';
diff --git a/pkgs/applications/science/logic/leo3/binary.nix b/pkgs/applications/science/logic/leo3/binary.nix
index 29a9adf94c4..dda18c49b72 100644
--- a/pkgs/applications/science/logic/leo3/binary.nix
+++ b/pkgs/applications/science/logic/leo3/binary.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, openjdk, runtimeShell}:
+{lib, stdenv, fetchurl, openjdk, runtimeShell}:
 stdenv.mkDerivation rec {
   pname = "leo3";
   version = "1.2";
@@ -21,9 +21,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "An automated theorem prover for classical higher-order logic with choice";
-    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;
     homepage = "https://page.mi.fu-berlin.de/lex/leo3/";
   };
 }
diff --git a/pkgs/applications/science/logic/logisim/default.nix b/pkgs/applications/science/logic/logisim/default.nix
index ce86b252311..1ca22cf769c 100644
--- a/pkgs/applications/science/logic/logisim/default.nix
+++ b/pkgs/applications/science/logic/logisim/default.nix
@@ -1,16 +1,16 @@
-{ stdenv, fetchurl, jre, makeWrapper }:
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
 
 let version = "2.7.1"; in
 
 stdenv.mkDerivation {
   pname = "logisim";
   inherit version;
-  
+
   src = fetchurl {
     url = "mirror://sourceforge/project/circuit/2.7.x/${version}/logisim-generic-${version}.jar";
     sha256 = "1hkvc9zc7qmvjbl9579p84hw3n8wl3275246xlzj136i5b0phain";
   };
-  
+
   phases = [ "installPhase" ];
 
   nativeBuildInputs = [makeWrapper];
@@ -19,11 +19,11 @@ stdenv.mkDerivation {
     mkdir -pv $out/bin
     makeWrapper ${jre}/bin/java $out/bin/logisim --add-flags "-jar $src"
   '';
-  
+
   meta = {
     homepage = "http://ozark.hendrix.edu/~burch/logisim";
     description = "Educational tool for designing and simulating digital logic circuits";
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl2Plus;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/ltl2ba/default.nix b/pkgs/applications/science/logic/ltl2ba/default.nix
index b5d13db3b9a..30c13c6036f 100644
--- a/pkgs/applications/science/logic/ltl2ba/default.nix
+++ b/pkgs/applications/science/logic/ltl2ba/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv }:
+{ fetchurl, lib, stdenv }:
 
 stdenv.mkDerivation rec {
   pname = "ltl2ba";
@@ -24,8 +24,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Fast translation from LTL formulae to Buchi automata";
     homepage    = "http://www.lsv.ens-cachan.fr/~gastin/ltl2ba";
-    license     = stdenv.lib.licenses.gpl2Plus;
-    platforms   = stdenv.lib.platforms.darwin ++ stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.gpl2Plus;
+    platforms   = lib.platforms.darwin ++ lib.platforms.linux;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/mcy/default.nix b/pkgs/applications/science/logic/mcy/default.nix
index eba910e07eb..dc1094f3e27 100644
--- a/pkgs/applications/science/logic/mcy/default.nix
+++ b/pkgs/applications/science/logic/mcy/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , yosys, symbiyosys, python3
 }:
 
@@ -44,8 +44,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Mutation-based coverage testing for hardware designs, with Yosys";
     homepage    = "https://github.com/YosysHQ/mcy";
-    license     = stdenv.lib.licenses.isc;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.isc;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/logic/monosat/default.nix b/pkgs/applications/science/logic/monosat/default.nix
index 19fba6e2993..259cdcea443 100644
--- a/pkgs/applications/science/logic/monosat/default.nix
+++ b/pkgs/applications/science/logic/monosat/default.nix
@@ -1,9 +1,9 @@
-{ stdenv, fetchpatch, fetchFromGitHub, cmake, zlib, gmp, jdk8,
+{ lib, stdenv, fetchpatch, fetchFromGitHub, cmake, zlib, gmp, jdk8,
   # The JDK we use on Darwin currenly makes extensive use of rpaths which are
   # annoying and break the python library, so let's not bother for now
   includeJava ? !stdenv.hostPlatform.isDarwin, includeGplCode ? true }:
 
-with stdenv.lib;
+with lib;
 
 let
   boolToCmake = x: if x then "ON" else "OFF";
diff --git a/pkgs/applications/science/logic/ott/default.nix b/pkgs/applications/science/logic/ott/default.nix
index 15a9fa5ccab..3542dab9382 100644
--- a/pkgs/applications/science/logic/ott/default.nix
+++ b/pkgs/applications/science/logic/ott/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, pkgconfig, ocaml, opaline }:
+{ lib, stdenv, fetchFromGitHub, pkgconfig, ocaml, opaline }:
 
 stdenv.mkDerivation rec {
   pname = "ott";
@@ -38,8 +38,8 @@ stdenv.mkDerivation rec {
       target-system terms.
     '';
     homepage = "http://www.cl.cam.ac.uk/~pes20/ott";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = with stdenv.lib.maintainers; [ jwiegley ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ jwiegley ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/otter/default.nix b/pkgs/applications/science/logic/otter/default.nix
index a7eec20548c..2ad066e53f7 100644
--- a/pkgs/applications/science/logic/otter/default.nix
+++ b/pkgs/applications/science/logic/otter/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, tcsh, libXaw, libXt, libX11}:
+{lib, stdenv, fetchurl, tcsh, libXaw, libXt, libX11}:
 let
   s = # Generated upstream information
   rec {
@@ -27,7 +27,7 @@ stdenv.mkDerivation {
     find . -perm -0100 -type f | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g"
     find . -perm -0100 -type f | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g"
 
-    sed -i -e "s/^XLIBS *=.*/XLIBS=-lXaw -lXt -lX11/" source/formed/Makefile 
+    sed -i -e "s/^XLIBS *=.*/XLIBS=-lXaw -lXt -lX11/" source/formed/Makefile
 
     make all
     make -C examples all
@@ -45,9 +45,9 @@ stdenv.mkDerivation {
   meta = {
     inherit (s) version;
     description = "A reliable first-order theorem prover";
-    license = stdenv.lib.licenses.publicDomain ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.publicDomain ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     broken = true;
   };
 }
diff --git a/pkgs/applications/science/logic/petrinizer/default.nix b/pkgs/applications/science/logic/petrinizer/default.nix
index d277e0e1521..5118795978d 100644
--- a/pkgs/applications/science/logic/petrinizer/default.nix
+++ b/pkgs/applications/science/logic/petrinizer/default.nix
@@ -1,6 +1,6 @@
 { mkDerivation, callPackage, buildPackages
 , async, base, bytestring, containers, fetchFromGitLab, mtl
-, parallel-io, parsec, stdenv, stm, transformers
+, parallel-io, parsec, lib, stdenv, stm, transformers
 }:
 let
   z3 = callPackage ./z3.nix { gomp = null; z3 = buildPackages.z3; };
@@ -26,6 +26,6 @@ mkDerivation rec {
     transformers
   ];
   description = "Safety and Liveness Analysis of Petri Nets with SMT solvers";
-  license = stdenv.lib.licenses.gpl3;
-  maintainers = with stdenv.lib.maintainers; [ raskin ];
+  license = lib.licenses.gpl3;
+  maintainers = with lib.maintainers; [ raskin ];
 }
diff --git a/pkgs/applications/science/logic/petrinizer/sbv-7.13.nix b/pkgs/applications/science/logic/petrinizer/sbv-7.13.nix
index ed10e9f3db1..96e216417df 100644
--- a/pkgs/applications/science/logic/petrinizer/sbv-7.13.nix
+++ b/pkgs/applications/science/logic/petrinizer/sbv-7.13.nix
@@ -1,7 +1,7 @@
 { mkDerivation, array, async, base, bytestring, containers
 , crackNum, deepseq, directory, doctest, filepath, generic-deriving
 , ghc, Glob, hlint, mtl, pretty, process, QuickCheck, random
-, stdenv, syb, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
+, lib, stdenv, syb, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
 , template-haskell, time, z3
 }:
 mkDerivation {
@@ -22,5 +22,5 @@ mkDerivation {
   testSystemDepends = [ z3 ];
   homepage = "http://leventerkok.github.com/sbv/";
   description = "SMT Based Verification: Symbolic Haskell theorem prover using SMT solving";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
 }
diff --git a/pkgs/applications/science/logic/petrinizer/z3.nix b/pkgs/applications/science/logic/petrinizer/z3.nix
index 4d868054c09..3574954c376 100644
--- a/pkgs/applications/science/logic/petrinizer/z3.nix
+++ b/pkgs/applications/science/logic/petrinizer/z3.nix
@@ -1,5 +1,5 @@
 { mkDerivation, fetchpatch
-, base, containers, gomp, hspec, QuickCheck, stdenv
+, base, containers, gomp, hspec, QuickCheck, lib, stdenv
 , transformers, z3
 }:
 mkDerivation {
@@ -13,7 +13,7 @@ mkDerivation {
   testHaskellDepends = [ base hspec QuickCheck ];
   homepage = "https://github.com/IagoAbal/haskell-z3";
   description = "Bindings for the Z3 Theorem Prover";
-  license = stdenv.lib.licenses.bsd3;
+  license = lib.licenses.bsd3;
   doCheck = false;
   patches = [
     (fetchpatch {
diff --git a/pkgs/applications/science/logic/picosat/default.nix b/pkgs/applications/science/logic/picosat/default.nix
index b13d871580c..48def5fc2e4 100644
--- a/pkgs/applications/science/logic/picosat/default.nix
+++ b/pkgs/applications/science/logic/picosat/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   pname = "picosat";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   configurePhase = "./configure.sh --shared --trace";
 
-  makeFlags = stdenv.lib.optional stdenv.isDarwin
+  makeFlags = lib.optional stdenv.isDarwin
     "SONAME=-Wl,-install_name,$(out)/lib/libpicosat.so";
 
   installPhase = ''
@@ -37,8 +37,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "SAT solver with proof and core support";
     homepage    = "http://fmv.jku.at/picosat/";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ roconnor thoughtpolice ];
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ roconnor thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/potassco/clingcon.nix b/pkgs/applications/science/logic/potassco/clingcon.nix
index b74583ca1a2..4d64a813e62 100644
--- a/pkgs/applications/science/logic/potassco/clingcon.nix
+++ b/pkgs/applications/science/logic/potassco/clingcon.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , bison
@@ -34,8 +34,8 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "Extension of clingo to handle constraints over integers";
-    license = stdenv.lib.licenses.gpl3; # for now GPL3, next version MIT!
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl3; # for now GPL3, next version MIT!
+    platforms = lib.platforms.unix;
     homepage = "https://potassco.org/";
     downloadPage = "https://github.com/potassco/clingcon/releases/";
     changelog = "https://github.com/potassco/clingcon/releases/tag/v${version}";
diff --git a/pkgs/applications/science/logic/potassco/clingo.nix b/pkgs/applications/science/logic/potassco/clingo.nix
index fd6b2c8d14c..f473c4f5366 100644
--- a/pkgs/applications/science/logic/potassco/clingo.nix
+++ b/pkgs/applications/science/logic/potassco/clingo.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, cmake }:
+{ lib, stdenv, fetchzip, cmake }:
 
 stdenv.mkDerivation rec {
   pname = "clingo";
@@ -16,9 +16,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "ASP system to ground and solve logic programs";
-    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;
     homepage = "https://potassco.org/";
     downloadPage = "https://github.com/potassco/clingo/releases/";
   };
diff --git a/pkgs/applications/science/logic/prover9/default.nix b/pkgs/applications/science/logic/prover9/default.nix
index fcdff855848..7fedca72b69 100644
--- a/pkgs/applications/science/logic/prover9/default.nix
+++ b/pkgs/applications/science/logic/prover9/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 
 stdenv.mkDerivation {
   name = "prover9-2009-11a";
@@ -39,7 +39,7 @@ stdenv.mkDerivation {
       for first-order and equational logic. Prover9 is a successor of
       the Otter Prover. This is the LADR command-line version.
     '';
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     maintainers = [];
   };
 }
diff --git a/pkgs/applications/science/logic/proverif/default.nix b/pkgs/applications/science/logic/proverif/default.nix
index 4242bb0599e..ba46d87581e 100644
--- a/pkgs/applications/science/logic/proverif/default.nix
+++ b/pkgs/applications/science/logic/proverif/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocamlPackages }:
+{ lib, stdenv, fetchurl, ocamlPackages }:
 
 stdenv.mkDerivation rec {
   pname = "proverif";
@@ -22,8 +22,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Cryptographic protocol verifier in the Dolev-Yao model";
     homepage    = "https://prosecco.gforge.inria.fr/personal/bblanche/proverif/";
-    license     = stdenv.lib.licenses.gpl2;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.gpl2;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/redprl/default.nix b/pkgs/applications/science/logic/redprl/default.nix
index 49245c73f2c..43a2ec7e97e 100644
--- a/pkgs/applications/science/logic/redprl/default.nix
+++ b/pkgs/applications/science/logic/redprl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, mlton }:
+{ lib, stdenv, fetchgit, mlton }:
 stdenv.mkDerivation {
   name = "redprl-2017-03-28";
   src = fetchgit {
@@ -21,8 +21,8 @@ stdenv.mkDerivation {
   meta = {
     description = "A proof assistant for Nominal Computational Type Theory";
     homepage = "http://www.redprl.org/";
-    license = stdenv.lib.licenses.mit;
-    maintainers = [ stdenv.lib.maintainers.acowley ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.acowley ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/sad/default.nix b/pkgs/applications/science/logic/sad/default.nix
index 77613a13571..8e4d19973ef 100644
--- a/pkgs/applications/science/logic/sad/default.nix
+++ b/pkgs/applications/science/logic/sad/default.nix
@@ -31,10 +31,10 @@ stdenv.mkDerivation {
       The system for automated deduction is intended for automated processing of formal mathematical texts
       written in a special language called ForTheL (FORmal THEory Language) or in a traditional first-order language
       '';
-    license = stdenv.lib.licenses.gpl3Plus;
-    maintainers = [ stdenv.lib.maintainers.schmitthenner ];
+    license = lib.licenses.gpl3Plus;
+    maintainers = [ lib.maintainers.schmitthenner ];
     homepage = "http://nevidal.org/sad.en.html";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     broken = true;  # ghc-8.4.4 is gone from Nixpkgs
   };
 }
diff --git a/pkgs/applications/science/logic/satallax/default.nix b/pkgs/applications/science/logic/satallax/default.nix
index 6c2b03b5b37..02d9408383a 100644
--- a/pkgs/applications/science/logic/satallax/default.nix
+++ b/pkgs/applications/science/logic/satallax/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ocaml, zlib, which, eprover, makeWrapper, coq}:
+{lib, stdenv, fetchurl, ocaml, zlib, which, eprover, makeWrapper, coq}:
 stdenv.mkDerivation rec {
   pname = "satallax";
   version = "2.7";
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
     mkdir -p "$out/libexec/satallax"
     cp picosat-*/picosat picosat-*/picomus "$out/libexec/satallax"
 
-    ( 
+    (
       cd minisat
       export MROOT=$PWD
       cd core
@@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
     mkdir -p "$out/share/doc/satallax" "$out/bin" "$out/lib" "$out/lib/satallax"
     cp bin/satallax.opt "$out/bin/satallax"
     wrapProgram "$out/bin/satallax" \
-      --suffix PATH : "${stdenv.lib.makeBinPath [ coq eprover ]}:$out/libexec/satallax" \
+      --suffix PATH : "${lib.makeBinPath [ coq eprover ]}:$out/libexec/satallax" \
       --add-flags "-M" --add-flags "$out/lib/satallax/modes"
 
     cp LICENSE README "$out/share/doc/satallax"
@@ -61,9 +61,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = ''Automated theorem prover for higher-order logic'';
-    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;
     downloadPage = "http://www.ps.uni-saarland.de/~cebrown/satallax/downloads.php";
     homepage = "http://www.ps.uni-saarland.de/~cebrown/satallax/index.php";
     updateWalker = true;
diff --git a/pkgs/applications/science/logic/saw-tools/default.nix b/pkgs/applications/science/logic/saw-tools/default.nix
index 71b26f8023a..1dd6dc1cfc8 100644
--- a/pkgs/applications/science/logic/saw-tools/default.nix
+++ b/pkgs/applications/science/logic/saw-tools/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, gmp4, ncurses, zlib, clang }:
+{ lib, stdenv, fetchurl, gmp4, ncurses, zlib, clang }:
 
 let
-  libPath = stdenv.lib.makeLibraryPath
+  libPath = lib.makeLibraryPath
     [ stdenv.cc.libc
       stdenv.cc.cc
       gmp4
@@ -53,8 +53,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Tools for software verification and analysis";
     homepage    = "https://saw.galois.com";
-    license     = stdenv.lib.licenses.unfreeRedistributable;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.unfreeRedistributable;
+    platforms   = lib.platforms.linux;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/statverif/default.nix b/pkgs/applications/science/logic/statverif/default.nix
index e0efb28819d..07365eef33f 100644
--- a/pkgs/applications/science/logic/statverif/default.nix
+++ b/pkgs/applications/science/logic/statverif/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml }:
+{ lib, stdenv, fetchurl, ocaml }:
 
 stdenv.mkDerivation rec {
   pname = "statverif";
@@ -27,8 +27,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Verification of stateful processes (via Proverif)";
     homepage    = "https://markryan.eu/research/statverif/";
-    license     = stdenv.lib.licenses.gpl2;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.gpl2;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/symbiyosys/default.nix b/pkgs/applications/science/logic/symbiyosys/default.nix
index 9cf8b0845d4..1f2ad4634de 100644
--- a/pkgs/applications/science/logic/symbiyosys/default.nix
+++ b/pkgs/applications/science/logic/symbiyosys/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ lib, stdenv, fetchFromGitHub
 , bash, python3, yosys
 , yices, boolector, z3, aiger
 }:
@@ -51,8 +51,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Tooling for Yosys-based verification flows";
     homepage    = "https://symbiyosys.readthedocs.io/";
-    license     = stdenv.lib.licenses.isc;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice emily ];
-    platforms   = stdenv.lib.platforms.all;
+    license     = lib.licenses.isc;
+    maintainers = with lib.maintainers; [ thoughtpolice emily ];
+    platforms   = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/science/logic/tlaplus/default.nix b/pkgs/applications/science/logic/tlaplus/default.nix
index 14944f5e19b..c4ba334b85f 100644
--- a/pkgs/applications/science/logic/tlaplus/default.nix
+++ b/pkgs/applications/science/logic/tlaplus/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, makeWrapper
+{ lib, stdenv, fetchFromGitHub, makeWrapper
 , adoptopenjdk-bin, jre, ant
 }:
 
@@ -33,8 +33,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "An algorithm specification language with model checking tools";
     homepage    = "http://lamport.azurewebsites.net/tla/tla.html";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/tlaplus/tlaps.nix b/pkgs/applications/science/logic/tlaplus/tlaps.nix
index 3872d3a9826..89bdd979fea 100644
--- a/pkgs/applications/science/logic/tlaplus/tlaps.nix
+++ b/pkgs/applications/science/logic/tlaplus/tlaps.nix
@@ -1,5 +1,5 @@
 { fetchurl
-, stdenv
+, lib, stdenv
 , ocaml, isabelle, cvc3, perl, wget, which
 }:
 
@@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
       consistent abstraction over the various “backend” verifiers.
     '';
     homepage    = "https://tla.msr-inria.inria.fr/tlaps/content/Home.html";
-    license     = stdenv.lib.licenses.bsd2;
-    platforms   = stdenv.lib.platforms.unix;
+    license     = lib.licenses.bsd2;
+    platforms   = lib.platforms.unix;
     maintainers = [ ];
   };
 
diff --git a/pkgs/applications/science/logic/tlaplus/toolbox.nix b/pkgs/applications/science/logic/tlaplus/toolbox.nix
index c9e97375b6c..1c33d923289 100644
--- a/pkgs/applications/science/logic/tlaplus/toolbox.nix
+++ b/pkgs/applications/science/logic/tlaplus/toolbox.nix
@@ -75,7 +75,7 @@ in stdenv.mkDerivation {
     '';
     # http://lamport.azurewebsites.net/tla/license.html
     license = with lib.licenses; [ mit ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     maintainers = [ ];
   };
 }
diff --git a/pkgs/applications/science/logic/twelf/default.nix b/pkgs/applications/science/logic/twelf/default.nix
index 975b989bd94..73fe423673b 100644
--- a/pkgs/applications/science/logic/twelf/default.nix
+++ b/pkgs/applications/science/logic/twelf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, smlnj, rsync }:
+{ lib, stdenv, fetchurl, pkgconfig, smlnj, rsync }:
 
 stdenv.mkDerivation rec {
   pname = "twelf";
@@ -44,8 +44,8 @@ stdenv.mkDerivation rec {
       Standard ML.
     '';
     homepage = "http://twelf.org/wiki/Main_Page";
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ jwiegley ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ jwiegley ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/logic/verifast/default.nix b/pkgs/applications/science/logic/verifast/default.nix
index 49618d2586b..2d625a1c1b2 100644
--- a/pkgs/applications/science/logic/verifast/default.nix
+++ b/pkgs/applications/science/logic/verifast/default.nix
@@ -1,9 +1,9 @@
-{ stdenv, fetchurl, gtk2, gdk-pixbuf, atk, pango, glib, cairo, freetype
+{ lib, stdenv, fetchurl, gtk2, gdk-pixbuf, atk, pango, glib, cairo, freetype
 , fontconfig, libxml2, gnome2 }:
 
 let
 
-  libPath = stdenv.lib.makeLibraryPath
+  libPath = lib.makeLibraryPath
     [ stdenv.cc.libc stdenv.cc.cc gtk2 gdk-pixbuf atk pango glib cairo
       freetype fontconfig libxml2 gnome2.gtksourceview
     ] + ":${stdenv.cc.cc.lib}/lib64:$out/libexec";
@@ -43,8 +43,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Verification for C and Java programs via separation logic";
     homepage    = "http://people.cs.kuleuven.be/~bart.jacobs/verifast/";
-    license     = stdenv.lib.licenses.mit;
+    license     = lib.licenses.mit;
     platforms   = [ "x86_64-linux" ];
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    maintainers = [ lib.maintainers.thoughtpolice ];
   };
 }
diff --git a/pkgs/applications/science/logic/workcraft/default.nix b/pkgs/applications/science/logic/workcraft/default.nix
index 9ce6592d998..cb0d668f536 100644
--- a/pkgs/applications/science/logic/workcraft/default.nix
+++ b/pkgs/applications/science/logic/workcraft/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, jre, makeWrapper }:
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "workcraft";
@@ -25,9 +25,9 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://workcraft.org/";
     description = "Framework for interpreted graph modeling, verification and synthesis";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ timor ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ timor ];
     inherit version;
   };
 }
diff --git a/pkgs/applications/science/logic/yices/default.nix b/pkgs/applications/science/logic/yices/default.nix
index a01a07b8954..67009657363 100644
--- a/pkgs/applications/science/logic/yices/default.nix
+++ b/pkgs/applications/science/logic/yices/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   # Includes a fix for the embedded soname being libyices.so.2.5, but
   # only installing the libyices.so.2.5.x file.
   installPhase = let
-    ver_XdotY = stdenv.lib.versions.majorMinor version;
+    ver_XdotY = lib.versions.majorMinor version;
   in ''
       make install LDCONFIG=true
       ln -sfr $out/lib/libyices.so.{${version},${ver_XdotY}}
diff --git a/pkgs/applications/science/logic/z3/4.4.0.nix b/pkgs/applications/science/logic/z3/4.4.0.nix
index a5388572db6..9b7dabeb720 100644
--- a/pkgs/applications/science/logic/z3/4.4.0.nix
+++ b/pkgs/applications/science/logic/z3/4.4.0.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, python }:
+{ lib, stdenv, fetchFromGitHub, python }:
 
 stdenv.mkDerivation rec {
   name = "z3-${version}";
@@ -34,8 +34,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A high-performance theorem prover and SMT solver";
     homepage    = "https://github.com/Z3Prover/z3";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.x86_64;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ttuegel ];
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.x86_64;
+    maintainers = with lib.maintainers; [ thoughtpolice ttuegel ];
   };
 }
diff --git a/pkgs/applications/science/logic/z3/default.nix b/pkgs/applications/science/logic/z3/default.nix
index 48512eff530..cd58740186f 100644
--- a/pkgs/applications/science/logic/z3/default.nix
+++ b/pkgs/applications/science/logic/z3/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, python, fixDarwinDylibNames
+{ lib, stdenv, fetchFromGitHub, python, fixDarwinDylibNames
 , javaBindings ? false
 , ocamlBindings ? false
 , pythonBindings ? true
@@ -9,7 +9,7 @@
 assert javaBindings -> jdk != null;
 assert ocamlBindings -> ocaml != null && findlib != null && zarith != null;
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   pname = "z3";
@@ -59,8 +59,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A high-performance theorem prover and SMT solver";
     homepage    = "https://github.com/Z3Prover/z3";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ttuegel ];
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ thoughtpolice ttuegel ];
   };
 }
diff --git a/pkgs/applications/science/logic/z3/tptp.nix b/pkgs/applications/science/logic/z3/tptp.nix
index 34449542abb..c63fad93f07 100644
--- a/pkgs/applications/science/logic/z3/tptp.nix
+++ b/pkgs/applications/science/logic/z3/tptp.nix
@@ -1,4 +1,4 @@
-{stdenv, z3, cmake}:
+{lib, stdenv, z3, cmake}:
 stdenv.mkDerivation rec {
   pname = "z3-tptp";
   version = z3.version;
@@ -26,6 +26,6 @@ stdenv.mkDerivation rec {
     inherit version;
     inherit (z3.meta) license homepage platforms;
     description = ''TPTP wrapper for Z3 prover'';
-    maintainers = [stdenv.lib.maintainers.raskin];
+    maintainers = [lib.maintainers.raskin];
   };
 }
diff --git a/pkgs/applications/science/machine-learning/sc2-headless/default.nix b/pkgs/applications/science/machine-learning/sc2-headless/default.nix
index 7bcc915daec..9438cd972f9 100644
--- a/pkgs/applications/science/machine-learning/sc2-headless/default.nix
+++ b/pkgs/applications/science/machine-learning/sc2-headless/default.nix
@@ -49,7 +49,7 @@ in stdenv.mkDerivation rec {
   '';
 
   meta = {
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     description = "Starcraft II headless linux client for machine learning research";
     license = {
       fullName = "BLIZZARD® STARCRAFT® II AI AND MACHINE LEARNING LICENSE";
diff --git a/pkgs/applications/science/math/LiE/default.nix b/pkgs/applications/science/math/LiE/default.nix
index f5f3bb0a42b..9b16fc1d67f 100644
--- a/pkgs/applications/science/math/LiE/default.nix
+++ b/pkgs/applications/science/math/LiE/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ lib, stdenv, fetchurl
 , bison, readline }:
 
 stdenv.mkDerivation {
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   meta = {
     description = "A Computer algebra package for Lie group computations";
     homepage = "http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/";
-    license = stdenv.lib.licenses.lgpl3; # see the website
+    license = lib.licenses.lgpl3; # see the website
 
     longDescription = ''
       LiE is a computer algebra system that is specialised in computations
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
       characteristics, we refer to the following sources of information.
     ''; # take from the website
 
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
     maintainers = [ ]; # this package is probably not going to change anyway
   };
 
diff --git a/pkgs/applications/science/math/R/default.nix b/pkgs/applications/science/math/R/default.nix
index 2191511a9c5..d9fbc626e00 100644
--- a/pkgs/applications/science/math/R/default.nix
+++ b/pkgs/applications/science/math/R/default.nix
@@ -25,14 +25,14 @@ stdenv.mkDerivation rec {
     bzip2 gfortran libX11 libXmu libXt libXt libjpeg libpng libtiff ncurses
     pango pcre2 perl readline texLive xz zlib less texinfo graphviz icu
     pkgconfig bison imake which blas lapack curl tcl tk jdk
-  ] ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa Foundation libobjc libcxx ];
+  ] ++ lib.optionals stdenv.isDarwin [ Cocoa Foundation libobjc libcxx ];
 
   patches = [
     ./no-usr-local-search-paths.patch
     ./fix-failing-test.patch
   ];
 
-  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  prePatch = lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure --replace "-install_name libR.dylib" "-install_name $out/lib/R/lib/libR.dylib"
   '';
 
@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     configureFlagsArray=(
       --disable-lto
-      --with${stdenv.lib.optionalString (!withRecommendedPackages) "out"}-recommended-packages
+      --with${lib.optionalString (!withRecommendedPackages) "out"}-recommended-packages
       --with-blas="-L${blas}/lib -lblas"
       --with-lapack="-L${lapack}/lib -llapack"
       --with-readline
@@ -51,7 +51,7 @@ stdenv.mkDerivation rec {
       --with-jpeglib
       --with-libtiff
       --with-ICU
-      ${stdenv.lib.optionalString enableStrictBarrier "--enable-strict-barrier"}
+      ${lib.optionalString enableStrictBarrier "--enable-strict-barrier"}
       ${if static then "--enable-R-static-lib" else "--enable-R-shlib"}
       AR=$(type -p ar)
       AWK=$(type -p gawk)
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
       JAVA_HOME="${jdk}"
       RANLIB=$(type -p ranlib)
       R_SHELL="${stdenv.shell}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
       --disable-R-framework
       OBJC="clang"
       CPPFLAGS="-isystem ${libcxx}/include/c++/v1"
diff --git a/pkgs/applications/science/math/bcal/default.nix b/pkgs/applications/science/math/bcal/default.nix
index 5df2d20549c..8cbf90a7187 100644
--- a/pkgs/applications/science/math/bcal/default.nix
+++ b/pkgs/applications/science/math/bcal/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, python3Packages, readline, bc }:
+{ lib, stdenv, fetchFromGitHub, python3Packages, readline, bc }:
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   pname = "bcal";
diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix
index 39213aff09a..068f9f0ea3c 100644
--- a/pkgs/applications/science/math/cplex/default.nix
+++ b/pkgs/applications/science/math/cplex/default.nix
@@ -1,7 +1,7 @@
 { lib, stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }:
 
 # To use this package, you need to download your own cplex installer from IBM
-# and override the releasePath attribute to point to the location of the file.  
+# and override the releasePath attribute to point to the location of the file.
 #
 # Note: cplex creates an individual build for each license which screws
 # somewhat with the use of functions like requireFile as the hash will be
@@ -10,13 +10,13 @@
 stdenv.mkDerivation rec {
   pname = "cplex";
   version = "128";
-  
+
   src =
     if releasePath == null then
       throw ''
         This nix expression requires that the cplex installer is already
-        downloaded to your machine. Get it from IBM: 
-        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/ 
+        downloaded to your machine. Get it from IBM:
+        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/
 
         Set `cplex.releasePath = /path/to/download;` in your
         ~/.config/nixpkgs/config.nix for `nix-*` commands, or
@@ -49,9 +49,9 @@ stdenv.mkDerivation rec {
       $out/bin
   '';
 
-  fixupPhase = 
-  let 
-    libraryPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
+  fixupPhase =
+  let
+    libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
   in ''
     interpreter=${stdenv.glibc}/lib/ld-linux-x86-64.so.2
 
@@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
         --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
     done
 
-    for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*; 
+    for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*;
     do
       if grep ELF $pgm > /dev/null;
       then
@@ -76,7 +76,7 @@ stdenv.mkDerivation rec {
     libArch = "x86-64_linux";
     libSuffix = "${version}0";
   };
-  
+
   meta = with lib; {
     description = "Optimization solver for mathematical programming";
     homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex";
diff --git a/pkgs/applications/science/math/csdp/default.nix b/pkgs/applications/science/math/csdp/default.nix
index ef9d5e733ca..02c4c134f92 100644
--- a/pkgs/applications/science/math/csdp/default.nix
+++ b/pkgs/applications/science/math/csdp/default.nix
@@ -24,6 +24,6 @@ stdenv.mkDerivation {
     license = lib.licenses.cpl10;
     maintainers = [ lib.maintainers.roconnor ];
     description = "A C Library for Semidefinite Programming";
-    platforms = stdenv.lib.platforms.unix;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/math/ecm/default.nix b/pkgs/applications/science/math/ecm/default.nix
index 3e8e5879950..c59b1a8729a 100644
--- a/pkgs/applications/science/math/ecm/default.nix
+++ b/pkgs/applications/science/math/ecm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gmp, m4 }:
+{ lib, stdenv, fetchurl, gmp, m4 }:
 
 let
   pname = "ecm";
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   };
 
   # See https://trac.sagemath.org/ticket/19233
-  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-asm-redc";
+  configureFlags = lib.optional stdenv.isDarwin "--disable-asm-redc";
 
   buildInputs = [ m4 gmp ];
 
@@ -23,9 +23,9 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Elliptic Curve Method for Integer Factorization";
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
     homepage = "http://ecm.gforge.inria.fr/";
-    maintainers = [ stdenv.lib.maintainers.roconnor ];
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
+    maintainers = [ lib.maintainers.roconnor ];
+    platforms = with lib.platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/applications/science/math/eukleides/default.nix b/pkgs/applications/science/math/eukleides/default.nix
index 879ad96a936..5f7fe58465d 100644
--- a/pkgs/applications/science/math/eukleides/default.nix
+++ b/pkgs/applications/science/math/eukleides/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, bison, flex, texinfo, readline, texLive }:
+{ lib, stdenv, fetchurl, bison, flex, texinfo, readline, texLive }:
 
 let
   name    = "eukleides";
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   meta = {
     description = "Geometry Drawing Language";
     homepage = "http://www.eukleides.org/";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
 
     longDescription = ''
       Eukleides is a computer language devoted to elementary plane
@@ -31,7 +31,7 @@ stdenv.mkDerivation {
       circles and conics.
     '';
 
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.peti ];
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/applications/science/math/fricas/default.nix b/pkgs/applications/science/math/fricas/default.nix
index 39ca53c47e6..a29d4036728 100644
--- a/pkgs/applications/science/math/fricas/default.nix
+++ b/pkgs/applications/science/math/fricas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, sbcl, libX11, libXpm, libICE, libSM, libXt, libXau, libXdmcp }:
+{ lib, stdenv, fetchurl, sbcl, libX11, libXpm, libICE, libSM, libXt, libXau, libXdmcp }:
 
 let
   version = "1.3.4";
@@ -19,9 +19,9 @@ stdenv.mkDerivation {
   meta = {
     homepage = "http://fricas.sourceforge.net/";
     description = "An advanced computer algebra system";
-    license = stdenv.lib.licenses.bsd3;
+    license = lib.licenses.bsd3;
 
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.sprock ];
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.sprock ];
   };
 }
diff --git a/pkgs/applications/science/math/geogebra/geogebra6.nix b/pkgs/applications/science/math/geogebra/geogebra6.nix
index 7bd58264893..4ed66d96930 100644
--- a/pkgs/applications/science/math/geogebra/geogebra6.nix
+++ b/pkgs/applications/science/math/geogebra/geogebra6.nix
@@ -1,4 +1,4 @@
-{ stdenv, unzip, fetchurl, electron_6, makeWrapper, geogebra }:
+{ lib, stdenv, unzip, fetchurl, electron_6, makeWrapper, geogebra }:
 let
   pname = "geogebra";
   version = "6-0-609-0";
@@ -6,7 +6,7 @@ let
   srcIcon = geogebra.srcIcon;
   desktopItem = geogebra.desktopItem;
 
-  meta = with stdenv.lib; geogebra.meta // {
+  meta = with lib; geogebra.meta // {
     license = licenses.geogebra;
     maintainers = with maintainers; [ voidless ];
     platforms = with platforms; linux ++ darwin;
@@ -38,7 +38,7 @@ let
     installPhase = ''
       mkdir -p $out/libexec/geogebra/ $out/bin
       cp -r GeoGebra-linux-x64/{resources,locales} "$out/"
-      makeWrapper ${stdenv.lib.getBin electron_6}/bin/electron $out/bin/geogebra --add-flags "$out/resources/app"
+      makeWrapper ${lib.getBin electron_6}/bin/electron $out/bin/geogebra --add-flags "$out/resources/app"
       install -Dm644 "${desktopItem}/share/applications/"* \
         -t $out/share/applications/
 
diff --git a/pkgs/applications/science/math/gfan/default.nix b/pkgs/applications/science/math/gfan/default.nix
index 7e2a4625d30..fd657963c39 100644
--- a/pkgs/applications/science/math/gfan/default.nix
+++ b/pkgs/applications/science/math/gfan/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gmp, mpir, cddlib}:
+{lib, stdenv, fetchurl, gmp, mpir, cddlib}:
 stdenv.mkDerivation rec {
   pname = "gfan";
   version = "0.6.2";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
     ./gfan-0.6.2-cddlib-prefix.patch
   ];
 
-  postPatch = stdenv.lib.optionalString stdenv.cc.isClang ''
+  postPatch = lib.optionalString stdenv.cc.isClang ''
     substituteInPlace Makefile --replace "-fno-guess-branch-probability" ""
   '';
 
@@ -23,9 +23,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = ''A software package for computing Gröbner fans and tropical varieties'';
-    license = stdenv.lib.licenses.gpl2 ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl2 ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
     homepage = "http://home.math.au.dk/jensen/software/gfan/gfan.html";
   };
 }
diff --git a/pkgs/applications/science/math/giac/default.nix b/pkgs/applications/science/math/giac/default.nix
index 7825fc1d9a2..8c391e25322 100644
--- a/pkgs/applications/science/math/giac/default.nix
+++ b/pkgs/applications/science/math/giac/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     sha256 = "1d0h1yb7qvh9x7wwv9yrzmcp712f49w1iljkxp4y6g9pzsmg1mmv";
   };
 
-  patches = stdenv.lib.optionals (!enableGUI) [
+  patches = lib.optionals (!enableGUI) [
     # when enableGui is false, giac is compiled without fltk. That means some
     # outputs differ in the make check. Patch around this:
     (fetchpatch {
@@ -41,9 +41,9 @@ stdenv.mkDerivation rec {
     readline gettext libpng libao perl ecm
     # gfortran.cc default output contains static libraries compiled without -fPIC
     # we want libgfortran.so.3 instead
-    (stdenv.lib.getLib gfortran.cc)
+    (lib.getLib gfortran.cc)
     lapack blas
-  ] ++ stdenv.lib.optionals enableGUI [
+  ] ++ lib.optionals enableGUI [
     libGL libGLU fltk xorg.libX11
   ];
 
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
 
   # xcas Phys and Turtle menus are broken with split outputs
   # and interactive use is likely to need docs
-  outputs = [ "out" ] ++ stdenv.lib.optional (!enableGUI) "doc";
+  outputs = [ "out" ] ++ lib.optional (!enableGUI) "doc";
 
   doCheck = true;
   preCheck = ''
@@ -74,7 +74,7 @@ stdenv.mkDerivation rec {
     "--enable-gc" "--enable-png" "--enable-gsl" "--enable-lapack"
     "--enable-pari" "--enable-ntl" "--enable-gmpxx" # "--enable-cocoa"
     "--enable-ao" "--enable-ecm" "--enable-glpk"
-  ] ++ stdenv.lib.optionals enableGUI [
+  ] ++ lib.optionals enableGUI [
     "--enable-gui" "--with-x"
   ];
 
@@ -94,7 +94,7 @@ stdenv.mkDerivation rec {
       mv "$out/share/giac/doc" "$doc/share/giac"
       mv "$out/share/giac/examples" "$doc/share/giac"
     fi
-  '' + stdenv.lib.optionalString (!enableGUI) ''
+  '' + lib.optionalString (!enableGUI) ''
     for i in pixmaps application-registry applications icons; do
       rm -r "$out/share/$i";
     done;
diff --git a/pkgs/applications/science/math/ginac/default.nix b/pkgs/applications/science/math/ginac/default.nix
index e20e15edeff..c55e8d9adff 100644
--- a/pkgs/applications/science/math/ginac/default.nix
+++ b/pkgs/applications/science/math/ginac/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ cln ];
 
-  buildInputs = [ readline ] ++ stdenv.lib.optional stdenv.isDarwin gmp;
+  buildInputs = [ readline ] ++ lib.optional stdenv.isDarwin gmp;
 
   nativeBuildInputs = [ pkgconfig python ];
 
diff --git a/pkgs/applications/science/math/glsurf/default.nix b/pkgs/applications/science/math/glsurf/default.nix
index 09d0d524168..599d4bac8e7 100644
--- a/pkgs/applications/science/math/glsurf/default.nix
+++ b/pkgs/applications/science/math/glsurf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocamlPackages, libGLU, libGL, freeglut
+{ lib, stdenv, fetchurl, ocamlPackages, libGLU, libGL, freeglut
 , libmysqlclient, mpfr, gmp, libtiff, libjpeg, libpng, giflib
 }:
 
@@ -26,6 +26,6 @@ stdenv.mkDerivation {
   meta = {
     homepage = "https://raffalli.eu/~christophe/glsurf/";
     description = "A program to draw implicit surfaces and curves";
-    license = stdenv.lib.licenses.lgpl21;
+    license = lib.licenses.lgpl21;
   };
 }
diff --git a/pkgs/applications/science/math/gmsh/default.nix b/pkgs/applications/science/math/gmsh/default.nix
index 1b6dc2ae007..4ed9c963ba3 100644
--- a/pkgs/applications/science/math/gmsh/default.nix
+++ b/pkgs/applications/science/math/gmsh/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
+{ lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
 , zlib, libGL, libGLU, xorg, opencascade-occt }:
 
 assert (!blas.isILP64) && (!lapack.isILP64);
@@ -24,6 +24,6 @@ stdenv.mkDerivation rec {
     description = "A three-dimensional finite element mesh generator";
     homepage = "http://gmsh.info/";
     platforms = [ "x86_64-linux" ];
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/applications/science/math/gurobi/default.nix b/pkgs/applications/science/math/gurobi/default.nix
index f2f406991e3..6066d0325f5 100644
--- a/pkgs/applications/science/math/gurobi/default.nix
+++ b/pkgs/applications/science/math/gurobi/default.nix
@@ -6,7 +6,7 @@ in stdenv.mkDerivation rec {
   pname = "gurobi";
   version = "${majorVersion}.0";
 
-  src = with stdenv.lib; fetchurl {
+  src = with lib; fetchurl {
     url = "http://packages.gurobi.com/${versions.majorMinor version}/gurobi${version}_linux64.tar.gz";
     sha256 = "1yjqbzqnq4jjkjm616d36bgd3rmqr0a1ii17n0prpdjzmdlq63dz";
   };
diff --git a/pkgs/applications/science/math/mathematica/10.nix b/pkgs/applications/science/math/mathematica/10.nix
index 277fb1984c4..9a8f05bc575 100644
--- a/pkgs/applications/science/math/mathematica/10.nix
+++ b/pkgs/applications/science/math/mathematica/10.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , coreutils
 , patchelf
 , requireFile
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
 
   src = requireFile rec {
     name = "Mathematica_${version}_LINUX.sh";
-    message = '' 
+    message = ''
       This nix expression requires that ${name} is
       already part of the store. Find the file on your Mathematica CD
       and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
@@ -69,9 +69,9 @@ stdenv.mkDerivation rec {
     libSM
   ]);
 
-  ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
 
@@ -104,7 +104,7 @@ stdenv.mkDerivation rec {
         echo "patching $f executable <<"
         patchelf --shrink-rpath "$f"
         patchelf \
-	  --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
           --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
           "$f" \
           && patchelf --shrink-rpath "$f" \
@@ -131,6 +131,6 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Wolfram Mathematica computational software system";
     homepage = "http://www.wolfram.com/mathematica/";
-    license = stdenv.lib.licenses.unfree;
+    license = lib.licenses.unfree;
   };
 }
diff --git a/pkgs/applications/science/math/mathematica/11.nix b/pkgs/applications/science/math/mathematica/11.nix
index 1c698a5e542..b8270cca908 100644
--- a/pkgs/applications/science/math/mathematica/11.nix
+++ b/pkgs/applications/science/math/mathematica/11.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , coreutils
 , patchelf
 , requireFile
@@ -26,7 +26,7 @@
 let
   l10n =
     import ./l10ns.nix {
-      lib = stdenv.lib;
+      lib = lib;
       inherit requireFile lang;
       majorVersion = "11";
     };
@@ -70,9 +70,9 @@ stdenv.mkDerivation rec {
     libSM
   ]);
 
-  ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
 
@@ -118,7 +118,7 @@ stdenv.mkDerivation rec {
         echo "patching $f executable <<"
         patchelf --shrink-rpath "$f"
         patchelf \
-	  --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
           --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
           "$f" \
           && patchelf --shrink-rpath "$f" \
@@ -145,6 +145,6 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Wolfram Mathematica computational software system";
     homepage = "http://www.wolfram.com/mathematica/";
-    license = stdenv.lib.licenses.unfree;
+    license = lib.licenses.unfree;
   };
 }
diff --git a/pkgs/applications/science/math/mathematica/9.nix b/pkgs/applications/science/math/mathematica/9.nix
index d0967485c01..43d7853e3d9 100644
--- a/pkgs/applications/science/math/mathematica/9.nix
+++ b/pkgs/applications/science/math/mathematica/9.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , coreutils
 , patchelf
 , requireFile
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
 
   src = requireFile {
     name = "Mathematica_9.0.0_LINUX.sh";
-    message = '' 
+    message = ''
       This nix expression requires that Mathematica_9.0.0_LINUX.sh is
       already part of the store. Find the file on your Mathematica CD
       and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
@@ -59,9 +59,9 @@ stdenv.mkDerivation rec {
     libxcb
   ]);
 
-  ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   phases = "unpackPhase installPhase fixupPhase";
 
@@ -117,6 +117,6 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Wolfram Mathematica computational software system";
     homepage = "http://www.wolfram.com/mathematica/";
-    license = stdenv.lib.licenses.unfree;
+    license = lib.licenses.unfree;
   };
 }
diff --git a/pkgs/applications/science/math/mathematica/default.nix b/pkgs/applications/science/math/mathematica/default.nix
index e91ad5e5f8c..497592f1c06 100644
--- a/pkgs/applications/science/math/mathematica/default.nix
+++ b/pkgs/applications/science/math/mathematica/default.nix
@@ -28,7 +28,7 @@
 let
   l10n =
     import ./l10ns.nix {
-      lib = stdenv.lib;
+      lib = lib;
       inherit requireFile lang;
     };
 in
@@ -74,9 +74,9 @@ stdenv.mkDerivation rec {
     libSM
   ]);
 
-  ldpath = stdenv.lib.makeLibraryPath buildInputs
-    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-      (":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
 
   unpackPhase = ''
     echo "=== Extracting makeself archive ==="
@@ -125,7 +125,7 @@ stdenv.mkDerivation rec {
         echo "patching $f executable <<"
         patchelf --shrink-rpath "$f"
         patchelf \
-	  --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
           --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
           "$f" \
           && patchelf --shrink-rpath "$f" \
@@ -144,7 +144,7 @@ stdenv.mkDerivation rec {
   '';
 
   dontBuild = true;
-  
+
   # This is primarily an IO bound build; there's little benefit to building remotely.
   preferLocalBuild = true;
 
diff --git a/pkgs/applications/science/math/maxima/default.nix b/pkgs/applications/science/math/maxima/default.nix
index cdc81a87646..01f086c92c7 100644
--- a/pkgs/applications/science/math/maxima/default.nix
+++ b/pkgs/applications/science/math/maxima/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, sbcl, texinfo, perl, python, makeWrapper, autoreconfHook
+{ lib, stdenv, fetchurl, fetchpatch, sbcl, texinfo, perl, python, makeWrapper, autoreconfHook
 , rlwrap ? null, tk ? null, gnuplot ? null, ecl ? null, ecl-fasl ? false
 }:
 
@@ -7,8 +7,8 @@ let
   version = "5.44.0";
 
   searchPath =
-    stdenv.lib.makeBinPath
-      (stdenv.lib.filter (x: x != null) [ sbcl ecl rlwrap tk gnuplot ]);
+    lib.makeBinPath
+      (lib.filter (x: x != null) [ sbcl ecl rlwrap tk gnuplot ]);
 in
 stdenv.mkDerivation ({
   inherit version;
@@ -21,7 +21,7 @@ stdenv.mkDerivation ({
 
   nativeBuildInputs = [ autoreconfHook ];
 
-  buildInputs = stdenv.lib.filter (x: x != null) [
+  buildInputs = lib.filter (x: x != null) [
     sbcl ecl texinfo perl python makeWrapper
     gnuplot   # required in the test suite
   ];
@@ -40,7 +40,7 @@ stdenv.mkDerivation ({
     ln -s ../maxima/${version}/emacs $out/share/emacs/site-lisp
     ln -s ../maxima/${version}/doc $out/share/doc/maxima
   ''
-   + (stdenv.lib.optionalString ecl-fasl ''
+   + (lib.optionalString ecl-fasl ''
      cp src/binary-ecl/maxima.fas* "$out/lib/maxima/${version}/binary-ecl/"
    '')
   ;
@@ -63,7 +63,7 @@ stdenv.mkDerivation ({
       url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/undoing_true_false_printing_patch.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
       sha256 = "0fvi3rcjv6743sqsbgdzazy9jb6r1p1yq63zyj9fx42wd1hgf7yx";
     })
-  ] ++ stdenv.lib.optionals ecl-fasl [
+  ] ++ lib.optionals ecl-fasl [
     # build fasl, needed for ECL support
     (fetchpatch {
       url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/maxima.system.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
@@ -94,7 +94,7 @@ stdenv.mkDerivation ({
   meta = {
     description = "Computer algebra system";
     homepage = "http://maxima.sourceforge.net";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
 
     longDescription = ''
       Maxima is a fairly complete computer algebra system written in
@@ -103,7 +103,7 @@ stdenv.mkDerivation ({
       symbolic integration, 3D plotting, and an ODE solver.
     '';
 
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.peti ];
+    platforms = lib.platforms.unix;
+    maintainers = [ lib.maintainers.peti ];
   };
 })
diff --git a/pkgs/applications/science/math/msieve/default.nix b/pkgs/applications/science/math/msieve/default.nix
index db7a1c14906..679b29cb062 100644
--- a/pkgs/applications/science/math/msieve/default.nix
+++ b/pkgs/applications/science/math/msieve/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, zlib, gmp, ecm }:
+{lib, stdenv, fetchurl, zlib, gmp, ecm }:
 
 stdenv.mkDerivation {
   name = "msieve-1.53";
@@ -22,9 +22,9 @@ stdenv.mkDerivation {
 
   meta = {
     description = "A C library implementing a suite of algorithms to factor large integers";
-    license = stdenv.lib.licenses.publicDomain;
+    license = lib.licenses.publicDomain;
     homepage = "http://msieve.sourceforge.net/";
-    maintainers = [ stdenv.lib.maintainers.roconnor ];
-    platforms = [ "x86_64-linux" ] ++ stdenv.lib.platforms.darwin;
+    maintainers = [ lib.maintainers.roconnor ];
+    platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
   };
 }
diff --git a/pkgs/applications/science/math/palp/default.nix b/pkgs/applications/science/math/palp/default.nix
index b5b9577d493..97b5f88e55b 100644
--- a/pkgs/applications/science/math/palp/default.nix
+++ b/pkgs/applications/science/math/palp/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     "format"
   ];
 
-  patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
+  patchPhase = lib.optionalString stdenv.isDarwin ''
     substituteInPlace GNUmakefile --replace gcc cc
   '';
 
@@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
     for file in poly class cws nef mori; do
         cp -p $file.x "$out/bin/$file-${dim}d.x"
     done
-  '' + stdenv.lib.optionalString doSymlink ''
+  '' + lib.optionalString doSymlink ''
     cd "$out/bin"
     for file in poly class cws nef mori; do
         ln -sf $file-6d.x $file.x
diff --git a/pkgs/applications/science/math/pari/default.nix b/pkgs/applications/science/math/pari/default.nix
index dd965e17c73..a99cbbbe0df 100644
--- a/pkgs/applications/science/math/pari/default.nix
+++ b/pkgs/applications/science/math/pari/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     # Versions with current majorMinor values are at http://pari.math.u-bordeaux.fr/pub/pari/unix/${pname}-${version}.tar.gz
-    url = "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
+    url = "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
     sha256 = "sha256-v8iPxPc1L0hA5uNSxy8DacvqikVAOxg0piafNwmXCxw=";
   };
 
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
     libX11
     tex
     perl
-  ] ++ stdenv.lib.optionals withThread [
+  ] ++ lib.optionals withThread [
     libpthreadstubs
   ];
 
@@ -34,14 +34,14 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--with-gmp=${gmp.dev}"
     "--with-readline=${readline.dev}"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--host=x86_64-darwin"
-  ++ stdenv.lib.optional withThread "--mt=pthread";
+  ] ++ lib.optional stdenv.isDarwin "--host=x86_64-darwin"
+  ++ lib.optional withThread "--mt=pthread";
 
   preConfigure = ''
     export LD=$CC
   '';
 
-  postConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+  postConfigure = lib.optionalString stdenv.isDarwin ''
     echo 'echo x86_64-darwin' > config/arch-osname
   '';
 
diff --git a/pkgs/applications/science/math/pcalc/default.nix b/pkgs/applications/science/math/pcalc/default.nix
index f372357fe7d..1ee45ca266a 100644
--- a/pkgs/applications/science/math/pcalc/default.nix
+++ b/pkgs/applications/science/math/pcalc/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchgit, bison, flex }:
+{ lib, stdenv, fetchgit, bison, flex }:
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   pname = "pcalc";
@@ -19,8 +19,8 @@ stdenv.mkDerivation rec {
     homepage = "http://pcalc.sourceforge.net/";
     description = "Programmer's calculator";
     license = licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [ ftrvxmtrx ];
-    platforms = stdenv.lib.platforms.linux;
+    maintainers = with lib.maintainers; [ ftrvxmtrx ];
+    platforms = lib.platforms.linux;
     inherit version;
   };
 }
diff --git a/pkgs/applications/science/math/perseus/default.nix b/pkgs/applications/science/math/perseus/default.nix
index 55293e6c8a7..242f2e2cea5 100644
--- a/pkgs/applications/science/math/perseus/default.nix
+++ b/pkgs/applications/science/math/perseus/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip }:
+{ lib, stdenv, fetchurl, unzip }:
 
 stdenv.mkDerivation {
   name = "perseus-4-beta";
@@ -33,8 +33,8 @@ stdenv.mkDerivation {
       matrices and so forth.
     '';
     homepage = "http://www.sas.upenn.edu/~vnanda/perseus/index.html";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = with stdenv.lib.maintainers; [erikryb];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [erikryb];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/math/polymake/default.nix b/pkgs/applications/science/math/polymake/default.nix
index d4f13f84f81..552881c5f1a 100644
--- a/pkgs/applications/science/math/polymake/default.nix
+++ b/pkgs/applications/science/math/polymake/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ lib, stdenv, fetchurl
 , ninja, libxml2, libxslt, readline, perl, gmp, mpfr, boost
 , bliss, ppl, singular, cddlib, lrs, nauty
 , ant, openjdk
@@ -39,9 +39,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "Software for research in polyhedral geometry";
-    license = stdenv.lib.licenses.gpl2 ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2 ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     homepage = "https://www.polymake.org/doku.php";
   };
 }
diff --git a/pkgs/applications/science/math/pspp/default.nix b/pkgs/applications/science/math/pspp/default.nix
index d6c5b58f0d5..9d76ef75d26 100644
--- a/pkgs/applications/science/math/pspp/default.nix
+++ b/pkgs/applications/science/math/pspp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libxml2, readline, zlib, perl, cairo, gtk3, gsl
+{ lib, stdenv, fetchurl, libxml2, readline, zlib, perl, cairo, gtk3, gsl
 , pkgconfig, gtksourceview, pango, gettext, dconf
 , makeWrapper, gsettings-desktop-schemas, hicolor-icon-theme
 , texinfo, ssw, python3
@@ -28,13 +28,13 @@ stdenv.mkDerivation rec {
      --prefix XDG_DATA_DIRS : "$out/share" \
      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS" \
      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
-     --prefix GIO_EXTRA_MODULES : "${stdenv.lib.getLib dconf}/lib/gio/modules"
+     --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules"
   '';
 
   meta = {
     homepage = "https://www.gnu.org/software/pspp/";
     description = "A free replacement for SPSS, a program for statistical analysis of sampled data";
-    license = stdenv.lib.licenses.gpl3Plus;
+    license = lib.licenses.gpl3Plus;
 
     longDescription = ''
       PSPP is a program for statistical analysis of sampled data. It is
@@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
       more traditional syntax commands.
     '';
 
-    platforms = stdenv.lib.platforms.unix;
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/math/ratpoints/default.nix b/pkgs/applications/science/math/ratpoints/default.nix
index fb205a69f03..823c8abf529 100644
--- a/pkgs/applications/science/math/ratpoints/default.nix
+++ b/pkgs/applications/science/math/ratpoints/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, gmp }:
+{ lib, stdenv, fetchurl, fetchpatch, gmp }:
 stdenv.mkDerivation rec {
   pname = "ratpoints";
   version = "2.1.3.p4";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ gmp ];
 
   makeFlags = [ "CC=cc" ];
-  buildFlags = stdenv.lib.optional stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
+  buildFlags = lib.optional stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
   installFlags = [ "INSTALL_DIR=$(out)" ];
 
   preInstall = ''mkdir -p "$out"/{bin,share,lib,include}'';
@@ -28,9 +28,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = ''A program to find rational points on hyperelliptic curves'';
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
     homepage = "http://www.mathe2.uni-bayreuth.de/stoll/programs/";
     updateWalker = true;
   };
diff --git a/pkgs/applications/science/math/ripser/default.nix b/pkgs/applications/science/math/ripser/default.nix
index 1c8ced5ed22..21f0d003391 100644
--- a/pkgs/applications/science/math/ripser/default.nix
+++ b/pkgs/applications/science/math/ripser/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchFromGitHub
+{ lib, stdenv, fetchurl, fetchFromGitHub
 , assembleReductionMatrix ? false
 , useCoefficients ? false
 , indicateProgress ? false
@@ -6,14 +6,14 @@
 , fileFormat ? "lowerTriangularCsv"
 }:
 
-with stdenv.lib;
+with lib;
 
 assert assertOneOf "fileFormat" fileFormat
   ["lowerTriangularCsv" "upperTriangularCsv" "dipha"];
 assert useGoogleHashmap -> sparsehash != null;
 
 let
-  inherit (stdenv.lib) optional;
+  inherit (lib) optional;
   version = "1.0";
 in
 stdenv.mkDerivation {
@@ -60,8 +60,8 @@ stdenv.mkDerivation {
   meta = {
     description = "A lean C++ code for the computation of Vietoris–Rips persistence barcodes";
     homepage = "https://github.com/Ripser/ripser";
-    license = stdenv.lib.licenses.lgpl3;
-    maintainers = with stdenv.lib.maintainers; [erikryb];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.lgpl3;
+    maintainers = with lib.maintainers; [erikryb];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/math/sage/sage.nix b/pkgs/applications/science/math/sage/sage.nix
index b9256e32f8b..106f9eea309 100644
--- a/pkgs/applications/science/math/sage/sage.nix
+++ b/pkgs/applications/science/math/sage/sage.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
     mkdir -p "$out/bin"
     makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage" \
       --set SAGE_DOC_SRC_OVERRIDE "${src}/src/doc" ${
-        stdenv.lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
+        lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
       } \
       --prefix JUPYTER_PATH : "${kernel-specs}"
   '';
diff --git a/pkgs/applications/science/math/scilab/default.nix b/pkgs/applications/science/math/scilab/default.nix
index 24b3feef51e..95c6c23fb09 100644
--- a/pkgs/applications/science/math/scilab/default.nix
+++ b/pkgs/applications/science/math/scilab/default.nix
@@ -35,14 +35,14 @@ stdenv.mkDerivation rec {
     # do not compile with PVM library
     "--without-pvm"
     # compile with GTK
-    (stdenv.lib.enableFeature withGtk "gtk")
-    (stdenv.lib.enableFeature withGtk "gtk2")
+    (lib.enableFeature withGtk "gtk")
+    (lib.enableFeature withGtk "gtk2")
     # compile with ocaml
-    (stdenv.lib.withFeature withOCaml "ocaml")
+    (lib.withFeature withOCaml "ocaml")
     # do not compile Java interface
     "--without-java"
     # use the X Window System
-    (stdenv.lib.withFeature withX "x")
+    (lib.withFeature withX "x")
     # compile with TCL/TK
   ] ++ lib.optionals withTk [
     "--with-tk"
diff --git a/pkgs/applications/science/math/scotch/default.nix b/pkgs/applications/science/math/scotch/default.nix
index 75a6b2dba68..6f8753ff38a 100644
--- a/pkgs/applications/science/math/scotch/default.nix
+++ b/pkgs/applications/science/math/scotch/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, bison, openmpi, flex, zlib}:
+{ lib, stdenv, fetchurl, bison, openmpi, flex, zlib}:
 
 stdenv.mkDerivation rec {
   version = "6.0.4";
@@ -24,13 +24,13 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering";
     longDescription = ''
-      Scotch is a software package for graph and mesh/hypergraph partitioning, graph clustering, 
+      Scotch is a software package for graph and mesh/hypergraph partitioning, graph clustering,
       and sparse matrix ordering.
     '';
     homepage = "http://www.labri.fr/perso/pelegrin/scotch";
-    license = stdenv.lib.licenses.cecill-c;
-    maintainers = [ stdenv.lib.maintainers.bzizou ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.cecill-c;
+    maintainers = [ lib.maintainers.bzizou ];
+    platforms = lib.platforms.linux;
   };
 }
 
diff --git a/pkgs/applications/science/math/weka/default.nix b/pkgs/applications/science/math/weka/default.nix
index c4fc19d6c6b..179801da379 100644
--- a/pkgs/applications/science/math/weka/default.nix
+++ b/pkgs/applications/science/math/weka/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, fetchurl, jre, unzip, makeWrapper }:
+{ lib, stdenv, fetchurl, jre, unzip, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "weka";
   version = "3.9.2";
 
   src = fetchurl {
-    url = "mirror://sourceforge/weka/${stdenv.lib.replaceChars ["."]["-"] "${pname}-${version}"}.zip";
+    url = "mirror://sourceforge/weka/${lib.replaceChars ["."]["-"] "${pname}-${version}"}.zip";
     sha256 = "0zwmhspmqb0a7cm6k6i0s6q3w19ws1g9dx3cp2v3g3vsif6cdh31";
   };
 
@@ -24,8 +24,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://www.cs.waikato.ac.nz/ml/weka/";
     description = "Collection of machine learning algorithms for data mining tasks";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.mimame ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.mimame ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/math/yacas/default.nix b/pkgs/applications/science/math/yacas/default.nix
index 06aab669df5..05d1f780bf3 100644
--- a/pkgs/applications/science/math/yacas/default.nix
+++ b/pkgs/applications/science/math/yacas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, perl
+{ lib, stdenv, fetchFromGitHub, cmake, perl
 , enableGui ? false, qt5
 , enableJupyter ? false, boost, jsoncpp, openssl, zmqpp
 }:
@@ -24,16 +24,16 @@ stdenv.mkDerivation rec {
   # Perl is only for the documentation
   nativeBuildInputs = [ cmake perl ];
   buildInputs = [
-  ] ++ stdenv.lib.optionals enableGui (with qt5; [ qtbase qtwebkit ])
-    ++ stdenv.lib.optionals enableJupyter [ boost jsoncpp openssl zmqpp ]
+  ] ++ lib.optionals enableGui (with qt5; [ qtbase qtwebkit ])
+    ++ lib.optionals enableJupyter [ boost jsoncpp openssl zmqpp ]
     ;
 
   meta = {
     description = "Easy to use, general purpose Computer Algebra System";
     homepage = "http://www.yacas.org/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
     broken = enableGui || enableJupyter;
   };
 }
diff --git a/pkgs/applications/science/medicine/aliza/default.nix b/pkgs/applications/science/medicine/aliza/default.nix
index b4e56591f9c..c6bfd6361f2 100644
--- a/pkgs/applications/science/medicine/aliza/default.nix
+++ b/pkgs/applications/science/medicine/aliza/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, rpmextract, makeWrapper, patchelf, qt4, zlib, libX11, libXt, libSM, libICE, libXext, libGLU, libGL }:
+{ lib, stdenv, fetchurl, rpmextract, makeWrapper, patchelf, qt4, zlib, libX11, libXt, libSM, libICE, libXext, libGLU, libGL }:
 
-with stdenv.lib;
+with lib;
 stdenv.mkDerivation {
   pname = "aliza";
   version = "1.98.32";
@@ -27,7 +27,7 @@ stdenv.mkDerivation {
   '';
 
   postInstall = let
-    libs = stdenv.lib.makeLibraryPath [ qt4 zlib stdenv.cc.cc libSM libICE libX11 libXext libXt libGLU libGL ];
+    libs = lib.makeLibraryPath [ qt4 zlib stdenv.cc.cc libSM libICE libX11 libXext libXt libGLU libGL ];
   in ''
     ${patchelf}/bin/patchelf \
       --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
diff --git a/pkgs/applications/science/medicine/dcmtk/default.nix b/pkgs/applications/science/medicine/dcmtk/default.nix
index 817ab578a82..0312043306a 100644
--- a/pkgs/applications/science/medicine/dcmtk/default.nix
+++ b/pkgs/applications/science/medicine/dcmtk/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, zlib, libtiff, libxml2, openssl, libiconv, libpng, cmake }:
+{ lib, stdenv, fetchFromGitHub, zlib, libtiff, libxml2, openssl, libiconv, libpng, cmake }:
 
-with stdenv.lib;
+with lib;
 stdenv.mkDerivation rec {
   pname = "dcmtk";
   version = "3.6.5";
diff --git a/pkgs/applications/science/misc/boinc/default.nix b/pkgs/applications/science/misc/boinc/default.nix
index 802abae80e1..e549fda1162 100644
--- a/pkgs/applications/science/misc/boinc/default.nix
+++ b/pkgs/applications/science/misc/boinc/default.nix
@@ -1,4 +1,4 @@
-{ fetchFromGitHub, stdenv, autoconf, automake, pkgconfig, m4, curl,
+{ fetchFromGitHub, lib, stdenv, autoconf, automake, pkgconfig, m4, curl,
 libGLU, libGL, libXmu, libXi, freeglut, libjpeg, libtool, wxGTK30, xcbutil,
 sqlite, gtk2, patchelf, libXScrnSaver, libnotify, libX11, libxcb }:
 
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Free software for distributed and grid computing";
     homepage = "https://boinc.berkeley.edu/";
-    license = stdenv.lib.licenses.lgpl2Plus;
-    platforms = stdenv.lib.platforms.linux;  # arbitrary choice
+    license = lib.licenses.lgpl2Plus;
+    platforms = lib.platforms.linux;  # arbitrary choice
   };
 }
diff --git a/pkgs/applications/science/misc/cytoscape/default.nix b/pkgs/applications/science/misc/cytoscape/default.nix
index 647492bbe31..db98e0db348 100644
--- a/pkgs/applications/science/misc/cytoscape/default.nix
+++ b/pkgs/applications/science/misc/cytoscape/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, jre, makeWrapper, substituteAll, coreutils }:
+{ lib, stdenv, fetchurl, jre, makeWrapper, substituteAll, coreutils }:
 
 stdenv.mkDerivation rec {
   pname = "cytoscape";
@@ -36,8 +36,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://www.cytoscape.org";
     description = "A general platform for complex network analysis and visualization";
-    license = stdenv.lib.licenses.lgpl21;
-    maintainers = [stdenv.lib.maintainers.mimame];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.lgpl21;
+    maintainers = [lib.maintainers.mimame];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/science/misc/fityk/default.nix b/pkgs/applications/science/misc/fityk/default.nix
index 18def1d24e2..3198b40711d 100644
--- a/pkgs/applications/science/misc/fityk/default.nix
+++ b/pkgs/applications/science/misc/fityk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, wxGTK30, boost, lua, zlib, bzip2
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, wxGTK30, boost, lua, zlib, bzip2
 , xylib, readline, gnuplot, swig3 }:
 
 let
@@ -21,8 +21,8 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Curve fitting and peak fitting software";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
     homepage = "http://fityk.nieto.pl/";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/misc/foldingathome/client.nix b/pkgs/applications/science/misc/foldingathome/client.nix
index bf7145113f5..cc3d5445b59 100644
--- a/pkgs/applications/science/misc/foldingathome/client.nix
+++ b/pkgs/applications/science/misc/foldingathome/client.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , autoPatchelfHook
 , buildFHSUserEnv
 , dpkg
@@ -9,7 +9,7 @@
 , extraPkgs ? []
 }:
 let
-  majMin = stdenv.lib.versions.majorMinor version;
+  majMin = lib.versions.majorMinor version;
   version = "7.6.13";
 
   fahclient = stdenv.mkDerivation rec {
@@ -52,8 +52,8 @@ buildFHSUserEnv {
   meta = {
     description = "Folding@home client";
     homepage = "https://foldingathome.org/";
-    license = stdenv.lib.licenses.unfree;
-    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/applications/science/misc/foldingathome/control.nix b/pkgs/applications/science/misc/foldingathome/control.nix
index 85be61f6686..832c6311759 100644
--- a/pkgs/applications/science/misc/foldingathome/control.nix
+++ b/pkgs/applications/science/misc/foldingathome/control.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , autoPatchelfHook
 , dpkg
 , fahviewer
@@ -7,7 +7,7 @@
 , python2
 }:
 let
-  majMin = stdenv.lib.versions.majorMinor version;
+  majMin = lib.versions.majorMinor version;
   version = "7.6.21";
 
   python = python2.withPackages
@@ -53,8 +53,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Folding@home control";
     homepage = "https://foldingathome.org/";
-    license = stdenv.lib.licenses.unfree;
-    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/applications/science/misc/foldingathome/viewer.nix b/pkgs/applications/science/misc/foldingathome/viewer.nix
index a383de621f2..52ca9c9e623 100644
--- a/pkgs/applications/science/misc/foldingathome/viewer.nix
+++ b/pkgs/applications/science/misc/foldingathome/viewer.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , autoPatchelfHook
 , dpkg
 , fetchurl
@@ -10,7 +10,7 @@
 , zlib
 }:
 let
-  majMin = stdenv.lib.versions.majorMinor version;
+  majMin = lib.versions.majorMinor version;
   version = "7.6.21";
 in
 stdenv.mkDerivation rec {
@@ -48,8 +48,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Folding@home viewer";
     homepage = "https://foldingathome.org/";
-    license = stdenv.lib.licenses.unfree;
-    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/applications/science/misc/golly/beta.nix b/pkgs/applications/science/misc/golly/beta.nix
index 36de6a1d4c5..7741f7ba65b 100644
--- a/pkgs/applications/science/misc/golly/beta.nix
+++ b/pkgs/applications/science/misc/golly/beta.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchgit
+{lib, stdenv, fetchgit
 , wxGTK, perl, python2, zlib, libGLU, libGL, libX11
 , automake, autoconf
 }:
@@ -43,9 +43,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "Cellular automata simulation program";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     downloadPage = "https://sourceforge.net/projects/golly/files/golly";
   };
 }
diff --git a/pkgs/applications/science/misc/golly/default.nix b/pkgs/applications/science/misc/golly/default.nix
index 1478bb64318..be61ec86b32 100644
--- a/pkgs/applications/science/misc/golly/default.nix
+++ b/pkgs/applications/science/misc/golly/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, wxGTK, perl, python2, zlib, libGLU, libGL, libX11}:
+{lib, stdenv, fetchurl, wxGTK, perl, python2, zlib, libGLU, libGL, libX11}:
 stdenv.mkDerivation rec {
   pname = "golly";
   version = "3.3";
@@ -31,9 +31,9 @@ stdenv.mkDerivation rec {
   meta = {
     inherit version;
     description = "Cellular automata simulation program";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     downloadPage = "https://sourceforge.net/projects/golly/files/golly";
   };
 }
diff --git a/pkgs/applications/science/misc/megam/default.nix b/pkgs/applications/science/misc/megam/default.nix
index 8bb64932f20..6c55027d3c6 100644
--- a/pkgs/applications/science/misc/megam/default.nix
+++ b/pkgs/applications/science/misc/megam/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, ocaml, makeWrapper, ncurses }:
+{ fetchurl, lib, stdenv, ocaml, makeWrapper, ncurses }:
 
 let version = "0.92"; in
 stdenv.mkDerivation {
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   };
 
   patches = [ ./ocaml-includes.patch ./ocaml-3.12.patch ];
-  
+
   buildInputs = [ ocaml ncurses ];
 
   nativeBuildInputs = [ makeWrapper ];
@@ -42,6 +42,6 @@ stdenv.mkDerivation {
     license = "non-commercial";
 
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;  # arbitrary choice
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;  # arbitrary choice
   };
 }
diff --git a/pkgs/applications/science/misc/openmodelica/default.nix b/pkgs/applications/science/misc/openmodelica/default.nix
index 8b027b52687..a18131993e5 100644
--- a/pkgs/applications/science/misc/openmodelica/default.nix
+++ b/pkgs/applications/science/misc/openmodelica/default.nix
@@ -5,7 +5,7 @@ doxygen, boost, openscenegraph, gnome2, xorg, git, bash, gtk2, makeWrapper }:
 
 let
 
-  fakegit = import ./fakegit.nix {inherit stdenv fetchgit fetchsvn bash;} ;
+  fakegit = import ./fakegit.nix { inherit lib stdenv fetchgit fetchsvn bash; };
 
 in
 
@@ -38,7 +38,7 @@ stdenv.mkDerivation {
     for e in $(cd $out/bin && ls); do
       wrapProgram $out/bin/$e \
         --prefix PATH : "${gnumake}/bin" \
-        --prefix LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ lapack blas ]}"
+        --prefix LIBRARY_PATH : "${lib.makeLibraryPath [ lapack blas ]}"
     done
   '';
 
diff --git a/pkgs/applications/science/misc/openmodelica/fakegit.nix b/pkgs/applications/science/misc/openmodelica/fakegit.nix
index de69626cd3e..47cca7c7491 100644
--- a/pkgs/applications/science/misc/openmodelica/fakegit.nix
+++ b/pkgs/applications/science/misc/openmodelica/fakegit.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchgit, fetchsvn, bash } :
+{ lib, stdenv, fetchgit, fetchsvn, bash }:
 
 let
   mkscript = path : text : ''
@@ -11,9 +11,9 @@ let
     sed -i "s@%out@$out@g" ${path}
     chmod +x ${path}
   '';
-  
+
   hashname = r: let
-    rpl = stdenv.lib.replaceChars [":" "/"] ["_" "_"];
+    rpl = lib.replaceChars [":" "/"] ["_" "_"];
   in
     (rpl r.url) + "-" + (rpl r.rev);
 
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
 
   buildCommand = ''
     mkdir -pv $out/repos
-    ${stdenv.lib.concatMapStrings
+    ${lib.concatMapStrings
        (r : ''
         cp -r ${fetchgit r} $out/repos/${hashname r}
        ''
@@ -55,7 +55,7 @@ stdenv.mkDerivation {
       chmod u+w -R $DEST
     ''}
 
-    ${stdenv.lib.concatMapStrings
+    ${lib.concatMapStrings
        (r : ''
         cp -r ${fetchsvn r} $out/repos/${hashname r}
        ''
diff --git a/pkgs/applications/science/misc/openmvg/default.nix b/pkgs/applications/science/misc/openmvg/default.nix
index 5db6092fa36..bf21983adcd 100644
--- a/pkgs/applications/science/misc/openmvg/default.nix
+++ b/pkgs/applications/science/misc/openmvg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, pkgconfig, cmake
+{ lib, stdenv, fetchFromGitHub, pkgconfig, cmake
 , libjpeg ? null
 , zlib ? null
 , libpng ? null
@@ -42,8 +42,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A library for computer-vision scientists and targeted for the Multiple View Geometry community";
     homepage = "https://openmvg.readthedocs.io/en/latest/";
-    license = stdenv.lib.licenses.mpl20;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ mdaiter ];
+    license = lib.licenses.mpl20;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ mdaiter ];
   };
 }
diff --git a/pkgs/applications/science/misc/root/5.nix b/pkgs/applications/science/misc/root/5.nix
index d8e6ae06a24..144827413b5 100644
--- a/pkgs/applications/science/misc/root/5.nix
+++ b/pkgs/applications/science/misc/root/5.nix
@@ -13,8 +13,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake pkg-config ];
   buildInputs = [ pcre python2 zlib libxml2 lz4 lzma gsl_1 xxHash ]
-    ++ stdenv.lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU libGL ]
-    ++ stdenv.lib.optionals (stdenv.isDarwin) [ Cocoa OpenGL ]
+    ++ lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU libGL ]
+    ++ lib.optionals (stdenv.isDarwin) [ Cocoa OpenGL ]
     ;
 
   patches = [
@@ -30,14 +30,14 @@ stdenv.mkDerivation rec {
 
   preConfigure = ''
     patchShebangs build/unix/
-    ln -s ${stdenv.lib.getDev stdenv.cc.libc}/include/AvailabilityMacros.h cint/cint/include/
+    ln -s ${lib.getDev stdenv.cc.libc}/include/AvailabilityMacros.h cint/cint/include/
   ''
   # Fix CINTSYSDIR for "build" version of rootcint
   # This is probably a bug that breaks out-of-source builds
   + ''
     substituteInPlace cint/cint/src/loadfile.cxx\
       --replace 'env = "cint";' 'env = "'`pwd`'/cint";'
-  '' + stdenv.lib.optionalString noSplash ''
+  '' + lib.optionalString noSplash ''
     substituteInPlace rootx/src/rootx.cxx --replace "gNoLogo = false" "gNoLogo = true"
   '';
 
@@ -75,7 +75,7 @@ stdenv.mkDerivation rec {
     "-Dxml=ON"
     "-Dxrootd=OFF"
   ]
-  ++ stdenv.lib.optional stdenv.isDarwin "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks";
+  ++ lib.optional stdenv.isDarwin "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks";
 
   setupHook = ./setup-hook.sh;
 
diff --git a/pkgs/applications/science/misc/root/default.nix b/pkgs/applications/science/misc/root/default.nix
index 8bfde114beb..425d3e1e4b9 100644
--- a/pkgs/applications/science/misc/root/default.nix
+++ b/pkgs/applications/science/misc/root/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
       --replace 'set(lcgpackages ' '#set(lcgpackages '
 
     patchShebangs build/unix/
-  '' + stdenv.lib.optionalString noSplash ''
+  '' + lib.optionalString noSplash ''
     substituteInPlace rootx/src/rootx.cxx --replace "gNoLogo = false" "gNoLogo = true"
   '';
 
@@ -70,8 +70,8 @@ stdenv.mkDerivation rec {
     "-Dxml=ON"
     "-Dxrootd=OFF"
   ]
-  ++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.lib.getDev stdenv.cc.libc}/include"
-  ++ stdenv.lib.optionals stdenv.isDarwin [
+  ++ lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${lib.getDev stdenv.cc.libc}/include"
+  ++ lib.optionals stdenv.isDarwin [
     "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks"
     "-DCMAKE_DISABLE_FIND_PACKAGE_Python2=TRUE"
 
diff --git a/pkgs/applications/science/misc/simgrid/default.nix b/pkgs/applications/science/misc/simgrid/default.nix
index 7cc702f2d53..771e79311c9 100644
--- a/pkgs/applications/science/misc/simgrid/default.nix
+++ b/pkgs/applications/science/misc/simgrid/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, cmake, perl, python3, boost, valgrind
+{ lib, stdenv, fetchFromGitLab, cmake, perl, python3, boost, valgrind
 # Optional requirements
 # Lua 5.3 needed and not available now
 #, luaSupport ? false, lua5
@@ -10,7 +10,7 @@
 , moreTests ? false
 }:
 
-with stdenv.lib;
+with lib;
 
 let
   optionOnOff = option: if option then "on" else "off";
diff --git a/pkgs/applications/science/misc/tulip/default.nix b/pkgs/applications/science/misc/tulip/default.nix
index f29cd41169d..62d638717f8 100644
--- a/pkgs/applications/science/misc/tulip/default.nix
+++ b/pkgs/applications/science/misc/tulip/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, libxml2, freetype, libGLU, libGL, glew, qt4
+{ fetchurl, lib, stdenv, libxml2, freetype, libGLU, libGL, glew, qt4
 , cmake, makeWrapper, libjpeg, python }:
 
 let version = "5.2.1"; in
@@ -31,9 +31,9 @@ stdenv.mkDerivation rec {
 
     homepage = "http://tulip.labri.fr/";
 
-    license = stdenv.lib.licenses.gpl3Plus;
+    license = lib.licenses.gpl3Plus;
 
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;  # arbitrary choice
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;  # arbitrary choice
   };
 }
diff --git a/pkgs/applications/science/misc/vite/default.nix b/pkgs/applications/science/misc/vite/default.nix
index 6f7735db82e..ed9d1852875 100644
--- a/pkgs/applications/science/misc/vite/default.nix
+++ b/pkgs/applications/science/misc/vite/default.nix
@@ -1,4 +1,4 @@
-{ fetchsvn, stdenv, cmake, qt4, libGLU, libGL }:
+{ fetchsvn, lib, stdenv, cmake, qt4, libGLU, libGL }:
 
 # ViTE 1.1 has several bugs, so use the SVN version.
 let
@@ -38,8 +38,8 @@ stdenv.mkDerivation {
     '';
 
     homepage = "http://vite.gforge.inria.fr/";
-    license = stdenv.lib.licenses.cecill20;
-    maintainers = with stdenv.lib.maintainers; [ ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.cecill20;
+    maintainers = with lib.maintainers; [ ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/science/molecular-dynamics/gromacs/default.nix b/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
index 6a243c1d917..c40faddbbf9 100644
--- a/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
+++ b/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
@@ -33,7 +33,7 @@ in stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ fftw perl hwloc ]
-  ++ (stdenv.lib.optionals mpiEnabled [ openmpi ]);
+  ++ (lib.optionals mpiEnabled [ openmpi ]);
 
   cmakeFlags = [
     "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix
index 561bb119f12..123afef03e8 100644
--- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix
+++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix
@@ -28,11 +28,11 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ fftw libpng blas lapack gzip ]
-    ++ (stdenv.lib.optionals withMPI [ mpi ]);
+    ++ (lib.optionals withMPI [ mpi ]);
 
   configurePhase = ''
     cd src
-    for pack in ${stdenv.lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
+    for pack in ${lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
   '';
 
   # Must do manual build due to LAMMPS requiring a seperate build for
diff --git a/pkgs/applications/science/physics/sacrifice/default.nix b/pkgs/applications/science/physics/sacrifice/default.nix
index 2c4757d92e4..34e4d989e95 100644
--- a/pkgs/applications/science/physics/sacrifice/default.nix
+++ b/pkgs/applications/science/physics/sacrifice/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, boost, hepmc2, lhapdf, pythia, makeWrapper }:
+{ lib, stdenv, fetchurl, boost, hepmc2, lhapdf, pythia, makeWrapper }:
 
 stdenv.mkDerivation {
   pname = "sacrifice";
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   preConfigure = ''
     substituteInPlace configure --replace HAVE_LCG=yes HAVE_LCG=no
   ''
-  + stdenv.lib.optionalString stdenv.isDarwin ''
+  + lib.optionalString stdenv.isDarwin ''
     substituteInPlace configure --replace LIB_SUFFIX=\"so\" LIB_SUFFIX=\"dylib\"
   '';
 
@@ -40,9 +40,9 @@ stdenv.mkDerivation {
 
   meta = {
     description = "A standalone contribution to AGILe for steering Pythia 8";
-    license     = stdenv.lib.licenses.gpl2;
+    license     = lib.licenses.gpl2;
     homepage    = "https://agile.hepforge.org/trac/wiki/Sacrifice";
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ veprbl ];
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ veprbl ];
   };
 }
diff --git a/pkgs/applications/science/physics/xfitter/default.nix b/pkgs/applications/science/physics/xfitter/default.nix
index 0713825ccef..d0a0585e69f 100644
--- a/pkgs/applications/science/physics/xfitter/default.nix
+++ b/pkgs/applications/science/physics/xfitter/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   #
   #   gfortran: error: unrecognized command line option '-stdlib=libc++'
   #
-    stdenv.lib.optionalString stdenv.isDarwin ''
+    lib.optionalString stdenv.isDarwin ''
       substituteInPlace src/Makefile.in \
         --replace "F77LD = \$(F77)" "F77LD = \$(CXXLD)" \
     '';
@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
   buildInputs =
     [ apfel apfelgrid applgrid blas lhapdf lapack mela root5 qcdnum libtirpc ]
     # pdf2yaml requires fmemopen and open_memstream which are not readily available on Darwin
-    ++ stdenv.lib.optional (!stdenv.isDarwin) libyaml
+    ++ lib.optional (!stdenv.isDarwin) libyaml
     ;
   propagatedBuildInputs = [ lynx ];
 
diff --git a/pkgs/applications/science/programming/fdr/default.nix b/pkgs/applications/science/programming/fdr/default.nix
index 3ac8267d8ae..8beecf2def9 100644
--- a/pkgs/applications/science/programming/fdr/default.nix
+++ b/pkgs/applications/science/programming/fdr/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation {
     sha256 = "0n2yqichym5xdawlgk3r7yha88k7ycnx6585jfrcm7043sls1i88";
   };
 
-  libPath = stdenv.lib.makeLibraryPath [
+  libPath = lib.makeLibraryPath [
     stdenv.cc.cc
     python27Packages.python
     qtbase
diff --git a/pkgs/applications/science/programming/plm/default.nix b/pkgs/applications/science/programming/plm/default.nix
index 852502e73b0..dd61c3668cc 100644
--- a/pkgs/applications/science/programming/plm/default.nix
+++ b/pkgs/applications/science/programming/plm/default.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
     description = "Free cross-platform programming exerciser";
     license = licenses.gpl3;
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.all;
+    platforms = lib.platforms.all;
     broken = true;
   };
 }
diff --git a/pkgs/applications/science/robotics/yarp/default.nix b/pkgs/applications/science/robotics/yarp/default.nix
index aa0062f8f3a..3b33096dc68 100644
--- a/pkgs/applications/science/robotics/yarp/default.nix
+++ b/pkgs/applications/science/robotics/yarp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, ace
+{ lib, stdenv, fetchFromGitHub, cmake, ace
 }:
 
 stdenv.mkDerivation rec {
@@ -28,9 +28,9 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Yet Another Robot Platform";
     homepage = "http://yarp.it";
-    license = stdenv.lib.licenses.lgpl21;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.nico202 ];
+    license = lib.licenses.lgpl21;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.nico202 ];
   };
 }