summary refs log tree commit diff
path: root/pkgs/applications/audio
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/audio')
-rw-r--r--pkgs/applications/audio/AMB-plugins/default.nix8
-rw-r--r--pkgs/applications/audio/FIL-plugins/default.nix8
-rw-r--r--pkgs/applications/audio/MMA/default.nix8
-rw-r--r--pkgs/applications/audio/abcde/default.nix2
-rw-r--r--pkgs/applications/audio/aeolus/default.nix8
-rw-r--r--pkgs/applications/audio/airwave/default.nix2
-rw-r--r--pkgs/applications/audio/ario/default.nix8
-rw-r--r--pkgs/applications/audio/asunder/default.nix4
-rw-r--r--pkgs/applications/audio/aucatctl/default.nix4
-rw-r--r--pkgs/applications/audio/audio-recorder/default.nix2
-rw-r--r--pkgs/applications/audio/aumix/default.nix6
-rw-r--r--pkgs/applications/audio/axoloti/libusb1.nix8
-rw-r--r--pkgs/applications/audio/bambootracker/default.nix2
-rw-r--r--pkgs/applications/audio/baudline/default.nix2
-rw-r--r--pkgs/applications/audio/cadence/default.nix4
-rw-r--r--pkgs/applications/audio/caps/default.nix8
-rw-r--r--pkgs/applications/audio/carla/default.nix2
-rw-r--r--pkgs/applications/audio/caudec/default.nix4
-rw-r--r--pkgs/applications/audio/cd-discid/default.nix2
-rw-r--r--pkgs/applications/audio/cdparanoia/default.nix10
-rw-r--r--pkgs/applications/audio/clementine/default.nix8
-rw-r--r--pkgs/applications/audio/clerk/default.nix2
-rw-r--r--pkgs/applications/audio/cmus/default.nix6
-rw-r--r--pkgs/applications/audio/cmusfm/default.nix2
-rw-r--r--pkgs/applications/audio/crip/default.nix8
-rw-r--r--pkgs/applications/audio/csound/csound-manual/default.nix8
-rw-r--r--pkgs/applications/audio/csound/default.nix2
-rw-r--r--pkgs/applications/audio/deadbeef/default.nix4
-rw-r--r--pkgs/applications/audio/easytag/default.nix2
-rw-r--r--pkgs/applications/audio/ecasound/default.nix4
-rw-r--r--pkgs/applications/audio/eflite/default.nix10
-rw-r--r--pkgs/applications/audio/ekho/default.nix2
-rw-r--r--pkgs/applications/audio/eq10q/default.nix8
-rw-r--r--pkgs/applications/audio/espeak/edit.nix2
-rw-r--r--pkgs/applications/audio/faust/faust1.nix2
-rw-r--r--pkgs/applications/audio/faust/faust2.nix4
-rw-r--r--pkgs/applications/audio/fmit/default.nix4
-rw-r--r--pkgs/applications/audio/fmsynth/default.nix8
-rw-r--r--pkgs/applications/audio/freewheeling/default.nix6
-rw-r--r--pkgs/applications/audio/ft2-clone/default.nix8
-rw-r--r--pkgs/applications/audio/gmu/default.nix4
-rw-r--r--pkgs/applications/audio/goattracker/default.nix4
-rw-r--r--pkgs/applications/audio/google-musicmanager/default.nix4
-rw-r--r--pkgs/applications/audio/google-play-music-desktop-player/default.nix8
-rw-r--r--pkgs/applications/audio/gpodder/default.nix2
-rw-r--r--pkgs/applications/audio/grandorgue/default.nix6
-rw-r--r--pkgs/applications/audio/gtklick/default.nix4
-rw-r--r--pkgs/applications/audio/guitarix/default.nix2
-rw-r--r--pkgs/applications/audio/helm/default.nix2
-rw-r--r--pkgs/applications/audio/i-score/default.nix8
-rw-r--r--pkgs/applications/audio/industrializer/default.nix8
-rw-r--r--pkgs/applications/audio/jack-capture/default.nix2
-rw-r--r--pkgs/applications/audio/jack-oscrolloscope/default.nix2
-rw-r--r--pkgs/applications/audio/jack-rack/default.nix8
-rw-r--r--pkgs/applications/audio/jackmeter/default.nix8
-rw-r--r--pkgs/applications/audio/jamulus/default.nix10
-rw-r--r--pkgs/applications/audio/japa/default.nix8
-rw-r--r--pkgs/applications/audio/klick/default.nix6
-rw-r--r--pkgs/applications/audio/ladspa-sdk/default.nix8
-rw-r--r--pkgs/applications/audio/ladspa-sdk/ladspah.nix8
-rw-r--r--pkgs/applications/audio/librespot/default.nix8
-rw-r--r--pkgs/applications/audio/lingot/default.nix12
-rw-r--r--pkgs/applications/audio/linuxband/default.nix8
-rw-r--r--pkgs/applications/audio/littlegptracker/default.nix12
-rw-r--r--pkgs/applications/audio/lsp-plugins/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/CharacterCompressor/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/CompBus/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/ConstantDetuneChorus/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/LazyLimiter/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/MBdistortion/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/RhythmDelay/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/VoiceOfFaust/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/faustCompressors/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/pluginUtils/default.nix4
-rw-r--r--pkgs/applications/audio/magnetophonDSP/shelfMultiBand/default.nix4
-rw-r--r--pkgs/applications/audio/meters_lv2/default.nix4
-rw-r--r--pkgs/applications/audio/mi2ly/default.nix8
-rw-r--r--pkgs/applications/audio/midisheetmusic/default.nix4
-rw-r--r--pkgs/applications/audio/mikmod/default.nix8
-rw-r--r--pkgs/applications/audio/mimic/default.nix10
-rw-r--r--pkgs/applications/audio/mimms/default.nix4
-rw-r--r--pkgs/applications/audio/moc/default.nix4
-rw-r--r--pkgs/applications/audio/mooSpace/default.nix6
-rw-r--r--pkgs/applications/audio/mopidy/mopidy.nix2
-rw-r--r--pkgs/applications/audio/mp3blaster/default.nix4
-rw-r--r--pkgs/applications/audio/mp3info/default.nix6
-rw-r--r--pkgs/applications/audio/mp3val/default.nix8
-rw-r--r--pkgs/applications/audio/mpc/default.nix2
-rw-r--r--pkgs/applications/audio/mpc123/default.nix6
-rw-r--r--pkgs/applications/audio/mpg123/default.nix12
-rw-r--r--pkgs/applications/audio/mpg321/default.nix4
-rw-r--r--pkgs/applications/audio/munt/default.nix2
-rw-r--r--pkgs/applications/audio/musikcube/default.nix2
-rw-r--r--pkgs/applications/audio/mympd/default.nix8
-rw-r--r--pkgs/applications/audio/ncmpc/default.nix2
-rw-r--r--pkgs/applications/audio/ncmpcpp/default.nix4
-rw-r--r--pkgs/applications/audio/non/default.nix8
-rw-r--r--pkgs/applications/audio/openmpt123/default.nix4
-rw-r--r--pkgs/applications/audio/opus-tools/default.nix8
-rw-r--r--pkgs/applications/audio/patchage/default.nix8
-rw-r--r--pkgs/applications/audio/pavucontrol/default.nix2
-rw-r--r--pkgs/applications/audio/pd-plugins/cyclone/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/gem/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/helmholtz/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/maxlib/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/mrpeach/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/puremapping/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/timbreid/default.nix8
-rw-r--r--pkgs/applications/audio/pd-plugins/zexy/default.nix8
-rw-r--r--pkgs/applications/audio/picard/default.nix4
-rw-r--r--pkgs/applications/audio/praat/default.nix6
-rw-r--r--pkgs/applications/audio/pt2-clone/default.nix2
-rw-r--r--pkgs/applications/audio/pulseaudio-ctl/default.nix2
-rw-r--r--pkgs/applications/audio/pulseaudio-dlna/default.nix12
-rw-r--r--pkgs/applications/audio/pulseaudio-dlna/zeroconf.nix2
-rw-r--r--pkgs/applications/audio/pulseeffects/default.nix8
-rw-r--r--pkgs/applications/audio/qjackctl/default.nix2
-rw-r--r--pkgs/applications/audio/qmidiroute/default.nix2
-rw-r--r--pkgs/applications/audio/quodlibet/default.nix6
-rw-r--r--pkgs/applications/audio/radiotray-ng/default.nix2
-rw-r--r--pkgs/applications/audio/reaper/default.nix4
-rw-r--r--pkgs/applications/audio/redoflacs/default.nix2
-rw-r--r--pkgs/applications/audio/renoise/default.nix20
-rw-r--r--pkgs/applications/audio/rhythmbox/default.nix2
-rw-r--r--pkgs/applications/audio/schismtracker/default.nix2
-rw-r--r--pkgs/applications/audio/shntool/default.nix8
-rw-r--r--pkgs/applications/audio/snd/default.nix8
-rw-r--r--pkgs/applications/audio/sonata/default.nix8
-rw-r--r--pkgs/applications/audio/sound-juicer/default.nix2
-rw-r--r--pkgs/applications/audio/soundscape-renderer/default.nix6
-rw-r--r--pkgs/applications/audio/soundtracker/default.nix2
-rw-r--r--pkgs/applications/audio/spectrojack/default.nix8
-rw-r--r--pkgs/applications/audio/split2flac/default.nix2
-rw-r--r--pkgs/applications/audio/spotify-tui/default.nix6
-rw-r--r--pkgs/applications/audio/spotify/default.nix2
-rw-r--r--pkgs/applications/audio/spotifyd/default.nix10
-rw-r--r--pkgs/applications/audio/squeezelite/default.nix4
-rw-r--r--pkgs/applications/audio/sunvox/default.nix2
-rw-r--r--pkgs/applications/audio/tap-plugins/default.nix4
-rw-r--r--pkgs/applications/audio/timemachine/default.nix8
-rw-r--r--pkgs/applications/audio/uade123/default.nix4
-rw-r--r--pkgs/applications/audio/vcv-rack/default.nix2
-rw-r--r--pkgs/applications/audio/wavegain/default.nix8
-rw-r--r--pkgs/applications/audio/whipper/default.nix4
-rw-r--r--pkgs/applications/audio/x42-plugins/default.nix4
-rw-r--r--pkgs/applications/audio/yasr/default.nix8
-rw-r--r--pkgs/applications/audio/ympd/default.nix8
147 files changed, 399 insertions, 399 deletions
diff --git a/pkgs/applications/audio/AMB-plugins/default.nix b/pkgs/applications/audio/AMB-plugins/default.nix
index eac2b4c783b..8b03a97d128 100644
--- a/pkgs/applications/audio/AMB-plugins/default.nix
+++ b/pkgs/applications/audio/AMB-plugins/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ladspaH
+{ lib, stdenv, fetchurl, ladspaH
 }:
 
 stdenv.mkDerivation rec {
@@ -26,8 +26,8 @@ stdenv.mkDerivation rec {
     '';
     version = version;
     homepage = "http://kokkinizita.linuxaudio.org/linuxaudio/ladspa/index.html";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/FIL-plugins/default.nix b/pkgs/applications/audio/FIL-plugins/default.nix
index 89bda1387d9..98fc3495d8f 100644
--- a/pkgs/applications/audio/FIL-plugins/default.nix
+++ b/pkgs/applications/audio/FIL-plugins/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ladspaH
+{ lib, stdenv, fetchurl, ladspaH
 }:
 
 stdenv.mkDerivation rec {
@@ -30,8 +30,8 @@ stdenv.mkDerivation rec {
     '';
     version = version;
     homepage = "http://kokkinizita.linuxaudio.org/linuxaudio/ladspa/index.html";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/MMA/default.nix b/pkgs/applications/audio/MMA/default.nix
index baeae7ae01f..ade595732c3 100644
--- a/pkgs/applications/audio/MMA/default.nix
+++ b/pkgs/applications/audio/MMA/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, python3, alsaUtils, timidity }:
+{ lib, stdenv, fetchurl, makeWrapper, python3, alsaUtils, timidity }:
 
   stdenv.mkDerivation rec {
   version = "20.12";
@@ -62,8 +62,8 @@
   meta = {
     description = "Creates MIDI tracks for a soloist to perform over from a user supplied file containing chords";
     homepage =  "https://www.mellowood.ca/mma/index.html";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/abcde/default.nix b/pkgs/applications/audio/abcde/default.nix
index a90051136cb..1c5fc571814 100644
--- a/pkgs/applications/audio/abcde/default.nix
+++ b/pkgs/applications/audio/abcde/default.nix
@@ -38,7 +38,7 @@ in
       for cmd in abcde cddb-tool abcde-musicbrainz-tool; do
         wrapProgram "$out/bin/$cmd" \
           --prefix PERL5LIB : "$PERL5LIB" \
-          --prefix PATH ":" ${stdenv.lib.makeBinPath [
+          --prefix PATH ":" ${lib.makeBinPath [
             "$out" which libcdio-paranoia cddiscid wget
             vorbis-tools id3v2 eyeD3 lame flac glyr
           ]}
diff --git a/pkgs/applications/audio/aeolus/default.nix b/pkgs/applications/audio/aeolus/default.nix
index c4982025999..000108b6de1 100644
--- a/pkgs/applications/audio/aeolus/default.nix
+++ b/pkgs/applications/audio/aeolus/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libclthreads, zita-alsa-pcmi, alsaLib, libjack2
+{ lib, stdenv, fetchurl, libclthreads, zita-alsa-pcmi, alsaLib, libjack2
 , libclxclient, libX11, libXft, readline
 }:
 
@@ -25,8 +25,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Synthetized (not sampled) pipe organ emulator";
     homepage = "http://kokkinizita.linuxaudio.org/linuxaudio/aeolus/index.html";
-    license = stdenv.lib.licenses.lgpl3;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.nico202 ];
+    license = lib.licenses.lgpl3;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.nico202 ];
   };
 }
diff --git a/pkgs/applications/audio/airwave/default.nix b/pkgs/applications/audio/airwave/default.nix
index d541afd2de3..438159201de 100644
--- a/pkgs/applications/audio/airwave/default.nix
+++ b/pkgs/applications/audio/airwave/default.nix
@@ -22,7 +22,7 @@ let
     };
     nativeBuildInputs = [ unzip ];
     installPhase = "cp -r . $out";
-    meta.license = stdenv.lib.licenses.unfree;
+    meta.license = lib.licenses.unfree;
   };
 
   wine-wow64 = wine.override {
diff --git a/pkgs/applications/audio/ario/default.nix b/pkgs/applications/audio/ario/default.nix
index 99a09e7ee33..c4a7829157d 100644
--- a/pkgs/applications/audio/ario/default.nix
+++ b/pkgs/applications/audio/ario/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, gettext, gtk3, intltool,
+{ lib, stdenv, fetchurl, pkgconfig, gettext, gtk3, intltool,
   wrapGAppsHook, libxml2, curl, mpd_clientlib, dbus-glib,
   libsoup, avahi, taglib
   }:
@@ -20,8 +20,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "GTK client for MPD (Music player daemon)";
     homepage = "http://ario-player.sourceforge.net/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.garrison ];
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.garrison ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/audio/asunder/default.nix b/pkgs/applications/audio/asunder/default.nix
index 610085a137a..2e849912edb 100644
--- a/pkgs/applications/audio/asunder/default.nix
+++ b/pkgs/applications/audio/asunder/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, gtk2, libcddb, intltool, pkgconfig, cdparanoia
+{ lib, stdenv, fetchurl, makeWrapper, gtk2, libcddb, intltool, pkgconfig, cdparanoia
 , mp3Support ? false, lame
 , oggSupport ? true, vorbis-tools
 , flacSupport ? true, flac
@@ -9,7 +9,7 @@
 #, aacSupport ? false, TODO: neroAacEnc
 }:
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   version = "2.9.7";
diff --git a/pkgs/applications/audio/aucatctl/default.nix b/pkgs/applications/audio/aucatctl/default.nix
index ad9fefb68b9..6670e06a21d 100644
--- a/pkgs/applications/audio/aucatctl/default.nix
+++ b/pkgs/applications/audio/aucatctl/default.nix
@@ -10,14 +10,14 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ sndio ]
-    ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.targetPlatform.isBSD)
+    ++ lib.optional (!stdenv.isDarwin && !stdenv.targetPlatform.isBSD)
     libbsd;
 
   outputs = [ "out" "man" ];
 
   preBuild = ''
     makeFlagsArray+=("PREFIX=$out")
-  '' + stdenv.lib.optionalString
+  '' + lib.optionalString
     (!stdenv.isDarwin && !stdenv.targetPlatform.isBSD) ''
       makeFlagsArray+=(LDADD="-lsndio -lbsd")
 
diff --git a/pkgs/applications/audio/audio-recorder/default.nix b/pkgs/applications/audio/audio-recorder/default.nix
index a66bb50f082..c1701671bee 100644
--- a/pkgs/applications/audio/audio-recorder/default.nix
+++ b/pkgs/applications/audio/audio-recorder/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
     glib dbus gtk3 librsvg libappindicator-gtk3
   ] ++ (with gst_all_1; [
     gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
-  ]) ++ stdenv.lib.optional pulseaudioSupport libpulseaudio;
+  ]) ++ lib.optional pulseaudioSupport libpulseaudio;
 
   meta = with lib; {
     description = "Audio recorder for GNOME and Unity Desktops";
diff --git a/pkgs/applications/audio/aumix/default.nix b/pkgs/applications/audio/aumix/default.nix
index 5bc7f843258..ffda8b6734d 100644
--- a/pkgs/applications/audio/aumix/default.nix
+++ b/pkgs/applications/audio/aumix/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gettext, ncurses
+{lib, stdenv, fetchurl, gettext, ncurses
 , gtkGUI ? false
 , pkgconfig ? null
 , gtk2 ? null}:
@@ -22,9 +22,9 @@ stdenv.mkDerivation rec {
       the command line or a script.
     '';
     homepage = "http://www.jpj.net/~trevor/aumix.html";
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
 
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/axoloti/libusb1.nix b/pkgs/applications/audio/axoloti/libusb1.nix
index e95b391fc78..f00167026b4 100644
--- a/pkgs/applications/audio/axoloti/libusb1.nix
+++ b/pkgs/applications/audio/axoloti/libusb1.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ pkgconfig ];
   propagatedBuildInputs =
-    stdenv.lib.optional stdenv.isLinux systemd ++
-    stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ];
+    lib.optional stdenv.isLinux systemd ++
+    lib.optionals stdenv.isDarwin [ libobjc IOKit ];
 
   patches = [
     (fetchpatch {
@@ -23,9 +23,9 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
+  NIX_LDFLAGS = lib.optionalString stdenv.isLinux "-lgcc_s";
 
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
+  preFixup = lib.optionalString stdenv.isLinux ''
     sed 's,-ludev,-L${lib.getLib systemd}/lib -ludev,' -i $out/lib/libusb-1.0.la
   '';
 
diff --git a/pkgs/applications/audio/bambootracker/default.nix b/pkgs/applications/audio/bambootracker/default.nix
index 8e9a566c172..592b0fb0730 100644
--- a/pkgs/applications/audio/bambootracker/default.nix
+++ b/pkgs/applications/audio/bambootracker/default.nix
@@ -13,7 +13,7 @@
 }:
 let
 
-  inherit (stdenv.lib) optional optionals;
+  inherit (lib) optional optionals;
 
 in
 mkDerivation rec {
diff --git a/pkgs/applications/audio/baudline/default.nix b/pkgs/applications/audio/baudline/default.nix
index 2f695b6ed7b..29c5130f575 100644
--- a/pkgs/applications/audio/baudline/default.nix
+++ b/pkgs/applications/audio/baudline/default.nix
@@ -3,7 +3,7 @@
 }:
 
 let
-  rpath = stdenv.lib.makeLibraryPath
+  rpath = lib.makeLibraryPath
     [ libXmu libXt libX11 libXext libXxf86vm libjack2 ];
 in
 stdenv.mkDerivation rec {
diff --git a/pkgs/applications/audio/cadence/default.nix b/pkgs/applications/audio/cadence/default.nix
index 7230bf63287..b94e8d2e6f2 100644
--- a/pkgs/applications/audio/cadence/default.nix
+++ b/pkgs/applications/audio/cadence/default.nix
@@ -98,8 +98,8 @@ mkDerivation rec {
   meta = {
     homepage = "https://github.com/falkTX/Cadence/";
     description = "Collection of tools useful for audio production";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [ worldofpeace ];
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ worldofpeace ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/applications/audio/caps/default.nix b/pkgs/applications/audio/caps/default.nix
index dc8511bf500..e0f71fa2646 100644
--- a/pkgs/applications/audio/caps/default.nix
+++ b/pkgs/applications/audio/caps/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 stdenv.mkDerivation rec {
   pname = "caps";
   version = "0.9.26";
@@ -23,8 +23,8 @@ stdenv.mkDerivation rec {
       resource demands and meaningful control interfaces.
     '';
     homepage = "http://www.quitte.de/dsp/caps.html";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.astsmtl ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.astsmtl ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/carla/default.nix b/pkgs/applications/audio/carla/default.nix
index 883daa2ddef..3800e351fab 100644
--- a/pkgs/applications/audio/carla/default.nix
+++ b/pkgs/applications/audio/carla/default.nix
@@ -5,7 +5,7 @@
   withGtk2 ? true, gtk2 ? null,
   withGtk3 ? true, gtk3 ? null }:
 
-with stdenv.lib;
+with lib;
 
 assert withFrontend -> python3Packages ? pyqt5;
 assert withQt -> qtbase != null;
diff --git a/pkgs/applications/audio/caudec/default.nix b/pkgs/applications/audio/caudec/default.nix
index 013cf9ef707..0360922c819 100644
--- a/pkgs/applications/audio/caudec/default.nix
+++ b/pkgs/applications/audio/caudec/default.nix
@@ -25,8 +25,8 @@ stdenv.mkDerivation {
 
   postFixup = ''
     for executable in $(cd $out/bin && ls); do
-	wrapProgram $out/bin/$executable \
-	  --prefix PATH : "${stdenv.lib.makeBinPath [ bc findutils sox procps opusTools lame flac ]}"
+  wrapProgram $out/bin/$executable \
+    --prefix PATH : "${lib.makeBinPath [ bc findutils sox procps opusTools lame flac ]}"
     done
   '';
 
diff --git a/pkgs/applications/audio/cd-discid/default.nix b/pkgs/applications/audio/cd-discid/default.nix
index 5dcb178dc79..109ce1295b4 100644
--- a/pkgs/applications/audio/cd-discid/default.nix
+++ b/pkgs/applications/audio/cd-discid/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   installFlags = [ "PREFIX=$(out)" "INSTALL=install" ];
 
   buildInputs = []
-    ++ stdenv.lib.optional stdenv.isDarwin IOKit;
+    ++ lib.optional stdenv.isDarwin IOKit;
 
   meta = with lib; {
     homepage = "http://linukz.org/cd-discid.shtml";
diff --git a/pkgs/applications/audio/cdparanoia/default.nix b/pkgs/applications/audio/cdparanoia/default.nix
index 54d55d1c1b6..29359b097d2 100644
--- a/pkgs/applications/audio/cdparanoia/default.nix
+++ b/pkgs/applications/audio/cdparanoia/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "1pv4zrajm46za0f6lv162iqffih57a8ly4pc69f7y0gfyigb8p80";
   };
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [
+  patches = lib.optionals stdenv.isDarwin [
     (fetchurl {
       url = "https://trac.macports.org/export/70964/trunk/dports/audio/cdparanoia/files/osx_interface.patch";
       sha256 = "1n86kzm2ssl8fdf5wlhp6ncb2bf6b9xlb5vg0mhc85r69prqzjiy";
@@ -17,19 +17,19 @@ stdenv.mkDerivation rec {
       url = "https://trac.macports.org/export/70964/trunk/dports/audio/cdparanoia/files/patch-paranoia_paranoia.c.10.4.diff";
       sha256 = "17l2qhn8sh4jy6ryy5si6ll6dndcm0r537rlmk4a6a8vkn852vad";
     })
-    ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./utils.patch
+    ] ++ lib.optional stdenv.hostPlatform.isMusl ./utils.patch
     ++ [./fix_private_keyword.patch];
 
-  nativeBuildInputs = stdenv.lib.optional stdenv.isAarch64 autoreconfHook;
+  nativeBuildInputs = lib.optional stdenv.isAarch64 autoreconfHook;
 
-  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [
+  propagatedBuildInputs = lib.optionals stdenv.isDarwin [
     Carbon
     IOKit
   ];
 
   hardeningDisable = [ "format" ];
 
-  preConfigure = "unset CC" + stdenv.lib.optionalString stdenv.isAarch64 '';
+  preConfigure = "unset CC" + lib.optionalString stdenv.isAarch64 '';
     cp ${gnu-config}/config.sub configure.sub
     cp ${gnu-config}/config.guess configure.guess
   '';
diff --git a/pkgs/applications/audio/clementine/default.nix b/pkgs/applications/audio/clementine/default.nix
index 500fb329356..b7b42b0aa7d 100644
--- a/pkgs/applications/audio/clementine/default.nix
+++ b/pkgs/applications/audio/clementine/default.nix
@@ -48,10 +48,10 @@ let
     sqlite
     taglib
   ]
-  ++ stdenv.lib.optionals (withIpod) [libgpod libplist usbmuxd]
-  ++ stdenv.lib.optionals (withMTP) [libmtp]
-  ++ stdenv.lib.optionals (withCD) [libcdio]
-  ++ stdenv.lib.optionals (withCloud) [sparsehash];
+  ++ lib.optionals (withIpod) [libgpod libplist usbmuxd]
+  ++ lib.optionals (withMTP) [libmtp]
+  ++ lib.optionals (withCD) [libcdio]
+  ++ lib.optionals (withCloud) [sparsehash];
 
   postPatch = ''
     sed -i src/CMakeLists.txt \
diff --git a/pkgs/applications/audio/clerk/default.nix b/pkgs/applications/audio/clerk/default.nix
index 03c693da15a..0724632a63e 100644
--- a/pkgs/applications/audio/clerk/default.nix
+++ b/pkgs/applications/audio/clerk/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   installPhase = ''
     DESTDIR=$out PREFIX=/ make install
     wrapProgram $out/bin/clerk \
-      --prefix PATH : "${stdenv.lib.makeBinPath [ rofi mpc_cli perl util-linux libnotify ]}"
+      --prefix PATH : "${lib.makeBinPath [ rofi mpc_cli perl util-linux libnotify ]}"
   '';
 
   meta = with lib; {
diff --git a/pkgs/applications/audio/cmus/default.nix b/pkgs/applications/audio/cmus/default.nix
index 2c8bf47cee9..5da6c63a81e 100644
--- a/pkgs/applications/audio/cmus/default.nix
+++ b/pkgs/applications/audio/cmus/default.nix
@@ -39,7 +39,7 @@
 #, vtxSupport ? true, libayemu ? null
 }:
 
-with stdenv.lib;
+with lib;
 
 assert samplerateSupport -> jackSupport;
 
@@ -120,8 +120,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ ncurses ]
-    ++ stdenv.lib.optional stdenv.cc.isClang clangGCC
-    ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv CoreAudio ]
+    ++ lib.optional stdenv.cc.isClang clangGCC
+    ++ lib.optionals stdenv.isDarwin [ libiconv CoreAudio ]
     ++ flatten (concatMap (a: a.deps) opts);
 
   makeFlags = [ "LD=$(CC)" ];
diff --git a/pkgs/applications/audio/cmusfm/default.nix b/pkgs/applications/audio/cmusfm/default.nix
index c07b887192a..307e06602e7 100644
--- a/pkgs/applications/audio/cmusfm/default.nix
+++ b/pkgs/applications/audio/cmusfm/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation {
       + Inside cmus run `:set status_display_program=cmusfm` to set up cmusfm
     '';
     homepage = "https://github.com/Arkq/cmusfm/";
-    maintainers = with stdenv.lib.maintainers; [ CharlesHD ];
+    maintainers = with lib.maintainers; [ CharlesHD ];
     license = licenses.gpl3Plus;
     platforms = platforms.linux ++ platforms.darwin;
   };
diff --git a/pkgs/applications/audio/crip/default.nix b/pkgs/applications/audio/crip/default.nix
index 0181ede26dd..c61f838bc3a 100644
--- a/pkgs/applications/audio/crip/default.nix
+++ b/pkgs/applications/audio/crip/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , makeWrapper
 
@@ -16,7 +16,7 @@
 , which
 }:
 
-with stdenv.lib;
+with lib;
 
 stdenv.mkDerivation rec {
   name = "crip-3.9";
@@ -60,8 +60,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://bach.dynet.com/crip/";
     description = "Terminal-based ripper/encoder/tagger tool for creating Ogg Vorbis/FLAC files";
-    license = stdenv.lib.licenses.gpl1;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl1;
+    platforms = lib.platforms.linux;
     maintainers = [ maintainers.endgame ];
   };
 }
diff --git a/pkgs/applications/audio/csound/csound-manual/default.nix b/pkgs/applications/audio/csound/csound-manual/default.nix
index 5cc8d71383b..ecd6685e217 100644
--- a/pkgs/applications/audio/csound/csound-manual/default.nix
+++ b/pkgs/applications/audio/csound/csound-manual/default.nix
@@ -1,5 +1,5 @@
 {
-  stdenv, fetchFromGitHub, docbook_xsl,
+  lib, stdenv, fetchFromGitHub, docbook_xsl,
   docbook_xml_dtd_45, python, pygments,
   libxslt
 }:
@@ -37,8 +37,8 @@ stdenv.mkDerivation {
   meta = {
     description = "The Csound Canonical Reference Manual";
     homepage = "https://github.com/csound/manual";
-    license = stdenv.lib.licenses.fdl12Plus;
-    maintainers = [ stdenv.lib.maintainers.hlolli ];
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.fdl12Plus;
+    maintainers = [ lib.maintainers.hlolli ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/audio/csound/default.nix b/pkgs/applications/audio/csound/default.nix
index 5a6a290af76..a63f7518494 100644
--- a/pkgs/applications/audio/csound/default.nix
+++ b/pkgs/applications/audio/csound/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   };
 
   cmakeFlags = [ "-DBUILD_CSOUND_AC=0" ] # fails to find Score.hpp
-    ++ stdenv.lib.optional (libjack2 != null) "-DJACK_HEADER=${libjack2}/include/jack/jack.h";
+    ++ lib.optional (libjack2 != null) "-DJACK_HEADER=${libjack2}/include/jack/jack.h";
 
   nativeBuildInputs = [ cmake flex bison gettext ];
   buildInputs = [ libsndfile libsamplerate boost ]
diff --git a/pkgs/applications/audio/deadbeef/default.nix b/pkgs/applications/audio/deadbeef/default.nix
index 0259f522d80..800458e7925 100644
--- a/pkgs/applications/audio/deadbeef/default.nix
+++ b/pkgs/applications/audio/deadbeef/default.nix
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
     sha256 = "161b0ll8v4cjgwwmk137hzvh0jidlkx56vjkpnr70f0x4jzv2nll";
   };
 
-  buildInputs = with stdenv.lib; [ jansson ]
+  buildInputs = with lib; [ jansson ]
     ++ optional gtk2Support gtk2
     ++ optionals gtk3Support [ gtk3 gsettings-desktop-schemas ]
     ++ optional vorbisSupport libvorbis
@@ -98,7 +98,7 @@ stdenv.mkDerivation rec {
     intltool
     libtool
     pkgconfig
-  ] ++ stdenv.lib.optional gtk3Support wrapGAppsHook;
+  ] ++ lib.optional gtk3Support wrapGAppsHook;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/applications/audio/easytag/default.nix b/pkgs/applications/audio/easytag/default.nix
index 5ea0871b62b..6f5431cf1d8 100644
--- a/pkgs/applications/audio/easytag/default.nix
+++ b/pkgs/applications/audio/easytag/default.nix
@@ -10,7 +10,7 @@ in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${name}.tar.xz";
     sha256 = "1mbxnqrw1fwcgraa1bgik25vdzvf97vma5pzknbwbqq5ly9fwlgw";
   };
 
diff --git a/pkgs/applications/audio/ecasound/default.nix b/pkgs/applications/audio/ecasound/default.nix
index 505e5a604ca..0de66b24e70 100644
--- a/pkgs/applications/audio/ecasound/default.nix
+++ b/pkgs/applications/audio/ecasound/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , pkg-config
 , alsaLib
@@ -59,7 +59,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Software package designed for multitrack audio processing";
-    license = with stdenv.lib.licenses;  [ gpl2 lgpl21 ];
+    license = with lib.licenses;  [ gpl2 lgpl21 ];
     homepage = "http://nosignal.fi/ecasound/";
   };
 }
diff --git a/pkgs/applications/audio/eflite/default.nix b/pkgs/applications/audio/eflite/default.nix
index 30a35501771..6a974abb8aa 100644
--- a/pkgs/applications/audio/eflite/default.nix
+++ b/pkgs/applications/audio/eflite/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, flite, alsaLib, debug ? false }:
+{ lib, stdenv, fetchurl, fetchpatch, flite, alsaLib, debug ? false }:
 
 stdenv.mkDerivation rec {
   pname = "eflite";
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     ./format.patch
   ];
 
-  CFLAGS = stdenv.lib.optionalString debug " -DDEBUG=2";
+  CFLAGS = lib.optionalString debug " -DDEBUG=2";
 
   meta = {
     homepage = "http://eflite.sourceforge.net";
@@ -44,8 +44,8 @@ stdenv.mkDerivation rec {
       a free text-to-speech engine developed at the CMU Speech
       Center as an off-shoot of Festival.
     '';
-    license = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ jhhuh ];
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ jhhuh ];
   };
 }
diff --git a/pkgs/applications/audio/ekho/default.nix b/pkgs/applications/audio/ekho/default.nix
index 86bf4faaa17..8897abd7007 100644
--- a/pkgs/applications/audio/ekho/default.nix
+++ b/pkgs/applications/audio/ekho/default.nix
@@ -28,7 +28,7 @@ in stdenv.mkDerivation rec {
     sha256 = "0ym6lpcpsvwvsiwlzkl1509a2hljwcw7synngrmqjq1n49ww00nj";
   };
 
-  preConfigure = with stdenv.lib; ''
+  preConfigure = with lib; ''
     NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${optionalString stdenv.is64bit "-D_x86_64"}"
     NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DEKHO_DATA_PATH=\"$out/share/ekho-data\""
   '';
diff --git a/pkgs/applications/audio/eq10q/default.nix b/pkgs/applications/audio/eq10q/default.nix
index 6c627c835ae..3531132f2fd 100644
--- a/pkgs/applications/audio/eq10q/default.nix
+++ b/pkgs/applications/audio/eq10q/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, cmake, fftw, gtkmm2, libxcb, lv2, pkg-config
+{ lib, stdenv, fetchurl, fetchpatch, cmake, fftw, gtkmm2, libxcb, lv2, pkg-config
 , xorg }:
 stdenv.mkDerivation rec {
   pname = "eq10q";
@@ -44,8 +44,8 @@ stdenv.mkDerivation rec {
       Nice GUI with powerful metering for every plugin.
     '';
     homepage = "http://eq10q.sourceforge.net/";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/espeak/edit.nix b/pkgs/applications/audio/espeak/edit.nix
index e027bb03cfc..c7c975ef953 100644
--- a/pkgs/applications/audio/espeak/edit.nix
+++ b/pkgs/applications/audio/espeak/edit.nix
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
             -e "s|@prefix@|$out|" \
             -i "$file"
     done
-  '' + stdenv.lib.optionalString (portaudio.api_version == 19) ''
+  '' + lib.optionalString (portaudio.api_version == 19) ''
     cp src/portaudio19.h src/portaudio.h
   '';
 
diff --git a/pkgs/applications/audio/faust/faust1.nix b/pkgs/applications/audio/faust/faust1.nix
index efa97738d3c..365055523ea 100644
--- a/pkgs/applications/audio/faust/faust1.nix
+++ b/pkgs/applications/audio/faust/faust1.nix
@@ -5,7 +5,7 @@
 , pkgconfig
 }:
 
-with stdenv.lib.strings;
+with lib.strings;
 
 let
 
diff --git a/pkgs/applications/audio/faust/faust2.nix b/pkgs/applications/audio/faust/faust2.nix
index 4c0229e8f34..52a291603f8 100644
--- a/pkgs/applications/audio/faust/faust2.nix
+++ b/pkgs/applications/audio/faust/faust2.nix
@@ -16,7 +16,7 @@
 , which
 }:
 
-with stdenv.lib.strings;
+with lib.strings;
 
 let
 
@@ -173,7 +173,7 @@ let
 
       propagatedBuildInputs = [ faust ] ++ propagatedBuildInputs;
 
-      libPath = stdenv.lib.makeLibraryPath propagatedBuildInputs;
+      libPath = lib.makeLibraryPath propagatedBuildInputs;
 
       postFixup = ''
 
diff --git a/pkgs/applications/audio/fmit/default.nix b/pkgs/applications/audio/fmit/default.nix
index f173d2fe02b..e22067c38fc 100644
--- a/pkgs/applications/audio/fmit/default.nix
+++ b/pkgs/applications/audio/fmit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, mkDerivation, fetchFromGitHub, fftw, qtbase, qtmultimedia, qmake, itstool, wrapQtAppsHook
+{ lib, stdenv, mkDerivation, fetchFromGitHub, fftw, qtbase, qtmultimedia, qmake, itstool, wrapQtAppsHook
 , alsaSupport ? true, alsaLib ? null
 , jackSupport ? false, libjack2 ? null
 , portaudioSupport ? false, portaudio ? null }:
@@ -7,7 +7,7 @@ assert alsaSupport -> alsaLib != null;
 assert jackSupport -> libjack2 != null;
 assert portaudioSupport -> portaudio != null;
 
-with stdenv.lib;
+with lib;
 
 mkDerivation rec {
   pname = "fmit";
diff --git a/pkgs/applications/audio/fmsynth/default.nix b/pkgs/applications/audio/fmsynth/default.nix
index d957c7ec33d..d8741525da5 100644
--- a/pkgs/applications/audio/fmsynth/default.nix
+++ b/pkgs/applications/audio/fmsynth/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, gtkmm2, lv2, lvtk, pkgconfig }:
+{ lib, stdenv, fetchFromGitHub, gtkmm2, lv2, lvtk, pkgconfig }:
 stdenv.mkDerivation {
   pname = "fmsynth-unstable";
   version = "2015-02-07";
@@ -42,8 +42,8 @@ stdenv.mkDerivation {
       - Hard real-time constraints
     '';
     homepage = "https://github.com/Themaister/libfmsynth";
-    license = stdenv.lib.licenses.mit;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.mit;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/freewheeling/default.nix b/pkgs/applications/audio/freewheeling/default.nix
index 071a4a9caab..f484a76e75a 100644
--- a/pkgs/applications/audio/freewheeling/default.nix
+++ b/pkgs/applications/audio/freewheeling/default.nix
@@ -45,8 +45,8 @@ stdenv.mkDerivation rec {
     '' ;
 
     homepage = "http://freewheeling.sourceforge.net";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.sepi ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.sepi ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/ft2-clone/default.nix b/pkgs/applications/audio/ft2-clone/default.nix
index b231b4a69ed..c1b8b808a1d 100644
--- a/pkgs/applications/audio/ft2-clone/default.nix
+++ b/pkgs/applications/audio/ft2-clone/default.nix
@@ -23,14 +23,14 @@ stdenv.mkDerivation rec {
   };
 
   # Adapt the linux-only CMakeLists to darwin (more reliable than make-macos.sh)
-  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+  postPatch = lib.optionalString stdenv.isDarwin ''
     sed -i -e 's@__LINUX_ALSA__@__MACOSX_CORE__@' -e 's@asound@@' CMakeLists.txt
   '';
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ SDL2 ]
-    ++ stdenv.lib.optional stdenv.isLinux alsaLib
-    ++ stdenv.lib.optionals stdenv.isDarwin [
+    ++ lib.optional stdenv.isLinux alsaLib
+    ++ lib.optionals stdenv.isDarwin [
          libiconv
          CoreAudio
          CoreMIDI
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
          Cocoa
        ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin [
+  NIX_LDFLAGS = lib.optionalString stdenv.isDarwin [
     "-framework CoreAudio"
     "-framework CoreMIDI"
     "-framework CoreServices"
diff --git a/pkgs/applications/audio/gmu/default.nix b/pkgs/applications/audio/gmu/default.nix
index bfe9f72d664..3e2087162f5 100644
--- a/pkgs/applications/audio/gmu/default.nix
+++ b/pkgs/applications/audio/gmu/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, SDL, SDL_gfx, SDL_image, tremor, flac, mpg123, libmikmod
+{lib, stdenv, fetchurl, SDL, SDL_gfx, SDL_image, tremor, flac, mpg123, libmikmod
 , speex, ncurses
 , keymap ? "default"
 , conf ? "unknown"
@@ -26,6 +26,6 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://wejp.k.vu/projects/gmu";
     description = "Open source music player for portable gaming consoles and handhelds";
-    license = stdenv.lib.licenses.gpl2;
+    license = lib.licenses.gpl2;
   };
 }
diff --git a/pkgs/applications/audio/goattracker/default.nix b/pkgs/applications/audio/goattracker/default.nix
index 76b5617d23c..30bb4099233 100644
--- a/pkgs/applications/audio/goattracker/default.nix
+++ b/pkgs/applications/audio/goattracker/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , unzip
 , copyDesktopItems
@@ -8,7 +8,7 @@
 , isStereo ? false
 }:
 
-with stdenv.lib;
+with lib;
 let
   pname = "goattracker" + optionalString isStereo "-stereo";
   desktopItem = makeDesktopItem {
diff --git a/pkgs/applications/audio/google-musicmanager/default.nix b/pkgs/applications/audio/google-musicmanager/default.nix
index a202b3ad280..e10a961a9e6 100644
--- a/pkgs/applications/audio/google-musicmanager/default.nix
+++ b/pkgs/applications/audio/google-musicmanager/default.nix
@@ -50,12 +50,12 @@ stdenv.mkDerivation rec {
   postFixup = ''
     patchelf \
       --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --set-rpath "$(patchelf --print-rpath $out/opt/google/musicmanager/minidump_upload):${stdenv.lib.makeLibraryPath [ stdenv.cc.cc.lib ]}" \
+      --set-rpath "$(patchelf --print-rpath $out/opt/google/musicmanager/minidump_upload):${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}" \
       $out/opt/google/musicmanager/minidump_upload
 
     patchelf \
       --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --set-rpath "$(patchelf --print-rpath $out/opt/google/musicmanager/MusicManager):$out/lib:${stdenv.lib.makeLibraryPath [
+      --set-rpath "$(patchelf --print-rpath $out/opt/google/musicmanager/MusicManager):$out/lib:${lib.makeLibraryPath [
         flac
         expat
         libidn
diff --git a/pkgs/applications/audio/google-play-music-desktop-player/default.nix b/pkgs/applications/audio/google-play-music-desktop-player/default.nix
index 509d3ddcf75..0be1cc45717 100644
--- a/pkgs/applications/audio/google-play-music-desktop-player/default.nix
+++ b/pkgs/applications/audio/google-play-music-desktop-player/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, alsaLib, atk, at-spi2-atk, cairo, cups, dbus, dpkg, expat, fontconfig, freetype
+{ lib, stdenv, alsaLib, atk, at-spi2-atk, cairo, cups, dbus, dpkg, expat, fontconfig, freetype
 , fetchurl, GConf, gdk-pixbuf, glib, gtk2, gtk3, libpulseaudio, makeWrapper, nspr
 , nss, pango, udev, xorg
 }:
@@ -69,14 +69,14 @@ stdenv.mkDerivation {
 
     wrapProgram $out/bin/google-play-music-desktop-player \
       --prefix LD_LIBRARY_PATH : "$out/share/google-play-music-desktop-player" \
-      --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath deps}"
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath deps}"
   '';
 
   meta = {
     homepage = "https://www.googleplaymusicdesktopplayer.com/";
     description = "A beautiful cross platform Desktop Player for Google Play Music";
-    license = stdenv.lib.licenses.mit;
+    license = lib.licenses.mit;
     platforms = [ "x86_64-linux" ];
-    maintainers = [ stdenv.lib.maintainers.SuprDewd ];
+    maintainers = [ lib.maintainers.SuprDewd ];
   };
 }
diff --git a/pkgs/applications/audio/gpodder/default.nix b/pkgs/applications/audio/gpodder/default.nix
index 08263026959..dea1f5fe7bc 100644
--- a/pkgs/applications/audio/gpodder/default.nix
+++ b/pkgs/applications/audio/gpodder/default.nix
@@ -19,7 +19,7 @@ python3Packages.buildPythonApplication rec {
     ./disable-autoupdate.patch
   ];
 
-  postPatch = with stdenv.lib; ''
+  postPatch = with lib; ''
     sed -i -re 's,^( *gpodder_dir *= *).*,\1"'"$out"'",' bin/gpodder
   '';
 
diff --git a/pkgs/applications/audio/grandorgue/default.nix b/pkgs/applications/audio/grandorgue/default.nix
index e2ba4ee2244..80008080ead 100644
--- a/pkgs/applications/audio/grandorgue/default.nix
+++ b/pkgs/applications/audio/grandorgue/default.nix
@@ -25,8 +25,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Virtual Pipe Organ Software";
     homepage = "https://sourceforge.net/projects/ourorgan";
-    license = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.puzzlewolf ];
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.puzzlewolf ];
   };
 }
diff --git a/pkgs/applications/audio/gtklick/default.nix b/pkgs/applications/audio/gtklick/default.nix
index a81834c1fff..ddd09ce4452 100644
--- a/pkgs/applications/audio/gtklick/default.nix
+++ b/pkgs/applications/audio/gtklick/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pythonPackages, gettext, klick}:
+{ lib, stdenv, fetchurl, pythonPackages, gettext, klick}:
 
 pythonPackages.buildPythonApplication rec {
   pname = "gtklick";
@@ -29,6 +29,6 @@ pythonPackages.buildPythonApplication rec {
   meta = {
     homepage = "http://das.nasophon.de/gtklick/";
     description = "Simple metronome with an easy-to-use GTK interface";
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/applications/audio/guitarix/default.nix b/pkgs/applications/audio/guitarix/default.nix
index 41c7db959e0..3f95ae82528 100644
--- a/pkgs/applications/audio/guitarix/default.nix
+++ b/pkgs/applications/audio/guitarix/default.nix
@@ -37,7 +37,7 @@
 }:
 
 let
-  inherit (stdenv.lib) optional;
+  inherit (lib) optional;
 in
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/applications/audio/helm/default.nix b/pkgs/applications/audio/helm/default.nix
index d20bbb8e573..1bf3ba6480b 100644
--- a/pkgs/applications/audio/helm/default.nix
+++ b/pkgs/applications/audio/helm/default.nix
@@ -72,7 +72,7 @@
         Simple arpeggiator
         Effects: Formant filter, stutter, delay
     '';
-    license = stdenv.lib.licenses.gpl3;
+    license = lib.licenses.gpl3;
     maintainers = [ maintainers.magnetophon ];
     platforms = platforms.linux;
   };
diff --git a/pkgs/applications/audio/i-score/default.nix b/pkgs/applications/audio/i-score/default.nix
index daedb9b9820..2592c38e142 100644
--- a/pkgs/applications/audio/i-score/default.nix
+++ b/pkgs/applications/audio/i-score/default.nix
@@ -22,7 +22,7 @@
   qttools,
   qtwebsockets,
   rtaudio,
-  stdenv
+  lib, stdenv
 }:
 
 stdenv.mkDerivation rec {
@@ -78,8 +78,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "An interactive sequencer for the intermedia arts";
     homepage = "http://i-score.org/";
-    license = stdenv.lib.licenses.cecill20;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.cecill20;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/industrializer/default.nix b/pkgs/applications/audio/industrializer/default.nix
index 593458506d8..f638eba3210 100644
--- a/pkgs/applications/audio/industrializer/default.nix
+++ b/pkgs/applications/audio/industrializer/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , alsaLib
 , audiofile
@@ -43,8 +43,8 @@ stdenv.mkDerivation rec {
       After a sound is rendered, it can be played and then saved to a .WAV file.
     '';
     homepage = "https://sourceforge.net/projects/industrializer/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/jack-capture/default.nix b/pkgs/applications/audio/jack-capture/default.nix
index 0cf21c6a8c8..f5134745a9c 100644
--- a/pkgs/applications/audio/jack-capture/default.nix
+++ b/pkgs/applications/audio/jack-capture/default.nix
@@ -26,6 +26,6 @@ stdenv.mkDerivation rec {
     homepage = "http://archive.notam02.no/arkiv/src";
     license = licenses.gpl2;
     maintainers = [ maintainers.goibhniu ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/jack-oscrolloscope/default.nix b/pkgs/applications/audio/jack-oscrolloscope/default.nix
index ffd9ec5cbc3..c6b971275d4 100644
--- a/pkgs/applications/audio/jack-oscrolloscope/default.nix
+++ b/pkgs/applications/audio/jack-oscrolloscope/default.nix
@@ -22,6 +22,6 @@ stdenv.mkDerivation rec {
     homepage = "http://das.nasophon.de/jack_oscrolloscope";
     license = licenses.gpl2;
     maintainers = [ maintainers.goibhniu ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/jack-rack/default.nix b/pkgs/applications/audio/jack-rack/default.nix
index d13dbcc1688..a65c8034f89 100644
--- a/pkgs/applications/audio/jack-rack/default.nix
+++ b/pkgs/applications/audio/jack-rack/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libjack2, ladspaH, gtk2, alsaLib, libxml2, lrdf }:
+{ lib, stdenv, fetchurl, pkgconfig, libjack2, ladspaH, gtk2, alsaLib, libxml2, lrdf }:
 stdenv.mkDerivation rec {
   name = "jack-rack-1.4.7";
   src = fetchurl {
@@ -18,8 +18,8 @@ stdenv.mkDerivation rec {
       computer into an effects box.
     '';
     homepage = "http://jack-rack.sourceforge.net/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.astsmtl ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.astsmtl ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/jackmeter/default.nix b/pkgs/applications/audio/jackmeter/default.nix
index d049cf81b11..499badac6d2 100644
--- a/pkgs/applications/audio/jackmeter/default.nix
+++ b/pkgs/applications/audio/jackmeter/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libjack2, pkgconfig }:
+{ lib, stdenv, fetchurl, libjack2, pkgconfig }:
 
 stdenv.mkDerivation rec {
   name = "jackmeter-0.4";
@@ -14,8 +14,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Console jack loudness meter";
     homepage = "https://www.aelius.com/njh/jackmeter/";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.marcweber ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.marcweber ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/jamulus/default.nix b/pkgs/applications/audio/jamulus/default.nix
index 4cc48b89f9c..55427ccfda4 100644
--- a/pkgs/applications/audio/jamulus/default.nix
+++ b/pkgs/applications/audio/jamulus/default.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, stdenv, fetchFromGitHub, fetchpatch, pkg-config, qtscript, qmake, libjack2
+{ mkDerivation, lib, stdenv, fetchFromGitHub, fetchpatch, pkg-config, qtscript, qmake, libjack2
 }:
 
 mkDerivation rec {
@@ -7,7 +7,7 @@ mkDerivation rec {
   src = fetchFromGitHub {
     owner = "corrados";
     repo = "jamulus";
-    rev = "r${stdenv.lib.replaceStrings [ "." ] [ "_" ] version}";
+    rev = "r${lib.replaceStrings [ "." ] [ "_" ] version}";
     sha256 = "11rwgd2car7ziqa0vancb363m4ca94pj480jfxywd6d81139jl15";
   };
 
@@ -20,8 +20,8 @@ mkDerivation rec {
     description = "Enables musicians to perform real-time jam sessions over the internet";
     longDescription = "You also need to enable JACK and should enable several real-time optimizations. See project website for details";
     homepage = "https://github.com/corrados/jamulus/wiki";
-    license = stdenv.lib.licenses.gpl2; # linked in git repo, at least
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.seb314 ];
+    license = lib.licenses.gpl2; # linked in git repo, at least
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.seb314 ];
   };
 }
diff --git a/pkgs/applications/audio/japa/default.nix b/pkgs/applications/audio/japa/default.nix
index 426fea21107..f45395eefa6 100644
--- a/pkgs/applications/audio/japa/default.nix
+++ b/pkgs/applications/audio/japa/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl,   alsaLib, libjack2, fftwFloat, libclthreads, libclxclient, libX11,  libXft, zita-alsa-pcmi, }:
+{ lib, stdenv, fetchurl,   alsaLib, libjack2, fftwFloat, libclthreads, libclxclient, libX11,  libXft, zita-alsa-pcmi, }:
 
 stdenv.mkDerivation rec {
   version = "0.9.2";
@@ -23,8 +23,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A 'perceptual' or 'psychoacoustic' audio spectrum analyser for JACK and ALSA";
     homepage = "http://kokkinizita.linuxaudio.org/linuxaudio/index.html";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/klick/default.nix b/pkgs/applications/audio/klick/default.nix
index 9ff063c1c80..05ac14eec09 100644
--- a/pkgs/applications/audio/klick/default.nix
+++ b/pkgs/applications/audio/klick/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, sconsPackages, pkgconfig
+{ lib, stdenv, fetchurl, sconsPackages, pkgconfig
 , libsamplerate, libsndfile, liblo, libjack2, boost }:
 
 stdenv.mkDerivation rec {
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "http://das.nasophon.de/klick/";
     description = "Advanced command-line metronome for JACK";
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/ladspa-sdk/default.nix b/pkgs/applications/audio/ladspa-sdk/default.nix
index 76acd1daba7..47a36ed1b5d 100644
--- a/pkgs/applications/audio/ladspa-sdk/default.nix
+++ b/pkgs/applications/audio/ladspa-sdk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 stdenv.mkDerivation rec {
   pname = "ladspa-sdk";
   version = "1.15";
@@ -21,8 +21,8 @@ stdenv.mkDerivation rec {
       three example programs (applyplugin, analyseplugin and listplugins).
     '';
     homepage = "http://www.ladspa.org/ladspa_sdk/overview.html";
-    license = stdenv.lib.licenses.lgpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.lgpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/ladspa-sdk/ladspah.nix b/pkgs/applications/audio/ladspa-sdk/ladspah.nix
index d51aa3b75e1..b497e91927b 100644
--- a/pkgs/applications/audio/ladspa-sdk/ladspah.nix
+++ b/pkgs/applications/audio/ladspa-sdk/ladspah.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 stdenv.mkDerivation rec {
   pname = "ladspa.h";
   version = "1.15";
@@ -19,8 +19,8 @@ stdenv.mkDerivation rec {
       For the full SDK, use the ladspa-sdk package.
     '';
     homepage = "http://www.ladspa.org/ladspa_sdk/overview.html";
-    license = stdenv.lib.licenses.lgpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.all;
+    license = lib.licenses.lgpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/audio/librespot/default.nix b/pkgs/applications/audio/librespot/default.nix
index 241a89caa0b..e8e6accefdb 100644
--- a/pkgs/applications/audio/librespot/default.nix
+++ b/pkgs/applications/audio/librespot/default.nix
@@ -17,7 +17,7 @@ rustPlatform.buildRustPackage rec {
 
   cargoPatches = [ ./cargo-lock.patch ];
 
-  cargoBuildFlags = with stdenv.lib; [
+  cargoBuildFlags = with lib; [
     "--no-default-features"
     "--features"
     (concatStringsSep "," (filter (x: x != "") [
@@ -31,9 +31,9 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ pkgconfig ];
 
-  buildInputs = [ openssl ] ++ stdenv.lib.optional withALSA alsaLib
-    ++ stdenv.lib.optional withPulseAudio libpulseaudio
-    ++ stdenv.lib.optional withPortAudio portaudio;
+  buildInputs = [ openssl ] ++ lib.optional withALSA alsaLib
+    ++ lib.optional withPulseAudio libpulseaudio
+    ++ lib.optional withPortAudio portaudio;
 
   doCheck = false;
 
diff --git a/pkgs/applications/audio/lingot/default.nix b/pkgs/applications/audio/lingot/default.nix
index f229e15871e..17a28315f19 100644
--- a/pkgs/applications/audio/lingot/default.nix
+++ b/pkgs/applications/audio/lingot/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , pkg-config
 , intltool
@@ -31,15 +31,15 @@ stdenv.mkDerivation rec {
     alsaLib
     libpulseaudio
     fftw
-  ] ++ stdenv.lib.optional jackSupport libjack2;
+  ] ++ lib.optional jackSupport libjack2;
 
-  configureFlags = stdenv.lib.optional (!jackSupport) "--disable-jack";
+  configureFlags = lib.optional (!jackSupport) "--disable-jack";
 
   meta = {
     description = "Not a Guitar-Only tuner";
     homepage = "https://www.nongnu.org/lingot/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = with stdenv.lib.platforms; linux;
-    maintainers = with stdenv.lib.maintainers; [ viric ];
+    license = lib.licenses.gpl2Plus;
+    platforms = with lib.platforms; linux;
+    maintainers = with lib.maintainers; [ viric ];
   };
 }
diff --git a/pkgs/applications/audio/linuxband/default.nix b/pkgs/applications/audio/linuxband/default.nix
index cd9ca5e2674..92933d21d13 100644
--- a/pkgs/applications/audio/linuxband/default.nix
+++ b/pkgs/applications/audio/linuxband/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, makeWrapper, pkgconfig, MMA, libjack2, libsmf, python2Packages }:
+{ lib, stdenv, fetchurl, makeWrapper, pkgconfig, MMA, libjack2, libsmf, python2Packages }:
 
 let
   inherit (python2Packages) pyGtkGlade pygtksourceview python;
@@ -30,8 +30,8 @@ in stdenv.mkDerivation rec {
   meta = {
     description = "A GUI front-end for MMA: Type in the chords, choose the groove and it will play an accompaniment";
     homepage = "http://linuxband.org/";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/littlegptracker/default.nix b/pkgs/applications/audio/littlegptracker/default.nix
index 9772425535f..638f54da515 100644
--- a/pkgs/applications/audio/littlegptracker/default.nix
+++ b/pkgs/applications/audio/littlegptracker/default.nix
@@ -20,8 +20,8 @@ stdenv.mkDerivation rec {
   buildInputs = [
     SDL
   ]
-  ++ stdenv.lib.optional stdenv.isDarwin Foundation
-  ++ stdenv.lib.optional stdenv.isLinux jack2;
+  ++ lib.optional stdenv.isDarwin Foundation
+  ++ lib.optional stdenv.isLinux jack2;
 
   patches = [
     # Remove outdated (pre-64bit) checks that would fail on modern platforms
@@ -32,13 +32,13 @@ stdenv.mkDerivation rec {
   preBuild = "cd projects";
 
   makeFlags = [ "CXX=${stdenv.cc.targetPrefix}c++" ]
-    ++ stdenv.lib.optionals stdenv.isLinux  [ "PLATFORM=DEB" ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ "PLATFORM=OSX" ];
+    ++ lib.optionals stdenv.isLinux  [ "PLATFORM=DEB" ]
+    ++ lib.optionals stdenv.isDarwin [ "PLATFORM=OSX" ];
 
   NIX_CFLAGS_COMPILE = [ "-fpermissive" ] ++
-    stdenv.lib.optional stdenv.hostPlatform.isAarch64 "-Wno-error=narrowing";
+    lib.optional stdenv.hostPlatform.isAarch64 "-Wno-error=narrowing";
 
-  NIX_LDFLAGS = stdenv.lib.optional stdenv.isDarwin "-framework Foundation";
+  NIX_LDFLAGS = lib.optional stdenv.isDarwin "-framework Foundation";
 
   installPhase = let extension = if stdenv.isDarwin then "app" else "deb-exe";
     in "install -Dm555 lgpt.${extension} $out/bin/lgpt";
diff --git a/pkgs/applications/audio/lsp-plugins/default.nix b/pkgs/applications/audio/lsp-plugins/default.nix
index e32b2e54f47..f4cb5e80890 100644
--- a/pkgs/applications/audio/lsp-plugins/default.nix
+++ b/pkgs/applications/audio/lsp-plugins/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, pkgconfig, makeWrapper
+{ lib, stdenv, fetchFromGitHub, pkgconfig, makeWrapper
 , libsndfile, jack2Full
 , libGLU, libGL, lv2, cairo
 , ladspaH, php }:
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
 
   buildFlags = [ "release" ];
 
-  meta = with stdenv.lib;
+  meta = with lib;
     { description = "Collection of open-source audio plugins";
       longDescription = ''
         Compatible with follwing formats:
diff --git a/pkgs/applications/audio/magnetophonDSP/CharacterCompressor/default.nix b/pkgs/applications/audio/magnetophonDSP/CharacterCompressor/default.nix
index e16198696a6..d7f0a7fb20e 100644
--- a/pkgs/applications/audio/magnetophonDSP/CharacterCompressor/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/CharacterCompressor/default.nix
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A compressor with character. For jack and lv2";
     homepage = "https://github.com/magnetophon/CharacterCompressor";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/CompBus/default.nix b/pkgs/applications/audio/magnetophonDSP/CompBus/default.nix
index 1ccc9f3fcd5..7a917d79c57 100644
--- a/pkgs/applications/audio/magnetophonDSP/CompBus/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/CompBus/default.nix
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A group of compressors mixed into a bus, sidechained from that mix bus. For jack and lv2";
     homepage = "https://github.com/magnetophon/CompBus";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/ConstantDetuneChorus/default.nix b/pkgs/applications/audio/magnetophonDSP/ConstantDetuneChorus/default.nix
index d5ed7e85b69..5ac71172325 100644
--- a/pkgs/applications/audio/magnetophonDSP/ConstantDetuneChorus/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/ConstantDetuneChorus/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A chorus algorithm that maintains constant and symmetric detuning depth (in cents), regardless of modulation rate. For jack and lv2";
     homepage = "https://github.com/magnetophon/constant-detune-chorus";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/LazyLimiter/default.nix b/pkgs/applications/audio/magnetophonDSP/LazyLimiter/default.nix
index 6d119394d5d..277b186fd4a 100644
--- a/pkgs/applications/audio/magnetophonDSP/LazyLimiter/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/LazyLimiter/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A fast yet clean lookahead limiter for jack and lv2";
     homepage = "https://magnetophon.github.io/LazyLimiter/";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/MBdistortion/default.nix b/pkgs/applications/audio/magnetophonDSP/MBdistortion/default.nix
index 0eb68e65eae..de7e573cbee 100644
--- a/pkgs/applications/audio/magnetophonDSP/MBdistortion/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/MBdistortion/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Mid-side multiband distortion for jack and lv2";
     homepage = "https://github.com/magnetophon/MBdistortion";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/RhythmDelay/default.nix b/pkgs/applications/audio/magnetophonDSP/RhythmDelay/default.nix
index be8ad72d28d..80c5bb89eee 100644
--- a/pkgs/applications/audio/magnetophonDSP/RhythmDelay/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/RhythmDelay/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Tap a rhythm into your delay! For jack and lv2";
     homepage = "https://github.com/magnetophon/RhythmDelay";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/VoiceOfFaust/default.nix b/pkgs/applications/audio/magnetophonDSP/VoiceOfFaust/default.nix
index dce2db4cb77..9bd4076f130 100644
--- a/pkgs/applications/audio/magnetophonDSP/VoiceOfFaust/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/VoiceOfFaust/default.nix
@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Turn your voice into a synthesizer";
     homepage = "https://github.com/magnetophon/VoiceOfFaust";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/faustCompressors/default.nix b/pkgs/applications/audio/magnetophonDSP/faustCompressors/default.nix
index 172b5ed3891..a90492f4235 100644
--- a/pkgs/applications/audio/magnetophonDSP/faustCompressors/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/faustCompressors/default.nix
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A collection of bread and butter compressors";
     homepage = "https://github.com/magnetophon/faustCompressors";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/pluginUtils/default.nix b/pkgs/applications/audio/magnetophonDSP/pluginUtils/default.nix
index 11d51d756ab..414e350caa0 100644
--- a/pkgs/applications/audio/magnetophonDSP/pluginUtils/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/pluginUtils/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Some simple utility lv2 plugins";
     homepage = "https://github.com/magnetophon/pluginUtils";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/magnetophonDSP/shelfMultiBand/default.nix b/pkgs/applications/audio/magnetophonDSP/shelfMultiBand/default.nix
index 360cee243c3..7dcdf985c82 100644
--- a/pkgs/applications/audio/magnetophonDSP/shelfMultiBand/default.nix
+++ b/pkgs/applications/audio/magnetophonDSP/shelfMultiBand/default.nix
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A multiband compressor made from shelving filters.";
     homepage = "https://github.com/magnetophon/shelfMultiBand";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/meters_lv2/default.nix b/pkgs/applications/audio/meters_lv2/default.nix
index cd9523d2710..86a608db4c8 100644
--- a/pkgs/applications/audio/meters_lv2/default.nix
+++ b/pkgs/applications/audio/meters_lv2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig
+{ lib, stdenv, fetchurl, pkgconfig
 , lv2, libGLU, libGL, gtk2, cairo, pango, fftwFloat, libjack2 }:
 
 let
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   preConfigure = "makeFlagsArray=( PREFIX=$out )";
   meter_VERSION = version;
 
-  meta = with stdenv.lib;
+  meta = with lib;
     { description = "Collection of audio level meters with GUI in LV2 plugin format";
       homepage = "http://x42.github.io/meters.lv2/";
       maintainers = with maintainers; [ ehmry ];
diff --git a/pkgs/applications/audio/mi2ly/default.nix b/pkgs/applications/audio/mi2ly/default.nix
index bc74a73b643..b4f7668394f 100644
--- a/pkgs/applications/audio/mi2ly/default.nix
+++ b/pkgs/applications/audio/mi2ly/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{lib, stdenv, fetchurl}:
 let
   s = # Generated upstream information
   rec {
@@ -33,9 +33,9 @@ stdenv.mkDerivation {
   meta = {
     inherit (s) version;
     description = "MIDI to Lilypond converter";
-    license = stdenv.lib.licenses.gpl2Plus ;
-    maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
     broken = true; # 2018-04-11
   };
 }
diff --git a/pkgs/applications/audio/midisheetmusic/default.nix b/pkgs/applications/audio/midisheetmusic/default.nix
index 1f408f6f628..bff9e807b43 100644
--- a/pkgs/applications/audio/midisheetmusic/default.nix
+++ b/pkgs/applications/audio/midisheetmusic/default.nix
@@ -47,8 +47,8 @@ in stdenv.mkDerivation {
     cp bin/Debug/MidiSheetMusic.exe $out/bin/.MidiSheetMusic.exe
 
     makeWrapper ${mono}/bin/mono $out/bin/midisheetmusic.mono.exe \
-      --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ gtk2 cups ]} \
-      --prefix PATH : ${stdenv.lib.makeBinPath [ timidity ]} \
+      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ gtk2 cups ]} \
+      --prefix PATH : ${lib.makeBinPath [ timidity ]} \
       --add-flags $out/bin/.MidiSheetMusic.exe
   '';
 
diff --git a/pkgs/applications/audio/mikmod/default.nix b/pkgs/applications/audio/mikmod/default.nix
index 9be303cb652..4d39616c99d 100644
--- a/pkgs/applications/audio/mikmod/default.nix
+++ b/pkgs/applications/audio/mikmod/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libmikmod, ncurses }:
+{ lib, stdenv, fetchurl, libmikmod, ncurses }:
 
 stdenv.mkDerivation rec {
   name = "mikmod-3.2.8";
@@ -13,8 +13,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Tracker music player for the terminal";
     homepage = "http://mikmod.shlomifish.org/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [ ];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ ];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/audio/mimic/default.nix b/pkgs/applications/audio/mimic/default.nix
index e33e69ad78c..52079e1f441 100644
--- a/pkgs/applications/audio/mimic/default.nix
+++ b/pkgs/applications/audio/mimic/default.nix
@@ -1,4 +1,4 @@
-{ config, stdenv, autoreconfHook, fetchFromGitHub, pkgconfig
+{ config, lib, stdenv, autoreconfHook, fetchFromGitHub, pkgconfig
 , alsaLib, libtool, icu
 , pulseaudioSupport ? config.pulseaudio or false, libpulseaudio }:
 
@@ -22,13 +22,13 @@ stdenv.mkDerivation rec {
     alsaLib
     libtool
     icu
-  ] ++ stdenv.lib.optional pulseaudioSupport libpulseaudio;
+  ] ++ lib.optional pulseaudioSupport libpulseaudio;
 
   meta = {
     description = "Mycroft's TTS engine, based on CMU's Flite (Festival Lite)";
     homepage = "https://mimic.mycroft.ai/";
-    license = stdenv.lib.licenses.free;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.noneucat ];
+    license = lib.licenses.free;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.noneucat ];
   };
 }
diff --git a/pkgs/applications/audio/mimms/default.nix b/pkgs/applications/audio/mimms/default.nix
index 47e9fa306dc..793ee3d263a 100644
--- a/pkgs/applications/audio/mimms/default.nix
+++ b/pkgs/applications/audio/mimms/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, pythonPackages, libmms }:
+{ fetchurl, lib, stdenv, pythonPackages, libmms }:
 
 pythonPackages.buildPythonApplication rec {
   pname = "mimms";
@@ -16,7 +16,7 @@ pythonPackages.buildPythonApplication rec {
 
   meta = {
     homepage = "https://savannah.nongnu.org/projects/mimms/";
-    license = stdenv.lib.licenses.gpl3;
+    license = lib.licenses.gpl3;
     description = "An mms (e.g. mms://) stream downloader";
 
     longDescription = ''
diff --git a/pkgs/applications/audio/moc/default.nix b/pkgs/applications/audio/moc/default.nix
index 96a4ab9fdaa..b2621a4ef11 100644
--- a/pkgs/applications/audio/moc/default.nix
+++ b/pkgs/applications/audio/moc/default.nix
@@ -25,7 +25,7 @@
 }:
 
 let
-  opt = stdenv.lib.optional;
+  opt = lib.optional;
   mkFlag = c: f: if c then "--with-${f}" else "--without-${f}";
 
 in stdenv.mkDerivation rec {
@@ -57,7 +57,7 @@ in stdenv.mkDerivation rec {
     ++ opt midiSupport timidity
     ++ opt modplugSupport libmodplug
     ++ opt mp3Support libmad
-    ++ stdenv.lib.optionals musepackSupport [ libmpc libmpcdec taglib ]
+    ++ lib.optionals musepackSupport [ libmpc libmpcdec taglib ]
     ++ opt vorbisSupport libvorbis
     ++ opt speexSupport speex
     ++ opt (ffmpegSupport && !withffmpeg4) ffmpeg_3
diff --git a/pkgs/applications/audio/mooSpace/default.nix b/pkgs/applications/audio/mooSpace/default.nix
index f6958c5e974..b7d7502d25a 100644
--- a/pkgs/applications/audio/mooSpace/default.nix
+++ b/pkgs/applications/audio/mooSpace/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, faust2jaqt, faust2lv2 }:
+{ lib, stdenv, fetchFromGitHub, faust2jaqt, faust2lv2 }:
 stdenv.mkDerivation rec {
   pname = "mooSpace";
   version = "unstable-2020-06-10";
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Variable reverb audio effect, jack and lv2";
     homepage = "https://github.com/modularev/mooSpace";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
   };
 }
diff --git a/pkgs/applications/audio/mopidy/mopidy.nix b/pkgs/applications/audio/mopidy/mopidy.nix
index 55b7646af07..63a28eb0f58 100644
--- a/pkgs/applications/audio/mopidy/mopidy.nix
+++ b/pkgs/applications/audio/mopidy/mopidy.nix
@@ -32,7 +32,7 @@ pythonPackages.buildPythonApplication rec {
       requests
       setuptools
       tornado
-    ] ++ stdenv.lib.optional (!stdenv.isDarwin) dbus-python
+    ] ++ lib.optional (!stdenv.isDarwin) dbus-python
   );
 
   # There are no tests
diff --git a/pkgs/applications/audio/mp3blaster/default.nix b/pkgs/applications/audio/mp3blaster/default.nix
index d7795524529..d7dd5f102db 100644
--- a/pkgs/applications/audio/mp3blaster/default.nix
+++ b/pkgs/applications/audio/mp3blaster/default.nix
@@ -14,11 +14,11 @@ stdenv.mkDerivation rec {
   buildInputs = [
     ncurses
     libvorbis
-  ] ++ stdenv.lib.optional stdenv.isDarwin SDL;
+  ] ++ lib.optional stdenv.isDarwin SDL;
 
   NIX_CFLAGS_COMPILE = toString ([
     "-Wno-narrowing"
-  ] ++ stdenv.lib.optionals stdenv.cc.isClang [
+  ] ++ lib.optionals stdenv.cc.isClang [
     "-Wno-reserved-user-defined-literal"
   ]);
 
diff --git a/pkgs/applications/audio/mp3info/default.nix b/pkgs/applications/audio/mp3info/default.nix
index 69ca271d27d..28ea6793f0d 100644
--- a/pkgs/applications/audio/mp3info/default.nix
+++ b/pkgs/applications/audio/mp3info/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, ncurses, pkgconfig, gtk2 }:
+{ fetchurl, lib, stdenv, ncurses, pkgconfig, gtk2 }:
 
 stdenv.mkDerivation rec {
   name = "mp3info-0.8.5a";
@@ -37,9 +37,9 @@ stdenv.mkDerivation rec {
 
     homepage = "http://www.ibiblio.org/mp3info/";
 
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
 
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/mp3val/default.nix b/pkgs/applications/audio/mp3val/default.nix
index 636fb7d9b9a..dc1a3085831 100644
--- a/pkgs/applications/audio/mp3val/default.nix
+++ b/pkgs/applications/audio/mp3val/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ lib, stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
   pname = "mp3val";
@@ -30,8 +30,8 @@ stdenv.mkDerivation rec {
       common types of tags (ID3v1, ID3v2, APEv2).
     '';
     homepage = "http://mp3val.sourceforge.net/index.shtml";
-    license = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.devhell ];
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.unix;
+    maintainers = [ lib.maintainers.devhell ];
   };
 }
diff --git a/pkgs/applications/audio/mpc/default.nix b/pkgs/applications/audio/mpc/default.nix
index a00ac7868b3..fcf438e5f0e 100644
--- a/pkgs/applications/audio/mpc/default.nix
+++ b/pkgs/applications/audio/mpc/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "1qbi0i9cq54rj8z2kapk8x8g1jkw2jz781niwb9i7kw4xfhvy5zx";
   };
 
-  buildInputs = [ mpd_clientlib ] ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv ];
+  buildInputs = [ mpd_clientlib ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
 
   nativeBuildInputs = [ meson ninja pkgconfig sphinx ];
 
diff --git a/pkgs/applications/audio/mpc123/default.nix b/pkgs/applications/audio/mpc123/default.nix
index ef5cb169a2c..7ce8af1de23 100644
--- a/pkgs/applications/audio/mpc123/default.nix
+++ b/pkgs/applications/audio/mpc123/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, gettext, libmpcdec, libao }:
+{ fetchurl, lib, stdenv, gettext, libmpcdec, libao }:
 
 let version = "0.2.4"; in
 stdenv.mkDerivation rec {
@@ -25,9 +25,9 @@ stdenv.mkDerivation rec {
 
     description = "A Musepack (.mpc) audio player";
 
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
 
     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/audio/mpg123/default.nix b/pkgs/applications/audio/mpg123/default.nix
index f3203566a13..0b46cffd19c 100644
--- a/pkgs/applications/audio/mpg123/default.nix
+++ b/pkgs/applications/audio/mpg123/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchurl
 , makeWrapper
 
@@ -18,9 +18,9 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ makeWrapper ];
 
-  buildInputs = [ perl ] ++ stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
+  buildInputs = [ perl ] ++ lib.optional (!stdenv.isDarwin) alsaLib;
 
-  configureFlags = stdenv.lib.optional
+  configureFlags = lib.optional
     (stdenv.hostPlatform ? mpg123)
     "--with-cpu=${stdenv.hostPlatform.mpg123.cpu}";
 
@@ -41,8 +41,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Fast console MPEG Audio Player and decoder library";
     homepage = "http://mpg123.org";
-    license = stdenv.lib.licenses.lgpl21;
-    maintainers = [ stdenv.lib.maintainers.ftrvxmtrx ];
-    platforms = stdenv.lib.platforms.unix;
+    license = lib.licenses.lgpl21;
+    maintainers = [ lib.maintainers.ftrvxmtrx ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/audio/mpg321/default.nix b/pkgs/applications/audio/mpg321/default.nix
index 1f98d31eb9c..0079947438c 100644
--- a/pkgs/applications/audio/mpg321/default.nix
+++ b/pkgs/applications/audio/mpg321/default.nix
@@ -25,11 +25,11 @@ stdenv.mkDerivation rec {
 
   configureFlags =
     [ ("--enable-alsa=" + (if stdenv.isLinux then "yes" else "no")) ]
-    ++ (stdenv.lib.optional (defaultAudio != null)
+    ++ (lib.optional (defaultAudio != null)
          "--with-default-audio=${defaultAudio}");
 
   buildInputs = [libao libid3tag libmad zlib]
-    ++ stdenv.lib.optional stdenv.isLinux alsaLib;
+    ++ lib.optional stdenv.isLinux alsaLib;
 
   installTargets = [ "install" "install-man" ];
 
diff --git a/pkgs/applications/audio/munt/default.nix b/pkgs/applications/audio/munt/default.nix
index 8d8ab419fdb..6d010c6cd95 100644
--- a/pkgs/applications/audio/munt/default.nix
+++ b/pkgs/applications/audio/munt/default.nix
@@ -15,7 +15,7 @@ in mkDerivation rec {
   src = fetchFromGitHub {
     owner = pname;
     repo = pname;
-    rev = with stdenv.lib.versions; "libmt32emu_${major version}_${minor version}_${patch version}";
+    rev = with lib.versions; "libmt32emu_${major version}_${minor version}_${patch version}";
     sha256 = "0bszhkbz24hhx32f973l6h5lkyn4lxhqrckiwmv765d1sba8n5bk";
   };
 
diff --git a/pkgs/applications/audio/musikcube/default.nix b/pkgs/applications/audio/musikcube/default.nix
index fba80928b0d..882fbaf3477 100644
--- a/pkgs/applications/audio/musikcube/default.nix
+++ b/pkgs/applications/audio/musikcube/default.nix
@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
     ncurses
     pulseaudio
     taglib
-  ] ++ stdenv.lib.optional systemdSupport systemd;
+  ] ++ lib.optional systemdSupport systemd;
 
   cmakeFlags = [
     "-DDISABLE_STRIP=true"
diff --git a/pkgs/applications/audio/mympd/default.nix b/pkgs/applications/audio/mympd/default.nix
index cc709822d9e..4e069e001da 100644
--- a/pkgs/applications/audio/mympd/default.nix
+++ b/pkgs/applications/audio/mympd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , cmake
 , pkg-config
@@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://jcorporation.github.io/mympd";
     description = "A standalone and mobile friendly web mpd client with a tiny footprint and advanced features";
-    maintainers = [ stdenv.lib.maintainers.doronbehar ];
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.doronbehar ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/applications/audio/ncmpc/default.nix b/pkgs/applications/audio/ncmpc/default.nix
index 2deff6162fb..4f0449401dd 100644
--- a/pkgs/applications/audio/ncmpc/default.nix
+++ b/pkgs/applications/audio/ncmpc/default.nix
@@ -4,7 +4,7 @@
 , pcre ? null
 }:
 
-with stdenv.lib;
+with lib;
 
 assert pcreSupport -> pcre != null;
 
diff --git a/pkgs/applications/audio/ncmpcpp/default.nix b/pkgs/applications/audio/ncmpcpp/default.nix
index 33308ebc61a..7f645ac7986 100644
--- a/pkgs/applications/audio/ncmpcpp/default.nix
+++ b/pkgs/applications/audio/ncmpcpp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, boost, mpd_clientlib, ncurses, pkgconfig, readline
+{ lib, stdenv, fetchurl, boost, mpd_clientlib, ncurses, pkgconfig, readline
 , libiconv, icu, curl
 , outputsSupport ? true # outputs screen
 , visualizerSupport ? false, fftw ? null # visualizer screen
@@ -9,7 +9,7 @@
 assert visualizerSupport -> (fftw != null);
 assert taglibSupport -> (taglib != null);
 
-with stdenv.lib;
+with lib;
 stdenv.mkDerivation rec {
   pname = "ncmpcpp";
   version = "0.9.1";
diff --git a/pkgs/applications/audio/non/default.nix b/pkgs/applications/audio/non/default.nix
index 9b4b147c230..fbdfb78cab0 100644
--- a/pkgs/applications/audio/non/default.nix
+++ b/pkgs/applications/audio/non/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, pkgconfig, python2, cairo, libjpeg, ntk, libjack2
+{ lib, stdenv, fetchFromGitHub, pkgconfig, python2, cairo, libjpeg, ntk, libjack2
 , libsndfile, ladspaH, liblo, libsigcxx, lrdf, wafHook
 }:
 
@@ -20,8 +20,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Lightweight and lightning fast modular Digital Audio Workstation";
     homepage = "http://non.tuxfamily.org";
-    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 ];
   };
 }
diff --git a/pkgs/applications/audio/openmpt123/default.nix b/pkgs/applications/audio/openmpt123/default.nix
index 486a9827511..ff7a40d5993 100644
--- a/pkgs/applications/audio/openmpt123/default.nix
+++ b/pkgs/applications/audio/openmpt123/default.nix
@@ -17,9 +17,9 @@ in stdenv.mkDerivation {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ zlib mpg123 libogg libvorbis portaudio libsndfile flac ]
-  ++ stdenv.lib.optional usePulseAudio libpulseaudio;
+  ++ lib.optional usePulseAudio libpulseaudio;
 
-  configureFlags = stdenv.lib.optional (!usePulseAudio) "--without-pulseaudio";
+  configureFlags = lib.optional (!usePulseAudio) "--without-pulseaudio";
 
   meta = with lib; {
     description = "A cross-platform command-line based module file player";
diff --git a/pkgs/applications/audio/opus-tools/default.nix b/pkgs/applications/audio/opus-tools/default.nix
index b8253b078be..f16e8e7a02d 100644
--- a/pkgs/applications/audio/opus-tools/default.nix
+++ b/pkgs/applications/audio/opus-tools/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, libogg, libao, pkgconfig, flac, opusfile, libopusenc}:
+{lib, stdenv, fetchurl, libogg, libao, pkgconfig, flac, opusfile, libopusenc}:
 
 stdenv.mkDerivation rec {
   name = "opus-tools-0.2";
@@ -13,8 +13,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Tools to work with opus encoded audio streams";
     homepage = "https://www.opus-codec.org/";
-    license = stdenv.lib.licenses.bsd2;
-    maintainers = with stdenv.lib.maintainers; [ ];
-    platforms = with stdenv.lib.platforms; unix;
+    license = lib.licenses.bsd2;
+    maintainers = with lib.maintainers; [ ];
+    platforms = with lib.platforms; unix;
   };
 }
diff --git a/pkgs/applications/audio/patchage/default.nix b/pkgs/applications/audio/patchage/default.nix
index ac679d6dd94..5f622877552 100644
--- a/pkgs/applications/audio/patchage/default.nix
+++ b/pkgs/applications/audio/patchage/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, alsaLib, boost, dbus-glib, fetchsvn, ganv, glibmm
+{ lib, stdenv, alsaLib, boost, dbus-glib, fetchsvn, ganv, glibmm
 , gtkmm2, libjack2, pkgconfig, python2, wafHook
 }:
 
@@ -19,8 +19,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Modular patch bay for Jack and ALSA systems";
     homepage = "http://non.tuxfamily.org";
-    license = stdenv.lib.licenses.lgpl3;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.nico202 ];
+    license = lib.licenses.lgpl3;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.nico202 ];
   };
 }
diff --git a/pkgs/applications/audio/pavucontrol/default.nix b/pkgs/applications/audio/pavucontrol/default.nix
index ffc56e54586..198fa1033ab 100644
--- a/pkgs/applications/audio/pavucontrol/default.nix
+++ b/pkgs/applications/audio/pavucontrol/default.nix
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
 
     homepage = "http://freedesktop.org/software/pulseaudio/pavucontrol/";
 
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = lib.licenses.gpl2Plus;
 
     maintainers = with maintainers; [ abbradar globin ];
     platforms = platforms.linux;
diff --git a/pkgs/applications/audio/pd-plugins/cyclone/default.nix b/pkgs/applications/audio/pd-plugins/cyclone/default.nix
index 56f1ec518de..03df731aef5 100644
--- a/pkgs/applications/audio/pd-plugins/cyclone/default.nix
+++ b/pkgs/applications/audio/pd-plugins/cyclone/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, puredata }:
+{ lib, stdenv, fetchFromGitHub, puredata }:
 
 stdenv.mkDerivation rec {
   pname = "cyclone";
@@ -26,8 +26,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A library of PureData classes, bringing some level of compatibility between Max/MSP and Pd environments";
     homepage = "http://puredata.info/downloads/cyclone";
-    license = stdenv.lib.licenses.tcltk;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.tcltk;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/gem/default.nix b/pkgs/applications/audio/pd-plugins/gem/default.nix
index a44ba689a61..aeb58911623 100644
--- a/pkgs/applications/audio/pd-plugins/gem/default.nix
+++ b/pkgs/applications/audio/pd-plugins/gem/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchFromGitHub
 , fetchpatch
 , autoreconfHook
@@ -43,8 +43,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Graphics Environment for Multimedia";
     homepage = "http://puredata.info/downloads/gem";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = [ stdenv.lib.maintainers.raboof ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.raboof ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/helmholtz/default.nix b/pkgs/applications/audio/pd-plugins/helmholtz/default.nix
index be5a385d308..9b50b40a5bb 100644
--- a/pkgs/applications/audio/pd-plugins/helmholtz/default.nix
+++ b/pkgs/applications/audio/pd-plugins/helmholtz/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, puredata }:
+{ lib, stdenv, fetchurl, unzip, puredata }:
 
 stdenv.mkDerivation {
   name = "helmholtz";
@@ -39,8 +39,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Time domain pitch tracker for Pure Data";
     homepage = "http://www.katjaas.nl/helmholtz/helmholtz.html";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.bsd3;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/maxlib/default.nix b/pkgs/applications/audio/pd-plugins/maxlib/default.nix
index aec793c4ee8..1fc3475bc6a 100644
--- a/pkgs/applications/audio/pd-plugins/maxlib/default.nix
+++ b/pkgs/applications/audio/pd-plugins/maxlib/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, puredata }:
+{ lib, stdenv, fetchFromGitHub, puredata }:
 
 stdenv.mkDerivation rec {
   pname = "maxlib";
@@ -26,8 +26,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A library of non-tilde externals for puredata, by Miller Puckette";
     homepage = "http://puredata.info/downloads/maxlib";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/mrpeach/default.nix b/pkgs/applications/audio/pd-plugins/mrpeach/default.nix
index cefee430ad5..71f5e9438e1 100644
--- a/pkgs/applications/audio/pd-plugins/mrpeach/default.nix
+++ b/pkgs/applications/audio/pd-plugins/mrpeach/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, puredata }:
+{ lib, stdenv, fetchurl, puredata }:
 
 stdenv.mkDerivation {
   pname = "mrpeach";
@@ -55,8 +55,8 @@ stdenv.mkDerivation {
   meta = {
     description = "A collection of Pd objectclasses for OSC-messages";
     homepage = "http://puredata.info/downloads/osc";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/puremapping/default.nix b/pkgs/applications/audio/pd-plugins/puremapping/default.nix
index 7a5014664d5..1eb6eb38931 100644
--- a/pkgs/applications/audio/pd-plugins/puremapping/default.nix
+++ b/pkgs/applications/audio/pd-plugins/puremapping/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, puredata }:
+{ lib, stdenv, fetchurl, unzip, puredata }:
 
 stdenv.mkDerivation rec {
   pname = "puremapping";
@@ -24,8 +24,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Set of externals to facilitate the use of sensors within Pure Data and to create complex relations between input and output of a dynamic system";
     homepage = "http://www.chnry.net/ch/?090-Pure-Mapping&lang=en";
-    license = stdenv.lib.licenses.gpl1;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl1;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/timbreid/default.nix b/pkgs/applications/audio/pd-plugins/timbreid/default.nix
index e68610a0226..e5e67ec44dd 100644
--- a/pkgs/applications/audio/pd-plugins/timbreid/default.nix
+++ b/pkgs/applications/audio/pd-plugins/timbreid/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, puredata, fftw }:
+{ lib, stdenv, fetchurl, unzip, puredata, fftw }:
 
 stdenv.mkDerivation rec {
   version = "0.7.0";
@@ -38,8 +38,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A collection of audio feature analysis externals for puredata";
     homepage = "http://williambrent.conflations.com/pages/research.html";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pd-plugins/zexy/default.nix b/pkgs/applications/audio/pd-plugins/zexy/default.nix
index 4f826908136..67c7cd18be8 100644
--- a/pkgs/applications/audio/pd-plugins/zexy/default.nix
+++ b/pkgs/applications/audio/pd-plugins/zexy/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoconf, automake, puredata }:
+{ lib, stdenv, fetchurl, autoconf, automake, puredata }:
 
 stdenv.mkDerivation rec {
   pname = "zexy";
@@ -29,8 +29,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "The swiss army knife for puredata";
     homepage = "http://puredata.info/downloads/zexy";
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.magnetophon ];
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.magnetophon ];
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/picard/default.nix b/pkgs/applications/audio/picard/default.nix
index 8a7c1b32245..733cb702c7e 100644
--- a/pkgs/applications/audio/picard/default.nix
+++ b/pkgs/applications/audio/picard/default.nix
@@ -22,7 +22,7 @@ in pythonPackages.buildPythonApplication rec {
   };
 
   nativeBuildInputs = [ gettext qt5.wrapQtAppsHook qt5.qtbase ]
-    ++ stdenv.lib.optionals (pyqt5.multimediaEnabled) [
+    ++ lib.optionals (pyqt5.multimediaEnabled) [
       qt5.qtmultimedia.bin
       gst_all_1.gstreamer
       gst_all_1.gst-vaapi
@@ -49,7 +49,7 @@ in pythonPackages.buildPythonApplication rec {
   preFixup = ''
     makeWrapperArgs+=("''${qtWrapperArgs[@]}")
   ''
-    + stdenv.lib.optionalString (pyqt5.multimediaEnabled) ''
+    + lib.optionalString (pyqt5.multimediaEnabled) ''
       makeWrapperArgs+=(--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0")
     ''
   ;
diff --git a/pkgs/applications/audio/praat/default.nix b/pkgs/applications/audio/praat/default.nix
index 5abab029bc9..b87e48768f1 100644
--- a/pkgs/applications/audio/praat/default.nix
+++ b/pkgs/applications/audio/praat/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, alsaLib, gtk2, pkgconfig }:
+{ lib, stdenv, fetchurl, alsaLib, gtk2, pkgconfig }:
 
 stdenv.mkDerivation rec {
   pname = "praat";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Doing phonetics by computer";
     homepage = "https://www.fon.hum.uva.nl/praat/";
-    license = stdenv.lib.licenses.gpl2Plus; # Has some 3rd-party code in it though
-    platforms = stdenv.lib.platforms.linux;
+    license = lib.licenses.gpl2Plus; # Has some 3rd-party code in it though
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/pt2-clone/default.nix b/pkgs/applications/audio/pt2-clone/default.nix
index 011ef8d12e5..6a093c91daf 100644
--- a/pkgs/applications/audio/pt2-clone/default.nix
+++ b/pkgs/applications/audio/pt2-clone/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = [ SDL2 ] ++ stdenv.lib.optional stdenv.isLinux alsaLib;
+  buildInputs = [ SDL2 ] ++ lib.optional stdenv.isLinux alsaLib;
 
   passthru.tests = {
     pt2-clone-opens = nixosTests.pt2-clone;
diff --git a/pkgs/applications/audio/pulseaudio-ctl/default.nix b/pkgs/applications/audio/pulseaudio-ctl/default.nix
index 245c58a2119..843c131ea65 100644
--- a/pkgs/applications/audio/pulseaudio-ctl/default.nix
+++ b/pkgs/applications/audio/pulseaudio-ctl/default.nix
@@ -2,7 +2,7 @@
 , bc, dbus, gawk, gnused, libnotify, pulseaudio }:
 
 let
-  path = stdenv.lib.makeBinPath [ bc dbus gawk gnused libnotify pulseaudio ];
+  path = lib.makeBinPath [ bc dbus gawk gnused libnotify pulseaudio ];
   pname = "pulseaudio-ctl";
 
 in stdenv.mkDerivation rec {
diff --git a/pkgs/applications/audio/pulseaudio-dlna/default.nix b/pkgs/applications/audio/pulseaudio-dlna/default.nix
index 3c80a521286..a19a03d4bd2 100644
--- a/pkgs/applications/audio/pulseaudio-dlna/default.nix
+++ b/pkgs/applications/audio/pulseaudio-dlna/default.nix
@@ -32,12 +32,12 @@ pythonPackages.buildPythonApplication {
     dbus-python docopt requests setproctitle protobuf psutil futures
     chardet notify2 netifaces pyroute2 pygobject2 lxml setuptools ]
     ++ [ zeroconf ]
-    ++ stdenv.lib.optional mp3Support lame
-    ++ stdenv.lib.optional opusSupport opusTools
-    ++ stdenv.lib.optional faacSupport faac
-    ++ stdenv.lib.optional flacSupport flac
-    ++ stdenv.lib.optional soxSupport sox
-    ++ stdenv.lib.optional vorbisSupport vorbis-tools;
+    ++ lib.optional mp3Support lame
+    ++ lib.optional opusSupport opusTools
+    ++ lib.optional faacSupport faac
+    ++ lib.optional flacSupport flac
+    ++ lib.optional soxSupport sox
+    ++ lib.optional vorbisSupport vorbis-tools;
 
   # upstream has no tests
   checkPhase = ''
diff --git a/pkgs/applications/audio/pulseaudio-dlna/zeroconf.nix b/pkgs/applications/audio/pulseaudio-dlna/zeroconf.nix
index e28aabe8dab..0e3eeac984a 100644
--- a/pkgs/applications/audio/pulseaudio-dlna/zeroconf.nix
+++ b/pkgs/applications/audio/pulseaudio-dlna/zeroconf.nix
@@ -19,7 +19,7 @@ buildPythonPackage rec {
   };
 
   propagatedBuildInputs = [ netifaces six enum-compat ifaddr ]
-    ++ stdenv.lib.optionals (pythonOlder "3.5") [ typing ];
+    ++ lib.optionals (pythonOlder "3.5") [ typing ];
 
   meta = with lib; {
     description = "A pure python implementation of multicast DNS service discovery";
diff --git a/pkgs/applications/audio/pulseeffects/default.nix b/pkgs/applications/audio/pulseeffects/default.nix
index f0f3ad60b41..a2c69818137 100644
--- a/pkgs/applications/audio/pulseeffects/default.nix
+++ b/pkgs/applications/audio/pulseeffects/default.nix
@@ -94,15 +94,15 @@ in stdenv.mkDerivation rec {
 
   preFixup = ''
     gappsWrapperArgs+=(
-      --set LV2_PATH "${stdenv.lib.makeSearchPath "lib/lv2" lv2Plugins}"
-      --set LADSPA_PATH "${stdenv.lib.makeSearchPath "lib/ladspa" ladspaPlugins}"
+      --set LV2_PATH "${lib.makeSearchPath "lib/lv2" lv2Plugins}"
+      --set LADSPA_PATH "${lib.makeSearchPath "lib/ladspa" ladspaPlugins}"
     )
   '';
 
   # Meson is no longer able to pick up Boost automatically.
   # https://github.com/NixOS/nixpkgs/issues/86131
-  BOOST_INCLUDEDIR = "${stdenv.lib.getDev boost}/include";
-  BOOST_LIBRARYDIR = "${stdenv.lib.getLib boost}/lib";
+  BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
+  BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
 
   meta = with lib; {
     description = "Limiter, compressor, reverberation, equalizer and auto volume effects for Pulseaudio applications";
diff --git a/pkgs/applications/audio/qjackctl/default.nix b/pkgs/applications/audio/qjackctl/default.nix
index 51972e6bfeb..719ddd28e2a 100644
--- a/pkgs/applications/audio/qjackctl/default.nix
+++ b/pkgs/applications/audio/qjackctl/default.nix
@@ -13,7 +13,7 @@ mkDerivation rec {
   src = fetchFromGitHub {
     owner = "rncbc";
     repo = "qjackctl";
-    rev = "${pname}_${stdenv.lib.replaceChars ["."] ["_"] version}";
+    rev = "${pname}_${lib.replaceChars ["."] ["_"] version}";
     sha256 = "044kgwk7pfywad4myza0s2kvfkl21zkqq5wgny7n3c43qlcgs3zr";
   };
 
diff --git a/pkgs/applications/audio/qmidiroute/default.nix b/pkgs/applications/audio/qmidiroute/default.nix
index ee983f78014..30062955bb5 100644
--- a/pkgs/applications/audio/qmidiroute/default.nix
+++ b/pkgs/applications/audio/qmidiroute/default.nix
@@ -25,6 +25,6 @@ stdenv.mkDerivation rec {
 
     license = licenses.gpl2;
     maintainers = [ maintainers.lebastr ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = lib.platforms.linux;
   };
 }
diff --git a/pkgs/applications/audio/quodlibet/default.nix b/pkgs/applications/audio/quodlibet/default.nix
index 00da41e308a..571097ad478 100644
--- a/pkgs/applications/audio/quodlibet/default.nix
+++ b/pkgs/applications/audio/quodlibet/default.nix
@@ -6,7 +6,7 @@
   webkitgtk ? null,
   keybinder3 ? null, gtksourceview ? null, libmodplug ? null, kakasi ? null, libappindicator-gtk3 ? null }:
 
-let optionals = stdenv.lib.optionals; in
+let optionals = lib.optionals; in
 python3.pkgs.buildPythonApplication rec {
   pname = "quodlibet${tag}";
   version = "4.3.0";
@@ -35,7 +35,7 @@ python3.pkgs.buildPythonApplication rec {
 
   LC_ALL = "en_US.UTF-8";
 
-  pytestFlags = stdenv.lib.optionals (xineBackend || !withGstPlugins) [
+  pytestFlags = lib.optionals (xineBackend || !withGstPlugins) [
     "--ignore=tests/plugin/test_replaygain.py"
   ] ++ [
     # requires networking
@@ -65,7 +65,7 @@ python3.pkgs.buildPythonApplication rec {
     runHook postCheck
   '';
 
-  preFixup = stdenv.lib.optionalString (kakasi != null) "gappsWrapperArgs+=(--prefix PATH : ${kakasi}/bin)";
+  preFixup = lib.optionalString (kakasi != null) "gappsWrapperArgs+=(--prefix PATH : ${kakasi}/bin)";
 
   meta = with lib; {
     description = "GTK-based audio player written in Python, using the Mutagen tagging library";
diff --git a/pkgs/applications/audio/radiotray-ng/default.nix b/pkgs/applications/audio/radiotray-ng/default.nix
index 9c5e6a931a9..746092977db 100644
--- a/pkgs/applications/audio/radiotray-ng/default.nix
+++ b/pkgs/applications/audio/radiotray-ng/default.nix
@@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
   doCheck = !stdenv.isAarch64; # single failure that I can't explain
 
   preFixup = ''
-    gappsWrapperArgs+=(--suffix PATH : ${stdenv.lib.makeBinPath [ dbus ]})
+    gappsWrapperArgs+=(--suffix PATH : ${lib.makeBinPath [ dbus ]})
     wrapProgram $out/bin/rt2rtng --prefix PYTHONPATH : $PYTHONPATH
   '';
 
diff --git a/pkgs/applications/audio/reaper/default.nix b/pkgs/applications/audio/reaper/default.nix
index 09f8bcfd6b6..a58fd289e24 100644
--- a/pkgs/applications/audio/reaper/default.nix
+++ b/pkgs/applications/audio/reaper/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   version = "6.19";
 
   src = fetchurl {
-    url = "https://www.reaper.fm/files/${stdenv.lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_x86_64.tar.xz";
+    url = "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_x86_64.tar.xz";
     sha256 = "1cdy5ilpfidz7xyqn2i41szr24ilcmpl35aw1vbashf0b6dg48la";
   };
 
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
     rm $out/opt/REAPER/uninstall-reaper.sh
 
     wrapProgram $out/opt/REAPER/reaper \
-      --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ libpulseaudio libjack2 ]}"
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libpulseaudio libjack2 ]}"
 
     mkdir $out/bin
     ln -s $out/opt/REAPER/reaper $out/bin/
diff --git a/pkgs/applications/audio/redoflacs/default.nix b/pkgs/applications/audio/redoflacs/default.nix
index 879acdf3a17..999dc90a6e4 100644
--- a/pkgs/applications/audio/redoflacs/default.nix
+++ b/pkgs/applications/audio/redoflacs/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
 
   postFixup = ''
     wrapProgram $out/bin/redoflacs \
-      --prefix PATH : ${stdenv.lib.makeBinPath ([ flac sox ])}
+      --prefix PATH : ${lib.makeBinPath ([ flac sox ])}
   '';
 
   meta = with lib; {
diff --git a/pkgs/applications/audio/renoise/default.nix b/pkgs/applications/audio/renoise/default.nix
index 0ae65cb8c37..2159fa630d9 100644
--- a/pkgs/applications/audio/renoise/default.nix
+++ b/pkgs/applications/audio/renoise/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, libX11, libXext, libXcursor, libXrandr, libjack2, alsaLib
+{ lib, stdenv, fetchurl, libX11, libXext, libXcursor, libXrandr, libjack2, alsaLib
 , mpg123, releasePath ? null }:
 
-with stdenv.lib;
+with lib;
 
 # To use the full release version:
 # 1) Sign into https://backstage.renoise.com and download the release version to some stable location.
@@ -19,15 +19,15 @@ stdenv.mkDerivation rec {
   src =
     if stdenv.hostPlatform.system == "x86_64-linux" then
         if releasePath == null then
-		    fetchurl {
-		      urls = [
-		          "https://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_Linux.tar.gz"
-		          "https://web.archive.org/web/https://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_Linux.tar.gz"
-		      ];
-		      sha256 = "1v249kmyidx55kppk3sry7yg6hl1a91ixhnwz36h4y134fs7bkrl";
-		    }
+        fetchurl {
+          urls = [
+              "https://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_Linux.tar.gz"
+              "https://web.archive.org/web/https://files.renoise.com/demo/Renoise_${urlVersion version}_Demo_Linux.tar.gz"
+          ];
+          sha256 = "1v249kmyidx55kppk3sry7yg6hl1a91ixhnwz36h4y134fs7bkrl";
+        }
         else
-        	releasePath
+          releasePath
     else throw "Platform is not supported by Renoise";
 
   buildInputs = [ alsaLib libjack2 libX11 libXcursor libXext libXrandr ];
diff --git a/pkgs/applications/audio/rhythmbox/default.nix b/pkgs/applications/audio/rhythmbox/default.nix
index c07d73530b5..ae45ca62eb9 100644
--- a/pkgs/applications/audio/rhythmbox/default.nix
+++ b/pkgs/applications/audio/rhythmbox/default.nix
@@ -22,7 +22,7 @@ in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${name}.tar.xz";
     sha256 = "142xcvw4l19jyr5i72nbnrihs953pvrrzcbijjn9dxmxszbv03pf";
   };
 
diff --git a/pkgs/applications/audio/schismtracker/default.nix b/pkgs/applications/audio/schismtracker/default.nix
index 02c8f28da65..3b5708529e0 100644
--- a/pkgs/applications/audio/schismtracker/default.nix
+++ b/pkgs/applications/audio/schismtracker/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoreconfHook python ];
 
-  buildInputs = [ SDL ] ++ stdenv.lib.optional stdenv.isLinux alsaLib;
+  buildInputs = [ SDL ] ++ lib.optional stdenv.isLinux alsaLib;
 
   meta = with lib; {
     description = "Music tracker application, free reimplementation of Impulse Tracker";
diff --git a/pkgs/applications/audio/shntool/default.nix b/pkgs/applications/audio/shntool/default.nix
index de18f3c2ce8..8b4f736ab1c 100644
--- a/pkgs/applications/audio/shntool/default.nix
+++ b/pkgs/applications/audio/shntool/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, flac }:
+{ lib, stdenv, fetchurl, flac }:
 
 stdenv.mkDerivation {
   version = "3.0.10";
@@ -14,8 +14,8 @@ stdenv.mkDerivation {
   meta = {
     description = "Multi-purpose WAVE data processing and reporting utility";
     homepage = "http://www.etree.org/shnutils/shntool/";
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = stdenv.lib.platforms.all;
-    maintainers = with stdenv.lib.maintainers; [ jcumming ];
+    license = lib.licenses.gpl2Plus;
+    platforms = lib.platforms.all;
+    maintainers = with lib.maintainers; [ jcumming ];
   };
 }
diff --git a/pkgs/applications/audio/snd/default.nix b/pkgs/applications/audio/snd/default.nix
index 76ea4efeace..bbabaffa7f3 100644
--- a/pkgs/applications/audio/snd/default.nix
+++ b/pkgs/applications/audio/snd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig
+{ lib, stdenv, fetchurl, pkgconfig
 , gtk2, alsaLib
 , fftw, gsl
 }:
@@ -21,9 +21,9 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Sound editor";
     homepage = "http://ccrma.stanford.edu/software/snd";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.free;
-    maintainers = with stdenv.lib.maintainers; [ ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.free;
+    maintainers = with lib.maintainers; [ ];
   };
 
 
diff --git a/pkgs/applications/audio/sonata/default.nix b/pkgs/applications/audio/sonata/default.nix
index afb02768960..bc098cedaf4 100644
--- a/pkgs/applications/audio/sonata/default.nix
+++ b/pkgs/applications/audio/sonata/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, wrapGAppsHook, gettext
+{ lib, stdenv, fetchFromGitHub, wrapGAppsHook, gettext
 , python3Packages, gnome3, gtk3, glib, gdk-pixbuf, gsettings-desktop-schemas, gobject-introspection }:
 
 let
@@ -74,8 +74,8 @@ in buildPythonApplication rec {
        - Available in 24 languages
     '';
     homepage = "https://www.nongnu.org/sonata/";
-    license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.rvl ];
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.rvl ];
   };
 }
diff --git a/pkgs/applications/audio/sound-juicer/default.nix b/pkgs/applications/audio/sound-juicer/default.nix
index e8ab895579c..08cbef146f1 100644
--- a/pkgs/applications/audio/sound-juicer/default.nix
+++ b/pkgs/applications/audio/sound-juicer/default.nix
@@ -9,7 +9,7 @@ in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${name}.tar.xz";
     sha256 = "19qg4xv0f9rkq34lragkmhii1llxsa87llbl28i759b0ks4f6sny";
   };
 
diff --git a/pkgs/applications/audio/soundscape-renderer/default.nix b/pkgs/applications/audio/soundscape-renderer/default.nix
index 741211bd90d..f849e2fe7be 100644
--- a/pkgs/applications/audio/soundscape-renderer/default.nix
+++ b/pkgs/applications/audio/soundscape-renderer/default.nix
@@ -1,4 +1,4 @@
-{ stdenv
+{ lib, stdenv
 , fetchgit
 , autoreconfHook
 , help2man
@@ -47,8 +47,8 @@ stdenv.mkDerivation {
   meta = {
     homepage = "http://spatialaudio.net/ssr/";
     description = "The SoundScape Renderer (SSR) is a tool for real-time spatial audio reproduction";
-    license = stdenv.lib.licenses.gpl3;
-    maintainers = [ stdenv.lib.maintainers.fridh ];
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.fridh ];
   };
 
 }
diff --git a/pkgs/applications/audio/soundtracker/default.nix b/pkgs/applications/audio/soundtracker/default.nix
index aa78bbf3de8..71fc763a5c5 100644
--- a/pkgs/applications/audio/soundtracker/default.nix
+++ b/pkgs/applications/audio/soundtracker/default.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     jack2
     audiofile
     goocanvas
-  ] ++ stdenv.lib.optional stdenv.isLinux alsaLib;
+  ] ++ lib.optional stdenv.isLinux alsaLib;
 
   hardeningDisable = [ "format" ];
 
diff --git a/pkgs/applications/audio/spectrojack/default.nix b/pkgs/applications/audio/spectrojack/default.nix
index 35534750d0c..c5e3211a646 100644
--- a/pkgs/applications/audio/spectrojack/default.nix
+++ b/pkgs/applications/audio/spectrojack/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libjack2, fftwFloat, gtk2 }:
+{ lib, stdenv, fetchurl, pkgconfig, libjack2, fftwFloat, gtk2 }:
 
 stdenv.mkDerivation rec {
   pname = "spectrojack";
@@ -24,8 +24,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A little spectrogram/audiogram/sonogram/whatever for JACK";
     homepage = "http://sed.free.fr/spectrojack";
-    license = stdenv.lib.licenses.publicDomain;
-    maintainers = with stdenv.lib.maintainers; [ sleexyz ];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.publicDomain;
+    maintainers = with lib.maintainers; [ sleexyz ];
+    platforms = with lib.platforms; linux;
   };
 }
diff --git a/pkgs/applications/audio/split2flac/default.nix b/pkgs/applications/audio/split2flac/default.nix
index 689e9e1cb24..92f0753fd78 100644
--- a/pkgs/applications/audio/split2flac/default.nix
+++ b/pkgs/applications/audio/split2flac/default.nix
@@ -9,7 +9,7 @@ let
   wrapSplit2flac =  format: ''
     makeWrapper $out/bin/.split2flac-wrapped $out/bin/split2${format} \
       --set SPLIT2FLAC_FORMAT ${format} \
-      --prefix PATH : ${stdenv.lib.makeBinPath [
+      --prefix PATH : ${lib.makeBinPath [
         shntool cuetools
         flac faac mp4v2 wavpack mac
         imagemagick libiconv enca lame pythonPackages.mutagen vorbis-tools
diff --git a/pkgs/applications/audio/spotify-tui/default.nix b/pkgs/applications/audio/spotify-tui/default.nix
index 55a725e59b0..6f43dc3f03e 100644
--- a/pkgs/applications/audio/spotify-tui/default.nix
+++ b/pkgs/applications/audio/spotify-tui/default.nix
@@ -13,10 +13,10 @@ rustPlatform.buildRustPackage rec {
 
   cargoSha256 = "100c7x603qyhav3p24clwfal4ngh0258x9lqsi84kcj4wq2f3i8f";
 
-  nativeBuildInputs = [ installShellFiles ] ++ stdenv.lib.optionals stdenv.isLinux [ pkgconfig python3 ];
+  nativeBuildInputs = [ installShellFiles ] ++ lib.optionals stdenv.isLinux [ pkgconfig python3 ];
   buildInputs = [ ]
-    ++ stdenv.lib.optionals stdenv.isLinux [ openssl libxcb ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ AppKit Security ];
+    ++ lib.optionals stdenv.isLinux [ openssl libxcb ]
+    ++ lib.optionals stdenv.isDarwin [ AppKit Security ];
 
   postInstall = ''
     for shell in bash fish zsh; do
diff --git a/pkgs/applications/audio/spotify/default.nix b/pkgs/applications/audio/spotify/default.nix
index bfc8757445c..43ecb67d64a 100644
--- a/pkgs/applications/audio/spotify/default.nix
+++ b/pkgs/applications/audio/spotify/default.nix
@@ -135,7 +135,7 @@ stdenv.mkDerivation {
         --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
         --set-rpath $rpath $out/share/spotify/spotify
 
-      librarypath="${stdenv.lib.makeLibraryPath deps}:$libdir"
+      librarypath="${lib.makeLibraryPath deps}:$libdir"
       wrapProgram $out/share/spotify/spotify \
         --prefix LD_LIBRARY_PATH : "$librarypath" \
         --prefix PATH : "${gnome3.zenity}/bin"
diff --git a/pkgs/applications/audio/spotifyd/default.nix b/pkgs/applications/audio/spotifyd/default.nix
index 737b8656c6a..4d52648a847 100644
--- a/pkgs/applications/audio/spotifyd/default.nix
+++ b/pkgs/applications/audio/spotifyd/default.nix
@@ -26,16 +26,16 @@ rustPackages_1_45.rustPlatform.buildRustPackage rec {
   cargoBuildFlags = [
     "--no-default-features"
     "--features"
-    "${stdenv.lib.optionalString withALSA "alsa_backend,"}${stdenv.lib.optionalString withPulseAudio "pulseaudio_backend,"}${stdenv.lib.optionalString withPortAudio "portaudio_backend,"}${stdenv.lib.optionalString withMpris "dbus_mpris,"}${stdenv.lib.optionalString withKeyring "dbus_keyring,"}"
+    "${lib.optionalString withALSA "alsa_backend,"}${lib.optionalString withPulseAudio "pulseaudio_backend,"}${lib.optionalString withPortAudio "portaudio_backend,"}${lib.optionalString withMpris "dbus_mpris,"}${lib.optionalString withKeyring "dbus_keyring,"}"
   ];
 
   nativeBuildInputs = [ pkgconfig ];
 
   buildInputs = [ openssl ]
-    ++ stdenv.lib.optional withALSA alsaLib
-    ++ stdenv.lib.optional withPulseAudio libpulseaudio
-    ++ stdenv.lib.optional withPortAudio portaudio
-    ++ stdenv.lib.optional (withMpris || withKeyring) dbus;
+    ++ lib.optional withALSA alsaLib
+    ++ lib.optional withPulseAudio libpulseaudio
+    ++ lib.optional withPortAudio portaudio
+    ++ lib.optional (withMpris || withKeyring) dbus;
 
   doCheck = false;
 
diff --git a/pkgs/applications/audio/squeezelite/default.nix b/pkgs/applications/audio/squeezelite/default.nix
index d5c84888eeb..6bb3bef8a50 100644
--- a/pkgs/applications/audio/squeezelite/default.nix
+++ b/pkgs/applications/audio/squeezelite/default.nix
@@ -9,8 +9,8 @@
 }:
 
 let
-  concatStringsSep = stdenv.lib.concatStringsSep;
-  optional = stdenv.lib.optional;
+  concatStringsSep = lib.concatStringsSep;
+  optional = lib.optional;
   opts = [ "-DLINKALL" ]
     ++ optional dsdSupport "-DDSD"
     ++ optional (!faad2Support) "-DNO_FAAD"
diff --git a/pkgs/applications/audio/sunvox/default.nix b/pkgs/applications/audio/sunvox/default.nix
index 12397f2fdbf..abc31d9f180 100644
--- a/pkgs/applications/audio/sunvox/default.nix
+++ b/pkgs/applications/audio/sunvox/default.nix
@@ -1,7 +1,7 @@
 { lib, stdenv, fetchurl, unzip, alsaLib, libX11, libXi, SDL2 }:
 
 let
-  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc alsaLib libX11 libXi SDL2 ];
+  libPath = lib.makeLibraryPath [ stdenv.cc.cc alsaLib libX11 libXi SDL2 ];
   arch =
     if stdenv.isAarch64
     then "arm64"
diff --git a/pkgs/applications/audio/tap-plugins/default.nix b/pkgs/applications/audio/tap-plugins/default.nix
index 2b04b450dec..c0b2c64822f 100644
--- a/pkgs/applications/audio/tap-plugins/default.nix
+++ b/pkgs/applications/audio/tap-plugins/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ladspa-sdk, pkgs, ... }:
+{ lib, stdenv, fetchurl, ladspa-sdk, pkgs, ... }:
 
 stdenv.mkDerivation rec {
   pname = "tap-plugins";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     substituteInPlace Makefile --replace /usr/local "$out"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Tom's Audio Processing plugins";
     longDescription = ''
       A number of LADSPA plugins including: TAP AutoPanner, TAP Chorus/Flanger, TAP DeEsser,
diff --git a/pkgs/applications/audio/timemachine/default.nix b/pkgs/applications/audio/timemachine/default.nix
index 8be43346bc0..399c39acf08 100644
--- a/pkgs/applications/audio/timemachine/default.nix
+++ b/pkgs/applications/audio/timemachine/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoconf, automake, pkgconfig, gtk2
+{ lib, stdenv, fetchFromGitHub, autoconf, automake, pkgconfig, gtk2
 , libjack2, libsndfile
 }:
 
@@ -24,9 +24,9 @@ stdenv.mkDerivation rec {
   meta = {
     description = "JACK audio recorder";
     homepage = "http://plugin.org.uk/timemachine/";
-    license = stdenv.lib.licenses.lgpl2;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.nico202 ];
+    license = lib.licenses.lgpl2;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.nico202 ];
   };
 }
 
diff --git a/pkgs/applications/audio/uade123/default.nix b/pkgs/applications/audio/uade123/default.nix
index 09e066dadac..44c8b0ecfb5 100644
--- a/pkgs/applications/audio/uade123/default.nix
+++ b/pkgs/applications/audio/uade123/default.nix
@@ -19,7 +19,7 @@ in stdenv.mkDerivation {
     description = "Plays old Amiga tunes through UAE emulation and cloned m68k-assembler Eagleplayer API";
     homepage = "http://zakalwe.fi/uade/";
     license = licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.gnidorah ];
-    platforms = stdenv.lib.platforms.unix;
+    maintainers = [ lib.maintainers.gnidorah ];
+    platforms = lib.platforms.unix;
   };
 }
diff --git a/pkgs/applications/audio/vcv-rack/default.nix b/pkgs/applications/audio/vcv-rack/default.nix
index 27844841482..8e836417f47 100644
--- a/pkgs/applications/audio/vcv-rack/default.nix
+++ b/pkgs/applications/audio/vcv-rack/default.nix
@@ -36,7 +36,7 @@ let
     sha256 = "17kd0lh2x3x12bxkyhq6z8sg6vxln8m9qirf0basvcsmylr6rb64";
   };
 in
-with stdenv.lib; stdenv.mkDerivation rec {
+with lib; stdenv.mkDerivation rec {
   pname = "VCV-Rack";
   version = "1.1.6";
 
diff --git a/pkgs/applications/audio/wavegain/default.nix b/pkgs/applications/audio/wavegain/default.nix
index d9b13f53273..f4ef7f6d8a5 100644
--- a/pkgs/applications/audio/wavegain/default.nix
+++ b/pkgs/applications/audio/wavegain/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ lib, stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation {
   name = "wavegain-1.3.1";
@@ -17,8 +17,8 @@ stdenv.mkDerivation {
   meta = {
     description = "ReplayGain for wave files";
     homepage = "https://github.com/MestreLion/wavegain";
-    license = stdenv.lib.licenses.lgpl21;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.robbinch ];
+    license = lib.licenses.lgpl21;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.robbinch ];
   };
 }
diff --git a/pkgs/applications/audio/whipper/default.nix b/pkgs/applications/audio/whipper/default.nix
index 227091dd581..8a46a06efce 100644
--- a/pkgs/applications/audio/whipper/default.nix
+++ b/pkgs/applications/audio/whipper/default.nix
@@ -3,7 +3,7 @@
 
 python3.pkgs.buildPythonApplication rec {
   pname = "whipper";
-  version = "0.9.1.dev7+g${stdenv.lib.substring 0 7 src.rev}";
+  version = "0.9.1.dev7+g${lib.substring 0 7 src.rev}";
 
   src = fetchFromGitHub {
     owner = "whipper-team";
@@ -37,7 +37,7 @@ python3.pkgs.buildPythonApplication rec {
   ];
 
   makeWrapperArgs = [
-    "--prefix" "PATH" ":" (stdenv.lib.makeBinPath [ accuraterip-checksum cdrdao util-linux flac sox ])
+    "--prefix" "PATH" ":" (lib.makeBinPath [ accuraterip-checksum cdrdao util-linux flac sox ])
   ];
 
   preBuild = ''
diff --git a/pkgs/applications/audio/x42-plugins/default.nix b/pkgs/applications/audio/x42-plugins/default.nix
index d3726eab7ff..485e0de1ee7 100644
--- a/pkgs/applications/audio/x42-plugins/default.nix
+++ b/pkgs/applications/audio/x42-plugins/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig
+{ lib, stdenv, fetchurl, pkgconfig
 , libltc, libsndfile, libsamplerate, ftgl, freefont_ttf, libjack2
 , libGLU, lv2, gtk2, cairo, pango, fftwFloat, zita-convolver }:
 
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
     sed -i 's|/usr/include/zita-convolver.h|${zita-convolver}/include/zita-convolver.h|g' ./convoLV2/Makefile
   '';
 
-  meta = with stdenv.lib;
+  meta = with lib;
     { description = "Collection of LV2 plugins by Robin Gareus";
       homepage = "https://github.com/x42/x42-plugins";
       maintainers = with maintainers; [ magnetophon ];
diff --git a/pkgs/applications/audio/yasr/default.nix b/pkgs/applications/audio/yasr/default.nix
index fed2ee0d8f7..21313b9c059 100644
--- a/pkgs/applications/audio/yasr/default.nix
+++ b/pkgs/applications/audio/yasr/default.nix
@@ -1,4 +1,4 @@
-{stdenv,fetchurl}:
+{lib, stdenv,fetchurl}:
 
 stdenv.mkDerivation rec {
   pname = "yasr";
@@ -21,8 +21,8 @@ stdenv.mkDerivation rec {
     homepage = "http://yasr.sourceforge.net";
     description = "A general-purpose console screen reader";
     longDescription = "Yasr is a general-purpose console screen reader for GNU/Linux and other Unix-like operating systems.";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [ jhhuh ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.gpl2;
+    maintainers = with lib.maintainers; [ jhhuh ];
   };
 }
diff --git a/pkgs/applications/audio/ympd/default.nix b/pkgs/applications/audio/ympd/default.nix
index 72c17aed52e..c12c060864d 100644
--- a/pkgs/applications/audio/ympd/default.nix
+++ b/pkgs/applications/audio/ympd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, pkg-config, mpd_clientlib, openssl }:
+{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, mpd_clientlib, openssl }:
 
 stdenv.mkDerivation rec {
   pname = "ympd";
@@ -17,8 +17,8 @@ stdenv.mkDerivation rec {
   meta = {
     homepage = "https://www.ympd.org";
     description = "Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS";
-    maintainers = [ stdenv.lib.maintainers.siddharthist ];
-    platforms = stdenv.lib.platforms.unix;
-    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.siddharthist ];
+    platforms = lib.platforms.unix;
+    license = lib.licenses.gpl2;
   };
 }