summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/SDL/default.nix28
-rw-r--r--pkgs/development/libraries/SDL2/default.nix46
-rw-r--r--pkgs/development/libraries/apr-util/default.nix24
-rw-r--r--pkgs/development/libraries/asio/generic.nix4
-rw-r--r--pkgs/development/libraries/aspell/dictionaries.nix8
-rw-r--r--pkgs/development/libraries/boost/generic.nix83
-rw-r--r--pkgs/development/libraries/cyrus-sasl/default.nix3
-rw-r--r--pkgs/development/libraries/faac/default.nix9
-rw-r--r--pkgs/development/libraries/faad2/default.nix5
-rw-r--r--pkgs/development/libraries/fftw/default.nix26
-rw-r--r--pkgs/development/libraries/geis/default.nix3
-rw-r--r--pkgs/development/libraries/glew/1.10.nix4
-rw-r--r--pkgs/development/libraries/gloox/default.nix9
-rw-r--r--pkgs/development/libraries/gtk/2.x.nix18
-rw-r--r--pkgs/development/libraries/hunspell/wrapper.nix5
-rw-r--r--pkgs/development/libraries/indicator-application/gtk2.nix4
-rw-r--r--pkgs/development/libraries/kerberos/heimdal.nix9
-rw-r--r--pkgs/development/libraries/lame/default.nix21
-rw-r--r--pkgs/development/libraries/libass/default.nix13
-rw-r--r--pkgs/development/libraries/libcollectdclient/default.nix1
-rw-r--r--pkgs/development/libraries/libidn2/default.nix8
-rw-r--r--pkgs/development/libraries/libmcrypt/default.nix8
-rw-r--r--pkgs/development/libraries/libqtav/default.nix4
-rw-r--r--pkgs/development/libraries/libspf2/default.nix4
-rw-r--r--pkgs/development/libraries/libtap/default.nix1
-rw-r--r--pkgs/development/libraries/libunique/3.x.nix5
-rw-r--r--pkgs/development/libraries/libutempter/default.nix4
-rw-r--r--pkgs/development/libraries/libvirt/default.nix38
-rw-r--r--pkgs/development/libraries/libvmi/default.nix10
-rw-r--r--pkgs/development/libraries/libytnef/default.nix4
-rw-r--r--pkgs/development/libraries/mesa/default.nix42
-rw-r--r--pkgs/development/libraries/nuspell/wrapper.nix6
-rw-r--r--pkgs/development/libraries/opencascade/default.nix7
-rw-r--r--pkgs/development/libraries/pcg-c/default.nix6
-rw-r--r--pkgs/development/libraries/pcre/default.nix14
-rw-r--r--pkgs/development/libraries/phonon/backends/gstreamer.nix2
-rw-r--r--pkgs/development/libraries/phonon/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/clmagma/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix6
-rw-r--r--pkgs/development/libraries/sope/default.nix17
-rw-r--r--pkgs/development/libraries/sqlite/archive-version.nix8
-rw-r--r--pkgs/development/libraries/sqlite/default.nix10
-rw-r--r--pkgs/development/libraries/srt/default.nix3
-rw-r--r--pkgs/development/libraries/unittest-cpp/default.nix4
-rw-r--r--pkgs/development/libraries/xvidcore/default.nix13
45 files changed, 240 insertions, 311 deletions
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index 3a2a048a860..5299135e9fe 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -11,17 +11,15 @@
 # NOTE: When editing this expression see if the same change applies to
 # SDL2 expression too
 
-with lib;
-
 let
   extraPropagatedBuildInputs = [ ]
-    ++ optionals x11Support [ libXext libICE libXrandr ]
-    ++ optionals (openglSupport && stdenv.isLinux) [ libGL libGLU ]
-    ++ optionals (openglSupport && stdenv.isDarwin) [ OpenGL GLUT ]
-    ++ optional alsaSupport alsa-lib
-    ++ optional pulseaudioSupport libpulseaudio
-    ++ optional stdenv.isDarwin Cocoa;
-  rpath = makeLibraryPath extraPropagatedBuildInputs;
+    ++ lib.optionals x11Support [ libXext libICE libXrandr ]
+    ++ lib.optionals (openglSupport && stdenv.isLinux) [ libGL libGLU ]
+    ++ lib.optionals (openglSupport && stdenv.isDarwin) [ OpenGL GLUT ]
+    ++ lib.optional alsaSupport alsa-lib
+    ++ lib.optional pulseaudioSupport libpulseaudio
+    ++ lib.optional stdenv.isDarwin Cocoa;
+  rpath = lib.makeLibraryPath extraPropagatedBuildInputs;
 in
 
 stdenv.mkDerivation rec {
@@ -40,13 +38,13 @@ stdenv.mkDerivation rec {
   outputBin = "dev"; # sdl-config
 
   nativeBuildInputs = [ pkg-config ]
-    ++ optional stdenv.isLinux libcap;
+    ++ lib.optional stdenv.isLinux libcap;
 
   propagatedBuildInputs = [ libiconv ] ++ extraPropagatedBuildInputs;
 
   buildInputs = [ ]
-    ++ optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
-    ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
+    ++ lib.optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
+    ++ lib.optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
 
   configureFlags = [
     "--disable-oss"
@@ -58,9 +56,9 @@ stdenv.mkDerivation rec {
   #   SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
   #
   # Please try revert the change that introduced this comment when updating SDL.
-  ] ++ optional stdenv.isDarwin "--disable-x11-shared"
-    ++ optional (!x11Support) "--without-x"
-    ++ optional alsaSupport "--with-alsa-prefix=${alsa-lib.out}/lib";
+  ] ++ lib.optional stdenv.isDarwin "--disable-x11-shared"
+    ++ lib.optional (!x11Support) "--without-x"
+    ++ lib.optional alsaSupport "--with-alsa-prefix=${alsa-lib.out}/lib";
 
   patches = [
     ./find-headers.patch
diff --git a/pkgs/development/libraries/SDL2/default.nix b/pkgs/development/libraries/SDL2/default.nix
index a38761ed7c5..f601e101660 100644
--- a/pkgs/development/libraries/SDL2/default.nix
+++ b/pkgs/development/libraries/SDL2/default.nix
@@ -55,8 +55,6 @@
 # NOTE: When editing this expression see if the same change applies to
 # SDL expression too
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "SDL2";
   version = "2.24.2";
@@ -88,40 +86,40 @@ stdenv.mkDerivation rec {
 
   depsBuildBuild = [ pkg-config ];
 
-  nativeBuildInputs = [ pkg-config ] ++ optionals waylandSupport [ wayland wayland-scanner ];
+  nativeBuildInputs = [ pkg-config ] ++ lib.optionals waylandSupport [ wayland wayland-scanner ];
 
   propagatedBuildInputs = dlopenPropagatedBuildInputs;
 
   dlopenPropagatedBuildInputs = [ ]
     # Propagated for #include <GLES/gl.h> in SDL_opengles.h.
-    ++ optional openglSupport libGL
+    ++ lib.optional openglSupport libGL
     # Propagated for #include <X11/Xlib.h> and <X11/Xatom.h> in SDL_syswm.h.
-    ++ optionals x11Support [ libX11 xorgproto ];
-
-  dlopenBuildInputs = optionals alsaSupport [ alsa-lib audiofile ]
-    ++ optional dbusSupport dbus
-    ++ optional libdecorSupport libdecor
-    ++ optional pipewireSupport pipewire
-    ++ optional pulseaudioSupport libpulseaudio
-    ++ optional udevSupport udev
-    ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
-    ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]
-    ++ optionals drmSupport [ libdrm mesa ];
+    ++ lib.optionals x11Support [ libX11 xorgproto ];
+
+  dlopenBuildInputs = lib.optionals alsaSupport [ alsa-lib audiofile ]
+    ++ lib.optional dbusSupport dbus
+    ++ lib.optional libdecorSupport libdecor
+    ++ lib.optional pipewireSupport pipewire
+    ++ lib.optional pulseaudioSupport libpulseaudio
+    ++ lib.optional udevSupport udev
+    ++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
+    ++ lib.optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]
+    ++ lib.optionals drmSupport [ libdrm mesa ];
 
   buildInputs = [ libiconv ]
     ++ dlopenBuildInputs
-    ++ optional ibusSupport ibus
-    ++ optional fcitxSupport fcitx
-    ++ optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
+    ++ lib.optional ibusSupport ibus
+    ++ lib.optional fcitxSupport fcitx
+    ++ lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
 
   enableParallelBuilding = true;
 
   configureFlags = [
     "--disable-oss"
-  ] ++ optional (!x11Support) "--without-x"
-  ++ optional alsaSupport "--with-alsa-prefix=${alsa-lib.out}/lib"
-  ++ optional stdenv.targetPlatform.isWindows "--disable-video-opengles"
-  ++ optional stdenv.isDarwin "--disable-sdltest";
+  ] ++ lib.optional (!x11Support) "--without-x"
+  ++ lib.optional alsaSupport "--with-alsa-prefix=${alsa-lib.out}/lib"
+  ++ lib.optional stdenv.targetPlatform.isWindows "--disable-video-opengles"
+  ++ lib.optional stdenv.isDarwin "--disable-sdltest";
 
   # We remove libtool .la files when static libs are requested,
   # because they make the builds of downstream libs like `SDL_tff`
@@ -156,9 +154,9 @@ stdenv.mkDerivation rec {
   # list the symbols used in this way.
   postFixup =
     let
-      rpath = makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
+      rpath = lib.makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
     in
-    optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
+    lib.optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
       for lib in $out/lib/*.so* ; do
         if ! [[ -L "$lib" ]]; then
           patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib"
diff --git a/pkgs/development/libraries/apr-util/default.nix b/pkgs/development/libraries/apr-util/default.nix
index 909965bb068..594ecfbdb30 100644
--- a/pkgs/development/libraries/apr-util/default.nix
+++ b/pkgs/development/libraries/apr-util/default.nix
@@ -10,8 +10,6 @@ assert sslSupport -> openssl != null;
 assert bdbSupport -> db != null;
 assert ldapSupport -> openldap != null;
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "apr-util";
   version = "1.6.1";
@@ -22,21 +20,21 @@ stdenv.mkDerivation rec {
   };
 
   patches = [ ./fix-libxcrypt-build.patch ]
-    ++ optional stdenv.isFreeBSD ./include-static-dependencies.patch;
+    ++ lib.optional stdenv.isFreeBSD ./include-static-dependencies.patch;
 
   NIX_CFLAGS_LINK = [ "-lcrypt" ];
 
   outputs = [ "out" "dev" ];
   outputBin = "dev";
 
-  nativeBuildInputs = [ makeWrapper ] ++ optional stdenv.isFreeBSD autoreconfHook;
+  nativeBuildInputs = [ makeWrapper ] ++ lib.optional stdenv.isFreeBSD autoreconfHook;
 
   configureFlags = [ "--with-apr=${apr.dev}" "--with-expat=${expat.dev}" ]
-    ++ optional (!stdenv.isCygwin) "--with-crypto"
-    ++ optional sslSupport "--with-openssl=${openssl.dev}"
-    ++ optional bdbSupport "--with-berkeley-db=${db.dev}"
-    ++ optional ldapSupport "--with-ldap=ldap"
-    ++ optionals stdenv.isCygwin
+    ++ lib.optional (!stdenv.isCygwin) "--with-crypto"
+    ++ lib.optional sslSupport "--with-openssl=${openssl.dev}"
+    ++ lib.optional bdbSupport "--with-berkeley-db=${db.dev}"
+    ++ lib.optional ldapSupport "--with-ldap=ldap"
+    ++ lib.optionals stdenv.isCygwin
       [ "--without-pgsql" "--without-sqlite2" "--without-sqlite3"
         "--without-freetds" "--without-berkeley-db" "--without-crypto" ]
     ;
@@ -53,10 +51,10 @@ stdenv.mkDerivation rec {
   '';
 
   propagatedBuildInputs = [ apr expat libiconv libxcrypt ]
-    ++ optional sslSupport openssl
-    ++ optional bdbSupport db
-    ++ optional ldapSupport openldap
-    ++ optional stdenv.isFreeBSD cyrus_sasl;
+    ++ lib.optional sslSupport openssl
+    ++ lib.optional bdbSupport db
+    ++ lib.optional ldapSupport openldap
+    ++ lib.optional stdenv.isFreeBSD cyrus_sasl;
 
   postInstall = ''
     for f in $out/lib/*.la $out/lib/apr-util-1/*.la $dev/bin/apu-1-config; do
diff --git a/pkgs/development/libraries/asio/generic.nix b/pkgs/development/libraries/asio/generic.nix
index 8bcc12ae2b3..cb9f1eb3024 100644
--- a/pkgs/development/libraries/asio/generic.nix
+++ b/pkgs/development/libraries/asio/generic.nix
@@ -2,8 +2,6 @@
 , version, sha256, ...
 }:
 
-with lib;
-
 stdenv.mkDerivation {
   pname = "asio";
   inherit version;
@@ -17,7 +15,7 @@ stdenv.mkDerivation {
 
   buildInputs = [ openssl ];
 
-  meta = {
+  meta = with lib; {
     homepage = "http://asio.sourceforge.net/";
     description = "Cross-platform C++ library for network and low-level I/O programming";
     license = licenses.boost;
diff --git a/pkgs/development/libraries/aspell/dictionaries.nix b/pkgs/development/libraries/aspell/dictionaries.nix
index 74caec57c2d..ea8a2133c82 100644
--- a/pkgs/development/libraries/aspell/dictionaries.nix
+++ b/pkgs/development/libraries/aspell/dictionaries.nix
@@ -1,7 +1,5 @@
 {lib, stdenv, fetchurl, aspell, which, writeScript}:
 
-with lib;
-
 /* HOWTO:
 
    * Add some of these to your profile or systemPackages.
@@ -105,7 +103,7 @@ let
         homepage = "http://ftp.gnu.org/gnu/aspell/dict/0index.html";
       } // (args.meta or {});
 
-    } // lib.optionalAttrs (stdenv.isDarwin && elem language [ "is" "nb" ]) {
+    } // lib.optionalAttrs (stdenv.isDarwin && lib.elem language [ "is" "nb" ]) {
       # tar: Cannot open: Illegal byte sequence
       unpackPhase = ''
         runHook preUnpack
@@ -115,7 +113,7 @@ let
         runHook postUnpack
       '';
 
-      postPatch = getAttr language {
+      postPatch = lib.getAttr language {
         is = ''
           cp icelandic.alias íslenska.alias
           sed -i 's/ .slenska\.alias/ íslenska.alias/g' Makefile.pre
@@ -137,7 +135,7 @@ let
       preBuild = ''
         # Aspell can't handle multiple data-dirs
         # Copy everything we might possibly need
-        ${concatMapStringsSep "\n" (p: ''
+        ${lib.concatMapStringsSep "\n" (p: ''
           cp -a ${p}/lib/aspell/* .
         '') ([ aspell ] ++ langInputs)}
         export ASPELL_CONF="data-dir $(pwd)"
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index feb41bf6294..4c6ba700457 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -34,20 +34,19 @@ assert enableNumpy -> enablePython;
 # Boost <1.69 can't be built on linux with clang >8, because pth was removed
 assert with lib; (stdenv.isLinux && toolset == "clang" && versionAtLeast stdenv.cc.version "8.0.0") -> versionAtLeast version "1.69";
 
-with lib;
 let
 
-  variant = concatStringsSep ","
-    (optional enableRelease "release" ++
-     optional enableDebug "debug");
+  variant = lib.concatStringsSep ","
+    (lib.optional enableRelease "release" ++
+     lib.optional enableDebug "debug");
 
-  threading = concatStringsSep ","
-    (optional enableSingleThreaded "single" ++
-     optional enableMultiThreaded "multi");
+  threading = lib.concatStringsSep ","
+    (lib.optional enableSingleThreaded "single" ++
+     lib.optional enableMultiThreaded "multi");
 
-  link = concatStringsSep ","
-    (optional enableShared "shared" ++
-     optional enableStatic "static");
+  link = lib.concatStringsSep ","
+    (lib.optional enableShared "shared" ++
+     lib.optional enableStatic "static");
 
   runtime-link = if enableShared then "shared" else "static";
 
@@ -61,16 +60,16 @@ let
   # [0]: https://github.com/boostorg/build/commit/0ef40cb86728f1cd804830fef89a6d39153ff632
   # [1]: https://github.com/boostorg/build/commit/316e26ca718afc65d6170029284521392524e4f8
   jobs =
-    if versionOlder version "1.58" then
+    if lib.versionOlder version "1.58" then
       "$(($NIX_BUILD_CORES<=64 ? $NIX_BUILD_CORES : 64))"
-    else if versionOlder version "1.65" then
+    else if lib.versionOlder version "1.65" then
       "$(($NIX_BUILD_CORES<=256 ? $NIX_BUILD_CORES : 256))"
     else
       "$NIX_BUILD_CORES";
 
   needUserConfig = stdenv.hostPlatform != stdenv.buildPlatform || useMpi || (stdenv.isDarwin && enableShared);
 
-  b2Args = concatStringsSep " " ([
+  b2Args = lib.concatStringsSep " " ([
     "--includedir=$dev/include"
     "--libdir=$out/lib"
     "-j${jobs}"
@@ -82,12 +81,12 @@ let
     "-sEXPAT_LIBPATH=${expat.out}/lib"
 
     # TODO: make this unconditional
-  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform ||
+  ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform ||
                   # required on mips; see 61d9f201baeef4c4bb91ad8a8f5f89b747e0dfe4
-                  (stdenv.hostPlatform.isMips && versionAtLeast version "1.79")) [
+                  (stdenv.hostPlatform.isMips && lib.versionAtLeast version "1.79")) [
     "address-model=${toString stdenv.hostPlatform.parsed.cpu.bits}"
     "architecture=${if stdenv.hostPlatform.isMips64
-                    then if versionOlder version "1.78" then "mips1" else "mips"
+                    then if lib.versionOlder version "1.78" then "mips1" else "mips"
                     else if stdenv.hostPlatform.parsed.cpu.name == "s390x" then "s390x"
                     else toString stdenv.hostPlatform.parsed.cpu.family}"
     "binary-format=${toString stdenv.hostPlatform.parsed.kernel.execFormat.name}"
@@ -100,13 +99,13 @@ let
            else if stdenv.hostPlatform.isMips32 then "o32"
            else if stdenv.hostPlatform.isMips64n64 then "n64"
            else "sysv"}"
-  ] ++ optional (link != "static") "runtime-link=${runtime-link}"
-    ++ optional (variant == "release") "debug-symbols=off"
-    ++ optional (toolset != null) "toolset=${toolset}"
-    ++ optional (!enablePython) "--without-python"
-    ++ optional needUserConfig "--user-config=user-config.jam"
-    ++ optional (stdenv.buildPlatform.isDarwin && stdenv.hostPlatform.isLinux) "pch=off"
-    ++ optionals (stdenv.hostPlatform.libc == "msvcrt") [
+  ] ++ lib.optional (link != "static") "runtime-link=${runtime-link}"
+    ++ lib.optional (variant == "release") "debug-symbols=off"
+    ++ lib.optional (toolset != null) "toolset=${toolset}"
+    ++ lib.optional (!enablePython) "--without-python"
+    ++ lib.optional needUserConfig "--user-config=user-config.jam"
+    ++ lib.optional (stdenv.buildPlatform.isDarwin && stdenv.hostPlatform.isLinux) "pch=off"
+    ++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "threadapi=win32"
   ] ++ extraB2Args
   );
@@ -121,38 +120,38 @@ stdenv.mkDerivation {
   patchFlags = [];
 
   patches = patches
-  ++ optional stdenv.isDarwin ./darwin-no-system-python.patch
+  ++ lib.optional stdenv.isDarwin ./darwin-no-system-python.patch
   # Fix boost-context segmentation faults on ppc64 due to ABI violation
-  ++ optional (versionAtLeast version "1.61" &&
-               versionOlder version "1.71") (fetchpatch {
+  ++ lib.optional (lib.versionAtLeast version "1.61" &&
+               lib.versionOlder version "1.71") (fetchpatch {
     url = "https://github.com/boostorg/context/commit/2354eca9b776a6739112833f64754108cc0d1dc5.patch";
     sha256 = "067m4bjpmcanqvg28djax9a10avmdwhlpfx6gn73kbqqq70dnz29";
     stripLen = 1;
     extraPrefix = "libs/context/";
   })
   # Fix compiler warning with GCC >= 8; TODO: patch may apply to older versions
-  ++ optional (versionAtLeast version "1.65" && versionOlder version "1.67")
+  ++ lib.optional (lib.versionAtLeast version "1.65" && lib.versionOlder version "1.67")
     (fetchpatch {
       url = "https://github.com/boostorg/mpl/commit/f48fd09d021db9a28bd7b8452c175897e1af4485.patch";
       sha256 = "15d2a636hhsb1xdyp44x25dyqfcaws997vnp9kl1mhzvxjzz7hb0";
       stripLen = 1;
     })
-  ++ optional (versionAtLeast version "1.65" && versionOlder version "1.70") (fetchpatch {
+  ++ lib.optional (lib.versionAtLeast version "1.65" && lib.versionOlder version "1.70") (fetchpatch {
     # support for Mips64n64 appeared in boost-context 1.70; this patch won't apply to pre-1.65 cleanly
     url = "https://github.com/boostorg/context/commit/e3f744a1862164062d579d1972272d67bdaa9c39.patch";
     sha256 = "sha256-qjQy1b4jDsIRrI+UYtcguhvChrMbGWO0UlEzEJHYzRI=";
     stripLen = 1;
     extraPrefix = "libs/context/";
   })
-  ++ optional (versionAtLeast version "1.70" && versionOlder version "1.73") ./cmake-paths.patch
-  ++ optional (versionAtLeast version "1.73") ./cmake-paths-173.patch
-  ++ optional (version == "1.77.0") (fetchpatch {
+  ++ lib.optional (lib.versionAtLeast version "1.70" && lib.versionOlder version "1.73") ./cmake-paths.patch
+  ++ lib.optional (lib.versionAtLeast version "1.73") ./cmake-paths-173.patch
+  ++ lib.optional (version == "1.77.0") (fetchpatch {
     url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch";
     relative = "include";
     sha256 = "sha256-KlmIbixcds6GyKYt1fx5BxDIrU7msrgDdYo9Va/KJR4=";
   });
 
-  meta = {
+  meta = with lib; {
     homepage = "http://boost.org/";
     description = "Collection of C++ libraries";
     license = licenses.boost;
@@ -175,7 +174,7 @@ stdenv.mkDerivation {
     inherit boostBuildPatches;
   };
 
-  preConfigure = optionalString useMpi ''
+  preConfigure = lib.optionalString useMpi ''
     cat << EOF >> user-config.jam
     using mpi : ${mpi}/bin/mpiCC ;
     EOF
@@ -183,7 +182,7 @@ stdenv.mkDerivation {
   # On darwin we need to add the `$out/lib` to the libraries' rpath explicitly,
   # otherwise the dynamic linker is unable to resolve the reference to @rpath
   # when the boost libraries want to load each other at runtime.
-  + optionalString (stdenv.isDarwin && enableShared) ''
+  + lib.optionalString (stdenv.isDarwin && enableShared) ''
     cat << EOF >> user-config.jam
     using clang-darwin : : ${stdenv.cc.targetPrefix}c++
       : <linkflags>"-rpath $out/lib/"
@@ -196,7 +195,7 @@ stdenv.mkDerivation {
   # uniform way for clang and gcc (which works thanks to our cc-wrapper).
   # We pass toolset later which will make b2 invoke everything in the right
   # way -- the other toolset in user-config.jam will be ignored.
-  + optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+  + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     cat << EOF >> user-config.jam
     using gcc : cross : ${stdenv.cc.targetPrefix}c++
       : <archiver>$AR
@@ -210,7 +209,7 @@ stdenv.mkDerivation {
     EOF
   ''
   # b2 needs to be explicitly told how to find Python when cross-compiling
-  + optionalString enablePython ''
+  + lib.optionalString enablePython ''
     cat << EOF >> user-config.jam
     using python : : ${python.interpreter}
       : ${python}/include/python${python.pythonVersion}
@@ -225,11 +224,11 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
 
   nativeBuildInputs = [ which boost-build ]
-    ++ optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+    ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
   buildInputs = [ expat zlib bzip2 libiconv ]
-    ++ optional enableIcu icu
-    ++ optionals enablePython [ libxcrypt python ]
-    ++ optional enableNumpy python.pkgs.numpy;
+    ++ lib.optional enableIcu icu
+    ++ lib.optionals enablePython [ libxcrypt python ]
+    ++ lib.optional enableNumpy python.pkgs.numpy;
 
   configureScript = "./bootstrap.sh";
   configurePlatforms = [];
@@ -239,7 +238,7 @@ stdenv.mkDerivation {
     "--includedir=$(dev)/include"
     "--libdir=$(out)/lib"
     "--with-bjam=b2" # prevent bootstrapping b2 in configurePhase
-  ] ++ optional (toolset != null) "--with-toolset=${toolset}"
+  ] ++ lib.optional (toolset != null) "--with-toolset=${toolset}"
     ++ [ (if enableIcu then "--with-icu=${icu.dev}" else "--without-icu") ];
 
   buildPhase = ''
@@ -265,7 +264,7 @@ stdenv.mkDerivation {
     # Make boost header paths relative so that they are not runtime dependencies
     cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
       -exec sed '1s/^\xef\xbb\xbf//;1i#line 1 "{}"' -i '{}' \;
-  '' + optionalString (stdenv.hostPlatform.libc == "msvcrt") ''
+  '' + lib.optionalString (stdenv.hostPlatform.libc == "msvcrt") ''
     $RANLIB "$out/lib/"*.a
   '';
 
diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix
index db23009b8fa..883b30c6a57 100644
--- a/pkgs/development/libraries/cyrus-sasl/default.nix
+++ b/pkgs/development/libraries/cyrus-sasl/default.nix
@@ -2,7 +2,6 @@
 , pam, libxcrypt, fixDarwinDylibNames, autoreconfHook, enableLdap ? false
 , buildPackages, pruneLibtoolFiles, nixosTests }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "cyrus-sasl";
   version = "2.1.28";
@@ -50,7 +49,7 @@ stdenv.mkDerivation rec {
     inherit (nixosTests) parsedmarc postfix;
   };
 
-  meta = {
+  meta = with lib; {
     homepage = "https://www.cyrusimap.org/sasl";
     description = "Library for adding authentication support to connection-based protocols";
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/faac/default.nix b/pkgs/development/libraries/faac/default.nix
index dbc56572d53..42f1f8db59b 100644
--- a/pkgs/development/libraries/faac/default.nix
+++ b/pkgs/development/libraries/faac/default.nix
@@ -5,7 +5,6 @@
 
 assert mp4v2Support -> (mp4v2 != null);
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "faac";
   version = "1.30";
@@ -16,19 +15,19 @@ stdenv.mkDerivation rec {
   };
 
   configureFlags = [ ]
-    ++ optional mp4v2Support "--with-external-mp4v2"
-    ++ optional drmSupport "--enable-drm";
+    ++ lib.optional mp4v2Support "--with-external-mp4v2"
+    ++ lib.optional drmSupport "--enable-drm";
 
   hardeningDisable = [ "format" ];
 
   nativeBuildInputs = [ autoreconfHook ];
 
   buildInputs = [ ]
-    ++ optional mp4v2Support mp4v2;
+    ++ lib.optional mp4v2Support mp4v2;
 
   enableParallelBuilding = true;
 
-  meta = {
+  meta = with lib; {
     description = "Open source MPEG-4 and MPEG-2 AAC encoder";
     license     = licenses.unfreeRedistributable;
     maintainers = with maintainers; [ codyopel ];
diff --git a/pkgs/development/libraries/faad2/default.nix b/pkgs/development/libraries/faad2/default.nix
index e62a90fcd2b..f72e6f4f954 100644
--- a/pkgs/development/libraries/faad2/default.nix
+++ b/pkgs/development/libraries/faad2/default.nix
@@ -11,7 +11,6 @@
 , vlc
 }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "faad2";
   version = "2.10.1";
@@ -24,7 +23,7 @@ stdenv.mkDerivation rec {
   };
 
   configureFlags = []
-    ++ optional drmSupport "--with-drm";
+    ++ lib.optional drmSupport "--with-drm";
 
   nativeBuildInputs = [ autoreconfHook ];
 
@@ -34,7 +33,7 @@ stdenv.mkDerivation rec {
     ocaml-faad = ocamlPackages.faad;
   };
 
-  meta = {
+  meta = with lib; {
     description = "An open source MPEG-4 and MPEG-2 AAC decoder";
     homepage = "https://sourceforge.net/projects/faac/";
     license     = licenses.gpl2Plus;
diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix
index e57cbc34fa2..c5edb592620 100644
--- a/pkgs/development/libraries/fftw/default.nix
+++ b/pkgs/development/libraries/fftw/default.nix
@@ -14,9 +14,7 @@
 , withDoc ? stdenv.cc.isGNU
 }:
 
-with lib;
-
-assert elem precision [ "single" "double" "long-double" "quad-precision" ];
+assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
 
 stdenv.mkDerivation rec {
   pname = "fftw-${precision}";
@@ -31,32 +29,32 @@ stdenv.mkDerivation rec {
   };
 
   outputs = [ "out" "dev" "man" ]
-    ++ optional withDoc "info"; # it's dev-doc only
+    ++ lib.optional withDoc "info"; # it's dev-doc only
   outputBin = "dev"; # fftw-wisdom
 
   nativeBuildInputs = [ gfortran ];
 
-  buildInputs = optionals stdenv.cc.isClang [
+  buildInputs = lib.optionals stdenv.cc.isClang [
     # TODO: This may mismatch the LLVM version sin the stdenv, see #79818.
     llvmPackages.openmp
-  ] ++ optional enableMpi mpi;
+  ] ++ lib.optional enableMpi mpi;
 
   configureFlags =
     [ "--enable-shared"
       "--enable-threads"
     ]
-    ++ optional (precision != "double") "--enable-${precision}"
+    ++ lib.optional (precision != "double") "--enable-${precision}"
     # all x86_64 have sse2
     # however, not all float sizes fit
-    ++ optional (stdenv.isx86_64 && (precision == "single" || precision == "double") )  "--enable-sse2"
-    ++ optional enableAvx "--enable-avx"
-    ++ optional enableAvx2 "--enable-avx2"
-    ++ optional enableAvx512 "--enable-avx512"
-    ++ optional enableFma "--enable-fma"
+    ++ lib.optional (stdenv.isx86_64 && (precision == "single" || precision == "double") )  "--enable-sse2"
+    ++ lib.optional enableAvx "--enable-avx"
+    ++ lib.optional enableAvx2 "--enable-avx2"
+    ++ lib.optional enableAvx512 "--enable-avx512"
+    ++ lib.optional enableFma "--enable-fma"
     ++ [ "--enable-openmp" ]
-    ++ optional enableMpi "--enable-mpi"
+    ++ lib.optional enableMpi "--enable-mpi"
     # doc generation causes Fortran wrapper generation which hard-codes gcc
-    ++ optional (!withDoc) "--disable-doc";
+    ++ lib.optional (!withDoc) "--disable-doc";
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/geis/default.nix b/pkgs/development/libraries/geis/default.nix
index e8476b0fefb..43b61e78fb4 100644
--- a/pkgs/development/libraries/geis/default.nix
+++ b/pkgs/development/libraries/geis/default.nix
@@ -15,7 +15,6 @@
 , xorgserver
 }:
 
-with lib;
 
 stdenv.mkDerivation rec {
   pname = "geis";
@@ -48,7 +47,7 @@ stdenv.mkDerivation rec {
     gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH")
   '';
 
-  meta = {
+  meta = with lib; {
     description = "A library for input gesture recognition";
     homepage = "https://launchpad.net/geis";
     license = licenses.gpl2;
diff --git a/pkgs/development/libraries/glew/1.10.nix b/pkgs/development/libraries/glew/1.10.nix
index a51b1060b8a..8fa77013e10 100644
--- a/pkgs/development/libraries/glew/1.10.nix
+++ b/pkgs/development/libraries/glew/1.10.nix
@@ -2,8 +2,6 @@
 , AGL, OpenGL
 }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "glew";
   version = "1.10.0";
@@ -20,7 +18,7 @@ stdenv.mkDerivation rec {
 
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
-    ${optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+    ${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
     ''}
   '';
diff --git a/pkgs/development/libraries/gloox/default.nix b/pkgs/development/libraries/gloox/default.nix
index f50704bcb65..8fc57d865fd 100644
--- a/pkgs/development/libraries/gloox/default.nix
+++ b/pkgs/development/libraries/gloox/default.nix
@@ -4,7 +4,6 @@
 , idnSupport ? true, libidn
 }:
 
-with lib;
 
 stdenv.mkDerivation rec{
   pname = "gloox";
@@ -16,11 +15,11 @@ stdenv.mkDerivation rec{
   };
 
   buildInputs = [ ]
-    ++ optional zlibSupport zlib
-    ++ optional sslSupport openssl
-    ++ optional idnSupport libidn;
+    ++ lib.optional zlibSupport zlib
+    ++ lib.optional sslSupport openssl
+    ++ lib.optional idnSupport libidn;
 
-  meta = {
+  meta = with lib; {
     description = "A portable high-level Jabber/XMPP library for C++";
     homepage = "http://camaya.net/gloox";
     license = licenses.gpl3;
diff --git a/pkgs/development/libraries/gtk/2.x.nix b/pkgs/development/libraries/gtk/2.x.nix
index 3568bbfed48..23680c9b675 100644
--- a/pkgs/development/libraries/gtk/2.x.nix
+++ b/pkgs/development/libraries/gtk/2.x.nix
@@ -7,8 +7,6 @@
 , fetchpatch, buildPackages
 }:
 
-with lib;
-
 let
 
   gtkCleanImmodulesCache = substituteAll {
@@ -44,7 +42,7 @@ stdenv.mkDerivation rec {
   patches = [
     ./patches/2.0-immodules.cache.patch
     ./patches/gtk2-theme-paths.patch
-  ] ++ optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.isDarwin [
     (fetchpatch {
       url = "https://bug557780.bugzilla-attachments.gnome.org/attachment.cgi?id=306776";
       sha256 = "0sp8f1r5c4j2nlnbqgv7s7nxa4cfwigvm033hvhb1ld652pjag4r";
@@ -54,13 +52,13 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = with xorg;
     [ glib cairo pango gdk-pixbuf atk ]
-    ++ optionals (stdenv.isLinux || stdenv.isDarwin) [
+    ++ lib.optionals (stdenv.isLinux || stdenv.isDarwin) [
          libXrandr libXrender libXcomposite libXi libXcursor
        ]
-    ++ optionals stdenv.isDarwin [ libXdamage ]
-    ++ optional xineramaSupport libXinerama
-    ++ optionals cupsSupport [ cups ]
-    ++ optionals stdenv.isDarwin [ AppKit Cocoa ];
+    ++ lib.optionals stdenv.isDarwin [ libXdamage ]
+    ++ lib.optional xineramaSupport libXinerama
+    ++ lib.optionals cupsSupport [ cups ]
+    ++ lib.optionals stdenv.isDarwin [ AppKit Cocoa ];
 
   preConfigure = if (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11" && stdenv.isDarwin) then ''
     MACOSX_DEPLOYMENT_TARGET=10.16
@@ -69,7 +67,7 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--with-gdktarget=${gdktarget}"
     "--with-xinput=yes"
-  ] ++ optionals stdenv.isDarwin [
+  ] ++ lib.optionals stdenv.isDarwin [
     "--disable-glibtest"
     "--disable-introspection"
     "--disable-visibility"
@@ -94,7 +92,7 @@ stdenv.mkDerivation rec {
     inherit gdktarget;
   };
 
-  meta = {
+  meta = with lib; {
     description = "A multi-platform toolkit for creating graphical user interfaces";
     homepage    = "https://www.gtk.org/";
     license     = licenses.lgpl2Plus;
diff --git a/pkgs/development/libraries/hunspell/wrapper.nix b/pkgs/development/libraries/hunspell/wrapper.nix
index d67fe230103..01987ab7185 100644
--- a/pkgs/development/libraries/hunspell/wrapper.nix
+++ b/pkgs/development/libraries/hunspell/wrapper.nix
@@ -1,10 +1,9 @@
 { stdenv, lib, hunspell, makeWrapper, dicts ? [] }:
-with lib;
 let
-  searchPath = makeSearchPath "share/hunspell" dicts;
+  searchPath = lib.makeSearchPath "share/hunspell" dicts;
 in
 stdenv.mkDerivation {
-  name = (appendToName "with-dicts" hunspell).name;
+  name = (lib.appendToName "with-dicts" hunspell).name;
   nativeBuildInputs = [ makeWrapper ];
   buildCommand = ''
     makeWrapper ${hunspell.bin}/bin/hunspell $out/bin/hunspell --prefix DICPATH : ${lib.escapeShellArg searchPath}
diff --git a/pkgs/development/libraries/indicator-application/gtk2.nix b/pkgs/development/libraries/indicator-application/gtk2.nix
index f75ade98c6d..9fe3575b7bc 100644
--- a/pkgs/development/libraries/indicator-application/gtk2.nix
+++ b/pkgs/development/libraries/indicator-application/gtk2.nix
@@ -3,8 +3,6 @@
 , glib, dbus-glib, json-glib
 , gtk2, libindicator-gtk2, libdbusmenu-gtk2, libappindicator-gtk2 }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "indicator-application-gtk2";
   version = "12.10.0.1";
@@ -45,7 +43,7 @@ stdenv.mkDerivation rec {
     "localstatedir=\${TMPDIR}"
   ];
 
-  meta = {
+  meta = with lib; {
     description = "Indicator to take menus from applications and place them in the panel (GTK 2 library for Xfce/LXDE)";
     homepage = "https://launchpad.net/indicators-gtk2";
     license = licenses.gpl3;
diff --git a/pkgs/development/libraries/kerberos/heimdal.nix b/pkgs/development/libraries/kerberos/heimdal.nix
index 792d4b102f4..e4a61a3c073 100644
--- a/pkgs/development/libraries/kerberos/heimdal.nix
+++ b/pkgs/development/libraries/kerberos/heimdal.nix
@@ -4,7 +4,6 @@
 , CoreFoundation, Security, SystemConfiguration
 }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "heimdal";
   version = "7.8.0";
@@ -22,9 +21,9 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoreconfHook pkg-config python3 perl bison flex texinfo ]
     ++ (with perlPackages; [ JSON ]);
-  buildInputs = optionals (stdenv.isLinux) [ libcap_ng ]
+  buildInputs = lib.optionals (stdenv.isLinux) [ libcap_ng ]
     ++ [ db sqlite openssl libedit openldap pam]
-    ++ optionals (stdenv.isDarwin) [ CoreFoundation Security SystemConfiguration ];
+    ++ lib.optionals (stdenv.isDarwin) [ CoreFoundation Security SystemConfiguration ];
 
   ## ugly, X should be made an option
   configureFlags = [
@@ -42,7 +41,7 @@ stdenv.mkDerivation rec {
     "--with-berkeley-db"
     "--with-berkeley-db-include=${db.dev}/include"
     "--with-openldap=${openldap.dev}"
-  ] ++ optionals (stdenv.isLinux) [
+  ] ++ lib.optionals (stdenv.isLinux) [
     "--with-capng"
   ];
 
@@ -91,7 +90,7 @@ stdenv.mkDerivation rec {
   #  hx_locl.h:67:25: fatal error: pkcs10_asn1.h: No such file or directory
   #enableParallelBuilding = true;
 
-  meta = {
+  meta = with lib; {
     description = "An implementation of Kerberos 5 (and some more stuff)";
     license = licenses.bsd3;
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/lame/default.nix b/pkgs/development/libraries/lame/default.nix
index 674defc42e2..506be919322 100644
--- a/pkgs/development/libraries/lame/default.nix
+++ b/pkgs/development/libraries/lame/default.nix
@@ -11,7 +11,6 @@
 , debugSupport ? false # Debugging (disables optimizations)
 }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "lame";
   version = "3.100";
@@ -25,24 +24,24 @@ stdenv.mkDerivation rec {
   outputMan = "out";
 
   nativeBuildInputs = [ ]
-    ++ optional nasmSupport nasm;
+    ++ lib.optional nasmSupport nasm;
 
   buildInputs = [ ]
     #++ optional efenceSupport libefence
     #++ optional mp3xSupport gtk1
-    ++ optional sndfileFileIOSupport libsndfile;
+    ++ lib.optional sndfileFileIOSupport libsndfile;
 
   configureFlags = [
-    (enableFeature nasmSupport "nasm")
-    (enableFeature cpmlSupport "cpml")
+    (lib.enableFeature nasmSupport "nasm")
+    (lib.enableFeature cpmlSupport "cpml")
     #(enableFeature efenceSupport "efence")
     (if sndfileFileIOSupport then "--with-fileio=sndfile" else "--with-fileio=lame")
-    (enableFeature analyzerHooksSupport "analyzer-hooks")
-    (enableFeature decoderSupport "decoder")
-    (enableFeature frontendSupport "frontend")
-    (enableFeature frontendSupport "dynamic-frontends")
+    (lib.enableFeature analyzerHooksSupport "analyzer-hooks")
+    (lib.enableFeature decoderSupport "decoder")
+    (lib.enableFeature frontendSupport "frontend")
+    (lib.enableFeature frontendSupport "dynamic-frontends")
     #(enableFeature mp3xSupport "mp3x")
-    (enableFeature mp3rtpSupport "mp3rtp")
+    (lib.enableFeature mp3rtpSupport "mp3rtp")
     (if debugSupport then "--enable-debug=alot" else "")
   ];
 
@@ -52,7 +51,7 @@ stdenv.mkDerivation rec {
     sed -i '/lame_init_old/d' include/libmp3lame.sym
   '';
 
-  meta = {
+  meta = with lib; {
     description = "A high quality MPEG Audio Layer III (MP3) encoder";
     homepage    = "http://lame.sourceforge.net";
     license     = licenses.lgpl2;
diff --git a/pkgs/development/libraries/libass/default.nix b/pkgs/development/libraries/libass/default.nix
index 118238f5f5a..7ed461516cc 100644
--- a/pkgs/development/libraries/libass/default.nix
+++ b/pkgs/development/libraries/libass/default.nix
@@ -8,7 +8,6 @@
 
 assert fontconfigSupport -> fontconfig != null;
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "libass";
   version = "0.16.0";
@@ -19,18 +18,18 @@ stdenv.mkDerivation rec {
   };
 
   configureFlags = [
-    (enableFeature fontconfigSupport "fontconfig")
-    (enableFeature rasterizerSupport "rasterizer")
-    (enableFeature largeTilesSupport "large-tiles")
+    (lib.enableFeature fontconfigSupport "fontconfig")
+    (lib.enableFeature rasterizerSupport "rasterizer")
+    (lib.enableFeature largeTilesSupport "large-tiles")
   ];
 
   nativeBuildInputs = [ pkg-config yasm ];
 
   buildInputs = [ freetype fribidi harfbuzz ]
-    ++ optional fontconfigSupport fontconfig
-    ++ optional stdenv.isDarwin libiconv;
+    ++ lib.optional fontconfigSupport fontconfig
+    ++ lib.optional stdenv.isDarwin libiconv;
 
-  meta = {
+  meta = with lib; {
     description = "Portable ASS/SSA subtitle renderer";
     homepage    = "https://github.com/libass/libass";
     license     = licenses.isc;
diff --git a/pkgs/development/libraries/libcollectdclient/default.nix b/pkgs/development/libraries/libcollectdclient/default.nix
index 919ddcd3f06..41c5565482f 100644
--- a/pkgs/development/libraries/libcollectdclient/default.nix
+++ b/pkgs/development/libraries/libcollectdclient/default.nix
@@ -1,5 +1,4 @@
 { lib, collectd }:
-with lib;
 
 collectd.overrideAttrs (oldAttrs: {
   pname = "libcollectdclient";
diff --git a/pkgs/development/libraries/libidn2/default.nix b/pkgs/development/libraries/libidn2/default.nix
index 724778999f5..9d7babd01dd 100644
--- a/pkgs/development/libraries/libidn2/default.nix
+++ b/pkgs/development/libraries/libidn2/default.nix
@@ -5,8 +5,6 @@
 # cgit) that are needed here should be included directly in Nixpkgs as
 # files.
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libidn2";
   version = "2.3.2";
@@ -20,14 +18,14 @@ stdenv.mkDerivation rec {
   # Beware: non-bootstrap libidn2 is overridden by ./hack.nix
   outputs = [ "bin" "dev" "out" "info" "devdoc" ];
 
-  patches = optional stdenv.isDarwin ./fix-error-darwin.patch;
+  patches = lib.optional stdenv.isDarwin ./fix-error-darwin.patch;
 
   enableParallelBuilding = true;
 
   # The above patch causes the documentation to be regenerated, so the
   # documentation tools are required.
-  nativeBuildInputs = optionals stdenv.isDarwin [ help2man texinfo ];
-  buildInputs = [ libunistring ] ++ optional stdenv.isDarwin libiconv;
+  nativeBuildInputs = lib.optionals stdenv.isDarwin [ help2man texinfo ];
+  buildInputs = [ libunistring ] ++ lib.optional stdenv.isDarwin libiconv;
   depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   meta = {
diff --git a/pkgs/development/libraries/libmcrypt/default.nix b/pkgs/development/libraries/libmcrypt/default.nix
index 953a6d03e5e..cdd6a7b2ec5 100644
--- a/pkgs/development/libraries/libmcrypt/default.nix
+++ b/pkgs/development/libraries/libmcrypt/default.nix
@@ -1,7 +1,5 @@
 { lib, stdenv, fetchurl, darwin, disablePosixThreads ? false }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libmcrypt";
   version = "2.5.8";
@@ -11,15 +9,15 @@ stdenv.mkDerivation rec {
     sha256 = "0gipgb939vy9m66d3k8il98rvvwczyaw2ixr8yn6icds9c3nrsz4";
   };
 
-  buildInputs = optional stdenv.isDarwin darwin.cctools;
+  buildInputs = lib.optional stdenv.isDarwin darwin.cctools;
 
-  configureFlags = optionals disablePosixThreads
+  configureFlags = lib.optionals disablePosixThreads
     [ "--disable-posix-threads" ];
 
   meta = {
     description = "Replacement for the old crypt() package and crypt(1) command, with extensions";
     homepage = "http://mcrypt.sourceforge.net";
     license = "GPL";
-    platforms = platforms.all;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/libqtav/default.nix b/pkgs/development/libraries/libqtav/default.nix
index c2d91b1d5b7..10f4b43f989 100644
--- a/pkgs/development/libraries/libqtav/default.nix
+++ b/pkgs/development/libraries/libqtav/default.nix
@@ -17,8 +17,6 @@
 , libva
 }:
 
-with lib;
-
 mkDerivation rec {
   pname = "libqtav";
   version = "unstable-2020-09-10";
@@ -64,7 +62,7 @@ mkDerivation rec {
 
   stripDebugList = [ "lib" "libexec" "bin" "qml" ];
 
-  meta = {
+  meta =  with lib; {
     description = "A multimedia playback framework based on Qt + FFmpeg";
     #license = licenses.lgpl21; # For the libraries / headers only.
     license = licenses.gpl3; # With the examples (under bin) and most likely some of the optional dependencies used.
diff --git a/pkgs/development/libraries/libspf2/default.nix b/pkgs/development/libraries/libspf2/default.nix
index 203f2768e37..b7bef297352 100644
--- a/pkgs/development/libraries/libspf2/default.nix
+++ b/pkgs/development/libraries/libspf2/default.nix
@@ -1,7 +1,5 @@
 { lib, stdenv, fetchFromGitHub, autoreconfHook, fetchpatch }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libspf2";
   version = "2.2.12";
@@ -35,7 +33,7 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  meta = {
+  meta = with lib; {
     description = "Implementation of the Sender Policy Framework for SMTP " +
                   "authorization (Helsinki Systems fork)";
     homepage = "https://github.com/helsinki-systems/libspf2";
diff --git a/pkgs/development/libraries/libtap/default.nix b/pkgs/development/libraries/libtap/default.nix
index ce7cb6bfd1e..47ca65e8490 100644
--- a/pkgs/development/libraries/libtap/default.nix
+++ b/pkgs/development/libraries/libtap/default.nix
@@ -1,6 +1,5 @@
 { lib, stdenv, fetchurl, pkg-config, cmake, perl }:
 
-with lib;
 stdenv.mkDerivation rec {
 
   pname = "libtap";
diff --git a/pkgs/development/libraries/libunique/3.x.nix b/pkgs/development/libraries/libunique/3.x.nix
index 72027b85ed4..086ca28676b 100644
--- a/pkgs/development/libraries/libunique/3.x.nix
+++ b/pkgs/development/libraries/libunique/3.x.nix
@@ -3,7 +3,6 @@
 , gtk-doc, docbook_xml_dtd_45, docbook_xsl
 , libxslt, libxml2 }:
 
-with lib;
 stdenv.mkDerivation rec {
 
   majorVer = "3.0";
@@ -23,8 +22,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://wiki.gnome.org/Attic/LibUnique";
     description = "A library for writing single instance applications";
-    license = licenses.lgpl21;
-    maintainers = [ maintainers.AndersonTorres ];
+    license = lib.licenses.lgpl21;
+    maintainers = [ lib.maintainers.AndersonTorres ];
     platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libutempter/default.nix b/pkgs/development/libraries/libutempter/default.nix
index 3b63ef9386b..717418e686b 100644
--- a/pkgs/development/libraries/libutempter/default.nix
+++ b/pkgs/development/libraries/libutempter/default.nix
@@ -1,7 +1,5 @@
 { stdenv, fetchurl, lib, glib }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libutempter";
   version = "1.2.1";
@@ -28,7 +26,7 @@ stdenv.mkDerivation rec {
     "mandir=\${out}/share/man"
   ];
 
-  meta = {
+  meta = with lib; {
     homepage = "https://github.com/altlinux/libutempter";
     description = "Interface for terminal emulators such as screen and xterm to record user sessions to utmp and wtmp files";
     longDescription = ''
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index 2a56a0cde20..734f96850c5 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -77,13 +77,11 @@
 , zfs
 }:
 
-with lib;
-
 let
   inherit (stdenv) isDarwin isLinux isx86_64;
-  binPath = makeBinPath ([
+  binPath = lib.makeBinPath ([
     dnsmasq
-  ] ++ optionals isLinux [
+  ] ++ lib.optionals isLinux [
     bridge-utils
     dmidecode
     dnsmasq
@@ -95,10 +93,10 @@ let
     numad
     pmutils
     systemd
-  ] ++ optionals enableIscsi [
+  ] ++ lib.optionals enableIscsi [
     libiscsi
     openiscsi
-  ] ++ optionals enableZfs [
+  ] ++ lib.optionals enableZfs [
     zfs
   ]);
 in
@@ -148,17 +146,17 @@ stdenv.mkDerivation rec {
 
     substituteInPlace meson.build \
       --replace "'dbus-daemon'," "'${lib.getBin dbus}/bin/dbus-daemon',"
-  '' + optionalString isLinux ''
+  '' + lib.optionalString isLinux ''
     sed -i 's,define PARTED "parted",define PARTED "${parted}/bin/parted",' \
       src/storage/storage_backend_disk.c \
       src/storage/storage_util.c
-  '' + optionalString isDarwin ''
+  '' + lib.optionalString isDarwin ''
     sed -i '/qemucapabilitiestest/d' tests/meson.build
     sed -i '/vircryptotest/d' tests/meson.build
     sed -i '/domaincapstest/d' tests/meson.build
     sed -i '/qemufirmwaretest/d' tests/meson.build
     sed -i '/qemuvhostusertest/d' tests/meson.build
-  '' + optionalString (isDarwin && isx86_64) ''
+  '' + lib.optionalString (isDarwin && isx86_64) ''
     sed -i '/qemucaps2xmltest/d' tests/meson.build
     sed -i '/qemuhotplugtest/d' tests/meson.build
     sed -i '/virnetdaemontest/d' tests/meson.build
@@ -178,9 +176,9 @@ stdenv.mkDerivation rec {
     perl
     perlPackages.XMLXPath
   ]
-  ++ optional (!isDarwin) rpcsvc-proto
+  ++ lib.optional (!isDarwin) rpcsvc-proto
   # NOTE: needed for rpcgen
-  ++ optional isDarwin darwin.developer_cmds;
+  ++ lib.optional isDarwin darwin.developer_cmds;
 
   buildInputs = [
     bash
@@ -197,7 +195,7 @@ stdenv.mkDerivation rec {
     readline
     xhtml1
     yajl
-  ] ++ optionals isLinux [
+  ] ++ lib.optionals isLinux [
     acl
     attr
     audit
@@ -213,17 +211,17 @@ stdenv.mkDerivation rec {
     parted
     systemd
     util-linux
-  ] ++ optionals isDarwin [
+  ] ++ lib.optionals isDarwin [
     AppKit
     Carbon
     gmp
     libiconv
   ]
-  ++ optionals enableCeph [ ceph ]
-  ++ optionals enableGlusterfs [ glusterfs ]
-  ++ optionals enableIscsi [ libiscsi openiscsi ]
-  ++ optionals enableXen [ xen ]
-  ++ optionals enableZfs [ zfs ];
+  ++ lib.optionals enableCeph [ ceph ]
+  ++ lib.optionals enableGlusterfs [ glusterfs ]
+  ++ lib.optionals enableIscsi [ libiscsi openiscsi ]
+  ++ lib.optionals enableXen [ xen ]
+  ++ lib.optionals enableZfs [ zfs ];
 
   preConfigure =
     let
@@ -348,7 +346,7 @@ stdenv.mkDerivation rec {
     # Added in nixpkgs:
     gettext() { "${gettext}/bin/gettext" "$@"; }
     '
-  '' + optionalString isLinux ''
+  '' + lib.optionalString isLinux ''
     for f in $out/lib/systemd/system/*.service ; do
       substituteInPlace $f --replace /bin/kill ${coreutils}/bin/kill
     done
@@ -372,7 +370,7 @@ stdenv.mkDerivation rec {
 
   passthru.tests.libvirtd = nixosTests.libvirtd;
 
-  meta = {
+  meta = with lib; {
     description = "A toolkit to interact with the virtualization capabilities of recent versions of Linux and other OSes";
     homepage = "https://libvirt.org/";
     changelog = "https://gitlab.com/libvirt/libvirt/-/raw/v${version}/NEWS.rst";
diff --git a/pkgs/development/libraries/libvmi/default.nix b/pkgs/development/libraries/libvmi/default.nix
index 36fd026eeed..cbcba106b83 100644
--- a/pkgs/development/libraries/libvmi/default.nix
+++ b/pkgs/development/libraries/libvmi/default.nix
@@ -10,8 +10,6 @@
   libvirt,
   xenSupport ? true }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libvmi";
   version = "0.12.0";
@@ -24,16 +22,16 @@ stdenv.mkDerivation rec {
     sha256 = "0wbi2nasb1gbci6cq23g6kq7i10rwi1y7r44rl03icr5prqjpdyv";
   };
 
-  buildInputs = [ glib libvirt json_c ] ++ (optional xenSupport xen);
+  buildInputs = [ glib libvirt json_c ] ++ (lib.optional xenSupport xen);
   nativeBuildInputs = [ autoreconfHook bison flex pkg-config ];
 
-  configureFlags = optional (!xenSupport) "--disable-xen";
+  configureFlags = lib.optional (!xenSupport) "--disable-xen";
 
   # libvmi uses dlopen() for the xen libraries, however autoPatchelfHook doesn't work here
-  postFixup = optionalString xenSupport ''
+  postFixup = lib.optionalString xenSupport ''
     libvmi="$out/lib/libvmi.so.${libVersion}"
     oldrpath=$(patchelf --print-rpath "$libvmi")
-    patchelf --set-rpath "$oldrpath:${makeLibraryPath [ xen ]}" "$libvmi"
+    patchelf --set-rpath "$oldrpath:${lib.makeLibraryPath [ xen ]}" "$libvmi"
   '';
 
   meta = with lib; {
diff --git a/pkgs/development/libraries/libytnef/default.nix b/pkgs/development/libraries/libytnef/default.nix
index f34834ae316..a4f358fa546 100644
--- a/pkgs/development/libraries/libytnef/default.nix
+++ b/pkgs/development/libraries/libytnef/default.nix
@@ -1,7 +1,5 @@
 { stdenv, lib, fetchFromGitHub, autoreconfHook }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "libytnef";
   version = "2.0";
@@ -15,7 +13,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoreconfHook ];
 
-  meta = {
+  meta = with lib; {
     inherit (src.meta) homepage;
     description = "Yeraze's TNEF Stream Reader - for winmail.dat files";
     license = licenses.gpl2Plus;
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index c853c172d24..a79c19eb2eb 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -36,13 +36,11 @@
   - libOSMesa is in $osmesa (~4 MB)
 */
 
-with lib;
-
 let
   # Release calendar: https://www.mesa3d.org/release-calendar.html
   # Release frequency: https://www.mesa3d.org/releasing.html#schedule
   version = "22.3.3";
-  branch  = versions.major version;
+  branch  = lib.versions.major version;
 
   withLibdrm = lib.meta.availableOn stdenv.hostPlatform libdrm;
 
@@ -115,43 +113,43 @@ self = stdenv.mkDerivation {
     "-Ddisk-cache-key=${placeholder "drivers"}"
     "-Ddri-search-path=${libglvnd.driverLink}/lib/dri"
 
-    "-Dplatforms=${concatStringsSep "," eglPlatforms}"
-    "-Dgallium-drivers=${concatStringsSep "," galliumDrivers}"
-    "-Dvulkan-drivers=${concatStringsSep "," vulkanDrivers}"
+    "-Dplatforms=${lib.concatStringsSep "," eglPlatforms}"
+    "-Dgallium-drivers=${lib.concatStringsSep "," galliumDrivers}"
+    "-Dvulkan-drivers=${lib.concatStringsSep "," vulkanDrivers}"
 
     "-Ddri-drivers-path=${placeholder "drivers"}/lib/dri"
     "-Dvdpau-libs-path=${placeholder "drivers"}/lib/vdpau"
     "-Domx-libs-path=${placeholder "drivers"}/lib/bellagio"
     "-Dva-libs-path=${placeholder "drivers"}/lib/dri"
     "-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d"
-    "-Dgallium-nine=${boolToString enableGalliumNine}" # Direct3D in Wine
-    "-Dosmesa=${boolToString enableOSMesa}" # used by wine
+    "-Dgallium-nine=${lib.boolToString enableGalliumNine}" # Direct3D in Wine
+    "-Dosmesa=${lib.boolToString enableOSMesa}" # used by wine
     "-Dmicrosoft-clc=disabled" # Only relevant on Windows (OpenCL 1.2 API on top of D3D12)
 
     # To enable non-mesa gbm backends to be found (e.g. Nvidia)
     "-Dgbm-backends-path=${libglvnd.driverLink}/lib/gbm:${placeholder "out"}/lib/gbm"
-  ] ++ optionals stdenv.isLinux [
+  ] ++ lib.optionals stdenv.isLinux [
     "-Dglvnd=true"
-  ] ++ optionals enableOpenCL [
+  ] ++ lib.optionals enableOpenCL [
     "-Dgallium-opencl=icd" # Enable the gallium OpenCL frontend
     "-Dgallium-rusticl=true" "-Drust_std=2021"
     "-Dclang-libdir=${llvmPackages.clang-unwrapped.lib}/lib"
-  ] ++ optional enablePatentEncumberedCodecs
+  ] ++ lib.optional enablePatentEncumberedCodecs
     "-Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec"
-  ++ optional (vulkanLayers != []) "-D vulkan-layers=${builtins.concatStringsSep "," vulkanLayers}";
+  ++ lib.optional (vulkanLayers != []) "-D vulkan-layers=${builtins.concatStringsSep "," vulkanLayers}";
 
   buildInputs = with xorg; [
     expat llvmPackages.libllvm libglvnd xorgproto
     libX11 libXext libxcb libXt libXfixes libxshmfence libXrandr
     libffi libvdpau libelf libXvMC
     libpthreadstubs openssl /*or another sha1 provider*/
-  ] ++ lib.optionals (elem "wayland" eglPlatforms) [ wayland wayland-protocols ]
+  ] ++ lib.optionals (lib.elem "wayland" eglPlatforms) [ wayland wayland-protocols ]
     ++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal ]
     ++ lib.optionals stdenv.isDarwin [ libunwind ]
     ++ lib.optionals enableOpenCL [ libclc llvmPackages.clang llvmPackages.clang-unwrapped rustc rust-bindgen' spirv-llvm-translator_14 ]
     ++ lib.optional withValgrind valgrind-light
     # Mesa will not build zink when gallium-drivers=auto
-    ++ lib.optional (elem "zink" galliumDrivers) vulkan-loader;
+    ++ lib.optional (lib.elem "zink" galliumDrivers) vulkan-loader;
 
   depsBuildBuild = [ pkg-config ];
 
@@ -160,21 +158,21 @@ self = stdenv.mkDerivation {
     intltool bison flex file
     python3Packages.python python3Packages.Mako
     jdupes glslang
-  ] ++ lib.optionals (elem "wayland" eglPlatforms) [
+  ] ++ lib.optionals (lib.elem "wayland" eglPlatforms) [
     wayland-scanner
   ];
 
   propagatedBuildInputs = with xorg; [
     libXdamage libXxf86vm
-  ] ++ optional withLibdrm libdrm
-    ++ optionals stdenv.isDarwin [ OpenGL Xplugin ];
+  ] ++ lib.optional withLibdrm libdrm
+    ++ lib.optionals stdenv.isDarwin [ OpenGL Xplugin ];
 
   doCheck = false;
 
   postInstall = ''
     # Some installs don't have any drivers so this directory is never created.
     mkdir -p $drivers $osmesa
-  '' + optionalString stdenv.isLinux ''
+  '' + lib.optionalString stdenv.isLinux ''
     mkdir -p $drivers/lib
 
     if [ -n "$(shopt -s nullglob; echo "$out/lib/libxatracker"*)" -o -n "$(shopt -s nullglob; echo "$out/lib/libvulkan_"*)" ]; then
@@ -199,7 +197,7 @@ self = stdenv.mkDerivation {
     for js in $drivers/share/vulkan/icd.d/*.json; do
       substituteInPlace "$js" --replace "$out" "$drivers"
     done
-  '' + optionalString enableOpenCL ''
+  '' + lib.optionalString enableOpenCL ''
     # Move OpenCL stuff
     mkdir -p $opencl/lib
     mv -t "$opencl/lib/"     \
@@ -221,7 +219,7 @@ self = stdenv.mkDerivation {
     done
   '';
 
-  postFixup = optionalString stdenv.isLinux ''
+  postFixup = lib.optionalString stdenv.isLinux ''
     # set the default search path for DRI drivers; used e.g. by X server
     substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace "$drivers" "${libglvnd.driverLink}"
     [ -f "$dev/lib/pkgconfig/d3d.pc" ] && substituteInPlace "$dev/lib/pkgconfig/d3d.pc" --replace "$drivers" "${libglvnd.driverLink}"
@@ -252,7 +250,7 @@ self = stdenv.mkDerivation {
     done
   '';
 
-  NIX_CFLAGS_COMPILE = optionals stdenv.isDarwin [ "-fno-common" ] ++ lib.optionals enableOpenCL [
+  NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-fno-common" ] ++ lib.optionals enableOpenCL [
     "-UPIPE_SEARCH_DIR"
     "-DPIPE_SEARCH_DIR=\"${placeholder "opencl"}/lib/gallium-pipe\""
   ];
@@ -274,7 +272,7 @@ self = stdenv.mkDerivation {
     };
   };
 
-  meta = {
+  meta = with lib; {
     description = "An open source 3D graphics library";
     longDescription = ''
       The Mesa project began as an open-source implementation of the OpenGL
diff --git a/pkgs/development/libraries/nuspell/wrapper.nix b/pkgs/development/libraries/nuspell/wrapper.nix
index 64108c33b7c..b3a929545f2 100644
--- a/pkgs/development/libraries/nuspell/wrapper.nix
+++ b/pkgs/development/libraries/nuspell/wrapper.nix
@@ -1,10 +1,10 @@
 { stdenv, lib, nuspell, makeWrapper, dicts ? [] }:
-with lib;
+
 let
-  searchPath = makeSearchPath "share/hunspell" dicts;
+  searchPath = lib.makeSearchPath "share/hunspell" dicts;
 in
 stdenv.mkDerivation {
-  name = (appendToName "with-dicts" nuspell).name;
+  name = (lib.appendToName "with-dicts" nuspell).name;
   nativeBuildInputs = [ makeWrapper ];
   buildCommand = ''
     makeWrapper ${nuspell}/bin/nuspell $out/bin/nuspell --prefix DICPATH : ${lib.escapeShellArg searchPath}
diff --git a/pkgs/development/libraries/opencascade/default.nix b/pkgs/development/libraries/opencascade/default.nix
index 5c262a3680c..fbad2e115e2 100644
--- a/pkgs/development/libraries/opencascade/default.nix
+++ b/pkgs/development/libraries/opencascade/default.nix
@@ -3,7 +3,6 @@
   OpenCL, Cocoa
 }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "opencascade-oce";
   version = "0.18.3";
@@ -20,7 +19,7 @@ stdenv.mkDerivation rec {
     libGL libGLU libXmu freetype fontconfig expat freeimage vtk
     gl2ps tbb
   ]
-    ++ optionals stdenv.isDarwin [OpenCL Cocoa]
+    ++ lib.optionals stdenv.isDarwin [OpenCL Cocoa]
   ;
 
   cmakeFlags = [
@@ -30,7 +29,7 @@ stdenv.mkDerivation rec {
     "-DOCE_WITH_GL2PS=ON"
     "-DOCE_MULTITHREAD_LIBRARY=TBB"
   ]
-  ++ optionals stdenv.isDarwin ["-DOCE_OSX_USE_COCOA=ON" "-DOCE_WITH_OPENCL=ON"];
+  ++ lib.optionals stdenv.isDarwin ["-DOCE_OSX_USE_COCOA=ON" "-DOCE_WITH_OPENCL=ON"];
 
   patches = [
     # Use fontconfig instead of hardcoded directory list
@@ -56,7 +55,7 @@ stdenv.mkDerivation rec {
       --replace FONTCONFIG_LIBRARIES FONTCONFIG_LINK_LIBRARIES
   '';
 
-  meta = {
+  meta = with lib; {
     description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
     homepage = "https://github.com/tpaviot/oce";
     maintainers = [ maintainers.viric ];
diff --git a/pkgs/development/libraries/pcg-c/default.nix b/pkgs/development/libraries/pcg-c/default.nix
index 95acc77922e..04aa6c7afbc 100644
--- a/pkgs/development/libraries/pcg-c/default.nix
+++ b/pkgs/development/libraries/pcg-c/default.nix
@@ -1,7 +1,5 @@
 { lib, stdenv, fetchzip }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   version = "0.94";
   pname = "pcg-c";
@@ -31,8 +29,8 @@ stdenv.mkDerivation rec {
       algorithms for random number generation. Unlike many general-purpose RNGs,
       they are also hard to predict.
     '';
-    platforms = platforms.unix;
-    maintainers = [ maintainers.linus ];
+    platforms = lib.platforms.unix;
+    maintainers = [ lib.maintainers.linus ];
     broken = stdenv.isi686; # https://github.com/imneme/pcg-c/issues/11
   };
 }
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index c4bbcf2ddfd..8bc1055279f 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -3,9 +3,7 @@
 , variant ? null
 }:
 
-with lib;
-
-assert elem variant [ null "cpp" "pcre16" "pcre32" ];
+assert lib.elem variant [ null "cpp" "pcre16" "pcre32" ];
 
 stdenv.mkDerivation rec {
   pname = "pcre"
@@ -21,11 +19,11 @@ stdenv.mkDerivation rec {
   outputs = [ "bin" "dev" "out" "doc" "man" ];
 
   # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
-  configureFlags = optional (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit=auto" ++ [
+  configureFlags = lib.optional (!(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit=auto" ++ [
     "--enable-unicode-properties"
     "--disable-cpp"
   ]
-    ++ optional (variant != null) "--enable-${variant}";
+    ++ lib.optional (variant != null) "--enable-${variant}";
 
   # https://bugs.exim.org/show_bug.cgi?id=2173
   patches = [ ./stacksize-detection.patch ];
@@ -40,7 +38,7 @@ stdenv.mkDerivation rec {
 
   postFixup = ''
     moveToOutput bin/pcre-config "$dev"
-  '' + optionalString (variant != null) ''
+  '' + lib.optionalString (variant != null) ''
     ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib,*a}
   '';
 
@@ -57,7 +55,7 @@ stdenv.mkDerivation rec {
       PCRE library is free, even for building proprietary software.
     '';
 
-    platforms = platforms.all;
-    maintainers = with maintainers; [ ];
+    platforms = lib.platforms.all;
+    maintainers = with lib.maintainers; [ ];
   };
 }
diff --git a/pkgs/development/libraries/phonon/backends/gstreamer.nix b/pkgs/development/libraries/phonon/backends/gstreamer.nix
index 73c27e9d8c1..3ef63aa2c35 100644
--- a/pkgs/development/libraries/phonon/backends/gstreamer.nix
+++ b/pkgs/development/libraries/phonon/backends/gstreamer.nix
@@ -3,8 +3,6 @@
 , debug ? false
 }:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "phonon-backend-gstreamer";
   version = "4.10.0";
diff --git a/pkgs/development/libraries/phonon/default.nix b/pkgs/development/libraries/phonon/default.nix
index 877bf973194..4966e379aec 100644
--- a/pkgs/development/libraries/phonon/default.nix
+++ b/pkgs/development/libraries/phonon/default.nix
@@ -12,8 +12,6 @@
 , debug ? false
 }:
 
-with lib;
-
 let
   soname = "phonon4qt5";
   buildsystemdir = "share/cmake/${soname}";
diff --git a/pkgs/development/libraries/science/math/clmagma/default.nix b/pkgs/development/libraries/science/math/clmagma/default.nix
index fe9fc540902..c5efbb757df 100644
--- a/pkgs/development/libraries/science/math/clmagma/default.nix
+++ b/pkgs/development/libraries/science/math/clmagma/default.nix
@@ -1,7 +1,5 @@
 { lib, stdenv, fetchurl, gfortran, opencl-headers, clblas, ocl-icd, mkl, intel-ocl }:
 
-with lib;
-
 let
   incfile = builtins.toFile "make.inc.custom" ''
     CC        = g++
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index f3ec52f6a5d..0477f859eef 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -32,8 +32,6 @@
 , python3
 }:
 
-with lib;
-
 let blas64_ = blas64; in
 
 let
@@ -121,7 +119,7 @@ let
   blas64 =
     if blas64_ != null
       then blas64_
-      else hasPrefix "x86_64" stdenv.hostPlatform.system;
+      else lib.hasPrefix "x86_64" stdenv.hostPlatform.system;
   # Convert flag values to format OpenBLAS's build expects.
   # `toString` is almost what we need other than bools,
   # which we need to map {true -> 1, false -> 0}
@@ -129,7 +127,7 @@ let
   mkMakeFlagValue = val:
     if !builtins.isBool val then toString val
     else if val then "1" else "0";
-  mkMakeFlagsFromConfig = mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}");
+  mkMakeFlagsFromConfig = lib.mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}");
 
   shlibExt = stdenv.hostPlatform.extensions.sharedLibrary;
 
diff --git a/pkgs/development/libraries/sope/default.nix b/pkgs/development/libraries/sope/default.nix
index 83442035d7b..62d3184a603 100644
--- a/pkgs/development/libraries/sope/default.nix
+++ b/pkgs/development/libraries/sope/default.nix
@@ -1,6 +1,5 @@
 { gnustep, lib, fetchFromGitHub , libxml2, openssl
 , openldap, mariadb, libmysqlclient, postgresql }:
-with lib;
 
 gnustep.stdenv.mkDerivation rec {
   pname = "sope";
@@ -15,10 +14,10 @@ gnustep.stdenv.mkDerivation rec {
 
   hardeningDisable = [ "format" ];
   nativeBuildInputs = [ gnustep.make ];
-  buildInputs = flatten ([ gnustep.base libxml2 openssl ]
-    ++ optional (openldap != null) openldap
-    ++ optionals (mariadb != null) [ libmysqlclient mariadb ]
-    ++ optional (postgresql != null) postgresql);
+  buildInputs = lib.flatten ([ gnustep.base libxml2 openssl ]
+    ++ lib.optional (openldap != null) openldap
+    ++ lib.optionals (mariadb != null) [ libmysqlclient mariadb ]
+    ++ lib.optional (postgresql != null) postgresql);
 
   postPatch = ''
     # Exclude NIX_ variables
@@ -30,9 +29,9 @@ gnustep.stdenv.mkDerivation rec {
   '';
 
   configureFlags = [ "--prefix=" "--disable-debug" "--enable-xml" "--with-ssl=ssl" ]
-    ++ optional (openldap != null) "--enable-openldap"
-    ++ optional (mariadb != null) "--enable-mysql"
-    ++ optional (postgresql != null) "--enable-postgresql";
+    ++ lib.optional (openldap != null) "--enable-openldap"
+    ++ lib.optional (mariadb != null) "--enable-mysql"
+    ++ lib.optional (postgresql != null) "--enable-postgresql";
 
   # Yes, this is ugly.
   preFixup = ''
@@ -40,7 +39,7 @@ gnustep.stdenv.mkDerivation rec {
     rm -rf $out/nix/store
   '';
 
-  meta = {
+  meta = with lib; {
     description = "An extensive set of frameworks which form a complete Web application server environment";
     license = licenses.publicDomain;
     homepage = "https://github.com/inverse-inc/sope";
diff --git a/pkgs/development/libraries/sqlite/archive-version.nix b/pkgs/development/libraries/sqlite/archive-version.nix
index 75d70680fbf..601bb6a5889 100644
--- a/pkgs/development/libraries/sqlite/archive-version.nix
+++ b/pkgs/development/libraries/sqlite/archive-version.nix
@@ -1,11 +1,9 @@
 lib: version:
 
-with lib;
-
 let
-  fragments = splitVersion version;
-  major = head fragments;
-  minor = concatMapStrings (fixedWidthNumber 2) (tail fragments);
+  fragments = lib.splitVersion version;
+  major = lib.head fragments;
+  minor = lib.concatMapStrings (lib.fixedWidthNumber 2) (lib.tail fragments);
 in
 
 major + minor + "00"
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index eb27c8c8b9e..f4654a843f6 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -9,14 +9,12 @@
 , enableDeserialize ? false
 }:
 
-with lib;
-
 let
   archiveVersion = import ./archive-version.nix lib;
 in
 
 stdenv.mkDerivation rec {
-  pname = "sqlite${optionalString interactive "-interactive"}";
+  pname = "sqlite${lib.optionalString interactive "-interactive"}";
   version = "3.40.1";
 
   # nixpkgs-update: no auto update
@@ -29,14 +27,14 @@ stdenv.mkDerivation rec {
   outputs = [ "bin" "dev" "out" ];
   separateDebugInfo = stdenv.isLinux;
 
-  buildInputs = [ zlib ] ++ optionals interactive [ readline ncurses ];
+  buildInputs = [ zlib ] ++ lib.optionals interactive [ readline ncurses ];
 
   # required for aarch64 but applied for all arches for simplicity
   preConfigure = ''
     patchShebangs configure
   '';
 
-  configureFlags = [ "--enable-threadsafe" ] ++ optional interactive "--enable-readline";
+  configureFlags = [ "--enable-threadsafe" ] ++ lib.optional interactive "--enable-readline";
 
   NIX_CFLAGS_COMPILE = toString ([
     "-DSQLITE_ENABLE_COLUMN_METADATA"
@@ -94,7 +92,7 @@ stdenv.mkDerivation rec {
     inherit sqldiff sqlite-analyzer tracker;
   };
 
-  meta = {
+  meta = with lib; {
     description = "A self-contained, serverless, zero-configuration, transactional SQL database engine";
     downloadPage = "https://sqlite.org/download.html";
     homepage = "https://www.sqlite.org/";
diff --git a/pkgs/development/libraries/srt/default.nix b/pkgs/development/libraries/srt/default.nix
index 2e1a96eebbd..97e55a03033 100644
--- a/pkgs/development/libraries/srt/default.nix
+++ b/pkgs/development/libraries/srt/default.nix
@@ -1,7 +1,6 @@
 { lib, stdenv, fetchFromGitHub, cmake, openssl
 }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "srt";
   version = "1.5.1";
@@ -28,7 +27,7 @@ stdenv.mkDerivation rec {
     "-UCMAKE_INSTALL_LIBDIR"
   ];
 
-  meta = {
+  meta = with lib; {
     description = "Secure, Reliable, Transport";
     homepage    = "https://github.com/Haivision/srt";
     license     = licenses.mpl20;
diff --git a/pkgs/development/libraries/unittest-cpp/default.nix b/pkgs/development/libraries/unittest-cpp/default.nix
index d185d32c816..6f27a71b3ee 100644
--- a/pkgs/development/libraries/unittest-cpp/default.nix
+++ b/pkgs/development/libraries/unittest-cpp/default.nix
@@ -1,7 +1,5 @@
 {lib, stdenv, fetchFromGitHub, cmake}:
 
-with lib;
-
 stdenv.mkDerivation rec {
   pname = "unittest-cpp";
   version = "2.0.0";
@@ -20,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://github.com/unittest-cpp/unittest-cpp";
     description = "Lightweight unit testing framework for C++";
-    license = licenses.mit;
+    license = lib.licenses.mit;
     maintainers = [];
     platforms = lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/xvidcore/default.nix b/pkgs/development/libraries/xvidcore/default.nix
index 57f2403cfe3..82520572c37 100644
--- a/pkgs/development/libraries/xvidcore/default.nix
+++ b/pkgs/development/libraries/xvidcore/default.nix
@@ -1,6 +1,5 @@
 { lib, stdenv, fetchurl, yasm, autoconf, automake, libtool }:
 
-with lib;
 stdenv.mkDerivation rec {
   pname = "xvidcore";
   version = "1.3.7";
@@ -13,7 +12,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     # Configure script is not in the root of the source directory
     cd build/generic
-  '' + optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.isDarwin ''
     # Undocumented darwin hack
     substituteInPlace configure --replace "-no-cpp-precomp" ""
   '';
@@ -21,22 +20,22 @@ stdenv.mkDerivation rec {
   configureFlags = [ ]
     # Undocumented darwin hack (assembly is probably disabled due to an
     # issue with nasm, however yasm is now used)
-    ++ optional stdenv.isDarwin "--enable-macosx_module --disable-assembly";
+    ++ lib.optional stdenv.isDarwin "--enable-macosx_module --disable-assembly";
 
   nativeBuildInputs = [ ]
-    ++ optional (!stdenv.isDarwin) yasm;
+    ++ lib.optional (!stdenv.isDarwin) yasm;
 
   buildInputs = [ ]
     # Undocumented darwin hack
-    ++ optionals stdenv.isDarwin [ autoconf automake libtool ];
+    ++ lib.optionals stdenv.isDarwin [ autoconf automake libtool ];
 
   # Don't remove static libraries (e.g. 'libs/*.a') on darwin.  They're needed to
   # compile ffmpeg (and perhaps other things).
-  postInstall = optionalString (!stdenv.isDarwin) ''
+  postInstall = lib.optionalString (!stdenv.isDarwin) ''
     rm $out/lib/*.a
   '';
 
-  meta = {
+  meta = with lib; {
     description = "MPEG-4 video codec for PC";
     homepage    = "https://www.xvid.com/";
     license     = licenses.gpl2;