about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/doc/manual/configuration/profiles/hardened.xml10
-rw-r--r--nixos/modules/profiles/hardened.nix7
-rw-r--r--nixos/modules/programs/command-not-found/command-not-found.pl4
-rw-r--r--pkgs/applications/audio/bs1770gain/default.nix22
-rw-r--r--pkgs/applications/editors/jetbrains/default.nix44
-rw-r--r--pkgs/applications/editors/joe/default.nix32
-rw-r--r--pkgs/applications/kde/akonadi/default.nix11
-rw-r--r--pkgs/applications/kde/default.nix1
-rw-r--r--pkgs/applications/kde/kaccounts-integration.nix23
-rw-r--r--pkgs/applications/misc/dbeaver/default.nix4
-rw-r--r--pkgs/applications/misc/pdfpc/default.nix10
-rw-r--r--pkgs/applications/networking/cluster/nomad/0.11.nix8
-rw-r--r--pkgs/applications/networking/cluster/nomad/0.12.nix8
-rw-r--r--pkgs/applications/networking/cluster/nomad/1.0.nix8
-rw-r--r--pkgs/applications/networking/cluster/nomad/generic.nix46
-rw-r--r--pkgs/applications/networking/iptraf-ng/default.nix31
-rw-r--r--pkgs/applications/networking/sniffers/wireshark/default.nix3
-rw-r--r--pkgs/applications/science/chemistry/quantum-espresso/default.nix4
-rw-r--r--pkgs/applications/science/misc/colmap/default.nix13
-rw-r--r--pkgs/development/compilers/gcc/10/Added-mcf-thread-model-support-from-mcfgthread.patch306
-rw-r--r--pkgs/development/compilers/gcc/10/default.nix22
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix7
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix7
-rw-r--r--pkgs/development/compilers/gcc/6/Added-mcf-thread-model-support-from-mcfgthread.patch285
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/7/Added-mcf-thread-model-support-from-mcfgthread.patch285
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/8/Added-mcf-thread-model-support-from-mcfgthread.patch306
-rw-r--r--pkgs/development/compilers/gcc/8/default.nix22
-rw-r--r--pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch306
-rw-r--r--pkgs/development/compilers/gcc/9/default.nix14
-rw-r--r--pkgs/development/compilers/gcc/common/mfcgthreads-patches-repo.nix1
-rwxr-xr-xpkgs/development/compilers/gcc/update-mcfgthread-patches.sh15
-rw-r--r--pkgs/development/compilers/go/2-dev.nix4
-rw-r--r--pkgs/development/compilers/idris2/default.nix4
-rw-r--r--pkgs/development/compilers/llvm/10/libc++/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/10/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/10/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/11/libc++/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/11/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/11/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/7/libc++/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/7/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/8/libc++/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/8/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/8/libunwind.nix4
-rw-r--r--pkgs/development/compilers/llvm/9/libc++/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/9/libc++abi.nix3
-rw-r--r--pkgs/development/compilers/llvm/9/libunwind.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix5
-rw-r--r--pkgs/development/libraries/accounts-qt/default.nix12
-rw-r--r--pkgs/development/libraries/arrow-cpp/default.nix3
-rw-r--r--pkgs/development/libraries/audiofile/default.nix2
-rw-r--r--pkgs/development/libraries/boost/generic.nix2
-rw-r--r--pkgs/development/libraries/fmt/default.nix4
-rw-r--r--pkgs/development/libraries/gflags/default.nix4
-rw-r--r--pkgs/development/libraries/gmp/5.1.x.nix5
-rw-r--r--pkgs/development/libraries/gmp/6.x.nix3
-rw-r--r--pkgs/development/libraries/libbacktrace/default.nix5
-rw-r--r--pkgs/development/libraries/libexecinfo/default.nix5
-rw-r--r--pkgs/development/libraries/libiberty/default.nix4
-rw-r--r--pkgs/development/libraries/libiconv/default.nix4
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix5
-rw-r--r--pkgs/development/libraries/libpfm/default.nix4
-rw-r--r--pkgs/development/libraries/libxml2/default.nix2
-rw-r--r--pkgs/development/libraries/libxsmm/default.nix2
-rw-r--r--pkgs/development/libraries/ncurses/default.nix2
-rw-r--r--pkgs/development/libraries/neon/default.nix4
-rw-r--r--pkgs/development/libraries/openssl/default.nix2
-rw-r--r--pkgs/development/libraries/rocksdb/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/mkl/default.nix5
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix4
-rw-r--r--pkgs/development/libraries/signond/default.nix30
-rw-r--r--pkgs/development/libraries/thrift/default.nix4
-rw-r--r--pkgs/development/libraries/umockdev/default.nix13
-rw-r--r--pkgs/development/libraries/umockdev/disable-failed-test.patch13
-rw-r--r--pkgs/development/libraries/umockdev/fix-test-paths.patch12
-rw-r--r--pkgs/development/libraries/zlib/default.nix10
-rw-r--r--pkgs/development/ocaml-modules/csv/default.nix2
-rw-r--r--pkgs/development/ocaml-modules/csv/lwt.nix2
-rw-r--r--pkgs/development/ocaml-modules/ppx_blob/default.nix8
-rw-r--r--pkgs/development/python-modules/adblock/default.nix63
-rw-r--r--pkgs/development/python-modules/asyncwhois/default.nix36
-rw-r--r--pkgs/development/python-modules/autobahn/default.nix4
-rw-r--r--pkgs/development/python-modules/impacket/default.nix10
-rw-r--r--pkgs/development/python-modules/ldapdomaindump/default.nix24
-rw-r--r--pkgs/development/python-modules/micawber/default.nix4
-rw-r--r--pkgs/development/python-modules/mocket/default.nix4
-rw-r--r--pkgs/development/python-modules/nocaselist/default.nix4
-rw-r--r--pkgs/development/python-modules/patator/default.nix19
-rw-r--r--pkgs/development/python-modules/pydicom/default.nix48
-rw-r--r--pkgs/development/python-modules/pysqlcipher3/default.nix24
-rw-r--r--pkgs/development/python-modules/python-whois/default.nix41
-rw-r--r--pkgs/development/python-modules/pytun/default.nix6
-rw-r--r--pkgs/development/python-modules/quandl/default.nix19
-rw-r--r--pkgs/development/python-modules/weasyprint/default.nix4
-rw-r--r--pkgs/development/python-modules/weasyprint/library-paths.patch16
-rw-r--r--pkgs/development/python-modules/whois/default.nix32
-rw-r--r--pkgs/development/tools/analysis/lcov/default.nix27
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix2
-rw-r--r--pkgs/development/tools/parsing/tree-sitter/default.nix4
-rw-r--r--pkgs/development/tools/sourcetrail/python.nix4
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix4
-rw-r--r--pkgs/os-specific/linux/busybox/default.nix2
-rw-r--r--pkgs/os-specific/linux/fatrace/default.nix21
-rw-r--r--pkgs/os-specific/linux/libcap/default.nix20
-rw-r--r--pkgs/os-specific/linux/rdma-core/default.nix4
-rw-r--r--pkgs/servers/gobetween/default.nix4
-rw-r--r--pkgs/servers/home-assistant/component-packages.nix2
-rw-r--r--pkgs/servers/metabase/default.nix6
-rw-r--r--pkgs/shells/zsh/default.nix1
-rw-r--r--pkgs/tools/audio/beets/badfiles-plugin-nix-paths.patch21
-rw-r--r--pkgs/tools/audio/beets/bash-completion-always-print.patch43
-rw-r--r--pkgs/tools/audio/beets/compatibility-with-breaking-changes-to-the-ast-module.patch55
-rw-r--r--pkgs/tools/audio/beets/convert-plugin-ffmpeg-path.patch43
-rw-r--r--pkgs/tools/audio/beets/default.nix179
-rw-r--r--pkgs/tools/audio/beets/keyfinder-default-bin.patch20
-rw-r--r--pkgs/tools/audio/beets/mutagen-1.43.patch40
-rw-r--r--pkgs/tools/audio/beets/plugins/alternatives.nix (renamed from pkgs/tools/audio/beets/alternatives-plugin.nix)0
-rw-r--r--pkgs/tools/audio/beets/plugins/check-tests.patch (renamed from pkgs/tools/audio/beets/beet-check-tests.patch)0
-rw-r--r--pkgs/tools/audio/beets/plugins/check.nix (renamed from pkgs/tools/audio/beets/check-plugin.nix)0
-rw-r--r--pkgs/tools/audio/beets/plugins/copyartifacts.nix (renamed from pkgs/tools/audio/beets/copyartifacts-plugin.nix)0
-rw-r--r--pkgs/tools/audio/beets/plugins/extrafiles.nix (renamed from pkgs/tools/audio/beets/extrafiles-plugin.nix)0
-rw-r--r--pkgs/tools/audio/beets/replaygain-default-bs1770gain.patch17
-rw-r--r--pkgs/tools/audio/beets/replaygain-default-ffmpeg.patch26
-rw-r--r--pkgs/tools/backup/duplicity/default.nix1
-rw-r--r--pkgs/tools/compression/bzip2/default.nix2
-rw-r--r--pkgs/tools/compression/lz4/default.nix3
-rw-r--r--pkgs/tools/compression/xz/default.nix4
-rw-r--r--pkgs/tools/filesystems/nixpart/0.4/parted.nix4
-rw-r--r--pkgs/tools/graphics/optipng/default.nix3
-rw-r--r--pkgs/tools/misc/hdf4/default.nix35
-rw-r--r--pkgs/tools/misc/hdf5/default.nix2
-rw-r--r--pkgs/tools/misc/ipxe/default.nix4
-rw-r--r--pkgs/tools/misc/parted/default.nix2
-rw-r--r--pkgs/tools/misc/toybox/default.nix2
-rw-r--r--pkgs/tools/misc/ttygif/default.nix8
-rw-r--r--pkgs/tools/networking/dropbear/default.nix2
-rw-r--r--pkgs/tools/package-management/nix/default.nix2
-rw-r--r--pkgs/tools/system/ipmitool/default.nix2
-rw-r--r--pkgs/tools/system/pciutils/default.nix2
-rw-r--r--pkgs/top-level/aliases.nix1
-rw-r--r--pkgs/top-level/all-packages.nix24
-rw-r--r--pkgs/top-level/ocaml-packages.nix5
-rw-r--r--pkgs/top-level/python-packages.nix20
-rw-r--r--pkgs/top-level/static.nix112
146 files changed, 2585 insertions, 689 deletions
diff --git a/nixos/doc/manual/configuration/profiles/hardened.xml b/nixos/doc/manual/configuration/profiles/hardened.xml
index dc83fc837e2a3..4a51754cc7ae2 100644
--- a/nixos/doc/manual/configuration/profiles/hardened.xml
+++ b/nixos/doc/manual/configuration/profiles/hardened.xml
@@ -7,7 +7,7 @@
 
  <para>
   A profile with most (vanilla) hardening options enabled by default,
-  potentially at the cost of features and performance.
+  potentially at the cost of stability, features and performance.
  </para>
 
  <para>
@@ -21,4 +21,12 @@
    xlink:href="https://github.com/nixos/nixpkgs/tree/master/nixos/modules/profiles/hardened.nix">
   profile source</literal> for further detail on which settings are altered.
  </para>
+ <warning>
+   <para>
+     This profile enables options that are known to affect system
+     stability. If you experience any stability issues when using the
+     profile, try disabling it. If you report an issue and use this
+     profile, always mention that you do.
+   </para>
+ </warning>
 </section>
diff --git a/nixos/modules/profiles/hardened.nix b/nixos/modules/profiles/hardened.nix
index 42ed62b063044..680fa40b91195 100644
--- a/nixos/modules/profiles/hardened.nix
+++ b/nixos/modules/profiles/hardened.nix
@@ -1,5 +1,10 @@
 # A profile with most (vanilla) hardening options enabled by default,
-# potentially at the cost of features and performance.
+# potentially at the cost of stability, features and performance.
+#
+# This profile enables options that are known to affect system
+# stability. If you experience any stability issues when using the
+# profile, try disabling it. If you report an issue and use this
+# profile, always mention that you do.
 
 { config, lib, pkgs, ... }:
 
diff --git a/nixos/modules/programs/command-not-found/command-not-found.pl b/nixos/modules/programs/command-not-found/command-not-found.pl
index 63c4925d43330..7515dd975c316 100644
--- a/nixos/modules/programs/command-not-found/command-not-found.pl
+++ b/nixos/modules/programs/command-not-found/command-not-found.pl
@@ -36,7 +36,7 @@ EOF
         exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV));
     } else {
         print STDERR <<EOF;
-The program '$program' is not in your PATH. You can make it available in a
+The program '$program' is not in your PATH. You can make it available in an
 ephemeral shell by typing:
   nix-shell -p $package
 EOF
@@ -44,7 +44,7 @@ EOF
 } else {
     print STDERR <<EOF;
 The program '$program' is not in your PATH. It is provided by several packages.
-You can make it available in a ephemeral shell by typing one of the following:
+You can make it available in an ephemeral shell by typing one of the following:
 EOF
     print STDERR "  nix-shell -p $_->{package}\n" foreach @$res;
 }
diff --git a/pkgs/applications/audio/bs1770gain/default.nix b/pkgs/applications/audio/bs1770gain/default.nix
deleted file mode 100644
index 76a789356193b..0000000000000
--- a/pkgs/applications/audio/bs1770gain/default.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-{ stdenv, fetchurl, ffmpeg, sox }:
-
-stdenv.mkDerivation rec {
-  pname = "bs1770gain";
-  version = "0.5.2";
-
-  src = fetchurl {
-    url = "mirror://sourceforge/bs1770gain/${pname}-${version}.tar.gz";
-    sha256 = "1p6yz5q7czyf9ard65sp4kawdlkg40cfscr3b24znymmhs3p7rbk";
-  };
-
-  buildInputs = [ ffmpeg sox ];
-
-  NIX_CFLAGS_COMPILE = "-Wno-error";
-
-  meta = with stdenv.lib; {
-    description = "A audio/video loudness scanner implementing ITU-R BS.1770";
-    license = licenses.gpl2Plus;
-    homepage = "http://bs1770gain.sourceforge.net/";
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/applications/editors/jetbrains/default.nix b/pkgs/applications/editors/jetbrains/default.nix
index 9638bea60c9a1..9d743b197e63e 100644
--- a/pkgs/applications/editors/jetbrains/default.nix
+++ b/pkgs/applications/editors/jetbrains/default.nix
@@ -269,12 +269,12 @@ in
 
   clion = buildClion rec {
     name = "clion-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description  = "C/C++ IDE. New. Intelligent. Cross-platform";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/cpp/CLion-${version}.tar.gz";
-      sha256 = "0kqja2c5pz0f9idc52mv7iy2pqq2kfcx4q4x1ywfn3gq3d8n5j7z"; /* updated by script */
+      sha256 = "1jfvwir79s0kcqmlx6bbkmc42bplgl7814mnqfcsdzni1qv62pws"; /* updated by script */
     };
     wmClass = "jetbrains-clion";
     update-channel = "CLion RELEASE"; # channel's id as in http://www.jetbrains.com/updates/updates.xml
@@ -282,12 +282,12 @@ in
 
   datagrip = buildDataGrip rec {
     name = "datagrip-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Your Swiss Army Knife for Databases and SQL";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/datagrip/${name}.tar.gz";
-      sha256 = "1j0mlsiqh80mspi2x9mi0h5hxhg5gw6395hyl9w33q8dxm95mx2d"; /* updated by script */
+      sha256 = "0jk7ywxk983ld5x71a59dh1hvlnli3sbvg7fbicahas5ml8clxfv"; /* updated by script */
     };
     wmClass = "jetbrains-datagrip";
     update-channel = "DataGrip RELEASE";
@@ -295,12 +295,12 @@ in
 
   goland = buildGoland rec {
     name = "goland-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Up and Coming Go IDE";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/go/${name}.tar.gz";
-      sha256 = "0hj1xm3c71y2z1jyv7j3xf2lcj2y0kyvsxd3jjyyhs31w1f3394j"; /* updated by script */
+      sha256 = "12gi1a2bmafmy7qgqwv3a7b5b46dlhw4ahmkm5pkq6pmxl4y6dmk"; /* updated by script */
     };
     wmClass = "jetbrains-goland";
     update-channel = "GoLand RELEASE";
@@ -308,12 +308,12 @@ in
 
   idea-community = buildIdea rec {
     name = "idea-community-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Integrated Development Environment (IDE) by Jetbrains, community edition";
     license = stdenv.lib.licenses.asl20;
     src = fetchurl {
       url = "https://download.jetbrains.com/idea/ideaIC-${version}.tar.gz";
-      sha256 = "0x1nsjw1m03iq7sd9i2qqlyribrzgi8yh6k5hnb630kvrxr8pxy6"; /* updated by script */
+      sha256 = "0am4h8w1dmjl08iphqy78ivb91vkrvskg95dgm24zcj0n8rwmaq6"; /* updated by script */
     };
     wmClass = "jetbrains-idea-ce";
     update-channel = "IntelliJ IDEA RELEASE";
@@ -321,12 +321,12 @@ in
 
   idea-ultimate = buildIdea rec {
     name = "idea-ultimate-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Integrated Development Environment (IDE) by Jetbrains, requires paid license";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/idea/ideaIU-${version}-no-jbr.tar.gz";
-      sha256 = "1l6bvfgzp27113rjy1y3jvp09cqx8gpnbgpwp83vsph7x0dhx8a3"; /* updated by script */
+      sha256 = "1kwz0aq4b664awppakj4syppk218nynwxv4ngc7pa3k9v4g2sdah"; /* updated by script */
     };
     wmClass = "jetbrains-idea";
     update-channel = "IntelliJ IDEA RELEASE";
@@ -347,12 +347,12 @@ in
 
   phpstorm = buildPhpStorm rec {
     name = "phpstorm-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Professional IDE for Web and PHP developers";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/webide/PhpStorm-${version}.tar.gz";
-      sha256 = "1d5rx7p7lvjzgp57n980f2bfrj14p1f4hxmyvx5pzzd86q7hrcbq"; /* updated by script */
+      sha256 = "1c5j3mbg8scsl4c90cjahdk5gs5q72y5a8fhkqa9zmy6di42k99x"; /* updated by script */
     };
     wmClass = "jetbrains-phpstorm";
     update-channel = "PhpStorm RELEASE";
@@ -360,12 +360,12 @@ in
 
   pycharm-community = buildPycharm rec {
     name = "pycharm-community-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.2"; /* updated by script */
     description = "PyCharm Community Edition";
     license = stdenv.lib.licenses.asl20;
     src = fetchurl {
       url = "https://download.jetbrains.com/python/${name}.tar.gz";
-      sha256 = "1c2izsqx27g4jy46iskx5zg00pd8jaf9x1p0vya4l2v5r49dk4jb"; /* updated by script */
+      sha256 = "1z3w6aah635fdrhrzp5af6sgj269jk7mv8vgdd83gxillkx9vq9k"; /* updated by script */
     };
     wmClass = "jetbrains-pycharm-ce";
     update-channel = "PyCharm RELEASE";
@@ -373,12 +373,12 @@ in
 
   pycharm-professional = buildPycharm rec {
     name = "pycharm-professional-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.2"; /* updated by script */
     description = "PyCharm Professional Edition";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/python/${name}.tar.gz";
-      sha256 = "1kzgy90zcligwa9r6r11kx99z0zm93mrzy700y2jwslyzapd16d0"; /* updated by script */
+      sha256 = "1fbb8v40q7vgn5v5dyxb211abr8swnxa3gw18kh3vlk6yc2crzfw"; /* updated by script */
     };
     wmClass = "jetbrains-pycharm";
     update-channel = "PyCharm RELEASE";
@@ -386,12 +386,12 @@ in
 
   rider = buildRider rec {
     name = "rider-${version}";
-    version = "2020.2.4"; /* updated by script */
+    version = "2020.3.2"; /* updated by script */
     description = "A cross-platform .NET IDE based on the IntelliJ platform and ReSharper";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/rider/JetBrains.Rider-${version}.tar.gz";
-      sha256 = "1anl48ifv5ayqn876dqckxc1b5fw1271pvamzf1vvk501wv6dpaf"; /* updated by script */
+      sha256 = "1dkgbd2nqkjcswf7j3pnrsaq9n5wk42abz2c4wgkrh1zrpgihd0j"; /* updated by script */
     };
     wmClass = "jetbrains-rider";
     update-channel = "Rider RELEASE";
@@ -399,12 +399,12 @@ in
 
   ruby-mine = buildRubyMine rec {
     name = "ruby-mine-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "The Most Intelligent Ruby and Rails IDE";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/ruby/RubyMine-${version}.tar.gz";
-      sha256 = "0ij6j9bxfqzj8gnrhhdgai22s1n5swd4waxd5zjvmv7q9j9cb2l5"; /* updated by script */
+      sha256 = "0drxzz6k0cmhir4szg8nwmsi9qh380vrryghmpvx9w83yrcain4c"; /* updated by script */
     };
     wmClass = "jetbrains-rubymine";
     update-channel = "RubyMine RELEASE";
@@ -412,12 +412,12 @@ in
 
   webstorm = buildWebStorm rec {
     name = "webstorm-${version}";
-    version = "2020.3"; /* updated by script */
+    version = "2020.3.1"; /* updated by script */
     description = "Professional IDE for Web and JavaScript development";
     license = stdenv.lib.licenses.unfree;
     src = fetchurl {
       url = "https://download.jetbrains.com/webstorm/WebStorm-${version}.tar.gz";
-      sha256 = "0sk7slwfr9jasid09hxw81sik5srn35vif3pbzpybig3yszbv6ld"; /* updated by script */
+      sha256 = "1bfq3xwnfz6f04d0lq584q7pg775a8y35b1b62w81dbfh43l4fj0"; /* updated by script */
     };
     wmClass = "jetbrains-webstorm";
     update-channel = "WebStorm RELEASE";
diff --git a/pkgs/applications/editors/joe/default.nix b/pkgs/applications/editors/joe/default.nix
index bb227512387d2..9470c7940d67b 100644
--- a/pkgs/applications/editors/joe/default.nix
+++ b/pkgs/applications/editors/joe/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl } :
 
 stdenv.mkDerivation rec {
-  version = "4.6";
   pname = "joe";
+  version = "4.6";
 
   src = fetchurl {
     url = "mirror://sourceforge/joe-editor/${pname}-${version}.tar.gz";
@@ -11,8 +11,36 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "A full featured terminal-based screen editor";
+    longDescription = ''
+      JOE (Joe's Own Editor) is a full featured terminal-based screen editor
+      which is distributed under the GNU General Public License (GPL). JOE has
+      been around since 1988 and comes standard with many Linux distributions.
+
+      JOE is being maintained by its original author Joseph Allen, plus all of
+      the people who send bug reports, feature suggestions and patches to the
+      project web site. JOE is hosted by SourceForge.net and its source code is
+      controlled under Mercurial.
+
+      JOE is a blending of MicroPro's venerable microcomputer word processor
+      WordStar and Richard Stallman's famous LISP based text editor GNU-EMACS
+      (but it does not use code from either program): most of the basic editing
+      keys are the same as in WordStar as is the overall feel of the editor. JOE
+      also has some of the key bindings and many of the powerful features of
+      EMACS.
+
+      JOE is written in C and its only dependency is libc. This makes JOE very
+      easy to build (just "configure" and "make install"), making it feasible to
+      include on small systems and recovery disks. The compiled binary is about
+      300K in x86. Note that JOE can use either the termcap or terminfo terminal
+      capabilities databases (or a built-in termcap entry for ANSI
+      terminals). The choice is controlled by a "configure" option. If terminfo
+      is used, a library is required to access the database (on some systems
+      this library is ncurses, but JOE does not use curses to control the
+      terminal - it has its own code for this).
+    '';
     homepage = "https://joe-editor.sourceforge.io";
-    license = licenses.gpl2;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/applications/kde/akonadi/default.nix b/pkgs/applications/kde/akonadi/default.nix
index 3c6ed88aa9bf3..d24e19f89e7e2 100644
--- a/pkgs/applications/kde/akonadi/default.nix
+++ b/pkgs/applications/kde/akonadi/default.nix
@@ -1,8 +1,9 @@
 {
   mkDerivation, lib, kdepimTeam,
-  extra-cmake-modules, shared-mime-info, qtbase,
-  boost, kcompletion, kconfigwidgets, kcrash, kdbusaddons, kdesignerplugin,
-  ki18n, kiconthemes, kio, kitemmodels, kwindowsystem, mysql, qttools,
+  extra-cmake-modules, shared-mime-info, qtbase, accounts-qt,
+  boost, kaccounts-integration, kcompletion, kconfigwidgets, kcrash, kdbusaddons,
+  kdesignerplugin, ki18n, kiconthemes, kio, kitemmodels, kwindowsystem, mysql, qttools,
+  signond,
 }:
 
 mkDerivation {
@@ -19,8 +20,8 @@ mkDerivation {
   ];
   nativeBuildInputs = [ extra-cmake-modules shared-mime-info ];
   buildInputs = [
-    kcompletion kconfigwidgets kcrash kdbusaddons kdesignerplugin ki18n
-    kiconthemes kio kwindowsystem qttools
+    kaccounts-integration kcompletion kconfigwidgets kcrash kdbusaddons kdesignerplugin
+    ki18n kiconthemes kio kwindowsystem accounts-qt qttools signond
   ];
   propagatedBuildInputs = [ boost kitemmodels ];
   outputs = [ "out" "dev" ];
diff --git a/pkgs/applications/kde/default.nix b/pkgs/applications/kde/default.nix
index f60ac76653d16..33f392fdccc71 100644
--- a/pkgs/applications/kde/default.nix
+++ b/pkgs/applications/kde/default.nix
@@ -86,6 +86,7 @@ let
       gwenview = callPackage ./gwenview.nix {};
       incidenceeditor = callPackage ./incidenceeditor.nix {};
       k3b = callPackage ./k3b.nix {};
+      kaccounts-integration = callPackage ./kaccounts-integration.nix {};
       kaddressbook = callPackage ./kaddressbook.nix {};
       kalarm = callPackage ./kalarm.nix {};
       kalarmcal = callPackage ./kalarmcal.nix {};
diff --git a/pkgs/applications/kde/kaccounts-integration.nix b/pkgs/applications/kde/kaccounts-integration.nix
new file mode 100644
index 0000000000000..ef69f564f128b
--- /dev/null
+++ b/pkgs/applications/kde/kaccounts-integration.nix
@@ -0,0 +1,23 @@
+{ mkDerivation, lib, extra-cmake-modules, kdoctools, kcmutils, kcoreaddons, kwallet, accounts-qt, signond }:
+
+mkDerivation {
+  pname = "kaccounts-integration";
+  meta = with lib; {
+    homepage = "https://community.kde.org/KTp/Setting_up_KAccounts";
+    description = "Online accounts integration";
+    maintainers = with maintainers; [ freezeboy ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+  nativeBuildInputs = [
+    extra-cmake-modules
+  ];
+  buildInputs = [
+    kcmutils
+    kcoreaddons
+    kdoctools
+    kwallet
+    accounts-qt
+    signond
+  ];
+}
diff --git a/pkgs/applications/misc/dbeaver/default.nix b/pkgs/applications/misc/dbeaver/default.nix
index a41ee209a0be5..f14f5aec8cb68 100644
--- a/pkgs/applications/misc/dbeaver/default.nix
+++ b/pkgs/applications/misc/dbeaver/default.nix
@@ -7,7 +7,7 @@
 
 stdenv.mkDerivation rec {
   pname = "dbeaver-ce";
-  version = "7.3.1";
+  version = "7.3.2";
 
   desktopItem = makeDesktopItem {
     name = "dbeaver";
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://dbeaver.io/files/${version}/dbeaver-ce-${version}-linux.gtk.x86_64.tar.gz";
-    sha256 = "sha256-4UVC5lBoGsW99L6AgM+1Rs07LCrvp2qVevBrooTbee4=";
+    sha256 = "sha256-4BVXcR8/E4uIrPQJe9KU9577j4XLTxJWTO8g0vCHWts=";
   };
 
   installPhase = ''
diff --git a/pkgs/applications/misc/pdfpc/default.nix b/pkgs/applications/misc/pdfpc/default.nix
index fc0bf62f1e9f8..216f8c4b8b8e1 100644
--- a/pkgs/applications/misc/pdfpc/default.nix
+++ b/pkgs/applications/misc/pdfpc/default.nix
@@ -1,16 +1,17 @@
 { stdenv, fetchFromGitHub, cmake, pkgconfig, vala, gtk3, libgee, fetchpatch
-, poppler, libpthreadstubs, gstreamer, gst-plugins-base, gst-plugins-good, gst-libav, librsvg, pcre, gobject-introspection, wrapGAppsHook }:
+, poppler, libpthreadstubs, gstreamer, gst-plugins-base, gst-plugins-good, gst-libav, librsvg, pcre, gobject-introspection, wrapGAppsHook
+, webkitgtk, discount, json-glib }:
 
 stdenv.mkDerivation rec {
   name = "${product}-${version}";
   product = "pdfpc";
-  version = "4.4.1";
+  version = "4.5.0";
 
   src = fetchFromGitHub {
     repo = product;
     owner = product;
     rev = "v${version}";
-    sha256 = "11n925c5jj3yfwnqkgxzqrmsrpqh8ls1g4idmqqzpsanpam1xvna";
+    sha256 = "0bmy51w6ypz927hxwp5g7wapqvzqmsi3w32rch6i3f94kg1152ck";
   };
 
   nativeBuildInputs = [
@@ -27,6 +28,9 @@ stdenv.mkDerivation rec {
     gst-plugins-base
     (gst-plugins-good.override { gtkSupport = true; })
     gst-libav
+    webkitgtk
+    discount
+    json-glib
   ];
 
   cmakeFlags = stdenv.lib.optional stdenv.isDarwin "-DMOVIES=OFF";
diff --git a/pkgs/applications/networking/cluster/nomad/0.11.nix b/pkgs/applications/networking/cluster/nomad/0.11.nix
index 2fd7c0403a3c4..58bdb694eed51 100644
--- a/pkgs/applications/networking/cluster/nomad/0.11.nix
+++ b/pkgs/applications/networking/cluster/nomad/0.11.nix
@@ -1,7 +1,11 @@
-{ callPackage, buildGoPackage }:
+{ callPackage
+, buildGoPackage
+, nvidia_x11
+, nvidiaGpuSupport
+}:
 
 callPackage ./generic.nix {
-  inherit buildGoPackage;
+  inherit buildGoPackage nvidia_x11 nvidiaGpuSupport;
   version = "0.11.8";
   sha256 = "1dhh07bifr02jh2lls8fv1d9ra67ymgh8qxqvpvm0cd0qdd469z1";
 }
diff --git a/pkgs/applications/networking/cluster/nomad/0.12.nix b/pkgs/applications/networking/cluster/nomad/0.12.nix
index 0120887957a85..b6e053e757de2 100644
--- a/pkgs/applications/networking/cluster/nomad/0.12.nix
+++ b/pkgs/applications/networking/cluster/nomad/0.12.nix
@@ -1,7 +1,11 @@
-{ callPackage, buildGoPackage }:
+{ callPackage
+, buildGoPackage
+, nvidia_x11
+, nvidiaGpuSupport
+}:
 
 callPackage ./generic.nix {
-  inherit buildGoPackage;
+  inherit buildGoPackage nvidia_x11 nvidiaGpuSupport;
   version = "0.12.9";
   sha256 = "1a0ig6pb0z3qp7zk4jgz3h241bifmjlyqsfikyy3sxdnzj7yha27";
 }
diff --git a/pkgs/applications/networking/cluster/nomad/1.0.nix b/pkgs/applications/networking/cluster/nomad/1.0.nix
index 4b0b62400193e..0b7b7c12d1a63 100644
--- a/pkgs/applications/networking/cluster/nomad/1.0.nix
+++ b/pkgs/applications/networking/cluster/nomad/1.0.nix
@@ -1,7 +1,11 @@
-{ callPackage, buildGoPackage }:
+{ callPackage
+, buildGoPackage
+, nvidia_x11
+, nvidiaGpuSupport
+}:
 
 callPackage ./generic.nix {
-  inherit buildGoPackage;
+  inherit buildGoPackage nvidia_x11 nvidiaGpuSupport;
   version = "1.0.1";
   sha256 = "07k81csyxhgc7bgn297zlqyvc55qb5fmiavi7dk81rdpg5m2zjvv";
 }
diff --git a/pkgs/applications/networking/cluster/nomad/generic.nix b/pkgs/applications/networking/cluster/nomad/generic.nix
index 0bfdb0b27f6e6..dc22ab41d8b64 100644
--- a/pkgs/applications/networking/cluster/nomad/generic.nix
+++ b/pkgs/applications/networking/cluster/nomad/generic.nix
@@ -1,4 +1,12 @@
-{ stdenv, buildGoPackage, fetchFromGitHub, version, sha256 }:
+{ lib
+, buildGoPackage
+, fetchFromGitHub
+, version
+, sha256
+, nvidiaGpuSupport
+, patchelf
+, nvidia_x11
+}:
 
 buildGoPackage rec {
   pname = "nomad";
@@ -14,23 +22,33 @@ buildGoPackage rec {
     inherit rev sha256;
   };
 
+  nativeBuildInputs = lib.optionals nvidiaGpuSupport [
+    patchelf
+  ];
+
   # ui:
   #  Nomad release commits include the compiled version of the UI, but the file
   #  is only included if we build with the ui tag.
-  # nonvidia:
-  #  We disable Nvidia GPU scheduling on Linux, as it doesn't work there:
-  #  Ref: https://github.com/hashicorp/nomad/issues/5535
-  preBuild = let
-    tags = ["ui"]
-      ++ stdenv.lib.optional stdenv.isLinux "nonvidia";
-    tagsString = stdenv.lib.concatStringsSep " " tags;
-  in ''
-    export buildFlagsArray=(
-      -tags="${tagsString}"
-    )
- '';
+  preBuild =
+    let
+      tags = [ "ui" ] ++ lib.optional (!nvidiaGpuSupport) "nonvidia";
+      tagsString = lib.concatStringsSep " " tags;
+    in
+    ''
+      export buildFlagsArray=(
+        -tags="${tagsString}"
+      )
+    '';
+
+  # The dependency on NVML isn't explicit. We have to make it so otherwise the
+  # binary will not know where to look for the relevant symbols.
+  postFixup = lib.optionalString nvidiaGpuSupport ''
+    for bin in $out/bin/*; do
+      patchelf --add-needed "${nvidia_x11}/lib/libnvidia-ml.so" "$bin"
+    done
+  '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://www.nomadproject.io/";
     description = "A Distributed, Highly Available, Datacenter-Aware Scheduler";
     platforms = platforms.unix;
diff --git a/pkgs/applications/networking/iptraf-ng/default.nix b/pkgs/applications/networking/iptraf-ng/default.nix
index 1fc81be240bf2..6d61acb4982f1 100644
--- a/pkgs/applications/networking/iptraf-ng/default.nix
+++ b/pkgs/applications/networking/iptraf-ng/default.nix
@@ -1,24 +1,27 @@
-{ stdenv, fetchurl, ncurses }:
+{ stdenv, fetchFromGitHub, ncurses }:
 
 stdenv.mkDerivation rec {
-  version = "1.1.4";
+  version = "1.2.1";
   pname = "iptraf-ng";
 
-  src = fetchurl {
-    url = "https://fedorahosted.org/releases/i/p/iptraf-ng/${pname}-${version}.tar.gz";
-    sha256 = "02gb8z9h2s6s1ybyikywz7jgb1mafdx88hijfasv3khcgkq0q53r";
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1f91w1bjaayr6ld95z2q55ny983bb0m05k1jrw2bcddvcihaiqb1";
   };
 
   buildInputs = [ ncurses ];
 
-  configurePhase = ''
-    ./configure --prefix=$out/usr --sysconfdir=$out/etc \
-                --localstatedir=$out/var --sbindir=$out/bin
-  '';
+  makeFlags = [
+    "DESTDIR=$(out)"
+    "prefix=/usr"
+    "sbindir=/bin"
+  ];
 
   hardeningDisable = [ "format" ];
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A console-based network monitoring utility (fork of iptraf)";
     longDescription = ''
       IPTraf-ng is a console-based network monitoring utility. IPTraf-ng
@@ -38,9 +41,9 @@ stdenv.mkDerivation rec {
       of the Linux kernel, so it can be used on a wide variety of supported
       network cards.
     '';
-    homepage = "https://fedorahosted.org/iptraf-ng/";
-    license = stdenv.lib.licenses.gpl2;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.devhell ];
+    homepage = "https://github.com/iptraf-ng/iptraf-ng";
+    license = licenses.gpl2Only;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ devhell ];
   };
 }
diff --git a/pkgs/applications/networking/sniffers/wireshark/default.nix b/pkgs/applications/networking/sniffers/wireshark/default.nix
index 66292e20c525d..cb29857e168d5 100644
--- a/pkgs/applications/networking/sniffers/wireshark/default.nix
+++ b/pkgs/applications/networking/sniffers/wireshark/default.nix
@@ -12,7 +12,6 @@ with stdenv.lib;
 let
   version = "3.4.2";
   variant = if withQt then "qt" else "cli";
-  pcap = libpcap.override { withBluez = stdenv.isLinux; };
 
 in stdenv.mkDerivation {
   pname = "wireshark-${variant}";
@@ -39,7 +38,7 @@ in stdenv.mkDerivation {
   ] ++ optional withQt qt5.wrapQtAppsHook;
 
   buildInputs = [
-    gettext pcre perl pcap lua5 libssh nghttp2 openssl libgcrypt
+    gettext pcre perl libpcap lua5 libssh nghttp2 openssl libgcrypt
     libgpgerror gnutls geoip c-ares python3 glib zlib makeWrapper
   ] ++ optionals withQt  (with qt5; [ qtbase qtmultimedia qtsvg qttools ])
     ++ optionals stdenv.isLinux  [ libcap libnl ]
diff --git a/pkgs/applications/science/chemistry/quantum-espresso/default.nix b/pkgs/applications/science/chemistry/quantum-espresso/default.nix
index 2443e6b23aba7..071091f2ecf20 100644
--- a/pkgs/applications/science/chemistry/quantum-espresso/default.nix
+++ b/pkgs/applications/science/chemistry/quantum-espresso/default.nix
@@ -4,12 +4,12 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = "6.5";
+  version = "6.6";
   pname = "quantum-espresso";
 
   src = fetchurl {
     url = "https://gitlab.com/QEF/q-e/-/archive/qe-${version}/q-e-qe-${version}.tar.gz";
-    sha256 = "00nnsq1vq579xsmkvwrgs6bdqdcbdlsmcp4yfynnvs40ca52m2r5";
+    sha256 = "0b3718bwdqfyssyz25jknijar79qh5cf1bbizv9faliz135mcilj";
   };
 
   passthru = {
diff --git a/pkgs/applications/science/misc/colmap/default.nix b/pkgs/applications/science/misc/colmap/default.nix
index 83dff3e08f157..60f9810dfb6a0 100644
--- a/pkgs/applications/science/misc/colmap/default.nix
+++ b/pkgs/applications/science/misc/colmap/default.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, lib, fetchpatch, fetchFromGitHub, cmake, boost17x, ceres-solver, eigen,
+{ mkDerivation, lib, fetchFromGitHub, cmake, boost17x, ceres-solver, eigen,
   freeimage, glog, libGLU, glew, qtbase,
   cudaSupport ? false, cudatoolkit ? null }:
 
@@ -7,22 +7,15 @@ assert !cudaSupport || cudatoolkit != null;
 let boost_static = boost17x.override { enableStatic = true; };
 in
 mkDerivation rec {
-  version = "3.5";
+  version = "3.6";
   pname = "colmap";
   src = fetchFromGitHub {
      owner = "colmap";
      repo = "colmap";
      rev = version;
-     sha256 = "1vnb62p0y2bnga173wmjs0lnyqdjikv0fkcxjzxm8187khk2lly8";
+     sha256 = "1kfivdmhpmdxjjf30rr57y2iy7xmdpg4h8aw3qgacv8ckfpgda3n";
   };
 
-  patches = [
-    (fetchpatch {
-      url = "https://github.com/colmap/colmap/commit/6af3d8b0048cecc3b9fc6f4e78c3214dd038180b.patch";
-      sha256 = "1zv5girmv4hv78w1xn131v8njwhpbyylc1m15731lnhrs8bri0jq";
-    })
-  ];
-
   buildInputs = [
     boost_static ceres-solver eigen
     freeimage glog libGLU glew qtbase
diff --git a/pkgs/development/compilers/gcc/10/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/10/Added-mcf-thread-model-support-from-mcfgthread.patch
new file mode 100644
index 0000000000000..d9809e828f10c
--- /dev/null
+++ b/pkgs/development/compilers/gcc/10/Added-mcf-thread-model-support-from-mcfgthread.patch
@@ -0,0 +1,306 @@
+From 86f2f767ddffd9f7c6f1470b987ae7b0d251b988 Mon Sep 17 00:00:00 2001
+From: Liu Hao <lh_mouse@126.com>
+Date: Wed, 25 Apr 2018 21:54:19 +0800
+Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
+
+Signed-off-by: Liu Hao <lh_mouse@126.com>
+---
+ config/gthr.m4                          |  1 +
+ gcc/config.gcc                          |  3 +++
+ gcc/config/i386/mingw-mcfgthread.h      |  1 +
+ gcc/config/i386/mingw-w64.h             |  2 +-
+ gcc/config/i386/mingw32.h               | 11 ++++++++++-
+ gcc/configure                           |  2 +-
+ gcc/configure.ac                        |  2 +-
+ libatomic/configure.tgt                 |  2 +-
+ libgcc/config.host                      |  6 ++++++
+ libgcc/config/i386/gthr-mcf.h           |  1 +
+ libgcc/config/i386/t-mingw-mcfgthread   |  2 ++
+ libgcc/configure                        |  1 +
+ libstdc++-v3/configure                  |  1 +
+ libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
+ libstdc++-v3/libsupc++/guard.cc         | 23 +++++++++++++++++++++++
+ libstdc++-v3/src/c++11/thread.cc        |  9 +++++++++
+ 16 files changed, 80 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/config/i386/mingw-mcfgthread.h
+ create mode 100644 libgcc/config/i386/gthr-mcf.h
+ create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
+
+diff --git a/config/gthr.m4 b/config/gthr.m4
+index 7b29f1f3327..82e21fe1709 100644
+--- a/config/gthr.m4
++++ b/config/gthr.m4
+@@ -21,6 +21,7 @@ case $1 in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ AC_SUBST(thread_header)
+ ])
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 46a9029acec..112c24e95a3 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1758,6 +1758,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ 	if test x$enable_threads = xposix ; then
+ 		tm_file="${tm_file} i386/mingw-pthread.h"
+ 	fi
++	if test x$enable_threads = xmcf ; then
++		tm_file="${tm_file} i386/mingw-mcfgthread.h"
++	fi
+ 	tm_file="${tm_file} i386/mingw32.h"
+ 	# This makes the logic if mingw's or the w64 feature set has to be used
+ 	case ${target} in
+diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
+new file mode 100644
+index 00000000000..ec381a7798f
+--- /dev/null
++++ b/gcc/config/i386/mingw-mcfgthread.h
+@@ -0,0 +1 @@
++#define TARGET_USE_MCFGTHREAD 1
+diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
+index 484dc7a9e9f..a15bbeea500 100644
+--- a/gcc/config/i386/mingw-w64.h
++++ b/gcc/config/i386/mingw-w64.h
+@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++		 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ #undef SPEC_32
+ #undef SPEC_64
+diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
+index 0612b87199a..76cea94f3b7 100644
+--- a/gcc/config/i386/mingw32.h
++++ b/gcc/config/i386/mingw32.h
+@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3.  If not see
+ 	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
+ 	 | MASK_MS_BITFIELD_LAYOUT)
+ 
++#ifndef TARGET_USE_MCFGTHREAD
++#define CPP_MCFGTHREAD()  ((void)0)
++#define LIB_MCFGTHREAD     ""
++#else
++#define CPP_MCFGTHREAD()  (builtin_define("__USING_MCFGTHREAD__"))
++#define LIB_MCFGTHREAD     " -lmcfgthread "
++#endif
++
+ /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
+    is for compatibility with native compiler.  */
+ #define EXTRA_OS_CPP_BUILTINS()					\
+@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
+ 	  builtin_define_std ("WIN64");				\
+ 	  builtin_define ("_WIN64");				\
+ 	}							\
++	CPP_MCFGTHREAD();	\
+     }								\
+   while (0)
+ 
+@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++                 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ /* Weak symbols do not get resolved if using a Windows dll import lib.
+    Make the unwind registration references strong undefs.  */
+diff --git a/gcc/configure b/gcc/configure
+index 6121e163259..52f0e00efe6 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11693,7 +11693,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index b066cc609e1..4ecdba88de7 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1612,7 +1612,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index ea8c34f8c71..23134ad7363 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -145,7 +145,7 @@ case "${target}" in
+   *-*-mingw*)
+ 	# OS support for atomic primitives.
+         case ${target_thread_file} in
+-          win32)
++          win32 | mcf)
+             config_path="${config_path} mingw"
+             ;;
+           posix)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 11b4acaff55..9fbd38650bd 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -737,6 +737,9 @@ i[34567]86-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+@@ -761,6 +764,9 @@ x86_64-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
+new file mode 100644
+index 00000000000..5ea2908361f
+--- /dev/null
++++ b/libgcc/config/i386/gthr-mcf.h
+@@ -0,0 +1 @@
++#include <mcfgthread/gthread.h>
+diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
+new file mode 100644
+index 00000000000..4b9b10e32d6
+--- /dev/null
++++ b/libgcc/config/i386/t-mingw-mcfgthread
+@@ -0,0 +1,2 @@
++SHLIB_PTHREAD_CFLAG =
++SHLIB_PTHREAD_LDFLAG = -lmcfgthread
+diff --git a/libgcc/configure b/libgcc/configure
+index b2f3f870844..eff889dc3b3 100644
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -5451,6 +5451,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
+index ba094be6f15..979a5ab9ace 100755
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15187,6 +15187,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
+index de920d714c6..665fb74bd6b 100644
+--- a/libstdc++-v3/libsupc++/atexit_thread.cc
++++ b/libstdc++-v3/libsupc++/atexit_thread.cc
+@@ -25,6 +25,22 @@
+ #include <cstdlib>
+ #include <new>
+ #include "bits/gthr.h"
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++extern "C" int
++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
++				 void *obj, void *dso_handle)
++  _GLIBCXX_NOTHROW
++{
++  return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
++  (void)dso_handle;
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
+ }
+ 
+ #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
++
++#endif // __USING_MCFGTHREAD__
+diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
+index 3a2ec3ad0d6..8b4cc96199b 100644
+--- a/libstdc++-v3/libsupc++/guard.cc
++++ b/libstdc++-v3/libsupc++/guard.cc
+@@ -28,6 +28,27 @@
+ #include <cxxabi.h>
+ #include <exception>
+ #include <new>
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++namespace __cxxabiv1 {
++
++extern "C" int __cxa_guard_acquire(__guard *g){
++	return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
++}
++extern "C" void __cxa_guard_abort(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
++}
++extern "C" void __cxa_guard_release(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
++}
++
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #include <ext/atomicity.h>
+ #include <ext/concurrence.h>
+ #include <bits/atomic_lockfree_defines.h>
+@@ -425,3 +446,5 @@ namespace __cxxabiv1
+ #endif
+   }
+ }
++
++#endif
+diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
+index 8238817c2e9..0c6a1f85f6f 100644
+--- a/libstdc++-v3/src/c++11/thread.cc
++++ b/libstdc++-v3/src/c++11/thread.cc
+@@ -55,6 +55,15 @@ static inline int get_nprocs()
+ #elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)
+ # include <unistd.h>
+ # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
++#elif defined(_WIN32)
++# include <windows.h>
++static inline int get_nprocs()
++{
++  SYSTEM_INFO sysinfo;
++  GetSystemInfo(&sysinfo);
++  return (int)sysinfo.dwNumberOfProcessors;
++}
++# define _GLIBCXX_NPROCS get_nprocs()
+ #else
+ # define _GLIBCXX_NPROCS 0
+ #endif
+-- 
+2.17.0
+
diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix
index 4f05cd3144cde..c31e7c426e02f 100644
--- a/pkgs/development/compilers/gcc/10/default.nix
+++ b/pkgs/development/compilers/gcc/10/default.nix
@@ -7,7 +7,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
@@ -61,10 +66,9 @@ let majorVersion = "10";
       ++ optional langAda ../gnat-cflags.patch
       ++ optional langFortran ../gfortran-driving.patch
       ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
-      ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
-        url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
-        sha256 = "1in5kvcknlpi9z1vvjw6jfmwy8k12zvbqlqfnq84qpm99r0rh00a";
-      });
+
+      # Obtain latest patch with ../update-mcfgthread-patches.sh
+      ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
 
     /* Cross-gcc settings (build == host != target) */
     crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
@@ -137,10 +141,10 @@ stdenv.mkDerivation ({
         )
     else "")
       + stdenv.lib.optionalString targetPlatform.isAvr ''
-	        makeFlagsArray+=(
-	           'LIMITS_H_TEST=false'
-	        )
-	      '';
+            makeFlagsArray+=(
+               'LIMITS_H_TEST=false'
+            )
+          '';
 
   inherit noSysDirs staticCompiler crossStageStatic
     libcCross crossMingw;
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 213d0c91ff34c..617a19e238ba8 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -7,7 +7,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 98d4b61648e37..7ea80ffbeb3f5 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -7,7 +7,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
diff --git a/pkgs/development/compilers/gcc/6/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/6/Added-mcf-thread-model-support-from-mcfgthread.patch
new file mode 100644
index 0000000000000..25e3a902cbf2c
--- /dev/null
+++ b/pkgs/development/compilers/gcc/6/Added-mcf-thread-model-support-from-mcfgthread.patch
@@ -0,0 +1,285 @@
+From 30534f48c6ede142dad0008d1641392d82b8a137 Mon Sep 17 00:00:00 2001
+From: Liu Hao <lh_mouse@126.com>
+Date: Mon, 18 Apr 2016 11:50:55 +0800
+Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
+
+Signed-off-by: Liu Hao <lh_mouse@126.com>
+---
+ config/gthr.m4                          |  1 +
+ gcc/config.gcc                          |  3 +++
+ gcc/config/i386/mingw-mcfgthread.h      |  1 +
+ gcc/config/i386/mingw-w64.h             |  2 +-
+ gcc/config/i386/mingw32.h               | 11 ++++++++++-
+ gcc/configure                           |  2 +-
+ gcc/configure.ac                        |  2 +-
+ libatomic/configure.tgt                 |  2 +-
+ libgcc/config.host                      |  6 ++++++
+ libgcc/config/i386/gthr-mcf.h           |  1 +
+ libgcc/config/i386/t-mingw-mcfgthread   |  2 ++
+ libgcc/configure                        |  1 +
+ libstdc++-v3/configure                  |  1 +
+ libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
+ libstdc++-v3/libsupc++/guard.cc         | 23 +++++++++++++++++++++++
+ 15 files changed, 71 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/config/i386/mingw-mcfgthread.h
+ create mode 100644 libgcc/config/i386/gthr-mcf.h
+ create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
+
+diff --git a/config/gthr.m4 b/config/gthr.m4
+index 7b29f1f3327..82e21fe1709 100644
+--- a/config/gthr.m4
++++ b/config/gthr.m4
+@@ -21,6 +21,7 @@ case $1 in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ AC_SUBST(thread_header)
+ ])
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 858b878d4b3..6f745790d64 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1722,6 +1722,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ 	if test x$enable_threads = xposix ; then
+ 		tm_file="${tm_file} i386/mingw-pthread.h"
+ 	fi
++	if test x$enable_threads = xmcf ; then
++		tm_file="${tm_file} i386/mingw-mcfgthread.h"
++	fi
+ 	tm_file="${tm_file} i386/mingw32.h"
+ 	# This makes the logic if mingw's or the w64 feature set has to be used
+ 	case ${target} in
+diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
+new file mode 100644
+index 00000000000..ec381a7798f
+--- /dev/null
++++ b/gcc/config/i386/mingw-mcfgthread.h
+@@ -0,0 +1 @@
++#define TARGET_USE_MCFGTHREAD 1
+diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
+index fe11333a2d1..cac85802f38 100644
+--- a/gcc/config/i386/mingw-w64.h
++++ b/gcc/config/i386/mingw-w64.h
+@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++		 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ #undef SPEC_32
+ #undef SPEC_64
+diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
+index e04818966fa..7b75a372506 100644
+--- a/gcc/config/i386/mingw32.h
++++ b/gcc/config/i386/mingw32.h
+@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3.  If not see
+ 	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
+ 	 | MASK_MS_BITFIELD_LAYOUT)
+ 
++#ifndef TARGET_USE_MCFGTHREAD
++#define CPP_MCFGTHREAD()  ((void)0)
++#define LIB_MCFGTHREAD     ""
++#else
++#define CPP_MCFGTHREAD()  (builtin_define("__USING_MCFGTHREAD__"))
++#define LIB_MCFGTHREAD     " -lmcfgthread "
++#endif
++
+ /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
+    is for compatibility with native compiler.  */
+ #define EXTRA_OS_CPP_BUILTINS()					\
+@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
+ 	  builtin_define_std ("WIN64");				\
+ 	  builtin_define ("_WIN64");				\
+ 	}							\
++	CPP_MCFGTHREAD();	\
+     }								\
+   while (0)
+ 
+@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++                 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ /* Weak symbols do not get resolved if using a Windows dll import lib.
+    Make the unwind registration references strong undefs.  */
+diff --git a/gcc/configure b/gcc/configure
+index 954673c1c43..6b5667f1c70 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11702,7 +11702,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 4c65d441e72..e6fa04ada4f 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1593,7 +1593,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index eab2765d7fd..f4058b6f4a2 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -124,7 +124,7 @@ case "${target}" in
+   *-*-mingw*)
+ 	# OS support for atomic primitives.
+         case ${target_thread_file} in
+-          win32)
++          win32 | mcf)
+             config_path="${config_path} mingw"
+             ;;
+           posix)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 2b139b8befc..fb18d2a042e 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -712,6 +712,9 @@ i[34567]86-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+@@ -736,6 +739,9 @@ x86_64-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
+new file mode 100644
+index 00000000000..5ea2908361f
+--- /dev/null
++++ b/libgcc/config/i386/gthr-mcf.h
+@@ -0,0 +1 @@
++#include <mcfgthread/gthread.h>
+diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
+new file mode 100644
+index 00000000000..4b9b10e32d6
+--- /dev/null
++++ b/libgcc/config/i386/t-mingw-mcfgthread
+@@ -0,0 +1,2 @@
++SHLIB_PTHREAD_CFLAG =
++SHLIB_PTHREAD_LDFLAG = -lmcfgthread
+diff --git a/libgcc/configure b/libgcc/configure
+index e7d6c75a6f7..664d0f852c4 100644
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -5077,6 +5077,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
+index b5ae4213f94..c484d3aee5f 100755
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15177,6 +15177,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
+index e6520c1094f..3d6907796dd 100644
+--- a/libstdc++-v3/libsupc++/atexit_thread.cc
++++ b/libstdc++-v3/libsupc++/atexit_thread.cc
+@@ -25,6 +25,22 @@
+ #include <cstdlib>
+ #include <new>
+ #include "bits/gthr.h"
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++extern "C" int
++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
++				 void *obj, void *dso_handle)
++  _GLIBCXX_NOTHROW
++{
++  return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
++  (void)dso_handle;
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+@@ -163,3 +179,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
+ }
+ 
+ #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
++
++#endif // __USING_MCFGTHREAD__
+diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
+index 9b617998ffe..a441fdbb616 100644
+--- a/libstdc++-v3/libsupc++/guard.cc
++++ b/libstdc++-v3/libsupc++/guard.cc
+@@ -28,6 +28,27 @@
+ #include <cxxabi.h>
+ #include <exception>
+ #include <new>
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++namespace __cxxabiv1 {
++
++extern "C" int __cxa_guard_acquire(__guard *g){
++	return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
++}
++extern "C" void __cxa_guard_abort(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
++}
++extern "C" void __cxa_guard_release(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
++}
++
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #include <ext/atomicity.h>
+ #include <ext/concurrence.h>
+ #if defined(__GTHREADS) && defined(__GTHREAD_HAS_COND) \
+@@ -424,3 +445,5 @@ namespace __cxxabiv1
+ #endif
+   }
+ }
++
++#endif
+-- 
+2.12.1
+
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index a2f034a4827fd..029777430ffa0 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -8,7 +8,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , flex
@@ -71,10 +76,9 @@ let majorVersion = "6";
       ++ optional langAda ../gnat-cflags.patch
       ++ optional langFortran ../gfortran-driving.patch
       ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch
-      ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
-        url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
-        sha256 = "1c449jgm1vx9g4kv82bxmvlgrwb8f6kwkl0gqmjlmhf7f4hjy2nr";
-      });
+
+      # Obtain latest patch with ../update-mcfgthread-patches.sh
+      ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
 
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
diff --git a/pkgs/development/compilers/gcc/7/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/7/Added-mcf-thread-model-support-from-mcfgthread.patch
new file mode 100644
index 0000000000000..0c5d0ee9e460c
--- /dev/null
+++ b/pkgs/development/compilers/gcc/7/Added-mcf-thread-model-support-from-mcfgthread.patch
@@ -0,0 +1,285 @@
+From d3cb66e4751fcbd581b81a14a973de2d78fc02ad Mon Sep 17 00:00:00 2001
+From: Liu Hao <lh_mouse@126.com>
+Date: Mon, 18 Apr 2016 11:50:55 +0800
+Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
+
+Signed-off-by: Liu Hao <lh_mouse@126.com>
+---
+ config/gthr.m4                          |  1 +
+ gcc/config.gcc                          |  3 +++
+ gcc/config/i386/mingw-mcfgthread.h      |  1 +
+ gcc/config/i386/mingw-w64.h             |  2 +-
+ gcc/config/i386/mingw32.h               | 11 ++++++++++-
+ gcc/configure                           |  2 +-
+ gcc/configure.ac                        |  2 +-
+ libatomic/configure.tgt                 |  2 +-
+ libgcc/config.host                      |  6 ++++++
+ libgcc/config/i386/gthr-mcf.h           |  1 +
+ libgcc/config/i386/t-mingw-mcfgthread   |  2 ++
+ libgcc/configure                        |  1 +
+ libstdc++-v3/configure                  |  1 +
+ libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
+ libstdc++-v3/libsupc++/guard.cc         | 23 +++++++++++++++++++++++
+ 15 files changed, 71 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/config/i386/mingw-mcfgthread.h
+ create mode 100644 libgcc/config/i386/gthr-mcf.h
+ create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
+
+diff --git a/config/gthr.m4 b/config/gthr.m4
+index 7b29f1f3327..82e21fe1709 100644
+--- a/config/gthr.m4
++++ b/config/gthr.m4
+@@ -21,6 +21,7 @@ case $1 in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ AC_SUBST(thread_header)
+ ])
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 8f91197f34e..59db37cac04 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1719,6 +1719,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ 	if test x$enable_threads = xposix ; then
+ 		tm_file="${tm_file} i386/mingw-pthread.h"
+ 	fi
++	if test x$enable_threads = xmcf ; then
++		tm_file="${tm_file} i386/mingw-mcfgthread.h"
++	fi
+ 	tm_file="${tm_file} i386/mingw32.h"
+ 	# This makes the logic if mingw's or the w64 feature set has to be used
+ 	case ${target} in
+diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
+new file mode 100644
+index 00000000000..ec381a7798f
+--- /dev/null
++++ b/gcc/config/i386/mingw-mcfgthread.h
+@@ -0,0 +1 @@
++#define TARGET_USE_MCFGTHREAD 1
+diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
+index 270ec0dd037..88966f79695 100644
+--- a/gcc/config/i386/mingw-w64.h
++++ b/gcc/config/i386/mingw-w64.h
+@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++		 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ #undef SPEC_32
+ #undef SPEC_64
+diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
+index e5f014cb473..989cfbe894e 100644
+--- a/gcc/config/i386/mingw32.h
++++ b/gcc/config/i386/mingw32.h
+@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3.  If not see
+ 	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
+ 	 | MASK_MS_BITFIELD_LAYOUT)
+ 
++#ifndef TARGET_USE_MCFGTHREAD
++#define CPP_MCFGTHREAD()  ((void)0)
++#define LIB_MCFGTHREAD     ""
++#else
++#define CPP_MCFGTHREAD()  (builtin_define("__USING_MCFGTHREAD__"))
++#define LIB_MCFGTHREAD     " -lmcfgthread "
++#endif
++
+ /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
+    is for compatibility with native compiler.  */
+ #define EXTRA_OS_CPP_BUILTINS()					\
+@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
+ 	  builtin_define_std ("WIN64");				\
+ 	  builtin_define ("_WIN64");				\
+ 	}							\
++	CPP_MCFGTHREAD();	\
+     }								\
+   while (0)
+ 
+@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++                 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ /* Weak symbols do not get resolved if using a Windows dll import lib.
+    Make the unwind registration references strong undefs.  */
+diff --git a/gcc/configure b/gcc/configure
+index ea73b151a4e..317200e5620 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11681,7 +11681,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 9d4c792a33f..d51899a5676 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1612,7 +1612,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index b8af3ab2546..73248438a8c 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -125,7 +125,7 @@ case "${target}" in
+   *-*-mingw*)
+ 	# OS support for atomic primitives.
+         case ${target_thread_file} in
+-          win32)
++          win32 | mcf)
+             config_path="${config_path} mingw"
+             ;;
+           posix)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index b279a6458f9..20d22f585da 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -710,6 +710,9 @@ i[34567]86-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+@@ -734,6 +737,9 @@ x86_64-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
+new file mode 100644
+index 00000000000..5ea2908361f
+--- /dev/null
++++ b/libgcc/config/i386/gthr-mcf.h
+@@ -0,0 +1 @@
++#include <mcfgthread/gthread.h>
+diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
+new file mode 100644
+index 00000000000..4b9b10e32d6
+--- /dev/null
++++ b/libgcc/config/i386/t-mingw-mcfgthread
+@@ -0,0 +1,2 @@
++SHLIB_PTHREAD_CFLAG =
++SHLIB_PTHREAD_LDFLAG = -lmcfgthread
+diff --git a/libgcc/configure b/libgcc/configure
+index 45c459788c3..8fc569ef16e 100644
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -5086,6 +5086,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
+index 2406cb9d946..50e7e4ced89 100755
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15182,6 +15182,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
+index 923a0707556..a55d85aad2d 100644
+--- a/libstdc++-v3/libsupc++/atexit_thread.cc
++++ b/libstdc++-v3/libsupc++/atexit_thread.cc
+@@ -25,6 +25,22 @@
+ #include <cstdlib>
+ #include <new>
+ #include "bits/gthr.h"
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++extern "C" int
++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
++				 void *obj, void *dso_handle)
++  _GLIBCXX_NOTHROW
++{
++  return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
++  (void)dso_handle;
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
+ }
+ 
+ #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
++
++#endif // __USING_MCFGTHREAD__
+diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
+index 19953bc52f0..72fd5f26d5b 100644
+--- a/libstdc++-v3/libsupc++/guard.cc
++++ b/libstdc++-v3/libsupc++/guard.cc
+@@ -28,6 +28,27 @@
+ #include <cxxabi.h>
+ #include <exception>
+ #include <new>
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++namespace __cxxabiv1 {
++
++extern "C" int __cxa_guard_acquire(__guard *g){
++	return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
++}
++extern "C" void __cxa_guard_abort(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
++}
++extern "C" void __cxa_guard_release(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
++}
++
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #include <ext/atomicity.h>
+ #include <ext/concurrence.h>
+ #include <bits/atomic_lockfree_defines.h>
+@@ -425,3 +446,5 @@ namespace __cxxabiv1
+ #endif
+   }
+ }
++
++#endif
+-- 
+2.12.1
+
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 6d066044ec1ee..d950d6ac35bbb 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -6,7 +6,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
@@ -68,10 +73,9 @@ let majorVersion = "7";
       ++ optional langFortran ../gfortran-driving.patch
       ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
       ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch
-      ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
-        url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
-        sha256 = "1nyjnshpq5gbcbbpfv27hy4ajvycmgkpiabkjlxnnrnq1d99k1ay";
-      });
+
+      # Obtain latest patch with ../update-mcfgthread-patches.sh
+      ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
 
     /* Cross-gcc settings (build == host != target) */
     crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
diff --git a/pkgs/development/compilers/gcc/8/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/8/Added-mcf-thread-model-support-from-mcfgthread.patch
new file mode 100644
index 0000000000000..d9809e828f10c
--- /dev/null
+++ b/pkgs/development/compilers/gcc/8/Added-mcf-thread-model-support-from-mcfgthread.patch
@@ -0,0 +1,306 @@
+From 86f2f767ddffd9f7c6f1470b987ae7b0d251b988 Mon Sep 17 00:00:00 2001
+From: Liu Hao <lh_mouse@126.com>
+Date: Wed, 25 Apr 2018 21:54:19 +0800
+Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
+
+Signed-off-by: Liu Hao <lh_mouse@126.com>
+---
+ config/gthr.m4                          |  1 +
+ gcc/config.gcc                          |  3 +++
+ gcc/config/i386/mingw-mcfgthread.h      |  1 +
+ gcc/config/i386/mingw-w64.h             |  2 +-
+ gcc/config/i386/mingw32.h               | 11 ++++++++++-
+ gcc/configure                           |  2 +-
+ gcc/configure.ac                        |  2 +-
+ libatomic/configure.tgt                 |  2 +-
+ libgcc/config.host                      |  6 ++++++
+ libgcc/config/i386/gthr-mcf.h           |  1 +
+ libgcc/config/i386/t-mingw-mcfgthread   |  2 ++
+ libgcc/configure                        |  1 +
+ libstdc++-v3/configure                  |  1 +
+ libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
+ libstdc++-v3/libsupc++/guard.cc         | 23 +++++++++++++++++++++++
+ libstdc++-v3/src/c++11/thread.cc        |  9 +++++++++
+ 16 files changed, 80 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/config/i386/mingw-mcfgthread.h
+ create mode 100644 libgcc/config/i386/gthr-mcf.h
+ create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
+
+diff --git a/config/gthr.m4 b/config/gthr.m4
+index 7b29f1f3327..82e21fe1709 100644
+--- a/config/gthr.m4
++++ b/config/gthr.m4
+@@ -21,6 +21,7 @@ case $1 in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ AC_SUBST(thread_header)
+ ])
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 46a9029acec..112c24e95a3 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1758,6 +1758,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ 	if test x$enable_threads = xposix ; then
+ 		tm_file="${tm_file} i386/mingw-pthread.h"
+ 	fi
++	if test x$enable_threads = xmcf ; then
++		tm_file="${tm_file} i386/mingw-mcfgthread.h"
++	fi
+ 	tm_file="${tm_file} i386/mingw32.h"
+ 	# This makes the logic if mingw's or the w64 feature set has to be used
+ 	case ${target} in
+diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
+new file mode 100644
+index 00000000000..ec381a7798f
+--- /dev/null
++++ b/gcc/config/i386/mingw-mcfgthread.h
+@@ -0,0 +1 @@
++#define TARGET_USE_MCFGTHREAD 1
+diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
+index 484dc7a9e9f..a15bbeea500 100644
+--- a/gcc/config/i386/mingw-w64.h
++++ b/gcc/config/i386/mingw-w64.h
+@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++		 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ #undef SPEC_32
+ #undef SPEC_64
+diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
+index 0612b87199a..76cea94f3b7 100644
+--- a/gcc/config/i386/mingw32.h
++++ b/gcc/config/i386/mingw32.h
+@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3.  If not see
+ 	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
+ 	 | MASK_MS_BITFIELD_LAYOUT)
+ 
++#ifndef TARGET_USE_MCFGTHREAD
++#define CPP_MCFGTHREAD()  ((void)0)
++#define LIB_MCFGTHREAD     ""
++#else
++#define CPP_MCFGTHREAD()  (builtin_define("__USING_MCFGTHREAD__"))
++#define LIB_MCFGTHREAD     " -lmcfgthread "
++#endif
++
+ /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
+    is for compatibility with native compiler.  */
+ #define EXTRA_OS_CPP_BUILTINS()					\
+@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
+ 	  builtin_define_std ("WIN64");				\
+ 	  builtin_define ("_WIN64");				\
+ 	}							\
++	CPP_MCFGTHREAD();	\
+     }								\
+   while (0)
+ 
+@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++                 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ /* Weak symbols do not get resolved if using a Windows dll import lib.
+    Make the unwind registration references strong undefs.  */
+diff --git a/gcc/configure b/gcc/configure
+index 6121e163259..52f0e00efe6 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11693,7 +11693,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index b066cc609e1..4ecdba88de7 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1612,7 +1612,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index ea8c34f8c71..23134ad7363 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -145,7 +145,7 @@ case "${target}" in
+   *-*-mingw*)
+ 	# OS support for atomic primitives.
+         case ${target_thread_file} in
+-          win32)
++          win32 | mcf)
+             config_path="${config_path} mingw"
+             ;;
+           posix)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 11b4acaff55..9fbd38650bd 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -737,6 +737,9 @@ i[34567]86-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+@@ -761,6 +764,9 @@ x86_64-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
+new file mode 100644
+index 00000000000..5ea2908361f
+--- /dev/null
++++ b/libgcc/config/i386/gthr-mcf.h
+@@ -0,0 +1 @@
++#include <mcfgthread/gthread.h>
+diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
+new file mode 100644
+index 00000000000..4b9b10e32d6
+--- /dev/null
++++ b/libgcc/config/i386/t-mingw-mcfgthread
+@@ -0,0 +1,2 @@
++SHLIB_PTHREAD_CFLAG =
++SHLIB_PTHREAD_LDFLAG = -lmcfgthread
+diff --git a/libgcc/configure b/libgcc/configure
+index b2f3f870844..eff889dc3b3 100644
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -5451,6 +5451,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
+index ba094be6f15..979a5ab9ace 100755
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15187,6 +15187,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
+index de920d714c6..665fb74bd6b 100644
+--- a/libstdc++-v3/libsupc++/atexit_thread.cc
++++ b/libstdc++-v3/libsupc++/atexit_thread.cc
+@@ -25,6 +25,22 @@
+ #include <cstdlib>
+ #include <new>
+ #include "bits/gthr.h"
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++extern "C" int
++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
++				 void *obj, void *dso_handle)
++  _GLIBCXX_NOTHROW
++{
++  return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
++  (void)dso_handle;
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
+ }
+ 
+ #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
++
++#endif // __USING_MCFGTHREAD__
+diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
+index 3a2ec3ad0d6..8b4cc96199b 100644
+--- a/libstdc++-v3/libsupc++/guard.cc
++++ b/libstdc++-v3/libsupc++/guard.cc
+@@ -28,6 +28,27 @@
+ #include <cxxabi.h>
+ #include <exception>
+ #include <new>
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++namespace __cxxabiv1 {
++
++extern "C" int __cxa_guard_acquire(__guard *g){
++	return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
++}
++extern "C" void __cxa_guard_abort(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
++}
++extern "C" void __cxa_guard_release(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
++}
++
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #include <ext/atomicity.h>
+ #include <ext/concurrence.h>
+ #include <bits/atomic_lockfree_defines.h>
+@@ -425,3 +446,5 @@ namespace __cxxabiv1
+ #endif
+   }
+ }
++
++#endif
+diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
+index 8238817c2e9..0c6a1f85f6f 100644
+--- a/libstdc++-v3/src/c++11/thread.cc
++++ b/libstdc++-v3/src/c++11/thread.cc
+@@ -55,6 +55,15 @@ static inline int get_nprocs()
+ #elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)
+ # include <unistd.h>
+ # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
++#elif defined(_WIN32)
++# include <windows.h>
++static inline int get_nprocs()
++{
++  SYSTEM_INFO sysinfo;
++  GetSystemInfo(&sysinfo);
++  return (int)sysinfo.dwNumberOfProcessors;
++}
++# define _GLIBCXX_NPROCS get_nprocs()
+ #else
+ # define _GLIBCXX_NPROCS 0
+ #endif
+-- 
+2.17.0
+
diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix
index 9e6a24d12948a..683a9edfe09d9 100644
--- a/pkgs/development/compilers/gcc/8/default.nix
+++ b/pkgs/development/compilers/gcc/8/default.nix
@@ -6,7 +6,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
@@ -58,10 +63,9 @@ let majorVersion = "8";
       ++ optional langFortran ../gfortran-driving.patch
       ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
       ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch
-      ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
-        url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
-        sha256 = "1in5kvcknlpi9z1vvjw6jfmwy8k12zvbqlqfnq84qpm99r0rh00a";
-      });
+
+      # Obtain latest patch with ../update-mcfgthread-patches.sh
+      ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
 
     /* Cross-gcc settings (build == host != target) */
     crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
@@ -134,10 +138,10 @@ stdenv.mkDerivation ({
         )
     else "")
       + stdenv.lib.optionalString targetPlatform.isAvr ''
-	        makeFlagsArray+=(
-	           'LIMITS_H_TEST=false'
-	        )
-	      '';
+            makeFlagsArray+=(
+               'LIMITS_H_TEST=false'
+            )
+          '';
 
   inherit noSysDirs staticCompiler crossStageStatic
     libcCross crossMingw;
diff --git a/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch
new file mode 100644
index 0000000000000..d9809e828f10c
--- /dev/null
+++ b/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch
@@ -0,0 +1,306 @@
+From 86f2f767ddffd9f7c6f1470b987ae7b0d251b988 Mon Sep 17 00:00:00 2001
+From: Liu Hao <lh_mouse@126.com>
+Date: Wed, 25 Apr 2018 21:54:19 +0800
+Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
+
+Signed-off-by: Liu Hao <lh_mouse@126.com>
+---
+ config/gthr.m4                          |  1 +
+ gcc/config.gcc                          |  3 +++
+ gcc/config/i386/mingw-mcfgthread.h      |  1 +
+ gcc/config/i386/mingw-w64.h             |  2 +-
+ gcc/config/i386/mingw32.h               | 11 ++++++++++-
+ gcc/configure                           |  2 +-
+ gcc/configure.ac                        |  2 +-
+ libatomic/configure.tgt                 |  2 +-
+ libgcc/config.host                      |  6 ++++++
+ libgcc/config/i386/gthr-mcf.h           |  1 +
+ libgcc/config/i386/t-mingw-mcfgthread   |  2 ++
+ libgcc/configure                        |  1 +
+ libstdc++-v3/configure                  |  1 +
+ libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
+ libstdc++-v3/libsupc++/guard.cc         | 23 +++++++++++++++++++++++
+ libstdc++-v3/src/c++11/thread.cc        |  9 +++++++++
+ 16 files changed, 80 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/config/i386/mingw-mcfgthread.h
+ create mode 100644 libgcc/config/i386/gthr-mcf.h
+ create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
+
+diff --git a/config/gthr.m4 b/config/gthr.m4
+index 7b29f1f3327..82e21fe1709 100644
+--- a/config/gthr.m4
++++ b/config/gthr.m4
+@@ -21,6 +21,7 @@ case $1 in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ AC_SUBST(thread_header)
+ ])
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 46a9029acec..112c24e95a3 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1758,6 +1758,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
+ 	if test x$enable_threads = xposix ; then
+ 		tm_file="${tm_file} i386/mingw-pthread.h"
+ 	fi
++	if test x$enable_threads = xmcf ; then
++		tm_file="${tm_file} i386/mingw-mcfgthread.h"
++	fi
+ 	tm_file="${tm_file} i386/mingw32.h"
+ 	# This makes the logic if mingw's or the w64 feature set has to be used
+ 	case ${target} in
+diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
+new file mode 100644
+index 00000000000..ec381a7798f
+--- /dev/null
++++ b/gcc/config/i386/mingw-mcfgthread.h
+@@ -0,0 +1 @@
++#define TARGET_USE_MCFGTHREAD 1
+diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
+index 484dc7a9e9f..a15bbeea500 100644
+--- a/gcc/config/i386/mingw-w64.h
++++ b/gcc/config/i386/mingw-w64.h
+@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++		 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ #undef SPEC_32
+ #undef SPEC_64
+diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
+index 0612b87199a..76cea94f3b7 100644
+--- a/gcc/config/i386/mingw32.h
++++ b/gcc/config/i386/mingw32.h
+@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3.  If not see
+ 	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
+ 	 | MASK_MS_BITFIELD_LAYOUT)
+ 
++#ifndef TARGET_USE_MCFGTHREAD
++#define CPP_MCFGTHREAD()  ((void)0)
++#define LIB_MCFGTHREAD     ""
++#else
++#define CPP_MCFGTHREAD()  (builtin_define("__USING_MCFGTHREAD__"))
++#define LIB_MCFGTHREAD     " -lmcfgthread "
++#endif
++
+ /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
+    is for compatibility with native compiler.  */
+ #define EXTRA_OS_CPP_BUILTINS()					\
+@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
+ 	  builtin_define_std ("WIN64");				\
+ 	  builtin_define ("_WIN64");				\
+ 	}							\
++	CPP_MCFGTHREAD();	\
+     }								\
+   while (0)
+ 
+@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
+ 		 "%{mwindows:-lgdi32 -lcomdlg32} " \
+      "%{fvtable-verify=preinit:-lvtv -lpsapi; \
+         fvtable-verify=std:-lvtv -lpsapi} " \
+-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
++                 LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ 
+ /* Weak symbols do not get resolved if using a Windows dll import lib.
+    Make the unwind registration references strong undefs.  */
+diff --git a/gcc/configure b/gcc/configure
+index 6121e163259..52f0e00efe6 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11693,7 +11693,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index b066cc609e1..4ecdba88de7 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1612,7 +1612,7 @@ case ${enable_threads} in
+     target_thread_file='single'
+     ;;
+   aix | dce | lynx | mipssde | posix | rtems | \
+-  single | tpf | vxworks | win32)
++  single | tpf | vxworks | win32 | mcf)
+     target_thread_file=${enable_threads}
+     ;;
+   *)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index ea8c34f8c71..23134ad7363 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -145,7 +145,7 @@ case "${target}" in
+   *-*-mingw*)
+ 	# OS support for atomic primitives.
+         case ${target_thread_file} in
+-          win32)
++          win32 | mcf)
+             config_path="${config_path} mingw"
+             ;;
+           posix)
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 11b4acaff55..9fbd38650bd 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -737,6 +737,9 @@ i[34567]86-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+@@ -761,6 +764,9 @@ x86_64-*-mingw*)
+ 	  posix)
+ 	    tmake_file="i386/t-mingw-pthread $tmake_file"
+ 	    ;;
++	  mcf)
++	    tmake_file="i386/t-mingw-mcfgthread $tmake_file"
++	    ;;
+ 	esac
+ 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
+ 	if test x$ac_cv_sjlj_exceptions = xyes; then
+diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
+new file mode 100644
+index 00000000000..5ea2908361f
+--- /dev/null
++++ b/libgcc/config/i386/gthr-mcf.h
+@@ -0,0 +1 @@
++#include <mcfgthread/gthread.h>
+diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
+new file mode 100644
+index 00000000000..4b9b10e32d6
+--- /dev/null
++++ b/libgcc/config/i386/t-mingw-mcfgthread
+@@ -0,0 +1,2 @@
++SHLIB_PTHREAD_CFLAG =
++SHLIB_PTHREAD_LDFLAG = -lmcfgthread
+diff --git a/libgcc/configure b/libgcc/configure
+index b2f3f870844..eff889dc3b3 100644
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -5451,6 +5451,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
+index ba094be6f15..979a5ab9ace 100755
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15187,6 +15187,7 @@ case $target_thread_file in
+     tpf)	thread_header=config/s390/gthr-tpf.h ;;
+     vxworks)	thread_header=config/gthr-vxworks.h ;;
+     win32)	thread_header=config/i386/gthr-win32.h ;;
++    mcf)	thread_header=config/i386/gthr-mcf.h ;;
+ esac
+ 
+ 
+diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
+index de920d714c6..665fb74bd6b 100644
+--- a/libstdc++-v3/libsupc++/atexit_thread.cc
++++ b/libstdc++-v3/libsupc++/atexit_thread.cc
+@@ -25,6 +25,22 @@
+ #include <cstdlib>
+ #include <new>
+ #include "bits/gthr.h"
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++extern "C" int
++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
++				 void *obj, void *dso_handle)
++  _GLIBCXX_NOTHROW
++{
++  return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
++  (void)dso_handle;
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
+ }
+ 
+ #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
++
++#endif // __USING_MCFGTHREAD__
+diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
+index 3a2ec3ad0d6..8b4cc96199b 100644
+--- a/libstdc++-v3/libsupc++/guard.cc
++++ b/libstdc++-v3/libsupc++/guard.cc
+@@ -28,6 +28,27 @@
+ #include <cxxabi.h>
+ #include <exception>
+ #include <new>
++
++#ifdef __USING_MCFGTHREAD__
++
++#include <mcfgthread/gthread.h>
++
++namespace __cxxabiv1 {
++
++extern "C" int __cxa_guard_acquire(__guard *g){
++	return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
++}
++extern "C" void __cxa_guard_abort(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
++}
++extern "C" void __cxa_guard_release(__guard *g) throw() {
++	::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
++}
++
++}
++
++#else // __USING_MCFGTHREAD__
++
+ #include <ext/atomicity.h>
+ #include <ext/concurrence.h>
+ #include <bits/atomic_lockfree_defines.h>
+@@ -425,3 +446,5 @@ namespace __cxxabiv1
+ #endif
+   }
+ }
++
++#endif
+diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
+index 8238817c2e9..0c6a1f85f6f 100644
+--- a/libstdc++-v3/src/c++11/thread.cc
++++ b/libstdc++-v3/src/c++11/thread.cc
+@@ -55,6 +55,15 @@ static inline int get_nprocs()
+ #elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)
+ # include <unistd.h>
+ # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
++#elif defined(_WIN32)
++# include <windows.h>
++static inline int get_nprocs()
++{
++  SYSTEM_INFO sysinfo;
++  GetSystemInfo(&sysinfo);
++  return (int)sysinfo.dwNumberOfProcessors;
++}
++# define _GLIBCXX_NPROCS get_nprocs()
+ #else
+ # define _GLIBCXX_NPROCS 0
+ #endif
+-- 
+2.17.0
+
diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix
index c64a9dcc3f57f..7827cb9850532 100644
--- a/pkgs/development/compilers/gcc/9/default.nix
+++ b/pkgs/development/compilers/gcc/9/default.nix
@@ -8,7 +8,12 @@
 , profiledCompiler ? false
 , langJit ? false
 , staticCompiler ? false
-, enableShared ? true
+, # N.B. the defult is intentionally not from an `isStatic`. See
+  # https://gcc.gnu.org/install/configure.html - this is about target
+  # platform libraries not host platform ones unlike normal. But since
+  # we can't rebuild those without also rebuilding the compiler itself,
+  # we opt to always build everything unlike our usual policy.
+  enableShared ? true
 , enableLTO ? true
 , texinfo ? null
 , perl ? null # optional, for texi2pod (then pod2man)
@@ -74,10 +79,9 @@ let majorVersion = "9";
       ++ optional langD ../libphobos.patch
       ++ optional langFortran ../gfortran-driving.patch
       ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
-      ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
-        url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
-        sha256 = "1in5kvcknlpi9z1vvjw6jfmwy8k12zvbqlqfnq84qpm99r0rh00a";
-      });
+
+      # Obtain latest patch with ../update-mcfgthread-patches.sh
+      ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch;
 
     /* Cross-gcc settings (build == host != target) */
     crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
diff --git a/pkgs/development/compilers/gcc/common/mfcgthreads-patches-repo.nix b/pkgs/development/compilers/gcc/common/mfcgthreads-patches-repo.nix
deleted file mode 100644
index f8822c6dba0e1..0000000000000
--- a/pkgs/development/compilers/gcc/common/mfcgthreads-patches-repo.nix
+++ /dev/null
@@ -1 +0,0 @@
-"740f233da00c4fb5bcc225b2e29768824bcecc58"
diff --git a/pkgs/development/compilers/gcc/update-mcfgthread-patches.sh b/pkgs/development/compilers/gcc/update-mcfgthread-patches.sh
new file mode 100755
index 0000000000000..c4fd79b26c342
--- /dev/null
+++ b/pkgs/development/compilers/gcc/update-mcfgthread-patches.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash -p curl
+
+# We use this script to download local copies instead of using
+# fetchpatch because lmhouse/MINGW-packages-dev is constantly rebased
+# against msys2/MINGW-packages-dev and won't have stable commit hashes.
+
+name=Added-mcf-thread-model-support-from-mcfgthread.patch
+source=https://raw.githubusercontent.com/lhmouse/MINGW-packages-dev/master/mingw-w64-gcc-git
+dest=$(dirname "$0")
+
+for majorVersion in 6 7 8 9 10; do
+    curl "$source/9000-gcc-$majorVersion-branch-$name" \
+         > "$dest/$majorVersion/$name"
+done
diff --git a/pkgs/development/compilers/go/2-dev.nix b/pkgs/development/compilers/go/2-dev.nix
index 44ee67ca8f6ab..9af08dde19e8c 100644
--- a/pkgs/development/compilers/go/2-dev.nix
+++ b/pkgs/development/compilers/go/2-dev.nix
@@ -35,8 +35,8 @@ let
 in
 
 stdenv.mkDerivation rec {
-  pname = "go";
-  version = "2";
+  pname = "go2-unstable";
+  version = "2020-12-08";
 
   src = fetchgit {
     url = https://go.googlesource.com/go;
diff --git a/pkgs/development/compilers/idris2/default.nix b/pkgs/development/compilers/idris2/default.nix
index 5bde4bbb720fb..275c294446213 100644
--- a/pkgs/development/compilers/idris2/default.nix
+++ b/pkgs/development/compilers/idris2/default.nix
@@ -5,13 +5,13 @@
 # Uses scheme to bootstrap the build of idris2
 stdenv.mkDerivation rec {
   pname = "idris2";
-  version = "0.2.1";
+  version = "0.2.2";
 
   src = fetchFromGitHub {
     owner = "idris-lang";
     repo = "Idris2";
     rev = "v${version}";
-    sha256 = "044slgl2pwvj939kz3z92n6l182plc5fzng1n4z4k6bg11msqq14";
+    sha256 = "18m483vccijfh9z6x4zgi37fql3q765x3ypkwixv3rwq9nxnd6hm";
   };
 
   strictDeps = true;
diff --git a/pkgs/development/compilers/llvm/10/libc++/default.nix b/pkgs/development/compilers/llvm/10/libc++/default.nix
index 95711903932e8..3511783be896e 100644
--- a/pkgs/development/compilers/llvm/10/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/10/libc++/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++";
diff --git a/pkgs/development/compilers/llvm/10/libc++abi.nix b/pkgs/development/compilers/llvm/10/libc++abi.nix
index 00371b862adb6..7335d06e4fe39 100644
--- a/pkgs/development/compilers/llvm/10/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/10/libc++abi.nix
@@ -1,5 +1,6 @@
 { stdenv, cmake, fetch, libcxx, libunwind, llvm, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
diff --git a/pkgs/development/compilers/llvm/10/libunwind.nix b/pkgs/development/compilers/llvm/10/libunwind.nix
index b13bacb363801..75e42260b7fa5 100644
--- a/pkgs/development/compilers/llvm/10/libunwind.nix
+++ b/pkgs/development/compilers/llvm/10/libunwind.nix
@@ -1,4 +1,6 @@
-{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
+{ stdenv, version, fetch, cmake, fetchpatch
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "libunwind";
diff --git a/pkgs/development/compilers/llvm/11/libc++/default.nix b/pkgs/development/compilers/llvm/11/libc++/default.nix
index 1ce879cccb67a..5c3ec87617c91 100644
--- a/pkgs/development/compilers/llvm/11/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/11/libc++/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++";
diff --git a/pkgs/development/compilers/llvm/11/libc++abi.nix b/pkgs/development/compilers/llvm/11/libc++abi.nix
index edf83197d2ca2..d173b1735cbe4 100644
--- a/pkgs/development/compilers/llvm/11/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/11/libc++abi.nix
@@ -1,5 +1,6 @@
 { stdenv, cmake, fetch, libcxx, libunwind, llvm, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
diff --git a/pkgs/development/compilers/llvm/11/libunwind.nix b/pkgs/development/compilers/llvm/11/libunwind.nix
index 5a4492e803f6c..b22da214417f4 100644
--- a/pkgs/development/compilers/llvm/11/libunwind.nix
+++ b/pkgs/development/compilers/llvm/11/libunwind.nix
@@ -1,4 +1,6 @@
-{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
+{ stdenv, version, fetch, cmake, fetchpatch
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "libunwind";
diff --git a/pkgs/development/compilers/llvm/7/libc++/default.nix b/pkgs/development/compilers/llvm/7/libc++/default.nix
index 76baadf1c6e97..ed4192a232e3a 100644
--- a/pkgs/development/compilers/llvm/7/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/7/libc++/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
-, enableShared ? ! stdenv.hostPlatform.isMusl }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++";
diff --git a/pkgs/development/compilers/llvm/7/libc++abi.nix b/pkgs/development/compilers/llvm/7/libc++abi.nix
index 7f2ec528f3c1b..4c46aeaa19108 100644
--- a/pkgs/development/compilers/llvm/7/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/7/libc++abi.nix
@@ -1,7 +1,8 @@
 { stdenv, cmake, fetch, libcxx, llvm, version
 , standalone ? false
   # on musl the shared objects don't build
-, enableShared ? ! stdenv.hostPlatform.isMusl }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
diff --git a/pkgs/development/compilers/llvm/8/libc++/default.nix b/pkgs/development/compilers/llvm/8/libc++/default.nix
index 01e0d8e008cb8..2ed54a22069b9 100644
--- a/pkgs/development/compilers/llvm/8/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/8/libc++/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++";
diff --git a/pkgs/development/compilers/llvm/8/libc++abi.nix b/pkgs/development/compilers/llvm/8/libc++abi.nix
index 590872aaab649..50a38dfa967ba 100644
--- a/pkgs/development/compilers/llvm/8/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/8/libc++abi.nix
@@ -1,5 +1,6 @@
 { stdenv, cmake, fetch, libcxx, libunwind, llvm, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
diff --git a/pkgs/development/compilers/llvm/8/libunwind.nix b/pkgs/development/compilers/llvm/8/libunwind.nix
index 646cd3c3ca4a7..3295d3922034d 100644
--- a/pkgs/development/compilers/llvm/8/libunwind.nix
+++ b/pkgs/development/compilers/llvm/8/libunwind.nix
@@ -1,4 +1,6 @@
-{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
+{ stdenv, version, fetch, cmake, fetchpatch
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libunwind";
diff --git a/pkgs/development/compilers/llvm/9/libc++/default.nix b/pkgs/development/compilers/llvm/9/libc++/default.nix
index c9f0e6254ab46..f5c3d21e7f1a3 100644
--- a/pkgs/development/compilers/llvm/9/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/9/libc++/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetch, cmake, python3, libcxxabi, fixDarwinDylibNames, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++";
diff --git a/pkgs/development/compilers/llvm/9/libc++abi.nix b/pkgs/development/compilers/llvm/9/libc++abi.nix
index 5b63560282c04..13f033091be2d 100644
--- a/pkgs/development/compilers/llvm/9/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/9/libc++abi.nix
@@ -1,5 +1,6 @@
 { stdenv, cmake, fetch, libcxx, libunwind, llvm, version
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation {
   pname = "libc++abi";
diff --git a/pkgs/development/compilers/llvm/9/libunwind.nix b/pkgs/development/compilers/llvm/9/libunwind.nix
index 883c36baf0627..98df98838f132 100644
--- a/pkgs/development/compilers/llvm/9/libunwind.nix
+++ b/pkgs/development/compilers/llvm/9/libunwind.nix
@@ -1,4 +1,6 @@
-{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
+{ stdenv, version, fetch, cmake, fetchpatch
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "libunwind";
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index e09f83a056c43..05740979b8ac1 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -1547,4 +1547,9 @@ self: super: {
   # https://github.com/Gabriel439/Haskell-Nix-Derivation-Library/pull/10
   nix-derivation = doJailbreak super.nix-derivation;
 
+  # Break out of overspecified constraint on QuickCheck.
+  # Fixed by https://github.com/haskell-servant/servant/commit/08579ca0039410e04d6c36c975ddc20165819db6
+  servant-client      = doJailbreak super.servant-client;
+  servant-client-core = doJailbreak super.servant-client-core;
+
 } // import ./configuration-tensorflow.nix {inherit pkgs haskellLib;} self super
diff --git a/pkgs/development/libraries/accounts-qt/default.nix b/pkgs/development/libraries/accounts-qt/default.nix
index b60d8d07385cc..4e2e33b852e82 100644
--- a/pkgs/development/libraries/accounts-qt/default.nix
+++ b/pkgs/development/libraries/accounts-qt/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitLab, doxygen, glib, libaccounts-glib, pkgconfig, qtbase, qmake }:
+{ mkDerivation, lib, fetchFromGitLab, doxygen, glib, libaccounts-glib, pkgconfig, qmake }:
 
-stdenv.mkDerivation rec {
+mkDerivation rec {
   pname = "accounts-qt";
   version = "1.16";
 
@@ -11,17 +11,13 @@ stdenv.mkDerivation rec {
     owner = "accounts-sso";
   };
 
-  buildInputs = [ glib libaccounts-glib qtbase ];
+  propagatedBuildInputs = [ glib libaccounts-glib ];
   nativeBuildInputs = [ doxygen pkgconfig qmake ];
 
-  preConfigure = ''
-    qmakeFlags="$qmakeFlags LIBDIR=$out/lib CMAKE_CONFIG_PATH=$out/lib/cmake"
-  '';
-
   # Hack to avoid TMPDIR in RPATHs.
   preFixup = ''rm -rf "$(pwd)" '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Qt library for accessing the online accounts database";
     homepage = "https://gitlab.com/accounts-sso";
     license = licenses.lgpl21;
diff --git a/pkgs/development/libraries/arrow-cpp/default.nix b/pkgs/development/libraries/arrow-cpp/default.nix
index 1d9a528b4c6a4..a9e738f7e9a1b 100644
--- a/pkgs/development/libraries/arrow-cpp/default.nix
+++ b/pkgs/development/libraries/arrow-cpp/default.nix
@@ -1,7 +1,8 @@
 { stdenv, lib, fetchurl, fetchFromGitHub, fetchpatch, fixDarwinDylibNames
 , autoconf, boost, brotli, cmake, flatbuffers, gflags, glog, gtest, lz4
 , perl, python3, rapidjson, snappy, thrift, utf8proc, which, zlib, zstd
-, enableShared ? true }:
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 let
   arrow-testing = fetchFromGitHub {
diff --git a/pkgs/development/libraries/audiofile/default.nix b/pkgs/development/libraries/audiofile/default.nix
index 9f945b15dec2a..86531a6ad25d8 100644
--- a/pkgs/development/libraries/audiofile/default.nix
+++ b/pkgs/development/libraries/audiofile/default.nix
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
   #
   # There might be a more sensible way to do this with autotools, but I am not
   # smart enough to discover it.
-  preBuild = lib.optionalString stdenv.targetPlatform.isStatic ''
+  preBuild = lib.optionalString stdenv.hostPlatform.isStatic ''
     make -C libaudiofile $makeFlags
     sed -i "s/dependency_libs=.*/dependency_libs=' -lstdc++'/" libaudiofile/libaudiofile.la
   '';
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index b3950cb0d3012..ec3a28e2b1a38 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -8,7 +8,7 @@
 , enableDebug ? false
 , enableSingleThreaded ? false
 , enableMultiThreaded ? true
-, enableShared ? !(stdenv.hostPlatform.libc == "msvcrt") # problems for now
+, enableShared ? !(with stdenv.hostPlatform; isStatic || libc == "msvcrt") # problems for now
 , enableStatic ? !enableShared
 , enablePython ? false
 , enableNumpy ? false
diff --git a/pkgs/development/libraries/fmt/default.nix b/pkgs/development/libraries/fmt/default.nix
index 8eac88df796c6..2f490891433b9 100644
--- a/pkgs/development/libraries/fmt/default.nix
+++ b/pkgs/development/libraries/fmt/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchFromGitHub, fetchpatch, cmake, enableShared ? true }:
+{ stdenv, fetchFromGitHub, fetchpatch, cmake
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 let
   generic = { version, sha256, patches ? [ ] }:
diff --git a/pkgs/development/libraries/gflags/default.nix b/pkgs/development/libraries/gflags/default.nix
index 733a572ac61b0..51c13f974336b 100644
--- a/pkgs/development/libraries/gflags/default.nix
+++ b/pkgs/development/libraries/gflags/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchFromGitHub, cmake, enableShared ? true}:
+{ stdenv, fetchFromGitHub, cmake
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "gflags";
diff --git a/pkgs/development/libraries/gmp/5.1.x.nix b/pkgs/development/libraries/gmp/5.1.x.nix
index a027d58de3964..a514934e96458 100644
--- a/pkgs/development/libraries/gmp/5.1.x.nix
+++ b/pkgs/development/libraries/gmp/5.1.x.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchurl, m4, cxx ? true, withStatic ? true }:
+{ stdenv, fetchurl, m4
+, cxx ? true
+, withStatic ? stdenv.hostPlatform.isStatic
+}:
 
 let inherit (stdenv.lib) optional; in
 
diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix
index 10e63f733a2d1..522976d3ab2c6 100644
--- a/pkgs/development/libraries/gmp/6.x.nix
+++ b/pkgs/development/libraries/gmp/6.x.nix
@@ -1,7 +1,8 @@
 { stdenv, fetchurl, m4
 , cxx ? !stdenv.hostPlatform.useAndroidPrebuilt && !stdenv.hostPlatform.isWasm
 , buildPackages
-, withStatic ? false }:
+, withStatic ? stdenv.hostPlatform.isStatic
+}:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
diff --git a/pkgs/development/libraries/libbacktrace/default.nix b/pkgs/development/libraries/libbacktrace/default.nix
index 0032941f870e1..ea7f4eb9fa8a8 100644
--- a/pkgs/development/libraries/libbacktrace/default.nix
+++ b/pkgs/development/libraries/libbacktrace/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, callPackage, fetchFromGitHub, enableStatic ? false, enableShared ? true }:
+{ stdenv, callPackage, fetchFromGitHub
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 let
   yesno = b: if b then "yes" else "no";
 in stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/libexecinfo/default.nix b/pkgs/development/libraries/libexecinfo/default.nix
index 9c649c223c122..feee754590b67 100644
--- a/pkgs/development/libraries/libexecinfo/default.nix
+++ b/pkgs/development/libraries/libexecinfo/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchurl, fetchpatch, enableStatic ? true, enableShared ? true }:
+{ stdenv, fetchurl, fetchpatch
+, enableStatic ? true
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "libexecinfo";
diff --git a/pkgs/development/libraries/libiberty/default.nix b/pkgs/development/libraries/libiberty/default.nix
index ff26c1029ef52..c7babb3038d3c 100644
--- a/pkgs/development/libraries/libiberty/default.nix
+++ b/pkgs/development/libraries/libiberty/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, buildPackages, staticBuild ? false }:
+{ stdenv, buildPackages
+, staticBuild ? stdenv.hostPlatform.isStatic
+}:
 
 let inherit (buildPackages.buildPackages) gcc; in
 
diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix
index 87969d6b2c7bf..35d01cd3e820d 100644
--- a/pkgs/development/libraries/libiconv/default.nix
+++ b/pkgs/development/libraries/libiconv/default.nix
@@ -1,6 +1,6 @@
 { fetchurl, stdenv, lib
-, enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
-, enableShared ? !stdenv.hostPlatform.useAndroidPrebuilt
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 # assert !stdenv.hostPlatform.isLinux || stdenv.hostPlatform != stdenv.buildPlatform; # TODO: improve on cross
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index 6aa4e049e4c32..c4e81d034fc9d 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchFromGitHub, cmake, nasm, enableStatic ? false, enableShared ? true }:
+{ stdenv, fetchFromGitHub, cmake, nasm
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
 
diff --git a/pkgs/development/libraries/libpfm/default.nix b/pkgs/development/libraries/libpfm/default.nix
index b29aeb2930a77..63b826258ae6e 100644
--- a/pkgs/development/libraries/libpfm/default.nix
+++ b/pkgs/development/libraries/libpfm/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchurl, enableShared ? true }:
+{ stdenv, fetchurl
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation (rec {
   version = "4.11.0";
diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix
index 5949288768889..10ad110d24e51 100644
--- a/pkgs/development/libraries/libxml2/default.nix
+++ b/pkgs/development/libraries/libxml2/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchurl, fetchpatch
 , zlib, xz, libintl, python, gettext, ncurses, findXMLCatalogs
-, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
+, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform
 , icuSupport ? false, icu ? null
 , enableShared ? stdenv.hostPlatform.libc != "msvcrt"
 , enableStatic ? !enableShared,
diff --git a/pkgs/development/libraries/libxsmm/default.nix b/pkgs/development/libraries/libxsmm/default.nix
index 30f060405f089..5e4a56a6d4de3 100644
--- a/pkgs/development/libraries/libxsmm/default.nix
+++ b/pkgs/development/libraries/libxsmm/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, coreutils, gfortran, gnused
 , python3, util-linux, which
 
-, enableStatic ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
 }:
 
 let
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 0e75bfbd5b518..17a924e6e74c5 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -3,7 +3,7 @@
 , abiVersion ? "6"
 , mouseSupport ? false
 , unicode ? true
-, enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
+, enableStatic ? stdenv.hostPlatform.isStatic
 , enableShared ? !enableStatic
 , withCxx ? !stdenv.hostPlatform.useAndroidPrebuilt
 
diff --git a/pkgs/development/libraries/neon/default.nix b/pkgs/development/libraries/neon/default.nix
index c9a2621f44003..e9ce6ee18b4fa 100644
--- a/pkgs/development/libraries/neon/default.nix
+++ b/pkgs/development/libraries/neon/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl, libxml2, pkgconfig, perl
 , compressionSupport ? true, zlib ? null
 , sslSupport ? true, openssl ? null
-, static ? false
-, shared ? true
+, static ? stdenv.hostPlatform.isStatic
+, shared ? !stdenv.hostPlatform.isStatic
 }:
 
 assert compressionSupport -> zlib != null;
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index fcd12ba587d04..2570c7cdb25a6 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -2,7 +2,7 @@
 , withCryptodev ? false, cryptodev
 , enableSSL2 ? false
 , enableSSL3 ? false
-, static ? false
+, static ? stdenv.hostPlatform.isStatic
 }:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix
index f17a114216bd4..12a731385ffe7 100644
--- a/pkgs/development/libraries/rocksdb/default.nix
+++ b/pkgs/development/libraries/rocksdb/default.nix
@@ -10,7 +10,7 @@
 , zstd
 , enableJemalloc ? false, jemalloc
 , enableLite ? false
-, enableShared ? true
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix
index 1887d53e30663..b631def3bb2e9 100644
--- a/pkgs/development/libraries/science/math/mkl/default.nix
+++ b/pkgs/development/libraries/science/math/mkl/default.nix
@@ -1,11 +1,12 @@
-{ callPackage
+{ stdenv
+, callPackage
 , stdenvNoCC
 , fetchurl
 , rpmextract
 , undmg
 , darwin
 , validatePkgConfig
-, enableStatic ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
 }:
 
 /*
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index d670a40f321d3..8df04e80ceb38 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -15,8 +15,8 @@
 # Select a specific optimization target (other than the default)
 # See https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt
 , target ? null
-, enableStatic ? false
-, enableShared ? true
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 with stdenv.lib;
diff --git a/pkgs/development/libraries/signond/default.nix b/pkgs/development/libraries/signond/default.nix
new file mode 100644
index 0000000000000..7e986ed2635e0
--- /dev/null
+++ b/pkgs/development/libraries/signond/default.nix
@@ -0,0 +1,30 @@
+{ mkDerivation, lib, fetchFromGitLab, qmake, doxygen }:
+
+mkDerivation rec {
+  pname = "signond";
+  version = "8.60";
+
+  src = fetchFromGitLab {
+    owner = "accounts-sso";
+    repo = pname;
+    rev = "VERSION_${version}";
+    sha256 = "pFpeJ13ut5EoP37W33WrYL2LzkX/k7ZKJcRpPO5l8i4=";
+  };
+
+  nativeBuildInputs = [
+    qmake
+    doxygen
+  ];
+
+  preConfigure = ''
+    substituteInPlace src/signond/signond.pro \
+      --replace "/etc" "@out@/etc"
+  '';
+
+  meta = with lib; {
+    homepage = "https://gitlab.com/accounts-sso/signond";
+    description = "Signon Daemon for Qt";
+    maintainers = with maintainers; [ freezeboy  ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/thrift/default.nix b/pkgs/development/libraries/thrift/default.nix
index 1879cac96c188..f5c8f64633bbd 100644
--- a/pkgs/development/libraries/thrift/default.nix
+++ b/pkgs/development/libraries/thrift/default.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchurl, fetchpatch, boost, zlib, libevent, openssl, python, cmake, pkgconfig
-, bison, flex, twisted, static ? false }:
+, bison, flex, twisted
+, static ? stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   pname = "thrift";
diff --git a/pkgs/development/libraries/umockdev/default.nix b/pkgs/development/libraries/umockdev/default.nix
index cd8c90f319d79..5050650635f42 100644
--- a/pkgs/development/libraries/umockdev/default.nix
+++ b/pkgs/development/libraries/umockdev/default.nix
@@ -17,23 +17,19 @@
 
 stdenv.mkDerivation rec {
   pname = "umockdev";
-  version = "0.15.2";
+  version = "0.15.4";
 
   outputs = [ "bin" "out" "dev" "doc" ];
 
   src = fetchurl {
     url = "https://github.com/martinpitt/umockdev/releases/download/${version}/${pname}-${version}.tar.xz";
-    sha256 = "19f21qb9ckwvlm7yzpnc0vcp092qbkms2yrafc26b9a63v4imj52";
+    sha256 = "09k8jwvsphd97hcagf0zaf0hwzlzq2r8jfgbmvj55k7ylrg8hjxg";
   };
 
   mesonFlags = [
     "-Dgtk_doc=true"
   ];
 
-  preCheck = ''
-    patchShebangs tests/test-static-code
-  '';
-
   buildInputs = [ glib systemd libgudev ];
 
   nativeBuildInputs = [
@@ -50,10 +46,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  # Test fail with libusb 1.0.24
-  # https://github.com/NixOS/nixpkgs/issues/107420
-  # https://github.com/martinpitt/umockdev/issues/115
-  doCheck = false;
+  doCheck = true;
 
   postInstall = ''
     mkdir -p $doc/share/doc/umockdev/
diff --git a/pkgs/development/libraries/umockdev/disable-failed-test.patch b/pkgs/development/libraries/umockdev/disable-failed-test.patch
deleted file mode 100644
index 69e74dd38b8d2..0000000000000
--- a/pkgs/development/libraries/umockdev/disable-failed-test.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/tests/test-umockdev-vala.vala b/tests/test-umockdev-vala.vala
-index 8b104b2..d9889b8 100644
---- a/tests/test-umockdev-vala.vala
-+++ b/tests/test-umockdev-vala.vala
-@@ -668,7 +668,7 @@ main (string[] args)
- 
-   /* tests for mocking ioctls */
-   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_static", t_usbfs_ioctl_static);
--  Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree", t_usbfs_ioctl_tree);
-+  /* Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree", t_usbfs_ioctl_tree); */
-   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_with_default_device", t_usbfs_ioctl_tree_with_default_device);
-   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_override_default_device", t_usbfs_ioctl_tree_override_default_device);
-   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_xz", t_usbfs_ioctl_tree_xz);
diff --git a/pkgs/development/libraries/umockdev/fix-test-paths.patch b/pkgs/development/libraries/umockdev/fix-test-paths.patch
deleted file mode 100644
index 53015d662684a..0000000000000
--- a/pkgs/development/libraries/umockdev/fix-test-paths.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ru3 umockdev-0.13.1/tests/test-umockdev.c umockdev-0.13.1-new/tests/test-umockdev.c
---- umockdev-0.13.1/tests/test-umockdev.c	2019-08-18 20:39:39.708262517 +0300
-+++ umockdev-0.13.1-new/tests/test-umockdev.c	2019-08-18 21:04:27.688761503 +0300
-@@ -1084,7 +1084,7 @@
- 
-     /* sys/ in other dir should not be trapped */
-     errno = 0;
--    dirfd = open("/run", O_RDONLY | O_DIRECTORY);
-+    dirfd = open("/tmp", O_RDONLY | O_DIRECTORY);
-     g_assert_cmpint(openat(dirfd, "sys", O_RDONLY), <, 0);
-     g_assert_cmpint(errno, ==, ENOENT);
-     g_assert_cmpint(openat64(dirfd, "sys", O_RDONLY), <, 0);
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index 98746968146d9..b780fcda3930a 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -1,17 +1,19 @@
 { stdenv
 , fetchurl
-# Note: If `{ static = false; shared = false; }`, upstream's default is used
-#       (which is building both static and shared as of zlib 1.2.11).
-, shared ? true
+, shared ? !stdenv.hostPlatform.isStatic
 , static ? true
 # If true, a separate .static ouput is created and the .a is moved there.
 # In this case `pkg-config` auto detection does not currently work if the
 # .static output is given as `buildInputs` to another package (#66461), because
 # the `.pc` file lists only the main output's lib dir.
 # If false, and if `{ static = true; }`, the .a stays in the main output.
-, splitStaticOutput ? static
+, splitStaticOutput ? shared && static
 }:
 
+# Without either the build will actually still succeed because the build
+# system makes an arbitrary choice, but we shouldn't be so indecisive.
+assert shared || static;
+
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
 # cgit) that are needed here should be included directly in Nixpkgs as
diff --git a/pkgs/development/ocaml-modules/csv/default.nix b/pkgs/development/ocaml-modules/csv/default.nix
index 2d017b9a916bc..60496ad28dac2 100644
--- a/pkgs/development/ocaml-modules/csv/default.nix
+++ b/pkgs/development/ocaml-modules/csv/default.nix
@@ -4,6 +4,8 @@ buildDunePackage rec {
   pname = "csv";
 	version = "2.4";
 
+	useDune2 = true;
+
 	src = fetchurl {
 		url = "https://github.com/Chris00/ocaml-${pname}/releases/download/${version}/csv-${version}.tbz";
 		sha256 = "13m9n8mdss6jfbiw7d5bybxn4n85vmg4zw7dc968qrgjfy0w9zhk";
diff --git a/pkgs/development/ocaml-modules/csv/lwt.nix b/pkgs/development/ocaml-modules/csv/lwt.nix
index 2fa9296d7e445..b0f771209aa61 100644
--- a/pkgs/development/ocaml-modules/csv/lwt.nix
+++ b/pkgs/development/ocaml-modules/csv/lwt.nix
@@ -6,7 +6,7 @@ else
 
 buildDunePackage {
   pname = "csv-lwt";
-  inherit (csv) src version meta;
+  inherit (csv) src version useDune2 meta;
 
   propagatedBuildInputs = [ csv ocaml_lwt ];
 
diff --git a/pkgs/development/ocaml-modules/ppx_blob/default.nix b/pkgs/development/ocaml-modules/ppx_blob/default.nix
index a64ff9cbef2dd..ac96e56d04e63 100644
--- a/pkgs/development/ocaml-modules/ppx_blob/default.nix
+++ b/pkgs/development/ocaml-modules/ppx_blob/default.nix
@@ -1,18 +1,18 @@
-{ lib, fetchurl, buildDunePackage, ocaml, alcotest, ocaml-migrate-parsetree }:
+{ lib, fetchurl, buildDunePackage, ocaml, alcotest, ppxlib }:
 
 buildDunePackage rec {
   pname = "ppx_blob";
-  version = "0.7.1";
+  version = "0.7.2";
 
   useDune2 = true;
 
   src = fetchurl {
     url = "https://github.com/johnwhitington/${pname}/releases/download/${version}/ppx_blob-${version}.tbz";
-    sha256 = "0m616ri6kmawflphiwm6j4djds27v0fjvi8xjz1fq5ydc1sq8d0l";
+    sha256 = "00haz1cmplk3j9ysh6j656zrldy60585fmlndmfhpd5332mxrfdw";
   };
 
   checkInputs = [ alcotest ];
-  buildInputs = [ ocaml-migrate-parsetree ];
+  propagatedBuildInputs = [ ppxlib ];
   doCheck = lib.versionAtLeast ocaml.version "4.05";
 
   meta = with lib; {
diff --git a/pkgs/development/python-modules/adblock/default.nix b/pkgs/development/python-modules/adblock/default.nix
new file mode 100644
index 0000000000000..de6d72a61ecfa
--- /dev/null
+++ b/pkgs/development/python-modules/adblock/default.nix
@@ -0,0 +1,63 @@
+{ stdenv
+, lib
+, rustPlatform
+, fetchFromGitHub
+, pipInstallHook
+, pythonImportsCheckHook
+, maturin
+, pkg-config
+, openssl
+, publicsuffix-list
+, isPy27
+, CoreFoundation
+, Security
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "adblock";
+  version = "0.4.0";
+  disabled = isPy27;
+
+  # Pypi only has binary releases
+  src = fetchFromGitHub {
+    owner = "ArniDagur";
+    repo = "python-adblock";
+    rev = version;
+    sha256 = "10d6ks2fyzbizq3kb69q478idj0h86k6ygjb6wl3zq3mf65ma4zg";
+  };
+  format = "pyproject";
+
+  cargoSha256 = "0di05j942rrm2crpdpp9czhh65fmidyrvdp2n3pipgnagy7nchc0";
+
+  nativeBuildInputs = [ pipInstallHook maturin pkg-config pythonImportsCheckHook ];
+
+  buildInputs = [ openssl ]
+    ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ];
+
+  PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat";
+
+  buildPhase = ''
+    runHook preBuild
+    maturin build --release --manylinux off --strip
+    runHook postBuild
+  '';
+
+  # There are no rust tests
+  doCheck = false;
+  pythonImportsCheck = [ "adblock" ];
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm644 -t dist target/wheels/*.whl
+    pipInstallPhase
+    runHook postInstall
+  '';
+
+  passthru.meta = with lib; {
+    description = "Python wrapper for Brave's adblocking library, which is written in Rust";
+    homepage = "https://github.com/ArniDagur/python-adblock/";
+    maintainers = with maintainers; [ petabyteboy ];
+    license = with licenses; [ asl20 mit ];
+    platforms = with platforms; [ all ];
+  };
+}
diff --git a/pkgs/development/python-modules/asyncwhois/default.nix b/pkgs/development/python-modules/asyncwhois/default.nix
new file mode 100644
index 0000000000000..ba8f212d2f341
--- /dev/null
+++ b/pkgs/development/python-modules/asyncwhois/default.nix
@@ -0,0 +1,36 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, pythonOlder
+, aiodns
+, tldextract
+, pytestCheckHook
+}:
+
+buildPythonPackage rec {
+  pname = "asyncwhois";
+  version = "0.2.0";
+  disabled = pythonOlder "3.6";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "0rdmg59jzzfz59b3ckg5187lc0wk9r0pzp9x09nq3xs21mcwqjxz";
+  };
+
+  propagatedBuildInputs = [
+    aiodns
+    tldextract
+  ];
+
+  # tests are only present at GitHub but not the released source tarballs
+  # https://github.com/pogzyb/asyncwhois/issues/10
+  doCheck = false;
+  pythonImportsCheck = [ "asyncwhois" ];
+
+  meta = with lib; {
+    description = "Python module for retrieving WHOIS information";
+    homepage = "https://github.com/pogzyb/asyncwhois";
+    license = with licenses; [ asl20 ];
+    maintainers = with maintainers; [ fab ];
+  };
+}
diff --git a/pkgs/development/python-modules/autobahn/default.nix b/pkgs/development/python-modules/autobahn/default.nix
index 909fb65996ba5..12aa86774d88e 100644
--- a/pkgs/development/python-modules/autobahn/default.nix
+++ b/pkgs/development/python-modules/autobahn/default.nix
@@ -4,11 +4,11 @@
 }:
 buildPythonPackage rec {
   pname = "autobahn";
-  version = "20.7.1";
+  version = "20.12.3";
 
   src = fetchPypi {
     inherit pname version;
-    sha256 = "86bbce30cdd407137c57670993a8f9bfdfe3f8e994b889181d85e844d5aa8dfb";
+    sha256 = "15b8zm7jalwisfwc08szxy3bh2bnn0hd41dbsnswi0lqwbh962j1";
   };
 
   propagatedBuildInputs = [ six txaio twisted zope_interface cffi cryptography pynacl ] ++
diff --git a/pkgs/development/python-modules/impacket/default.nix b/pkgs/development/python-modules/impacket/default.nix
index dee40a6dbba2a..15d148f168f15 100644
--- a/pkgs/development/python-modules/impacket/default.nix
+++ b/pkgs/development/python-modules/impacket/default.nix
@@ -1,4 +1,4 @@
-{ lib, buildPythonPackage, fetchPypi, isPy3k }:
+{ lib, buildPythonPackage, fetchPypi, flask, ldapdomaindump, pycryptodomex, pyasn1, pyopenssl }:
 
 buildPythonPackage rec {
   pname = "impacket";
@@ -9,16 +9,18 @@ buildPythonPackage rec {
     sha256 = "4bf7e7b595356585599b4b2773b8a463d7b9765c97012dcd5a44eb6d547f6a1d";
   };
 
-  disabled = isPy3k;
+  propagatedBuildInputs = [ flask ldapdomaindump pycryptodomex pyasn1 pyopenssl ];
 
-  # no tests
+  # fail with:
+  # RecursionError: maximum recursion depth exceeded
   doCheck = false;
+  pythonImportsCheck = [ "impacket" ];
 
   meta = with lib; {
     description = "Network protocols Constructors and Dissectors";
     homepage = "https://github.com/CoreSecurity/impacket";
     # Modified Apache Software License, Version 1.1
     license = licenses.free;
-    maintainers = with maintainers; [ peterhoeg ];
+    maintainers = with maintainers; [ SuperSandro2000 ];
   };
 }
diff --git a/pkgs/development/python-modules/ldapdomaindump/default.nix b/pkgs/development/python-modules/ldapdomaindump/default.nix
new file mode 100644
index 0000000000000..3e1358cd8f223
--- /dev/null
+++ b/pkgs/development/python-modules/ldapdomaindump/default.nix
@@ -0,0 +1,24 @@
+{ lib, buildPythonPackage, fetchPypi, dnspython, future, ldap3 }:
+
+buildPythonPackage rec {
+  pname = "ldapdomaindump";
+  version = "0.9.3";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "10cis8cllpa9qi5qil9k7521ag3921mxwg2wj9nyn0lk41rkjagc";
+  };
+
+  propagatedBuildInputs = [ dnspython future ldap3 ];
+
+  # requires ldap server
+  doCheck = false;
+  pythonImportsCheck = [ "ldapdomaindump" ];
+
+  meta = with lib; {
+    description = "Active Directory information dumper via LDAP";
+    homepage = "https://github.com/dirkjanm/ldapdomaindump/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ SuperSandro2000 ];
+  };
+}
diff --git a/pkgs/development/python-modules/micawber/default.nix b/pkgs/development/python-modules/micawber/default.nix
index 5129fe253c71c..0240a21aca33f 100644
--- a/pkgs/development/python-modules/micawber/default.nix
+++ b/pkgs/development/python-modules/micawber/default.nix
@@ -2,11 +2,11 @@
 
 buildPythonPackage rec {
   pname = "micawber";
-  version = "0.5.1";
+  version = "0.5.2";
 
   src = fetchPypi {
     inherit pname version;
-    sha256 = "5e1e6fbab5bfc1edc6d575b900707c24a3484c51cf2e01f059a7e070724a3633";
+    sha256 = "ac2d737d8ff27ed01ea3825ed8806970e8137d7b342cef37b39b6dd17e6eb3a4";
   };
 
   propagatedBuildInputs = [ beautifulsoup4 ];
diff --git a/pkgs/development/python-modules/mocket/default.nix b/pkgs/development/python-modules/mocket/default.nix
index 60b32665ca84c..f7e97bb955c38 100644
--- a/pkgs/development/python-modules/mocket/default.nix
+++ b/pkgs/development/python-modules/mocket/default.nix
@@ -9,11 +9,11 @@
 
 buildPythonPackage rec {
   pname = "mocket";
-  version = "3.9.4";
+  version = "3.9.35";
 
   src = fetchPypi {
     inherit pname version;
-    sha256 = "0b3nx8qa66isfl7rm3ljgxflr087qwabnf0a2xa1l5s28rikfj04";
+    sha256 = "d822a2adfd8e028a2856785fbfe78e7dd8c7a3b623516298aef6d42a4c9149d1";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/python-modules/nocaselist/default.nix b/pkgs/development/python-modules/nocaselist/default.nix
index 055b55da45d3d..e7947eba92aeb 100644
--- a/pkgs/development/python-modules/nocaselist/default.nix
+++ b/pkgs/development/python-modules/nocaselist/default.nix
@@ -4,11 +4,11 @@
 
 buildPythonPackage rec {
   pname = "nocaselist";
-  version = "1.0.3";
+  version = "1.0.4";
 
   src = fetchPypi {
     inherit pname version;
-    sha256 = "fm3st9hVY7kESRPJCH70tpG8PaTXrR2IlozepAlVMyY=";
+    sha256 = "73a9c0659e7135c66e46a6ab06e2cb637ce9248d73c690ebd31afb72a4e03ac0";
   };
 
   checkInputs = [
diff --git a/pkgs/development/python-modules/patator/default.nix b/pkgs/development/python-modules/patator/default.nix
index 81d9e50b28ff0..b876e913e3cf0 100644
--- a/pkgs/development/python-modules/patator/default.nix
+++ b/pkgs/development/python-modules/patator/default.nix
@@ -1,22 +1,28 @@
-{ stdenv, buildPythonPackage, isPy3k, fetchPypi,
-  paramiko, pycurl, ajpy, pyopenssl, cx_oracle, mysqlclient,
-  psycopg2, pycrypto, dnspython, ipy, pysnmp, pyasn1 }:
+{ stdenv, buildPythonPackage, isPy27, fetchPypi
+, paramiko, pycurl, ajpy, impacket, pyopenssl, cx_oracle, mysqlclient
+, psycopg2, pycrypto, dnspython, ipy, pysnmp, pyasn1, pysqlcipher3 }:
 
 
 buildPythonPackage rec {
   pname = "patator";
   version = "0.9";
-  disabled = !(isPy3k);
+  disabled = isPy27;
 
   src = fetchPypi {
     inherit pname version;
     sha256 = "68cb24bdc3042ee0d47a288b19a8b99a6c54bdbd4ddf0c5817d9b9ac0a0d8a15";
   };
 
+  postPatch = ''
+    substituteInPlace requirements.txt \
+      --replace psycopg2-binary psycopg2
+  '';
+
   propagatedBuildInputs = [
     paramiko
     pycurl
     ajpy
+    impacket
     pyopenssl
     cx_oracle
     mysqlclient
@@ -26,15 +32,16 @@ buildPythonPackage rec {
     ipy
     pysnmp
     pyasn1
+    pysqlcipher3
   ];
 
-  # No tests provided by patator
+  # tests require docker-compose and vagrant
   doCheck = false;
 
   meta = with stdenv.lib; {
     description = "multi-purpose brute-forcer";
     homepage = "https://github.com/lanjelot/patator";
     license = licenses.gpl2;
-    maintainers = with maintainers; [ y0no ];
+    maintainers = with maintainers; [ y0no SuperSandro2000 ];
   };
 }
diff --git a/pkgs/development/python-modules/pydicom/default.nix b/pkgs/development/python-modules/pydicom/default.nix
index 24186c09dcd51..450a6a3c049ed 100644
--- a/pkgs/development/python-modules/pydicom/default.nix
+++ b/pkgs/development/python-modules/pydicom/default.nix
@@ -1,29 +1,55 @@
 { stdenv
 , buildPythonPackage
-, fetchPypi
+, fetchFromGitHub
 , isPy27
-, pytest
 , pytestrunner
 , pytestCheckHook
 , numpy
 , pillow
 }:
 
-buildPythonPackage rec {
-  version = "2.1.1";
+let
   pname = "pydicom";
-  disabled = isPy27;
+  version = "2.1.2";
+
+  src = fetchFromGitHub {
+    owner = "${pname}";
+    repo = "${pname}";
+    rev = "v${version}";
+    sha256 = "sha256-iExy+mUs1uqs/u9N6btlqyP6/TvoPVsuOuzs56zZAS8=";
+  };
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "72a11086f6a277c1529a552583fde73e03256a912173f15e9bc256e5b28f28f1";
+  # Pydicom needs pydicom-data to run some tests. If these files are downloaded
+  # before the package creation, it'll try to download during the checkPhase.
+  test_data = fetchFromGitHub {
+    owner = "${pname}";
+    repo = "${pname}-data";
+    rev = "bbb723879690bb77e077a6d57657930998e92bd5";
+    sha256 = "sha256-dCI1temvpNWiWJYVfQZKy/YJ4ad5B0e9hEKHJnEeqzk=";
   };
 
+in
+buildPythonPackage {
+  inherit pname version src;
+  disabled = isPy27;
+
   propagatedBuildInputs = [ numpy pillow ];
 
-  checkInputs = [ pytest pytestrunner pytestCheckHook ];
-  disabledTests = [ "test_invalid_bit_depth_raises" ];
-  # harmless failure; see https://github.com/pydicom/pydicom/issues/1119
+  checkInputs = [ pytestrunner pytestCheckHook ];
+
+  # Setting $HOME to prevent pytest to try to create a folder inside
+  # /homeless-shelter which is read-only.
+  # Linking pydicom-data dicom files to $HOME/.pydicom/data
+  preCheck = ''
+    export HOME=$TMP/test-home
+    mkdir -p $HOME/.pydicom/
+    ln -s ${test_data}/data_store/data $HOME/.pydicom/data
+  '';
+
+  # This test try to remove a dicom inside $HOME/.pydicom/data/ and download it again.
+  disabledTests = [
+    "test_fetch_data_files"
+  ];
 
   meta = with stdenv.lib; {
     homepage = "https://pydicom.github.io";
diff --git a/pkgs/development/python-modules/pysqlcipher3/default.nix b/pkgs/development/python-modules/pysqlcipher3/default.nix
new file mode 100644
index 0000000000000..ab3f949cf1edb
--- /dev/null
+++ b/pkgs/development/python-modules/pysqlcipher3/default.nix
@@ -0,0 +1,24 @@
+{ lib, buildPythonPackage, fetchPypi, pythonAtLeast, sqlcipher }:
+
+buildPythonPackage rec {
+  pname = "pysqlcipher3";
+  version = "1.0.3";
+
+  disabled = pythonAtLeast "3.9";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "0c54m18h52llwkfc9zaag3qkmfzzp5a1w9jzsm5hd2nfdsxmnkk9";
+  };
+
+  buildInputs = [ sqlcipher ];
+
+  pythonImportsCheck = [ "pysqlcipher3" ];
+
+  meta = with lib; {
+    description = "Python 3 bindings for SQLCipher";
+    homepage = "https://github.com/rigglemania/pysqlcipher3/";
+    license = licenses.zlib;
+    maintainers = with maintainers; [ SuperSandro2000 ];
+  };
+}
diff --git a/pkgs/development/python-modules/python-whois/default.nix b/pkgs/development/python-modules/python-whois/default.nix
new file mode 100644
index 0000000000000..c4d163100ca98
--- /dev/null
+++ b/pkgs/development/python-modules/python-whois/default.nix
@@ -0,0 +1,41 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, future
+, nose
+, pytestCheckHook
+, simplejson
+}:
+
+buildPythonPackage rec {
+  pname = "python-whois";
+  version = "0.7.3";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "05jaxbnlw5wck0hl124py364jqrx7a4mmv0hy3d2jzvmp0012sk5";
+  };
+
+  propagatedBuildInputs = [ future ];
+
+  checkInputs = [
+    nose
+    pytestCheckHook
+    simplejson
+  ];
+
+  # Exclude tests that require network access
+  disabledTests = [
+    "test_dk_parse"
+    "test_ipv4"
+    "test_ipv6"
+  ];
+  pythonImportsCheck = [ "whois" ];
+
+  meta = with lib; {
+    description = "Python module to produce parsed WHOIS data";
+    homepage = "https://github.com/richardpenman/whois";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ fab ];
+  };
+}
diff --git a/pkgs/development/python-modules/pytun/default.nix b/pkgs/development/python-modules/pytun/default.nix
index fed78cea96fe5..b37dbf26fb7b1 100644
--- a/pkgs/development/python-modules/pytun/default.nix
+++ b/pkgs/development/python-modules/pytun/default.nix
@@ -5,15 +5,16 @@
 
 buildPythonPackage rec {
   pname = "pytun";
-  version = "2.2.1";
+  version = "2.3.0";
 
   src = fetchFromGitHub {
     rev = "v${version}";
     owner = "montag451";
     repo = "pytun";
-    sha256 = "1bxk0z0v8m0b01xg94f039j3bsclkshb7girvjqfzk5whbd2nryh";
+    sha256 = "1cqq8aci38058fjh4a0xf21wac177fw576p2yjl2b8jd9rnsqbl5";
   };
 
+  # Test directory contains examples, not tests.
   doCheck = false;
 
   meta = with stdenv.lib; {
@@ -23,5 +24,4 @@ buildPythonPackage rec {
     maintainers = with maintainers; [ montag451 ];
     platforms = platforms.linux;
   };
-
 }
diff --git a/pkgs/development/python-modules/quandl/default.nix b/pkgs/development/python-modules/quandl/default.nix
index 33fc54241d9a4..56b80a4676b86 100644
--- a/pkgs/development/python-modules/quandl/default.nix
+++ b/pkgs/development/python-modules/quandl/default.nix
@@ -1,11 +1,10 @@
-{
-  lib, fetchPypi, buildPythonPackage, isPy3k, pythonOlder,
-  # runtime dependencies
-  pandas, numpy, requests, inflection, python-dateutil, six, more-itertools, importlib-metadata,
-  # test suite dependencies
-  nose, unittest2, flake8, httpretty, mock, jsondate, parameterized, faker, factory_boy,
-  # additional runtime dependencies are required on Python 2.x
-  pyOpenSSL ? null, ndg-httpsclient ? null, pyasn1 ? null
+{ lib, fetchPypi, buildPythonPackage, isPy3k, pythonOlder
+# runtime dependencies
+, pandas, numpy, requests, inflection, python-dateutil, six, more-itertools, importlib-metadata
+# test suite dependencies
+, nose, unittest2, flake8, httpretty, mock, jsondate, parameterized, faker, factory_boy
+# additional runtime dependencies are required on Python 2.x
+, pyopenssl, ndg-httpsclient, pyasn1
 }:
 
 buildPythonPackage rec {
@@ -19,8 +18,6 @@ buildPythonPackage rec {
     sha256 = "0zpw0nwqr4g56l9z4my0fahfgpcmfx74acbmv6nfx1dmq5ggraf3";
   };
 
-  doCheck = true;
-
   checkInputs = [
     nose
     unittest2
@@ -42,7 +39,7 @@ buildPythonPackage rec {
     six
     more-itertools
   ] ++ lib.optionals (!isPy3k) [
-    pyOpenSSL
+    pyopenssl
     ndg-httpsclient
     pyasn1
   ] ++ lib.optionals (pythonOlder "3.8") [
diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix
index c1eaa1fd75437..06f7a9f1011b3 100644
--- a/pkgs/development/python-modules/weasyprint/default.nix
+++ b/pkgs/development/python-modules/weasyprint/default.nix
@@ -23,7 +23,7 @@
 
 buildPythonPackage rec {
   pname = "weasyprint";
-  version = "50";
+  version = "52";
   disabled = !isPy3k;
 
   # excluded test needs the Ahem font
@@ -59,7 +59,7 @@ buildPythonPackage rec {
   src = fetchPypi {
     inherit version;
     pname = "WeasyPrint";
-    sha256 = "0invs96zvmcr6wh5klj52jrcnr9qg150v9wpmbhcsf3vv1d1hbcw";
+    sha256 = "0rwf43111ws74m8b1alkkxzz57g0np3vmd8as74adwnxslfcg4gs";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/python-modules/weasyprint/library-paths.patch b/pkgs/development/python-modules/weasyprint/library-paths.patch
index eabbdbdcd6ee9..c6eb87c94585d 100644
--- a/pkgs/development/python-modules/weasyprint/library-paths.patch
+++ b/pkgs/development/python-modules/weasyprint/library-paths.patch
@@ -1,8 +1,8 @@
 diff --git a/weasyprint/fonts.py b/weasyprint/fonts.py
-index 377716c1..2016e01c 100644
+index 79e3b5b..4438eb4 100644
 --- a/weasyprint/fonts.py
 +++ b/weasyprint/fonts.py
-@@ -48,11 +48,8 @@ else:
+@@ -45,11 +45,8 @@ else:
      # with OSError: dlopen() failed to load a library: cairo / cairo-2
      # So let's hope we find the same file as cairo already did ;)
      # Same applies to pangocairo requiring pangoft2
@@ -10,26 +10,26 @@ index 377716c1..2016e01c 100644
 -                        'libfontconfig-1.dll',
 -                        'libfontconfig.so.1', 'libfontconfig-1.dylib')
 -    pangoft2 = dlopen(ffi, 'pangoft2-1.0', 'libpangoft2-1.0-0',
--                      'libpangoft2-1.0.so', 'libpangoft2-1.0.dylib')
+-                      'libpangoft2-1.0.so.0', 'libpangoft2-1.0.dylib')
 +    fontconfig = dlopen(ffi, '@fontconfig@')
 +    pangoft2 = dlopen(ffi, '@pangoft2@')
  
      ffi.cdef('''
          // FontConfig
 diff --git a/weasyprint/text.py b/weasyprint/text.py
-index 035074e9..08e40395 100644
+index 1dc5e4d..b070bad 100644
 --- a/weasyprint/text.py
 +++ b/weasyprint/text.py
-@@ -243,12 +243,9 @@ def dlopen(ffi, *names):
+@@ -255,12 +255,9 @@ def dlopen(ffi, *names):
      return ffi.dlopen(names[0])  # pragma: no cover
  
  
--gobject = dlopen(ffi, 'gobject-2.0', 'libgobject-2.0-0', 'libgobject-2.0.so',
+-gobject = dlopen(ffi, 'gobject-2.0', 'libgobject-2.0-0', 'libgobject-2.0.so.0',
 -                 'libgobject-2.0.dylib')
--pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so',
+-pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so.0',
 -               'libpango-1.0.dylib')
 -pangocairo = dlopen(ffi, 'pangocairo-1.0', 'libpangocairo-1.0-0',
--                    'libpangocairo-1.0.so', 'libpangocairo-1.0.dylib')
+-                    'libpangocairo-1.0.so.0', 'libpangocairo-1.0.dylib')
 +gobject = dlopen(ffi, '@gobject@')
 +pango = dlopen(ffi, '@pango@')
 +pangocairo = dlopen(ffi, '@pangocairo@')
diff --git a/pkgs/development/python-modules/whois/default.nix b/pkgs/development/python-modules/whois/default.nix
new file mode 100644
index 0000000000000..759bc0cd8ee91
--- /dev/null
+++ b/pkgs/development/python-modules/whois/default.nix
@@ -0,0 +1,32 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, pytestCheckHook
+, inetutils
+}:
+
+buildPythonPackage rec {
+  pname = "whois";
+  version = "0.9.7";
+
+  src = fetchFromGitHub {
+    owner = "DannyCork";
+    repo = "python-whois";
+    rev = version;
+    sha256 = "1rbc4xif4dn455vc8dhxdvwszrb0nik5q9fy12db6mxfx6zikb7z";
+  };
+
+  # whois is needed
+  propagatedBuildInputs = [ inetutils ];
+
+  # tests require network access
+  doCheck = false;
+  pythonImportsCheck = [ "whois" ];
+
+  meta = with lib; {
+    description = "Python module/library for retrieving WHOIS information";
+    homepage = "https://github.com/DannyCork/python-whois/";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ fab ];
+  };
+}
diff --git a/pkgs/development/tools/analysis/lcov/default.nix b/pkgs/development/tools/analysis/lcov/default.nix
index 6ac778180b77b..c6faeaa72f238 100644
--- a/pkgs/development/tools/analysis/lcov/default.nix
+++ b/pkgs/development/tools/analysis/lcov/default.nix
@@ -1,24 +1,16 @@
- {stdenv, fetchurl, fetchpatch, perl, perlPackages, makeWrapper }:
+ {stdenv, fetchFromGitHub, perl, perlPackages, makeWrapper }:
 
 stdenv.mkDerivation rec {
-  name = "lcov-1.14";
-
-  src = fetchurl {
-    url = "mirror://sourceforge/ltp/${name}.tar.gz";
-    sha256 = "06h7ixyznf6vz1qvksjgy5f3q2nw9akf6zx59npf0h3l32cmd68l";
+  pname = "lcov";
+  version = "1.15";
+
+  src = fetchFromGitHub {
+    owner = "linux-test-project";
+    repo = "lcov";
+    rev = "v${version}";
+    sha256 = "1kvc7fkp45w48f0bxwbxvxkicnjrrydki0hllg294n1wrp80zzyk";
   };
 
-  patches =
-    [ (fetchpatch {
-        url = "https://github.com/linux-test-project/lcov/commit/ebfeb3e179e450c69c3532f98cd5ea1fbf6ccba7.patch";
-        sha256 = "0dalkqbjb6a4vp1lcsxd39dpn5fzdf7ihsjbiviq285s15nxdj1j";
-      })
-      (fetchpatch {
-        url = "https://github.com/linux-test-project/lcov/commit/75fbae1cfc5027f818a0bb865bf6f96fab3202da.patch";
-        sha256 = "0v1hn0511dxqbf50ppwasc6vmg0m6rns7ydbdy2rdbn0j7gxw30x";
-      })
-    ];
-
   buildInputs = [ perl makeWrapper ];
 
   preBuild = ''
@@ -28,6 +20,7 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     wrapProgram $out/bin/lcov --set PERL5LIB ${perlPackages.makeFullPerlPath [ perlPackages.PerlIOgzip perlPackages.JSON ]}
+    wrapProgram $out/bin/genpng --set PERL5LIB ${perlPackages.makeFullPerlPath [ perlPackages.GD ]}
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index fb3293aee4418..5592685214606 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -2,7 +2,7 @@
 , fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext
 # Enabling all targets increases output size to a multiple.
 , withAllTargets ? false, libbfd, libopcodes
-, enableShared ? true
+, enableShared ? !stdenv.hostPlatform.isStatic
 , noSysDirs
 , gold ? !stdenv.buildPlatform.isDarwin || stdenv.hostPlatform == stdenv.targetPlatform
 , bison ? null
diff --git a/pkgs/development/tools/parsing/tree-sitter/default.nix b/pkgs/development/tools/parsing/tree-sitter/default.nix
index 72150b5ac0bf7..78fb3b7f937f2 100644
--- a/pkgs/development/tools/parsing/tree-sitter/default.nix
+++ b/pkgs/development/tools/parsing/tree-sitter/default.nix
@@ -5,8 +5,8 @@
 , Security
 , callPackage
 
-, enableShared ? true
-, enableStatic ? false
+, enableShared ? !stdenv.hostPlatform.isStatic
+, enableStatic ? stdenv.hostPlatform.isStatic
 , webUISupport ? false
 }:
 
diff --git a/pkgs/development/tools/sourcetrail/python.nix b/pkgs/development/tools/sourcetrail/python.nix
index 113abb77d61b6..8ec9c9a2297f9 100644
--- a/pkgs/development/tools/sourcetrail/python.nix
+++ b/pkgs/development/tools/sourcetrail/python.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     owner = "CoatiSoftware";
     repo = pname;
     rev = version;
-    sha256 = "05hlpd3am029pv1wi6mys3q0ggp64axmg8bdf1fabl9cl9jffscq";
+    sha256 = "01jaigxigq6dvfwq018gn9qw7i6p4jm0y71lqzschfv9vwf6ga45";
     fetchSubmodules = true;
   };
 
@@ -64,5 +64,7 @@ stdenv.mkDerivation rec {
     description = "Python indexer for Sourcetrail";
     homepage = "https://github.com/CoatiSoftware/SourcetrailPythonIndexer";
     license = licenses.gpl3;
+    broken = stdenv.isDarwin;
+    # https://github.com/NixOS/nixpkgs/pull/107533#issuecomment-751063675
   };
 }
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
index 0532c88b66b9f..72ef086f59909 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
@@ -1,6 +1,6 @@
 { stdenv, appleDerivation, lib
-, enableStatic ? stdenv.targetPlatform.isiOS
-, enableShared ? !stdenv.targetPlatform.isiOS
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 appleDerivation {
diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix
index 026ea6fd2e8e4..99909e6262efa 100644
--- a/pkgs/os-specific/linux/busybox/default.nix
+++ b/pkgs/os-specific/linux/busybox/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, buildPackages, fetchurl, fetchFromGitLab
-, enableStatic ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
 , enableMinimal ? false
 # Allow forcing musl without switching stdenv itself, e.g. for our bootstrapping:
 # nix build -f pkgs/top-level/release.nix stdenvBootstrapTools.x86_64-linux.dist
diff --git a/pkgs/os-specific/linux/fatrace/default.nix b/pkgs/os-specific/linux/fatrace/default.nix
index 69d1afad8a685..62767f6827854 100644
--- a/pkgs/os-specific/linux/fatrace/default.nix
+++ b/pkgs/os-specific/linux/fatrace/default.nix
@@ -1,12 +1,18 @@
-{ stdenv, fetchurl, python3, which }:
+{ stdenv
+, fetchFromGitHub
+, python3
+, which
+}:
 
 stdenv.mkDerivation rec {
   pname = "fatrace";
-  version = "0.13";
+  version = "0.16.1";
 
-  src = fetchurl {
-    url = "https://launchpad.net/fatrace/trunk/${version}/+download/${pname}-${version}.tar.bz2";
-    sha256 = "0hrh45bpzncw0jkxw3x2smh748r65k2yxvfai466043bi5q0d2vx";
+  src = fetchFromGitHub {
+    owner = "martinpitt";
+    repo = pname;
+    rev = version;
+    sha256 = "0lxfqin2bw9235yah8ylb4p8lc3755050sjg30z3gy7bab0lfyg9";
   };
 
   buildInputs = [ python3 which ];
@@ -14,16 +20,13 @@ stdenv.mkDerivation rec {
   postPatch = ''
     substituteInPlace power-usage-report \
       --replace "'which'" "'${which}/bin/which'"
-
-    # Avoid a glibc >= 2.25 deprecation warning that gets fatal via -Werror.
-    sed 1i'#include <sys/sysmacros.h>' -i fatrace.c
   '';
 
   makeFlags = [ "PREFIX=$(out)" ];
 
   meta = with stdenv.lib; {
     description = "Report system-wide file access events";
-    homepage = "https://launchpad.net/fatrace/";
+    homepage = "https://github.com/martinpitt/fatrace";
     license = licenses.gpl3Plus;
     longDescription = ''
       fatrace reports file access events from all running processes.
diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix
index 713c4b5d13d96..ab78a3a33d8fa 100644
--- a/pkgs/os-specific/linux/libcap/default.nix
+++ b/pkgs/os-specific/linux/libcap/default.nix
@@ -1,5 +1,9 @@
-{ stdenv, lib, buildPackages, fetchurl, attr, perl, pam
-, static ? stdenv.targetPlatform.isStatic }:
+{ stdenv, lib, buildPackages, fetchurl, attr, perl
+, usePam ? !isStatic, pam ? null
+, isStatic ? stdenv.hostPlatform.isStatic
+}:
+
+assert usePam -> pam != null;
 
 stdenv.mkDerivation rec {
   pname = "libcap";
@@ -10,21 +14,21 @@ stdenv.mkDerivation rec {
     sha256 = "1qf80lifygbnxwvqjf8jz5j24n6fqqx4ixnkbf76xs2vrmcq664j";
   };
 
-  patches = lib.optional static ./no-shared-lib.patch;
+  patches = lib.optional isStatic ./no-shared-lib.patch;
 
   outputs = [ "out" "dev" "lib" "man" "doc" ]
-    ++ lib.optional (pam != null) "pam";
+    ++ lib.optional usePam "pam";
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [ perl ];
 
-  buildInputs = [ pam ];
+  buildInputs = lib.optional usePam pam;
 
   propagatedBuildInputs = [ attr ];
 
   makeFlags = [
     "lib=lib"
-    "PAM_CAP=${if pam == null then "no" else "yes"}"
+    "PAM_CAP=${if usePam then "yes" else "no"}"
     "BUILD_CC=$(CC_FOR_BUILD)"
     "CC:=$(CC)"
   ];
@@ -48,10 +52,10 @@ stdenv.mkDerivation rec {
   installFlags = [ "RAISE_SETFCAP=no" ];
 
   postInstall = ''
-    ${lib.optionalString (!static) ''rm "$lib"/lib/*.a''}
+    ${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
     mkdir -p "$doc/share/doc/${pname}-${version}"
     cp License "$doc/share/doc/${pname}-${version}/"
-  '' + stdenv.lib.optionalString (pam != null) ''
+  '' + stdenv.lib.optionalString usePam ''
     mkdir -p "$pam/lib/security"
     mv "$lib"/lib/security "$pam/lib"
   '';
diff --git a/pkgs/os-specific/linux/rdma-core/default.nix b/pkgs/os-specific/linux/rdma-core/default.nix
index 042a54ff15753..339a6cbbf2909 100644
--- a/pkgs/os-specific/linux/rdma-core/default.nix
+++ b/pkgs/os-specific/linux/rdma-core/default.nix
@@ -4,7 +4,7 @@
 } :
 
 let
-  version = "31.2";
+  version = "33.0";
 
 in stdenv.mkDerivation {
   pname = "rdma-core";
@@ -14,7 +14,7 @@ in stdenv.mkDerivation {
     owner = "linux-rdma";
     repo = "rdma-core";
     rev = "v${version}";
-    sha256 = "0njfn8ziip57a2s435d4s0p3yylb85y7hdgbq660vwpsia9fb4sq";
+    sha256 = "04q4z95nxxxjc674qnbwn19bv18nl3x7xwp6aql17h1cw3gdmhw4";
   };
 
   nativeBuildInputs = [ cmake pkgconfig pandoc docutils makeWrapper ];
diff --git a/pkgs/servers/gobetween/default.nix b/pkgs/servers/gobetween/default.nix
index 9f28a89f51eba..f429f9ad385b6 100644
--- a/pkgs/servers/gobetween/default.nix
+++ b/pkgs/servers/gobetween/default.nix
@@ -1,4 +1,6 @@
-{ buildGoModule, fetchFromGitHub, lib, enableStatic ? false }:
+{ stdenv, buildGoModule, fetchFromGitHub, lib
+, enableStatic ? stdenv.hostPlatform.isStatic
+}:
 
 buildGoModule rec {
   pname = "gobetween";
diff --git a/pkgs/servers/home-assistant/component-packages.nix b/pkgs/servers/home-assistant/component-packages.nix
index 9b3b6e662b911..855e52cdbd849 100644
--- a/pkgs/servers/home-assistant/component-packages.nix
+++ b/pkgs/servers/home-assistant/component-packages.nix
@@ -925,7 +925,7 @@
     "webostv" = ps: with ps; [ ]; # missing inputs: aiopylgtv
     "websocket_api" = ps: with ps; [ aiohttp-cors ];
     "wemo" = ps: with ps; [ ]; # missing inputs: pywemo
-    "whois" = ps: with ps; [ ]; # missing inputs: python-whois
+    "whois" = ps: with ps; [ python-whois ];
     "wiffi" = ps: with ps; [ ]; # missing inputs: wiffi
     "wilight" = ps: with ps; [ ]; # missing inputs: pywilight
     "wink" = ps: with ps; [ aiohttp-cors ]; # missing inputs: pubnubsub-handler python-wink
diff --git a/pkgs/servers/metabase/default.nix b/pkgs/servers/metabase/default.nix
index 8e16a59452eb7..25702df7b3806 100644
--- a/pkgs/servers/metabase/default.nix
+++ b/pkgs/servers/metabase/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   pname = "metabase";
-  version = "0.37.3";
+  version = "0.37.4";
 
   src = fetchurl {
-    url = "http://downloads.metabase.com/v${version}/metabase.jar";
-    sha256 = "0ka0k0ficvw8srpaa89l0jdzpl4n7hjwz18r41kw1hzk2ydd3p5c";
+    url = "https://downloads.metabase.com/v${version}/metabase.jar";
+    sha256 = "0l781b7mc33kkp4ic57ylghxw671b4ldv6b0wgphmrrwmp0cd3vm";
   };
 
   nativeBuildInputs = [ makeWrapper ];
diff --git a/pkgs/shells/zsh/default.nix b/pkgs/shells/zsh/default.nix
index 56c76289e857f..eab6d88a0b7d1 100644
--- a/pkgs/shells/zsh/default.nix
+++ b/pkgs/shells/zsh/default.nix
@@ -26,6 +26,7 @@ stdenv.mkDerivation {
     "--with-tcsetpgrp"
     "--enable-pcre"
     "--enable-zprofile=${placeholder "out"}/etc/zprofile"
+    "--disable-site-fndir"
   ];
 
   # the zsh/zpty module is not available on hydra
diff --git a/pkgs/tools/audio/beets/badfiles-plugin-nix-paths.patch b/pkgs/tools/audio/beets/badfiles-plugin-nix-paths.patch
new file mode 100644
index 0000000000000..6956183344c47
--- /dev/null
+++ b/pkgs/tools/audio/beets/badfiles-plugin-nix-paths.patch
@@ -0,0 +1,21 @@
+diff --git i/beetsplug/badfiles.py w/beetsplug/badfiles.py
+index 36b45de3..5208b696 100644
+--- i/beetsplug/badfiles.py
++++ w/beetsplug/badfiles.py
+@@ -71,14 +71,14 @@ class BadFiles(BeetsPlugin):
+         return status, errors, [line for line in output.split("\n") if line]
+ 
+     def check_mp3val(self, path):
+-        status, errors, output = self.run_command(["mp3val", path])
++        status, errors, output = self.run_command(["@mp3val@/bin/mp3val", path])
+         if status == 0:
+             output = [line for line in output if line.startswith("WARNING:")]
+             errors = len(output)
+         return status, errors, output
+ 
+     def check_flac(self, path):
+-        return self.run_command(["flac", "-wst", path])
++        return self.run_command(["@flac@/bin/flac", "-wst", path])
+ 
+     def check_custom(self, command):
+         def checker(path):
diff --git a/pkgs/tools/audio/beets/bash-completion-always-print.patch b/pkgs/tools/audio/beets/bash-completion-always-print.patch
new file mode 100644
index 0000000000000..7bc3e57117e32
--- /dev/null
+++ b/pkgs/tools/audio/beets/bash-completion-always-print.patch
@@ -0,0 +1,43 @@
+diff --git i/beets/ui/commands.py w/beets/ui/commands.py
+index 4d010f4b..0b023585 100755
+--- i/beets/ui/commands.py
++++ w/beets/ui/commands.py
+@@ -1741,20 +1741,6 @@ default_commands.append(config_cmd)
+ def print_completion(*args):
+     for line in completion_script(default_commands + plugins.commands()):
+         print_(line, end=u'')
+-    if not any(map(os.path.isfile, BASH_COMPLETION_PATHS)):
+-        log.warning(u'Warning: Unable to find the bash-completion package. '
+-                    u'Command line completion might not work.')
+-
+-BASH_COMPLETION_PATHS = map(syspath, [
+-    u'/etc/bash_completion',
+-    u'/usr/share/bash-completion/bash_completion',
+-    u'/usr/local/share/bash-completion/bash_completion',
+-    # SmartOS
+-    u'/opt/local/share/bash-completion/bash_completion',
+-    # Homebrew (before bash-completion2)
+-    u'/usr/local/etc/bash_completion',
+-])
+-
+ 
+ def completion_script(commands):
+     """Yield the full completion shell script as strings.
+diff --git i/test/test_ui.py w/test/test_ui.py
+index 5cfed1fd..9d3dc458 100644
+--- i/test/test_ui.py
++++ w/test/test_ui.py
+@@ -1230,12 +1230,7 @@ class CompletionTest(_common.TestCase, TestHelper):
+                                   stdout=subprocess.PIPE, env=env)
+ 
+         # Load bash_completion library.
+-        for path in commands.BASH_COMPLETION_PATHS:
+-            if os.path.exists(util.syspath(path)):
+-                bash_completion = path
+-                break
+-        else:
+-            self.skipTest(u'bash-completion script not found')
++        self.skipTest(u'bash-completion script not found')
+         try:
+             with open(util.syspath(bash_completion), 'rb') as f:
+                 tester.stdin.writelines(f)
diff --git a/pkgs/tools/audio/beets/compatibility-with-breaking-changes-to-the-ast-module.patch b/pkgs/tools/audio/beets/compatibility-with-breaking-changes-to-the-ast-module.patch
deleted file mode 100644
index 4865b6f623418..0000000000000
--- a/pkgs/tools/audio/beets/compatibility-with-breaking-changes-to-the-ast-module.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 771ce704ebeac4cd9bd74b3ddde9fb01f3dc7eb4 Mon Sep 17 00:00:00 2001
-From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com>
-Date: Tue, 9 Jun 2020 19:34:31 +0200
-Subject: [PATCH] compatibility with breaking changes to the ast module
-
-new in 3.10, also backported to 3.8 and 3.9: https://github.com/python/cpython/pull/20649
-In fact, our generation of some Literals has been invalid since Python
-3.4, fix that too.
----
- beets/util/functemplate.py | 29 ++++++++++++++++++++---------
- 1 file changed, 20 insertions(+), 9 deletions(-)
-
-diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py
-index af22b790..266534a9 100644
---- a/beets/util/functemplate.py
-+++ b/beets/util/functemplate.py
-@@ -73,15 +73,26 @@ def ex_literal(val):
-     """An int, float, long, bool, string, or None literal with the given
-     value.
-     """
--    if val is None:
--        return ast.Name('None', ast.Load())
--    elif isinstance(val, six.integer_types):
--        return ast.Num(val)
--    elif isinstance(val, bool):
--        return ast.Name(bytes(val), ast.Load())
--    elif isinstance(val, six.string_types):
--        return ast.Str(val)
--    raise TypeError(u'no literal for {0}'.format(type(val)))
-+    if sys.version_info[:2] < (3, 4):
-+        if val is None:
-+            return ast.Name('None', ast.Load())
-+        elif isinstance(val, six.integer_types):
-+            return ast.Num(val)
-+        elif isinstance(val, bool):
-+            return ast.Name(bytes(val), ast.Load())
-+        elif isinstance(val, six.string_types):
-+            return ast.Str(val)
-+        raise TypeError(u'no literal for {0}'.format(type(val)))
-+    elif sys.version_info[:2] < (3, 6):
-+        if val in [None, True, False]:
-+            return ast.NameConstant(val)
-+        elif isinstance(val, six.integer_types):
-+            return ast.Num(val)
-+        elif isinstance(val, six.string_types):
-+            return ast.Str(val)
-+        raise TypeError(u'no literal for {0}'.format(type(val)))
-+    else:
-+        return ast.Constant(val)
- 
- 
- def ex_varassign(name, expr):
--- 
-2.27.0
-
diff --git a/pkgs/tools/audio/beets/convert-plugin-ffmpeg-path.patch b/pkgs/tools/audio/beets/convert-plugin-ffmpeg-path.patch
new file mode 100644
index 0000000000000..bcc77179d7968
--- /dev/null
+++ b/pkgs/tools/audio/beets/convert-plugin-ffmpeg-path.patch
@@ -0,0 +1,43 @@
+diff --git i/beetsplug/convert.py w/beetsplug/convert.py
+index 70363f6e..2962aa4f 100644
+--- i/beetsplug/convert.py
++++ w/beetsplug/convert.py
+@@ -81,7 +81,7 @@ def get_format(fmt=None):
+         command = config['convert']['command'].as_str()
+     elif 'opts' in keys:
+         # Undocumented option for backwards compatibility with < 1.3.1.
+-        command = u'ffmpeg -i $source -y {0} $dest'.format(
++        command = u'@ffmpeg@/bin/ffmpeg -i $source -y {0} $dest'.format(
+             config['convert']['opts'].as_str()
+         )
+     if 'extension' in keys:
+@@ -121,22 +121,22 @@ class ConvertPlugin(BeetsPlugin):
+             u'id3v23': u'inherit',
+             u'formats': {
+                 u'aac': {
+-                    u'command': u'ffmpeg -i $source -y -vn -acodec aac '
++                    u'command': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec aac '
+                                 u'-aq 1 $dest',
+                     u'extension': u'm4a',
+                 },
+                 u'alac': {
+-                    u'command': u'ffmpeg -i $source -y -vn -acodec alac $dest',
++                    u'command': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec alac $dest',
+                     u'extension': u'm4a',
+                 },
+-                u'flac': u'ffmpeg -i $source -y -vn -acodec flac $dest',
+-                u'mp3': u'ffmpeg -i $source -y -vn -aq 2 $dest',
++                u'flac': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec flac $dest',
++                u'mp3': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -aq 2 $dest',
+                 u'opus':
+-                    u'ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest',
++                    u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest',
+                 u'ogg':
+-                    u'ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest',
++                    u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest',
+                 u'wma':
+-                    u'ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest',
++                    u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest',
+             },
+             u'max_bitrate': 500,
+             u'auto': False,
diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix
index 56551891a4a5f..f72692c845c7f 100644
--- a/pkgs/tools/audio/beets/default.nix
+++ b/pkgs/tools/audio/beets/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins
+{ stdenv, lib, fetchFromGitHub, writeScript, glibcLocales, diffPlugins, substituteAll
 , pythonPackages, imagemagick, gobject-introspection, gst_all_1
 , runtimeShell
 , fetchpatch
@@ -6,61 +6,70 @@
 # Attributes needed for tests of the external plugins
 , callPackage, beets
 
-, enableAbsubmit       ? stdenv.lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
-, enableAcousticbrainz ? true
-, enableAcoustid       ? true
-, enableBadfiles       ? true, flac ? null, mp3val ? null
-, enableConvert        ? true, ffmpeg_3 ? null
-, enableDiscogs        ? true
-, enableEmbyupdate     ? true
-, enableFetchart       ? true
-, enableGmusic         ? true
-, enableKeyfinder      ? true, keyfinder-cli ? null
-, enableKodiupdate     ? true
-, enableLastfm         ? true
-, enableLoadext        ? true
-, enableMpd            ? true
-, enablePlaylist       ? true
-, enableReplaygain     ? true, bs1770gain ? null
-, enableSonosUpdate    ? true
-, enableSubsonicupdate ? true
-, enableThumbnails     ? true
-, enableWeb            ? true
+, enableAbsubmit         ? lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
+, enableAcousticbrainz   ? true
+, enableAcoustid         ? true
+, enableBadfiles         ? true, flac ? null, mp3val ? null
+, enableBeatport         ? true
+, enableBpsync           ? true
+, enableConvert          ? true, ffmpeg ? null
+, enableDeezer           ? true
+, enableDiscogs          ? true
+, enableEmbyupdate       ? true
+, enableFetchart         ? true
+, enableGmusic           ? true
+, enableKeyfinder        ? true, keyfinder-cli ? null
+, enableKodiupdate       ? true
+, enableLastfm           ? true
+, enableLoadext          ? true
+, enableMpd              ? true
+, enablePlaylist         ? true
+, enableReplaygain       ? true
+, enableSonosUpdate      ? true
+, enableSubsonicplaylist ? true
+, enableSubsonicupdate   ? true
+, enableThumbnails       ? true
+, enableWeb              ? true
 
 # External plugins
-, enableAlternatives   ? false
-, enableCheck          ? false, liboggz ? null
-, enableCopyArtifacts  ? false
-, enableExtraFiles     ? false
+, enableAlternatives     ? false
+, enableCheck            ? false, liboggz ? null
+, enableCopyArtifacts    ? false
+, enableExtraFiles       ? false
 
 , bashInteractive, bash-completion
 }:
 
-assert enableAbsubmit    -> essentia-extractor            != null;
-assert enableAcoustid    -> pythonPackages.pyacoustid     != null;
+assert enableAbsubmit    -> essentia-extractor               != null;
+assert enableAcoustid    -> pythonPackages.pyacoustid        != null;
 assert enableBadfiles    -> flac != null && mp3val != null;
+assert enableBeatport    -> pythonPackages.requests_oauthlib != null;
+assert enableBpsync      -> enableBeatport;
 assert enableCheck       -> flac != null && mp3val != null && liboggz != null;
-assert enableConvert     -> ffmpeg_3 != null;
-assert enableDiscogs     -> pythonPackages.discogs_client != null;
-assert enableFetchart    -> pythonPackages.responses      != null;
-assert enableGmusic      -> pythonPackages.gmusicapi      != null;
-assert enableKeyfinder   -> keyfinder-cli != null;
-assert enableLastfm      -> pythonPackages.pylast         != null;
-assert enableMpd         -> pythonPackages.mpd2           != null;
-assert enableReplaygain  -> bs1770gain                    != null;
-assert enableSonosUpdate -> pythonPackages.soco           != null;
-assert enableThumbnails  -> pythonPackages.pyxdg          != null;
-assert enableWeb         -> pythonPackages.flask          != null;
-
-with stdenv.lib;
+assert enableConvert     -> ffmpeg                         != null;
+assert enableDiscogs     -> pythonPackages.discogs_client    != null;
+assert enableFetchart    -> pythonPackages.responses         != null;
+assert enableGmusic      -> pythonPackages.gmusicapi         != null;
+assert enableKeyfinder   -> keyfinder-cli                    != null;
+assert enableLastfm      -> pythonPackages.pylast            != null;
+assert enableMpd         -> pythonPackages.mpd2              != null;
+assert enableReplaygain  -> ffmpeg                         != null;
+assert enableSonosUpdate -> pythonPackages.soco              != null;
+assert enableThumbnails  -> pythonPackages.pyxdg             != null;
+assert enableWeb         -> pythonPackages.flask             != null;
+
+with lib;
 
 let
   optionalPlugins = {
     absubmit = enableAbsubmit;
     acousticbrainz = enableAcousticbrainz;
     badfiles = enableBadfiles;
+    beatport = enableBeatport;
+    bpsync = enableBpsync;
     chroma = enableAcoustid;
     convert = enableConvert;
+    deezer = enableDeezer;
     discogs = enableDiscogs;
     embyupdate = enableEmbyupdate;
     fetchart = enableFetchart;
@@ -75,18 +84,19 @@ let
     playlist = enablePlaylist;
     replaygain = enableReplaygain;
     sonosupdate = enableSonosUpdate;
+    subsonicplaylist = enableSubsonicplaylist;
     subsonicupdate = enableSubsonicupdate;
     thumbnails = enableThumbnails;
     web = enableWeb;
   };
 
   pluginsWithoutDeps = [
-    "beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
-    "export" "filefilter" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
+    "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
+    "export" "filefilter" "fish" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
     "hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs" "lyrics"
-    "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "permissions" "play"
+    "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "parentwork" "permissions" "play"
     "plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
-    "types" "zero"
+    "types" "unimported" "zero"
   ];
 
   enabledOptionalPlugins = attrNames (filterAttrs (_: id) optionalPlugins);
@@ -102,28 +112,33 @@ let
     enableAlternatives = false;
     enableCopyArtifacts = false;
     enableExtraFiles = false;
-  }).overrideAttrs (stdenv.lib.const {
+  }).overrideAttrs (const {
     doInstallCheck = false;
   });
 
   pluginArgs = externalTestArgs // { inherit pythonPackages; };
 
   plugins = {
-    alternatives = callPackage ./alternatives-plugin.nix pluginArgs;
-    check = callPackage ./check-plugin.nix pluginArgs;
-    copyartifacts = callPackage ./copyartifacts-plugin.nix pluginArgs;
-    extrafiles = callPackage ./extrafiles-plugin.nix pluginArgs;
+    alternatives = callPackage ./plugins/alternatives.nix pluginArgs;
+    check = callPackage ./plugins/check.nix pluginArgs;
+    copyartifacts = callPackage ./plugins/copyartifacts.nix pluginArgs;
+    extrafiles = callPackage ./plugins/extrafiles.nix pluginArgs;
   };
 
 in pythonPackages.buildPythonApplication rec {
   pname = "beets";
-  version = "1.4.9";
+  # While there is a stable version, 1.4.9, it is more than 1000 commits behind
+  # master and lacks many bug fixes and improvements[1]. Also important,
+  # unstable does not require bs1770gain[2].
+  # [1]: https://discourse.beets.io/t/forming-a-beets-core-team/639
+  # [2]: https://github.com/NixOS/nixpkgs/pull/90504
+  version = "unstable-2020-12-22";
 
   src = fetchFromGitHub {
     owner = "beetbox";
     repo = "beets";
-    rev = "v${version}";
-    sha256 = "1qxdqbzvz97zgykzdwn78g2xyxmg0q2jdb12dnjnrwvhmjv67vi8";
+    rev = "53dcb24d10788897f20c341774b474808ec2c0b6";
+    sha256 = "sha256-P++NA13T2TRHW3Se10np8BSe/WRBYAKRte5xKoHKW50=";
   };
 
   propagatedBuildInputs = [
@@ -137,19 +152,25 @@ in pythonPackages.buildPythonApplication rec {
     pythonPackages.unidecode
     pythonPackages.gst-python
     pythonPackages.pygobject3
+    pythonPackages.reflink
+    pythonPackages.confuse
+    pythonPackages.mediafile
     gobject-introspection
   ] ++ optional enableAbsubmit      essentia-extractor
     ++ optional enableAcoustid      pythonPackages.pyacoustid
+    ++ optional enableBeatport      pythonPackages.requests_oauthlib
     ++ optional (enableFetchart
+              || enableDeezer
               || enableEmbyupdate
               || enableKodiupdate
               || enableLoadext
               || enablePlaylist
+              || enableSubsonicplaylist
               || enableSubsonicupdate
               || enableAcousticbrainz)
                                     pythonPackages.requests
     ++ optional enableCheck         plugins.check
-    ++ optional enableConvert       ffmpeg_3
+    ++ optional enableConvert       ffmpeg
     ++ optional enableDiscogs       pythonPackages.discogs_client
     ++ optional enableGmusic        pythonPackages.gmusicapi
     ++ optional enableKeyfinder     keyfinder-cli
@@ -187,41 +208,35 @@ in pythonPackages.buildPythonApplication rec {
   ];
 
   patches = [
-    ./replaygain-default-bs1770gain.patch
+    # Bash completion fix for Nix
+    ./bash-completion-always-print.patch
+    # From some reason upstream assumes the program 'keyfinder-cli' is located
+    # in the path as `KeyFinder`
     ./keyfinder-default-bin.patch
-    ./mutagen-1.43.patch
-    (fetchpatch {
-      # Fixes failing testcases around the werkzeug component; can dropped after 1.4.9
-      url = "https://github.com/beetbox/beets/commit/d43d54e21cde97f57f19486925ab56b419254cc8.patch";
-      sha256 = "13n2gzmcgfi0m2ycl2r1hpczgksplnkc3y6b66vg57rx5y8nnv5c";
+  ]
+    # We need to force ffmpeg as the default, since we do not package
+    # bs1770gain, and set the absolute path there, to avoid impurities.
+    ++ lib.optional enableReplaygain (substituteAll {
+      src = ./replaygain-default-ffmpeg.patch;
+      ffmpeg = getBin ffmpeg;
     })
+    # Put absolute Nix paths in place
+    ++ lib.optional enableConvert (substituteAll {
+      src = ./convert-plugin-ffmpeg-path.patch;
+      ffmpeg = getBin ffmpeg;
+    })
+    ++ lib.optional enableBadfiles (substituteAll {
+      src = ./badfiles-plugin-nix-paths.patch;
+      inherit mp3val flac;
+    })
+  ;
 
-    # Fixes 548 tests due to breaking changes to the ast module
-    # https://github.com/beetbox/beets/pull/3621
-    # Can be dropped after 1.4.9
-    ./compatibility-with-breaking-changes-to-the-ast-module.patch
-  ];
-
+  # Disable failing tests
   postPatch = ''
     sed -i -e '/assertIn.*item.*path/d' test/test_info.py
     echo echo completion tests passed > test/rsrc/test_completion.sh
 
-    sed -i -e '/^BASH_COMPLETION_PATHS *=/,/^])$/ {
-      /^])$/i u"${completion}"
-    }' beets/ui/commands.py
-  '' + optionalString enableBadfiles ''
-    sed -i -e '/self\.run_command(\[/ {
-      s,"flac","${flac.bin}/bin/flac",
-      s,"mp3val","${mp3val}/bin/mp3val",
-    }' beetsplug/badfiles.py
-  '' + optionalString enableConvert ''
-    sed -i -e 's,\(util\.command_output(\)\([^)]\+\)),\1[b"${ffmpeg_3.bin}/bin/ffmpeg" if args[0] == b"ffmpeg" else args[0]] + \2[1:]),' beetsplug/convert.py
-  '' + optionalString enableReplaygain ''
-    sed -i -re '
-      s!^( *cmd *= *b?['\'''"])(bs1770gain['\'''"])!\1${bs1770gain}/bin/\2!
-    ' beetsplug/replaygain.py
-    sed -i -e 's/if has_program.*bs1770gain.*:/if True:/' \
-      test/test_replaygain.py
+    sed -i -e 's/len(mf.images)/0/' test/test_zero.py
   '';
 
   postInstall = ''
@@ -281,7 +296,7 @@ in pythonPackages.buildPythonApplication rec {
     description = "Music tagger and library organizer";
     homepage = "http://beets.io";
     license = licenses.mit;
-    maintainers = with maintainers; [ aszlig domenkozar pjones ];
+    maintainers = with maintainers; [ aszlig domenkozar doronbehar lovesegfault pjones ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/tools/audio/beets/keyfinder-default-bin.patch b/pkgs/tools/audio/beets/keyfinder-default-bin.patch
index 1ea195a678e8c..ec6bc3a5561c5 100644
--- a/pkgs/tools/audio/beets/keyfinder-default-bin.patch
+++ b/pkgs/tools/audio/beets/keyfinder-default-bin.patch
@@ -1,8 +1,8 @@
 diff --git a/beetsplug/keyfinder.py b/beetsplug/keyfinder.py
-index 34a4abc..59e8539 100644
+index 702003f0..08689cd8 100644
 --- a/beetsplug/keyfinder.py
 +++ b/beetsplug/keyfinder.py
-@@ -30,7 +30,7 @@ class KeyFinderPlugin(BeetsPlugin):
+@@ -31,7 +31,7 @@ class KeyFinderPlugin(BeetsPlugin):
      def __init__(self):
          super(KeyFinderPlugin, self).__init__()
          self.config.add({
@@ -11,18 +11,8 @@ index 34a4abc..59e8539 100644
              u'auto': True,
              u'overwrite': False,
          })
-@@ -59,8 +59,7 @@ class KeyFinderPlugin(BeetsPlugin):
-                 continue
- 
-             try:
--                output = util.command_output([bin, '-f',
--                                              util.syspath(item.path)])
-+                output = util.command_output([bin, util.syspath(item.path)])
-             except (subprocess.CalledProcessError, OSError) as exc:
-                 self._log.error(u'execution failed: {0}', exc)
-                 continue
 diff --git a/test/test_keyfinder.py b/test/test_keyfinder.py
-index 57e2bcd..c1ee916 100644
+index c8735e47..d7d670a4 100644
 --- a/test/test_keyfinder.py
 +++ b/test/test_keyfinder.py
 @@ -44,7 +44,7 @@ class KeyFinderTest(unittest.TestCase, TestHelper):
@@ -31,6 +21,6 @@ index 57e2bcd..c1ee916 100644
          command_output.assert_called_with(
 -            ['KeyFinder', '-f', util.syspath(item.path)])
 +            ['keyfinder-cli', util.syspath(item.path)])
- 
+
      def test_add_key_on_import(self, command_output):
-         command_output.return_value = 'dbm'
+         command_output.return_value = util.CommandOutput(b"dbm", b"")
diff --git a/pkgs/tools/audio/beets/mutagen-1.43.patch b/pkgs/tools/audio/beets/mutagen-1.43.patch
deleted file mode 100644
index d0d448c15e9a5..0000000000000
--- a/pkgs/tools/audio/beets/mutagen-1.43.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-Backport
-https://github.com/beetbox/mediafile/commit/b3343c4ee08d1251ae5e2344401a2f5892b4e868
-https://github.com/beetbox/mediafile/commit/d2fc3b59f77c515b02dfe7ad936f89264375d2b4
-to Beets 1.4.9.
-
-diff --git i/setup.py w/setup.py
-index 79278f8b..b8d60687 100755
---- i/setup.py
-+++ w/setup.py
-@@ -87,7 +87,7 @@ setup(
- 
-     install_requires=[
-         'six>=1.9',
--        'mutagen>=1.33',
-+        'mutagen>=1.43',
-         'unidecode',
-         'musicbrainzngs>=0.4',
-         'pyyaml',
-diff --git i/test/test_mediafile.py w/test/test_mediafile.py
-index 36a2c53a..0ddde44e 100644
---- i/test/test_mediafile.py
-+++ w/test/test_mediafile.py
-@@ -888,7 +888,7 @@ class WavpackTest(ReadWriteTestBase, unittest.TestCase):
-         'bitrate': 109312,
-         'format': u'WavPack',
-         'samplerate': 44100,
--        'bitdepth': 0,
-+        'bitdepth': 16,
-         'channels': 1,
-     }
- 
-@@ -912,7 +912,7 @@ class AIFFTest(ReadWriteTestBase, unittest.TestCase):
-         'bitrate': 705600,
-         'format': u'AIFF',
-         'samplerate': 44100,
--        'bitdepth': 0,
-+        'bitdepth': 16,
-         'channels': 1,
-     }
- 
diff --git a/pkgs/tools/audio/beets/alternatives-plugin.nix b/pkgs/tools/audio/beets/plugins/alternatives.nix
index fdad7dd89844b..fdad7dd89844b 100644
--- a/pkgs/tools/audio/beets/alternatives-plugin.nix
+++ b/pkgs/tools/audio/beets/plugins/alternatives.nix
diff --git a/pkgs/tools/audio/beets/beet-check-tests.patch b/pkgs/tools/audio/beets/plugins/check-tests.patch
index 2de97b86c8b44..2de97b86c8b44 100644
--- a/pkgs/tools/audio/beets/beet-check-tests.patch
+++ b/pkgs/tools/audio/beets/plugins/check-tests.patch
diff --git a/pkgs/tools/audio/beets/check-plugin.nix b/pkgs/tools/audio/beets/plugins/check.nix
index 241dcdad45213..241dcdad45213 100644
--- a/pkgs/tools/audio/beets/check-plugin.nix
+++ b/pkgs/tools/audio/beets/plugins/check.nix
diff --git a/pkgs/tools/audio/beets/copyartifacts-plugin.nix b/pkgs/tools/audio/beets/plugins/copyartifacts.nix
index 9432cb9bd0b95..9432cb9bd0b95 100644
--- a/pkgs/tools/audio/beets/copyartifacts-plugin.nix
+++ b/pkgs/tools/audio/beets/plugins/copyartifacts.nix
diff --git a/pkgs/tools/audio/beets/extrafiles-plugin.nix b/pkgs/tools/audio/beets/plugins/extrafiles.nix
index 7d0e446ce6051..7d0e446ce6051 100644
--- a/pkgs/tools/audio/beets/extrafiles-plugin.nix
+++ b/pkgs/tools/audio/beets/plugins/extrafiles.nix
diff --git a/pkgs/tools/audio/beets/replaygain-default-bs1770gain.patch b/pkgs/tools/audio/beets/replaygain-default-bs1770gain.patch
deleted file mode 100644
index 538f9e9330398..0000000000000
--- a/pkgs/tools/audio/beets/replaygain-default-bs1770gain.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py
-index 40b3a3a..9b54a5a 100644
---- a/beetsplug/replaygain.py
-+++ b/beetsplug/replaygain.py
-@@ -627,11 +627,10 @@ class ReplayGainPlugin(BeetsPlugin):
-         super(ReplayGainPlugin, self).__init__()
-         self.import_stages = [self.imported]
- 
--        # default backend is 'command' for backward-compatibility.
-         self.config.add({
-             'overwrite': False,
-             'auto': True,
--            'backend': u'command',
-+            'backend': u'bs1770gain',
-             'targetlevel': 89,
-         })
- 
diff --git a/pkgs/tools/audio/beets/replaygain-default-ffmpeg.patch b/pkgs/tools/audio/beets/replaygain-default-ffmpeg.patch
new file mode 100644
index 0000000000000..0ceba3c094423
--- /dev/null
+++ b/pkgs/tools/audio/beets/replaygain-default-ffmpeg.patch
@@ -0,0 +1,26 @@
+diff --git i/beetsplug/replaygain.py w/beetsplug/replaygain.py
+index 9d6fa23c..c5800039 100644
+--- i/beetsplug/replaygain.py
++++ w/beetsplug/replaygain.py
+@@ -391,7 +391,7 @@ class FfmpegBackend(Backend):
+ 
+     def __init__(self, config, log):
+         super(FfmpegBackend, self).__init__(config, log)
+-        self._ffmpeg_path = "ffmpeg"
++        self._ffmpeg_path = "@ffmpeg@/bin/ffmpeg"
+ 
+         # check that ffmpeg is installed
+         try:
+@@ -1228,11 +1228,10 @@ class ReplayGainPlugin(BeetsPlugin):
+     def __init__(self):
+         super(ReplayGainPlugin, self).__init__()
+ 
+-        # default backend is 'command' for backward-compatibility.
+         self.config.add({
+             'overwrite': False,
+             'auto': True,
+-            'backend': u'command',
++            'backend': u'ffmpeg',
+             'threads': cpu_count(),
+             'parallel_on_import': False,
+             'per_disc': False,
diff --git a/pkgs/tools/backup/duplicity/default.nix b/pkgs/tools/backup/duplicity/default.nix
index c29af7b2fd4e3..712d1d6f86e33 100644
--- a/pkgs/tools/backup/duplicity/default.nix
+++ b/pkgs/tools/backup/duplicity/default.nix
@@ -49,6 +49,7 @@ pythonPackages.buildPythonApplication rec {
   propagatedBuildInputs = with pythonPackages; [
     b2sdk
     boto
+    boto3
     cffi
     cryptography
     ecdsa
diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix
index 3e20258cbbeeb..96d560145df73 100644
--- a/pkgs/tools/compression/bzip2/default.nix
+++ b/pkgs/tools/compression/bzip2/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl
-, linkStatic ? (stdenv.hostPlatform.system == "i686-cygwin")
+, linkStatic ? with stdenv.hostPlatform; isStatic || isCygwin
 , autoreconfHook
 }:
 
diff --git a/pkgs/tools/compression/lz4/default.nix b/pkgs/tools/compression/lz4/default.nix
index 0124a0b3d63b7..7fceb3854ebcd 100644
--- a/pkgs/tools/compression/lz4/default.nix
+++ b/pkgs/tools/compression/lz4/default.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchFromGitHub, valgrind, fetchpatch
-, enableStatic ? false, enableShared ? true
+, enableStatic ? stdenv.hostPlatform.isStatic
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/tools/compression/xz/default.nix b/pkgs/tools/compression/xz/default.nix
index 0b6082bb57809..161619a048362 100644
--- a/pkgs/tools/compression/xz/default.nix
+++ b/pkgs/tools/compression/xz/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchurl, enableStatic ? false }:
+{ stdenv, fetchurl
+, enableStatic ? stdenv.hostPlatform.isStatic
+}:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
diff --git a/pkgs/tools/filesystems/nixpart/0.4/parted.nix b/pkgs/tools/filesystems/nixpart/0.4/parted.nix
index 7fe1b74546687..d3fc9ce96f58d 100644
--- a/pkgs/tools/filesystems/nixpart/0.4/parted.nix
+++ b/pkgs/tools/filesystems/nixpart/0.4/parted.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchurl, fetchpatch, lvm2, libuuid, gettext, readline
-, util-linux, check, enableStatic ? false }:
+, util-linux, check
+, enableStatic ? stdenv.hostPlatform.isStatic
+}:
 
 stdenv.mkDerivation rec {
   name = "parted-3.1";
diff --git a/pkgs/tools/graphics/optipng/default.nix b/pkgs/tools/graphics/optipng/default.nix
index 93c2f2c350256..571e89297c789 100644
--- a/pkgs/tools/graphics/optipng/default.nix
+++ b/pkgs/tools/graphics/optipng/default.nix
@@ -1,4 +1,5 @@
-{ stdenv, fetchurl, libpng, static ? false
+{ stdenv, fetchurl, libpng
+, static ? stdenv.hostPlatform.isStatic
 }:
 
 # This package comes with its own copy of zlib, libpng and pngxtern
diff --git a/pkgs/tools/misc/hdf4/default.nix b/pkgs/tools/misc/hdf4/default.nix
index b15eba8b7bc3d..a1aff8575279e 100644
--- a/pkgs/tools/misc/hdf4/default.nix
+++ b/pkgs/tools/misc/hdf4/default.nix
@@ -4,6 +4,7 @@
 , fixDarwinDylibNames
 , cmake
 , libjpeg
+, libtirpc
 , zlib
 , szip ? null
 }:
@@ -16,6 +17,30 @@ stdenv.mkDerivation rec {
     sha256 = "04nbgfxyj5jg4d6sr28162cxbfwqgv0sa7vz1ayzvm8wbbpkbq5x";
   };
 
+  patches = [
+    # Note that the PPC, SPARC and s390 patches are only needed so the aarch64 patch applies cleanly
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/hdf/raw/edbe5f49646b609f5bc9aeeee5a2be47e9556e8c/f/hdf-ppc.patch";
+      sha256 = "0dbbfpsvvqzy9zyfv38gd81zzc44gxjib9sd8scxqnkkqprj6jq0";
+    })
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/hdf/raw/edbe5f49646b609f5bc9aeeee5a2be47e9556e8c/f/hdf-4.2.4-sparc.patch";
+      sha256 = "0ip4prcjpa404clm87ib7l71605mws54x9492n9pbz5yb51r9aqh";
+    })
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/hdf/raw/edbe5f49646b609f5bc9aeeee5a2be47e9556e8c/f/hdf-s390.patch";
+      sha256 = "0aiqbr4s1l19y3r3y4wjd5fkv9cfc8rlr4apbh1p0d57wyvqa7i3";
+    })
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/hdf/raw/edbe5f49646b609f5bc9aeeee5a2be47e9556e8c/f/hdf-arm.patch";
+      sha256 = "157k1avvkpf3x89m1fv4a1kgab6k3jv74rskazrmjivgzav4qaw3";
+    })
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/hdf/raw/edbe5f49646b609f5bc9aeeee5a2be47e9556e8c/f/hdf-aarch64.patch";
+      sha256 = "112svcsilk16ybbsi8ywnxfl2p1v44zh3rfn4ijnl8z08vfqrvvs";
+    })
+  ];
+
   nativeBuildInputs = [
     cmake
   ] ++ stdenv.lib.optionals stdenv.isDarwin [
@@ -24,11 +49,19 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     libjpeg
+    libtirpc
     szip
     zlib
   ];
 
-  preConfigure = stdenv.lib.optionalString (szip != null) "export SZIP_INSTALL=${szip}";
+  preConfigure = ''
+    # Make tirpc discovery work with CMAKE_PREFIX_PATH
+    substituteInPlace config/cmake/FindXDR.cmake \
+      --replace 'find_path(XDR_INCLUDE_DIR NAMES rpc/types.h PATHS "/usr/include" "/usr/include/tirpc")' \
+                'find_path(XDR_INCLUDE_DIR NAMES rpc/types.h PATH_SUFFIXES include/tirpc)'
+  '' + stdenv.lib.optionalString (szip != null) ''
+    export SZIP_INSTALL=${szip}
+  '';
 
   cmakeFlags = [
     "-DBUILD_SHARED_LIBS=ON"
diff --git a/pkgs/tools/misc/hdf5/default.nix b/pkgs/tools/misc/hdf5/default.nix
index e56108767aba9..891fadac12ac6 100644
--- a/pkgs/tools/misc/hdf5/default.nix
+++ b/pkgs/tools/misc/hdf5/default.nix
@@ -6,7 +6,7 @@
 , zlib ? null
 , szip ? null
 , mpi ? null
-, enableShared ? true
+, enableShared ? !stdenv.hostPlatform.isStatic
 }:
 
 # cpp and mpi options are mutually exclusive
diff --git a/pkgs/tools/misc/ipxe/default.nix b/pkgs/tools/misc/ipxe/default.nix
index 87b26f223bc8f..beb6f0e708bf1 100644
--- a/pkgs/tools/misc/ipxe/default.nix
+++ b/pkgs/tools/misc/ipxe/default.nix
@@ -19,7 +19,7 @@ in
 
 stdenv.mkDerivation rec {
   pname = "ipxe";
-  version = "1.20.1";
+  version = "1.21.1";
 
   nativeBuildInputs = [ perl cdrkit syslinux xz openssl gnu-efi mtools ];
 
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     owner = "ipxe";
     repo = "ipxe";
     rev = "v${version}";
-    sha256 = "0w7h7y97gj9nqvbmsg1zp6zj5mpbbpckqbbx7bpp6k3ahy5fk8zp";
+    sha256 = "1pkf1n1c0rdlzfls8fvjvi1sd9xjd9ijqlyz3wigr70ijcv6x8i9";
   };
 
   # not possible due to assembler code
diff --git a/pkgs/tools/misc/parted/default.nix b/pkgs/tools/misc/parted/default.nix
index b00a0836021f8..2b21b2f1427c1 100644
--- a/pkgs/tools/misc/parted/default.nix
+++ b/pkgs/tools/misc/parted/default.nix
@@ -11,7 +11,7 @@
 , python3
 , util-linux
 , check
-, enableStatic ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/tools/misc/toybox/default.nix b/pkgs/tools/misc/toybox/default.nix
index e7a08877e90f3..5ae211bd23761 100644
--- a/pkgs/tools/misc/toybox/default.nix
+++ b/pkgs/tools/misc/toybox/default.nix
@@ -1,7 +1,7 @@
 {
   stdenv, lib, fetchFromGitHub, which,
   buildPackages,
-  enableStatic ? false,
+  enableStatic ? stdenv.hostPlatform.isStatic,
   enableMinimal ? false,
   extraConfig ? ""
 }:
diff --git a/pkgs/tools/misc/ttygif/default.nix b/pkgs/tools/misc/ttygif/default.nix
index 5a14dade01b84..dd74f5effed67 100644
--- a/pkgs/tools/misc/ttygif/default.nix
+++ b/pkgs/tools/misc/ttygif/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub }:
+{ stdenv, fetchFromGitHub, makeWrapper, imagemagick, xorg }:
 
 stdenv.mkDerivation rec {
   pname = "ttygif";
@@ -13,6 +13,12 @@ stdenv.mkDerivation rec {
 
   makeFlags = [ "CC:=$(CC)" "PREFIX=${placeholder "out"}" ];
 
+  nativeBuildInputs = [ makeWrapper ];
+  postInstall = ''
+    wrapProgram $out/bin/ttygif \
+      --prefix PATH : ${stdenv.lib.makeBinPath [ imagemagick xorg.xwd ]}
+  '';
+
   meta = with stdenv.lib; {
     homepage = "https://github.com/icholy/ttygif";
     description = "Convert terminal recordings to animated gifs";
diff --git a/pkgs/tools/networking/dropbear/default.nix b/pkgs/tools/networking/dropbear/default.nix
index 88217302915e7..605e95c9392a9 100644
--- a/pkgs/tools/networking/dropbear/default.nix
+++ b/pkgs/tools/networking/dropbear/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchurl, glibc, zlib
-, enableStatic ? false
+, enableStatic ? stdenv.hostPlatform.isStatic
 , sftpPath ? "/run/current-system/sw/libexec/sftp-server"
 }:
 
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index 06f5a651f69e4..868be79c1a49e 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -22,7 +22,7 @@ common =
   , confDir
   , withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
   , withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
-  , enableStatic ? false
+  , enableStatic ? stdenv.hostPlatform.isStatic
   , name, suffix ? "", src, patches ? []
 
   }:
diff --git a/pkgs/tools/system/ipmitool/default.nix b/pkgs/tools/system/ipmitool/default.nix
index b5da2db67fe8b..196e59953fe73 100644
--- a/pkgs/tools/system/ipmitool/default.nix
+++ b/pkgs/tools/system/ipmitool/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, openssl, fetchpatch, static ? false }:
+{ stdenv, lib, fetchurl, openssl, fetchpatch, static ? stdenv.hostPlatform.isStatic }:
 
 let
   pkgname = "ipmitool";
diff --git a/pkgs/tools/system/pciutils/default.nix b/pkgs/tools/system/pciutils/default.nix
index cf6616417ed06..c062e1f3bd086 100644
--- a/pkgs/tools/system/pciutils/default.nix
+++ b/pkgs/tools/system/pciutils/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, zlib, kmod, which
-, static ? stdenv.targetPlatform.isStatic
+, static ? stdenv.hostPlatform.isStatic
 , darwin ? null
 }:
 
diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix
index 6f95da017edd8..4a4277c207299 100644
--- a/pkgs/top-level/aliases.nix
+++ b/pkgs/top-level/aliases.nix
@@ -78,6 +78,7 @@ mapAliases ({
   bittorrentSync = throw "bittorrentSync has been deprecated by resilio-sync."; # added 2019-06-03
   bittorrentSync14 = throw "bittorrentSync14 has been deprecated by resilio-sync."; # added 2019-06-03
   bittorrentSync20 = throw "bittorrentSync20 has been deprecated by resilio-sync."; # added 2019-06-03
+  bs1770gain = throw "bs1770gain has been removed from nixpkgs, as it had no maintainer or reverse dependencies."; # added 2021-01-02
   btc1 = throw "btc1 has been removed, it was abandoned by upstream"; # added 2020-11-03
   buildPerlPackage = perlPackages.buildPerlPackage; # added 2018-10-12
   buildGo112Package = throw "buildGo112Package has been removed"; # added 2020-04-26
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 30ab4e774a812..df1e8fdd04009 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -6129,12 +6129,18 @@ in
   # with different versions we pin Go for all versions.
   nomad_0_11 = callPackage ../applications/networking/cluster/nomad/0.11.nix {
     buildGoPackage = buildGo114Package;
+    inherit (linuxPackages) nvidia_x11;
+    nvidiaGpuSupport = config.cudaSupport or (!stdenv.isLinux);
   };
   nomad_0_12 = callPackage ../applications/networking/cluster/nomad/0.12.nix {
     buildGoPackage = buildGo114Package;
+    inherit (linuxPackages) nvidia_x11;
+    nvidiaGpuSupport = config.cudaSupport or (!stdenv.isLinux);
   };
   nomad_1_0 = callPackage ../applications/networking/cluster/nomad/1.0.nix {
     buildGoPackage = buildGo115Package;
+    inherit (linuxPackages) nvidia_x11;
+    nvidiaGpuSupport = config.cudaSupport or (!stdenv.isLinux);
   };
 
   notable = callPackage ../applications/misc/notable { };
@@ -9012,7 +9018,7 @@ in
   colm = callPackage ../development/compilers/colm { };
 
   colmap = libsForQt514.callPackage ../applications/science/misc/colmap { };
-  colmapWithCuda = colmap.override { cudaSupport = true; };
+  colmapWithCuda = colmap.override { cudaSupport = true; cudatoolkit = cudatoolkit_11; };
 
   chickenPackages_4 = callPackage ../development/compilers/chicken/4 { };
   chickenPackages_5 = callPackage ../development/compilers/chicken/5 { };
@@ -15768,9 +15774,9 @@ in
 
     inherit (kdeApplications.override { libsForQt5 = self; })
       libkdcraw libkexiv2 libkipi libkomparediff2 libksane libkcddb akonadi-contacts
-      akonadi-calendar akonadi-notes akonadi-search kidentitymanagement kontactinterface
-      kldap akonadi akregator ark bomber bovo dolphin dragon elisa ffmpegthumbs filelight
-      granatier gwenview k3b kaddressbook kalzium kapptemplate kapman kate katomic
+      akonadi-calendar akonadi-notes akonadi-search kaccounts-integration kidentitymanagement
+      kontactinterface kldap akonadi akregator ark bomber bovo dolphin dragon elisa ffmpegthumbs
+      filelight granatier gwenview k3b kaddressbook kalzium kapptemplate kapman kate katomic
       kblackbox kblocks kbounce kcachegrind kcalc kcharselect kcolorchooser
       kdenlive kdf kdialog kdiamond keditbookmarks kfind kfloppy kget kgpg khelpcenter
       kig kigo killbots kitinerary kleopatra klettres klines kmag kmail kmines kmix kmplot
@@ -15918,6 +15924,8 @@ in
     # Not a library, but we do want it to be built for every qt version there
     # is, to allow users to choose the right build if needed.
     sddm = callPackage ../applications/display-managers/sddm { };
+
+    signond = callPackage ../development/libraries/signond {};
   };
 
   qtEnv = qt5.env;
@@ -20799,8 +20807,6 @@ in
 
   bristol = callPackage ../applications/audio/bristol { };
 
-  bs1770gain = callPackage ../applications/audio/bs1770gain { };
-
   bjumblr = callPackage ../applications/audio/bjumblr { };
 
   bschaffl = callPackage ../applications/audio/bschaffl { };
@@ -21666,12 +21672,16 @@ in
 
   wireshark = callPackage ../applications/networking/sniffers/wireshark {
     inherit (darwin.apple_sdk.frameworks) ApplicationServices SystemConfiguration;
+    libpcap = libpcap.override { withBluez = stdenv.isLinux; };
   };
   wireshark-qt = wireshark;
 
   # The GTK UI is deprecated by upstream. You probably want the QT version.
   wireshark-gtk = throw "wireshark-gtk is not supported anymore. Use wireshark-qt or wireshark-cli instead.";
-  wireshark-cli = wireshark.override { withQt = false; };
+  wireshark-cli = wireshark.override {
+    withQt = false;
+    libpcap = libpcap.override { withBluez = stdenv.isLinux; };
+  };
 
   sngrep = callPackage ../applications/networking/sniffers/sngrep {};
 
diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix
index 2a62a3378174d..e5d0f60ee5d03 100644
--- a/pkgs/top-level/ocaml-packages.nix
+++ b/pkgs/top-level/ocaml-packages.nix
@@ -916,10 +916,7 @@ let
 
     pprint = callPackage ../development/ocaml-modules/pprint { };
 
-    ppx_blob =
-      if lib.versionAtLeast ocaml.version "4.02"
-      then callPackage ../development/ocaml-modules/ppx_blob {}
-      else null;
+    ppx_blob = callPackage ../development/ocaml-modules/ppx_blob { };
 
     ppx_cstruct = callPackage ../development/ocaml-modules/cstruct/ppx.nix {};
 
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 4e48b424947ef..4a3577020af70 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -167,6 +167,10 @@ in {
 
   adb-shell = callPackage ../development/python-modules/adb-shell { };
 
+  adblock = callPackage ../development/python-modules/adblock {
+    inherit (pkgs.darwin.apple_sdk.frameworks) CoreFoundation Security;
+  };
+
   addic7ed-cli = callPackage ../development/python-modules/addic7ed-cli { };
 
   adguardhome= callPackage ../development/python-modules/adguardhome { };
@@ -455,6 +459,8 @@ in {
 
   async-upnp-client = callPackage ../development/python-modules/async-upnp-client { };
 
+  asyncwhois = callPackage ../development/python-modules/asyncwhois { };
+
   atlassian-python-api = callPackage ../development/python-modules/atlassian-python-api { };
 
   atom = callPackage ../development/python-modules/atom { };
@@ -3405,9 +3411,13 @@ in {
 
   lazy-object-proxy = callPackage ../development/python-modules/lazy-object-proxy { };
 
+  ldap = callPackage ../development/python-modules/ldap {
+    inherit (pkgs) openldap cyrus_sasl;
+  };
+
   ldap3 = callPackage ../development/python-modules/ldap3 { };
 
-  ldap = callPackage ../development/python-modules/ldap { inherit (pkgs) openldap cyrus_sasl; };
+  ldapdomaindump = callPackage ../development/python-modules/ldapdomaindump { };
 
   ldappool = callPackage ../development/python-modules/ldappool { };
 
@@ -5722,6 +5732,10 @@ in {
 
   pysptk = callPackage ../development/python-modules/pysptk { };
 
+  pysqlcipher3 = callPackage ../development/python-modules/pysqlcipher3 {
+    inherit (pkgs) sqlcipher;
+  };
+
   pysqlite = callPackage ../development/python-modules/pysqlite { };
 
   pysqueezebox = callPackage ../development/python-modules/pysqueezebox { };
@@ -6149,6 +6163,8 @@ in {
 
   python-vlc = callPackage ../development/python-modules/python-vlc { };
 
+  python-whois = callPackage ../development/python-modules/python-whois { };
+
   python-wifi = callPackage ../development/python-modules/python-wifi { };
 
   python-xmp-toolkit = callPackage ../development/python-modules/python-xmp-toolkit { };
@@ -7900,6 +7916,8 @@ in {
 
   whitenoise = callPackage ../development/python-modules/whitenoise { };
 
+  whois = callPackage ../development/python-modules/whois { };
+
   whoosh = callPackage ../development/python-modules/whoosh { };
 
   widgetsnbextension = callPackage ../development/python-modules/widgetsnbextension { };
diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix
index 6720a019cbced..f1d3ea2a1598c 100644
--- a/pkgs/top-level/static.nix
+++ b/pkgs/top-level/static.nix
@@ -112,87 +112,23 @@ in {
     enableApp = false;
   };
 
-  ncurses = super.ncurses.override {
-    enableStatic = true;
-  };
-  libxml2 = super.libxml2.override ({
-    enableShared = false;
-    enableStatic = true;
-  } // optionalAttrs super.stdenv.hostPlatform.isDarwin {
-    pythonSupport = false;
-  });
   zlib = super.zlib.override {
-    static = true;
-    shared = false;
-    splitStaticOutput = false;
-
     # Don’t use new stdenv zlib because
     # it doesn’t like the --disable-shared flag
     stdenv = super.stdenv;
   };
-  xz = super.xz.override {
-    enableStatic = true;
-  };
-  busybox = super.busybox.override {
-    enableStatic = true;
-  };
-  libiberty = super.libiberty.override {
-    staticBuild = true;
-  };
-  libpfm = super.libpfm.override {
-    enableShared = false;
-  };
-  ipmitool = super.ipmitool.override {
-    static = true;
-  };
-  neon = super.neon.override {
-    static = true;
-    shared = false;
-  };
-  fmt = super.fmt.override {
-    enableShared = false;
-  };
   gifsicle = super.gifsicle.override {
     static = true;
   };
-  bzip2 = super.bzip2.override {
-    linkStatic = true;
-  };
-  optipng = super.optipng.override {
-    static = true;
-  };
-  openblas = super.openblas.override {
-    enableStatic = true;
-    enableShared = false;
-  };
-  mkl = super.mkl.override { enableStatic = true; };
-  nix = super.nix.override { enableStatic = true; };
-  nixUnstable = super.nixUnstable.override { enableStatic = true; };
-  openssl = (super.openssl_1_1.override { static = true; }).overrideAttrs (o: {
+  openssl = super.openssl_1_1.overrideAttrs (o: {
     # OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags.
     configureFlags = (removeUnknownConfigureFlags o.configureFlags);
   });
-  arrow-cpp = super.arrow-cpp.override {
-    enableShared = false;
-  };
   boost = super.boost.override {
-    enableStatic = true;
-    enableShared = false;
-
     # Don’t use new stdenv for boost because it doesn’t like the
     # --disable-shared flag
     stdenv = super.stdenv;
   };
-  thrift = super.thrift.override {
-    static = true;
-    twisted = null;
-  };
-  gmp = super.gmp.override {
-    withStatic = true;
-  };
-  gflags = super.gflags.override {
-    enableShared = false;
-  };
   cdo = super.cdo.override {
     enable_all_static = true;
   };
@@ -202,13 +138,6 @@ in {
   crc32c = super.crc32c.override {
     staticOnly = true;
   };
-  parted = super.parted.override {
-    enableStatic = true;
-  };
-  libiconvReal = super.libiconvReal.override {
-    enableShared = false;
-    enableStatic = true;
-  };
   perl = super.perl.override {
     # Don’t use new stdenv zlib because
     # it doesn’t like the --disable-shared flag
@@ -220,24 +149,9 @@ in {
   snappy = super.snappy.override {
     static = true;
   };
-  lz4 = super.lz4.override {
-    enableShared = false;
-    enableStatic = true;
-  };
   libressl = super.libressl.override {
     buildShared = false;
   };
-  libjpeg_turbo = super.libjpeg_turbo.override {
-    enableStatic = true;
-    enableShared = false;
-  };
-
-  darwin = super.darwin // {
-    libiconv = super.darwin.libiconv.override {
-      enableShared = false;
-      enableStatic = true;
-    };
-  };
 
   kmod = super.kmod.override {
     withStatic = true;
@@ -260,21 +174,6 @@ in {
     static = true;
   };
 
-  llvmPackages_8 = super.llvmPackages_8 // {
-    libraries = super.llvmPackages_8.libraries // rec {
-      libcxxabi = super.llvmPackages_8.libraries.libcxxabi.override {
-        enableShared = false;
-      };
-      libcxx = super.llvmPackages_8.libraries.libcxx.override {
-        enableShared = false;
-        inherit libcxxabi;
-      };
-      libunwind = super.llvmPackages_8.libraries.libunwind.override {
-        enableShared = false;
-      };
-    };
-  };
-
   ocaml-ng = self.lib.mapAttrs (_: set:
     if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set
   ) super.ocaml-ng;
@@ -289,13 +188,6 @@ in {
   # Note: -static doesn’t work on darwin
   libev = super.libev.override { static = !super.stdenv.hostPlatform.isDarwin; };
 
-  libexecinfo = super.libexecinfo.override { enableShared = false; };
-
-  tree-sitter = super.tree-sitter.override {
-    enableShared = false;
-    enableStatic = true;
-  };
-
   xorg = super.xorg.overrideScope' (xorgself: xorgsuper: {
     libX11 = xorgsuper.libX11.overrideAttrs (attrs: {
       depsBuildBuild = attrs.depsBuildBuild ++ [ (self.buildPackages.stdenv.cc.libc.static or null) ];
@@ -319,6 +211,4 @@ in {
       configureFlags = attrs.configureFlags ++ [ "--disable-shared" ];
     });
   });
-
-  libcap = super.libcap.override { pam = null; };
 }