about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/os-specific')
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/default.nix122
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/lib/default.nix18
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/package-set.nix96
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-fix-typedefs-locations.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-fix-typedefs-locations.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-install-dirs.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-msun-arch-subdir.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-msun-arch-subdir.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-no-force--lcompiler-rt.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-no-force--lcompiler-rt.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libnetbsd-do-install.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/libnetbsd-do-install.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/librpcsvc-include-subdir.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/librpcsvc-include-subdir.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch13
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/no-perms-BSD.include.dist.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/no-perms-BSD.include.dist.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-gnu-date.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-gnu-date.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-no-explicit-intrinsics-dep.patch (renamed from nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-no-explicit-intrinsics-dep.patch)0
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch32
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch40
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch10
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch32
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch13
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch10
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch13
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch42
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix9
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix241
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/config.nix36
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix25
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix25
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix23
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/package.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/gencat.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix33
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/install.nix76
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix315
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix21
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix24
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix49
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix32
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libsbuf.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix23
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix9
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix19
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/make.nix27
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix21
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix218
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix22
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix19
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mknod.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix37
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix11
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix3
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/source.nix1
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/stat.nix19
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/statHook.nix16
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix148
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix28
-rwxr-xr-xnixpkgs/pkgs/os-specific/bsd/freebsd/update.py22
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/freebsd/versions.json59
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix314
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/compat/package.nix172
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/config.nix27
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/csu.nix49
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/fts/package.nix19
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/headers.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/i18n_module.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/include.nix32
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix81
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/ld_elf_so.nix16
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libc.nix59
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libcurses.nix24
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libedit.nix52
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libm.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpci.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/base.nix1
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/headers.nix17
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix39
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libresolv.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librpcsvc.nix28
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librt.nix7
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libterminfo.nix33
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix39
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/lorder.nix21
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/make.nix97
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix15
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/mkDerivation.nix173
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/nbperf.nix1
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/package.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh1
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/hook.nix17
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/package.nix21
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix55
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/headers.nix50
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/package.nix50
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tic.nix31
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tsort.nix21
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/uudecode.nix7
-rw-r--r--nixpkgs/pkgs/os-specific/bsd/setup-hook.sh1
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/apple-source-releases/default.nix3
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix38
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/apple-source-releases/macos-11.0.1.nix1
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/apple-source-releases/system_cmds/meson.build9
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/openwith/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/raycast/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/rectangle/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/darwin/utm/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/batman-adv/version.nix10
-rw-r--r--nixpkgs/pkgs/os-specific/linux/bcc/absolute-ausyscall.patch43
-rw-r--r--nixpkgs/pkgs/os-specific/linux/bcc/default.nix122
-rw-r--r--nixpkgs/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch14
-rw-r--r--nixpkgs/pkgs/os-specific/linux/bcc/libbcc-path.patch11
-rw-r--r--nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix71
-rw-r--r--nixpkgs/pkgs/os-specific/linux/cpupower-gui/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/cryptodev/default.nix15
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ddcci/default.nix13
-rw-r--r--nixpkgs/pkgs/os-specific/linux/digimend/default.nix13
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ena/default.nix10
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ena/override-features-api-detection.patch55
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ffado/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/firmware/firmware-manager/default.nix7
-rw-r--r--nixpkgs/pkgs/os-specific/linux/firmware/fwupd-efi/default.nix11
-rw-r--r--nixpkgs/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/firmware/ivsc-firmware/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/firmware/linux-firmware/source.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/fnotifystat/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/fscrypt/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/fw-ectool/default.nix33
-rw-r--r--nixpkgs/pkgs/os-specific/linux/fwts/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/game-devices-udev-rules/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/guvcview/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/hwdata/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/iproute/default.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ipu6-drivers/default.nix2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ivsc-driver/default.nix2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/common-config.nix19
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/generic.nix2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/hardened/patches.json82
-rwxr-xr-xnixpkgs/pkgs/os-specific/linux/kernel/hardened/update.py1
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/htmldocs.nix18
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/kernels-org.json32
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.10.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.15.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.6.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/xanmod-kernels.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kernel/zen-kernels.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kvmfr/default.nix3
-rw-r--r--nixpkgs/pkgs/os-specific/linux/kvmfr/linux-6-4-compat.patch16
-rw-r--r--nixpkgs/pkgs/os-specific/linux/ledger-udev-rules/default.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/libbpf/0.x.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/libbpf/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/libcap-ng/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/libsepol/default.nix2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/libzbc/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/microcode/intel.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/mm-tools/default.nix (renamed from nixpkgs/pkgs/os-specific/linux/vm-tools/default.nix)4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/mstflint_access/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/nftables/default.nix16
-rw-r--r--nixpkgs/pkgs/os-specific/linux/nftables/fix-py-libnftables.patch13
-rw-r--r--nixpkgs/pkgs/os-specific/linux/nftables/python.nix26
-rwxr-xr-xnixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/pam/default.nix22
-rw-r--r--nixpkgs/pkgs/os-specific/linux/piper/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/power-profiles-daemon/default.nix9
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8189es/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8189fs/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8192eu/default.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8723ds/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8812au/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8821cu/default.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/rtl8852au/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/semodule-utils/default.nix2
-rw-r--r--nixpkgs/pkgs/os-specific/linux/sysdig/default.nix40
-rw-r--r--nixpkgs/pkgs/os-specific/linux/systemd/default.nix7
-rw-r--r--nixpkgs/pkgs/os-specific/linux/tbs/default.nix12
-rw-r--r--nixpkgs/pkgs/os-specific/linux/tiscamera/default.nix6
-rw-r--r--nixpkgs/pkgs/os-specific/linux/tuna/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/uhk-agent/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/waydroid/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/zenmonitor/default.nix4
-rw-r--r--nixpkgs/pkgs/os-specific/linux/zfs/2_2.nix8
-rw-r--r--nixpkgs/pkgs/os-specific/linux/zfs/unstable.nix8
187 files changed, 2967 insertions, 1837 deletions
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/default.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/default.nix
index b7cf5484c9e9..c605d9f70937 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/default.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/default.nix
@@ -1,72 +1,64 @@
-{ stdenv, lib, stdenvNoCC
-, makeScopeWithSplicing', generateSplicesForMkScope
-, buildPackages
-, fetchgit, fetchzip
+{
+  lib,
+  makeScopeWithSplicing',
+  generateSplicesForMkScope,
+  callPackage,
+  crossLibcStdenv,
+  attributePathToSplice ? [ "freebsd" ],
+  branch ? "release/14.0.0",
 }:
 
 let
-  inherit (buildPackages.buildPackages) rsync;
-
   versions = builtins.fromJSON (builtins.readFile ./versions.json);
 
-  version = "13.1.0";
-  branch = "release/${version}";
-
-in makeScopeWithSplicing' {
-  otherSplices = generateSplicesForMkScope "freebsd";
-  f = (self: lib.packagesFromDirectoryRecursive {
-    callPackage = self.callPackage;
-    directory = ./pkgs;
-  } // {
-    sourceData = versions.${branch};
-
-    ports = fetchzip {
-      url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
-      sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
-    };
-
-    compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
-    freebsd-lib = import ./lib { inherit version; };
-
-    # The manual callPackages below should in principle be unnecessary, but are
-    # necessary. See note in ../netbsd/default.nix
-
-    compat = self.callPackage ./pkgs/compat/package.nix {
-      inherit stdenv;
-      inherit (buildPackages.freebsd) makeMinimal boot-install;
-    };
-
-    csu = self.callPackage ./pkgs/csu.nix {
-      inherit (buildPackages.freebsd) makeMinimal install gencat;
-      inherit (self) include;
-    };
-
-    include = self.callPackage ./pkgs/include/package.nix {
-      inherit (buildPackages.freebsd) makeMinimal install rpcgen;
+  badBranchError =
+    branch:
+    throw ''
+      Unknown FreeBSD branch ${branch}!
+      FreeBSD branches normally look like one of:
+      * `release/<major>.<minor>.0` for tagged releases without security updates
+      * `releng/<major>.<minor>` for release update branches with security updates
+      * `stable/<major>` for stable versions working towards the next minor release
+      * `main` for the latest development version
+
+      Branches can be selected by overriding the `branch` attribute on the freebsd package set.
+    '';
+
+  # `./package-set.nix` should never know the name of the package set we
+  # are constructing; just this function is allowed to know that. This
+  # is why we:
+  #
+  #  - do the splicing for cross compilation here
+  #
+  #  - construct the *anonymized* `buildFreebsd` attribute to be passed
+  #    to `./package-set.nix`.
+  callFreeBSDWithAttrs =
+    extraArgs:
+    let
+      # we do not include the branch in the splice here because the branch
+      # parameter to this file will only ever take on one value - more values
+      # are provided through overrides.
+      otherSplices = generateSplicesForMkScope attributePathToSplice;
+    in
+    makeScopeWithSplicing' {
+      inherit otherSplices;
+      f =
+        self:
+        {
+          inherit branch;
+        }
+        // callPackage ./package-set.nix (
+          {
+            sourceData = versions.${self.branch} or (throw (badBranchError self.branch));
+            versionData = self.sourceData.version;
+            buildFreebsd = otherSplices.selfBuildHost;
+            patchesRoot = ./patches/${self.versionData.revision};
+          }
+          // extraArgs
+        ) self;
     };
-
-    install = self.callPackage ./pkgs/install.nix {
-      inherit (buildPackages.freebsd) makeMinimal;
-      inherit (self) mtree libnetbsd;
-    };
-
-    libc = self.callPackage ./pkgs/libc/package.nix {
-      inherit (buildPackages.freebsd) makeMinimal install gencat rpcgen;
-      inherit (self) csu include;
-    };
-
-    libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
-      inherit (buildPackages.freebsd) makeMinimal;
-    };
-
-    mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
-      inherit stdenv;
-      inherit (buildPackages.freebsd) makeMinimal install tsort;
-    };
-
-    makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
-      inherit (self) make;
-    };
-
-  });
+in
+{
+  freebsd = callFreeBSDWithAttrs { };
+  freebsdCross = callFreeBSDWithAttrs { stdenv = crossLibcStdenv; };
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix
index d62c01f5eb88..6696d12912e6 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix
@@ -1,4 +1,11 @@
-{ lib, stdenv, linuxHeaders, freebsd, runCommandCC, buildPackages }:
+{
+  lib,
+  stdenv,
+  linuxHeaders,
+  freebsd,
+  runCommandCC,
+  buildPackages,
+}:
 
 stdenv.mkDerivation {
   pname = "evdev-proto";
@@ -28,7 +35,7 @@ stdenv.mkDerivation {
   TOUCH = "touch";
   XARGS = "xargs";
 
-  ABI_FILE = runCommandCC "abifile" {} "$CC -shared -o $out";
+  ABI_FILE = runCommandCC "abifile" { } "$CC -shared -o $out";
   CLEAN_FETCH_ENV = true;
   INSTALL_AS_USER = true;
   NO_CHECKSUM = true;
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/lib/default.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/lib/default.nix
index 30fea7e17dce..26119a8ba196 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/lib/default.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/lib/default.nix
@@ -3,14 +3,16 @@
 {
   inherit version;
 
-  mkBsdArch = stdenv':  {
-    x86_64 = "amd64";
-    aarch64 = "arm64";
-    i486 = "i386";
-    i586 = "i386";
-    i686 = "i386";
-  }.${stdenv'.hostPlatform.parsed.cpu.name}
-    or stdenv'.hostPlatform.parsed.cpu.name;
+  mkBsdArch =
+    stdenv':
+    {
+      x86_64 = "amd64";
+      aarch64 = "arm64";
+      i486 = "i386";
+      i586 = "i386";
+      i686 = "i386";
+    }
+    .${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
 
   install-wrapper = builtins.readFile ./install-wrapper.sh;
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/package-set.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/package-set.nix
new file mode 100644
index 000000000000..dfde4a0a31fa
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/package-set.nix
@@ -0,0 +1,96 @@
+{
+  stdenv,
+  lib,
+  stdenvNoCC,
+  fetchzip,
+  sourceData,
+  versionData,
+  buildFreebsd,
+  patchesRoot,
+}:
+
+self:
+
+lib.packagesFromDirectoryRecursive {
+  callPackage = self.callPackage;
+  directory = ./pkgs;
+}
+// {
+  inherit sourceData patchesRoot versionData;
+  patches = ./patches/${self.versionData.revision};
+
+  # Keep the crawled portion of Nixpkgs finite.
+  buildFreebsd = lib.dontRecurseIntoAttrs buildFreebsd;
+
+  ports = fetchzip {
+    url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
+    sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
+  };
+
+  compatIsNeeded = !stdenvNoCC.hostPlatform.isFreeBSD;
+  compatIfNeeded = lib.optional self.compatIsNeeded self.compat;
+  freebsd-lib = import ./lib {
+    version = lib.concatStringsSep "." (
+      map toString (
+        lib.filter (x: x != null) [
+          self.versionData.major
+          self.versionData.minor
+          self.versionData.patch or null
+        ]
+      )
+    );
+  };
+
+  # The manual callPackages below should in principle be unnecessary, but are
+  # necessary. See note in ../netbsd/default.nix
+
+  compat = self.callPackage ./pkgs/compat/package.nix {
+    inherit stdenv;
+    inherit (buildFreebsd) makeMinimal;
+  };
+
+  csu = self.callPackage ./pkgs/csu.nix {
+    inherit (buildFreebsd) makeMinimal install gencat;
+    inherit (self) include;
+  };
+
+  include = self.callPackage ./pkgs/include/package.nix { inherit (buildFreebsd) rpcgen mtree; };
+
+  install = self.callPackage ./pkgs/install.nix {
+    inherit (buildFreebsd) makeMinimal;
+    inherit (self) libmd libnetbsd;
+  };
+
+  libc = self.callPackage ./pkgs/libc/package.nix {
+    inherit (buildFreebsd)
+      makeMinimal
+      install
+      gencat
+      rpcgen
+      mkcsmapper
+      mkesdb
+      ;
+    inherit (self) csu include;
+  };
+
+  libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix { inherit (buildFreebsd) makeMinimal; };
+
+  libmd = self.callPackage ./pkgs/libmd.nix { inherit (buildFreebsd) makeMinimal; };
+
+  mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
+    inherit stdenv;
+    inherit (buildFreebsd)
+      freebsdSetupHook
+      makeMinimal
+      install
+      tsort
+      lorder
+      ;
+  };
+
+  makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; };
+
+  mtree = self.callPackage ./pkgs/mtree.nix { inherit (self) libnetbsd libmd; };
+
+  tsort = self.callPackage ./pkgs/tsort.nix { inherit (buildFreebsd) makeMinimal install; };
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-fix-typedefs-locations.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-fix-typedefs-locations.patch
index 3336a2504e58..3336a2504e58 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-fix-typedefs-locations.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-fix-typedefs-locations.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-install-dirs.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch
index 9bb2bea32ee9..9bb2bea32ee9 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/compat-install-dirs.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-msun-arch-subdir.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-msun-arch-subdir.patch
index 4a69e85a986a..4a69e85a986a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-msun-arch-subdir.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-msun-arch-subdir.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-no-force--lcompiler-rt.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-no-force--lcompiler-rt.patch
index 60176fb73cf7..60176fb73cf7 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/libc-no-force--lcompiler-rt.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libc-no-force--lcompiler-rt.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/libnetbsd-do-install.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libnetbsd-do-install.patch
index a7bd032d2be5..a7bd032d2be5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/libnetbsd-do-install.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/libnetbsd-do-install.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/librpcsvc-include-subdir.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/librpcsvc-include-subdir.patch
index 38e06682869f..38e06682869f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/librpcsvc-include-subdir.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/librpcsvc-include-subdir.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch
new file mode 100644
index 000000000000..2a6e560d1d28
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch
@@ -0,0 +1,13 @@
+--- a/contrib/mtree/Makefile	2023-12-04 23:02:13.919144141 -0700
++++ b/contrib/mtree/Makefile		2023-12-04 23:02:58.371810109 -0700
+@@ -10,8 +10,8 @@
+ SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \
+        verify.c getid.c pack_dev.c only.c
+ .if (${HOSTPROG:U} == "")
+-DPADD+= ${LIBUTIL}
+-LDADD+= -lutil
++LIBADD+= ${LIBUTIL}
++#LIBADD+= -lutil
+ .endif
+
+ CPPFLAGS+=	-I${NETBSDSRCDIR}/sbin/mknod
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/no-perms-BSD.include.dist.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/no-perms-BSD.include.dist.patch
index 985617ee0f45..985617ee0f45 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/no-perms-BSD.include.dist.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/no-perms-BSD.include.dist.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-gnu-date.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-gnu-date.patch
index 2356446baf85..2356446baf85 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-gnu-date.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-gnu-date.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-no-explicit-intrinsics-dep.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-no-explicit-intrinsics-dep.patch
index edf44de5bb0d..edf44de5bb0d 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/sys-no-explicit-intrinsics-dep.patch
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/13.1/sys-no-explicit-intrinsics-dep.patch
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch
new file mode 100644
index 000000000000..f43d87c01e54
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch
@@ -0,0 +1,11 @@
+--- a/share/mk/src.libnames.mk	2023-12-21 23:56:50.767042385 -0800
++++ b/share/mk/src.libnames.mk	2023-12-21 23:56:39.671089506 -0800
+@@ -392,7 +392,7 @@
+ _DP_ztest=	geom m nvpair umem zpool pthread avl zfs_core spl zutil zfs uutil icp
+ # The libc dependencies are not strictly needed but are defined to make the
+ # assert happy.
+-_DP_c=		compiler_rt
++_DP_c=		
+ # Use libssp_nonshared only on i386 and power*.  Other archs emit direct calls
+ # to __stack_chk_fail, not __stack_chk_fail_local provided by libssp_nonshared.
+ .if ${MK_SSP} != "no" && \
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch
new file mode 100644
index 000000000000..3336a2504e58
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch
@@ -0,0 +1,32 @@
+--- a/tools/build/cross-build/include/common/sys/_types.h
++++ b/tools/build/cross-build/include/common/sys/_types.h
+@@ -47,3 +47,6 @@
+  * Neither GLibc nor macOS define __va_list but many FreeBSD headers require it.
+  */
+ typedef __builtin_va_list __va_list;
++
++typedef __UINTPTR_TYPE__ __uintptr_t;
++typedef __INTPTR_TYPE__ __intptr_t;
+--- a/tools/build/cross-build/include/common/sys/types.h
++++ b/tools/build/cross-build/include/common/sys/types.h
+@@ -49,9 +49,6 @@
+ #include <sys/sysmacros.h>
+ #endif
+ 
+-typedef __UINTPTR_TYPE__ __uintptr_t;
+-typedef __INTPTR_TYPE__ __intptr_t;
+-
+ /* needed for gencat */
+ typedef int __nl_item;
+ 
+--- a/tools/build/cross-build/include/linux/sys/types.h
++++ b/tools/build/cross-build/include/linux/sys/types.h
+@@ -39,6 +39,8 @@
+ 
+ #include_next <sys/types.h>
+ 
++#include <sys/_types.h>
++
+ #ifndef __size_t
+ typedef __SIZE_TYPE__ __size_t;
+ #endif
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch
new file mode 100644
index 000000000000..4bc21cf8eb14
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch
@@ -0,0 +1,40 @@
+diff --git a/tools/build/Makefile b/tools/build/Makefile
+index 948a5f9dfdb..592af84eeae 100644
+--- a/tools/build/Makefile
++++ b/tools/build/Makefile
+@@ -327,14 +327,14 @@ host-symlinks:
+ # and cross-tools stages. We do this here using mkdir since mtree may not exist
+ # yet (this happens if we are crossbuilding from Linux/Mac).
+ INSTALLDIR_LIST= \
+-	bin \
+-	lib/geom \
+-	usr/include/casper \
+-	usr/include/private/ucl \
+-	usr/include/private/zstd \
+-	usr/lib \
+-	usr/libdata/pkgconfig \
+-	usr/libexec
++	${BINDIR} \
++	${LIBDIR}/geom \
++	${INCLUDEDIR}/casper \
++	${INCLUDEDIR}/private/ucl \
++	${INCLUDEDIR}/private/zstd \
++	${LIBDIR} \
++	${LIBDIR}/libdata/pkgconfig \
++	${LIBEXECDIR}
+ 
+ installdirs:
+ 	mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,}
+@@ -352,9 +352,9 @@ installdirs:
+ 	    rm -rf "${DESTDIR}/${_dir}"; \
+ 	fi
+ .endfor
+-	ln -sfn bin ${DESTDIR}/sbin
+-	ln -sfn ../bin ${DESTDIR}/usr/bin
+-	ln -sfn ../bin ${DESTDIR}/usr/sbin
++	ln -sfn bin ${DESTDIR}/${SBINDIR}
++	ln -sfn ../bin ${DESTDIR}/${BINDIR}
++	ln -sfn ../bin ${DESTDIR}/${SBINDIR}
+ .for _group in ${INCSGROUPS:NINCS}
+ 	mkdir -p "${DESTDIR}/${${_group}DIR}"
+ .endfor
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch
new file mode 100644
index 000000000000..a69c5501ddd1
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch
@@ -0,0 +1,11 @@
+--- a/usr.bin/xinstall/Makefile	2023-09-23 19:18:49.165192183 -0700
++++ b/usr.bin/xinstall/Makefile	2023-12-06 17:06:57.836888028 -0700
+@@ -14,7 +14,7 @@
+ CFLAGS+=	-I${SRCTOP}/lib/libnetbsd
+ 
+ LIBADD=		md
+-CFLAGS+=	-DWITH_MD5 -DWITH_RIPEMD160
++CFLAGS+=		-I${BSDSRCDIR}/contrib/libc-vis -I${BSDSRCDIR}/lib/libnetbsd
+ 
+ .ifdef BOOTSTRAPPING
+ # For the bootstrap we disable copy_file_range()
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch
new file mode 100644
index 000000000000..4a69e85a986a
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch
@@ -0,0 +1,11 @@
+--- a/lib/libc/Makefile
++++ b/lib/libc/Makefile
+@@ -194,7 +194,7 @@ SUBDIR.${MK_TESTS}+= tests
+ # recording a build dependency
+ CFLAGS+= -I${SRCTOP}/lib/libutil
+ # Same issue with libm
+-MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
++MSUN_ARCH_SUBDIR = ${MACHINE_CPUARCH:S/i386/i387/}
+ # unfortunately msun/src contains both private and public headers
+ CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
+ .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch
new file mode 100644
index 000000000000..60176fb73cf7
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch
@@ -0,0 +1,10 @@
+--- a/lib/libc/Makefile
++++ b/lib/libc/Makefile
+@@ -58,7 +58,6 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
+ # Link with static libcompiler_rt.a.
+ #
+ LDFLAGS+= -nodefaultlibs
+-LIBADD+=	compiler_rt
+ 
+ .if ${MK_SSP} != "no" && \
+     (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch
new file mode 100644
index 000000000000..a7bd032d2be5
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch
@@ -0,0 +1,32 @@
+diff --git a/Makefile b/Makefile
+index 22710f3d933..22effc848cf 100644
+--- a/lib/libnetbsd/Makefile
++++ b/lib/libnetbsd/Makefile
+@@ -9,6 +9,26 @@ CFLAGS+=	-I${.CURDIR}
+ 
+ SRCS+=	efun.c sockaddr_snprintf.c strsuftoll.c util.c util.h
+ 
+-INTERNALLIB=
++INCSGROUPS= INCS SYSINCS NETINETINCS
++
++INCS+= \
++	glob.h \
++	pthread.h \
++	rmd160.h \
++	sha1.h \
++	sha2.h \
++	stdlib.h \
++	util.h
++
++SYSINCSDIR= ${INCLUDEDIR}/sys
++SYSINCS+= \
++	sys/cdefs.h \
++	sys/event.h \
++	sys/types.h \
++	sys/wait.h
++
++NETINETINCSDIR= ${INCLUDEDIR}/netinet
++NETINETINCS+= \
++	netinet/in.h
+ 
+ .include <bsd.lib.mk>
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch
new file mode 100644
index 000000000000..38e06682869f
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch
@@ -0,0 +1,11 @@
+--- a/lib/librpcsvc/Makefile
++++ b/lib/librpcsvc/Makefile
+@@ -20,7 +20,7 @@ OTHERSRCS+= yp_passwd.c yp_update.c
+ 
+ RPCCOM=	RPCGEN_CPP=${CPP:Q} rpcgen -C
+ 
+-INCDIRS= -I${SYSROOT:U${DESTDIR}}/usr/include/rpcsvc
++INCDIRS= -I${INCLUDEDIR}/rpcsvc
+ 
+ CFLAGS+= -DYP ${INCDIRS}
+ 
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch
new file mode 100644
index 000000000000..2a6e560d1d28
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch
@@ -0,0 +1,13 @@
+--- a/contrib/mtree/Makefile	2023-12-04 23:02:13.919144141 -0700
++++ b/contrib/mtree/Makefile		2023-12-04 23:02:58.371810109 -0700
+@@ -10,8 +10,8 @@
+ SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \
+        verify.c getid.c pack_dev.c only.c
+ .if (${HOSTPROG:U} == "")
+-DPADD+= ${LIBUTIL}
+-LDADD+= -lutil
++LIBADD+= ${LIBUTIL}
++#LIBADD+= -lutil
+ .endif
+
+ CPPFLAGS+=	-I${NETBSDSRCDIR}/sbin/mknod
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch
new file mode 100644
index 000000000000..985617ee0f45
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch
@@ -0,0 +1,11 @@
+--- a/etc/mtree/BSD.include.dist
++++ b/etc/mtree/BSD.include.dist
+@@ -3,7 +3,7 @@
+ # Please see the file src/etc/mtree/README before making changes to this file.
+ #
+ 
+-/set type=dir uname=root gname=wheel mode=0755
++/set type=dir
+ .
+     arpa
+     ..
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch
new file mode 100644
index 000000000000..45f0d0c51eec
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch
@@ -0,0 +1,10 @@
+--- a/libexec/rtld-elf/Makefile
++++ b/libexec/rtld-elf/Makefile
+@@ -86,7 +86,6 @@ 
+ 
+ # Some of the required math functions (div & mod) are implemented in
+ # libcompiler_rt on some architectures.
+-LIBADD+=	compiler_rt
+ 
+ .include <bsd.prog.mk>
+ ${PROG_FULL}:  ${VERSION_MAP}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch
new file mode 100644
index 000000000000..2356446baf85
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
+index c594724d814..d5287c7b992 100644
+--- a/sys/conf/newvers.sh
++++ b/sys/conf/newvers.sh
+@@ -177,7 +177,7 @@ u=${USER:-root}
+ d=$(pwd)
+ h=${HOSTNAME:-$(hostname)}
+ if [ -n "$SOURCE_DATE_EPOCH" ]; then
+-	if ! t=$(date -r $SOURCE_DATE_EPOCH 2>/dev/null); then
++	if ! t=$(date -d @$SOURCE_DATE_EPOCH 2>/dev/null); then
+ 		echo "Invalid SOURCE_DATE_EPOCH" >&2
+ 		exit 1
+ 	fi
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch
new file mode 100644
index 000000000000..5cf926d4519b
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch
@@ -0,0 +1,42 @@
+--- a/sys/modules/aesni/Makefile	2023-12-16 09:19:28.454892154 -0700
++++ b/sys/Modules/aesni/Makefile	2023-12-16 09:19:41.975047684 -0700
+@@ -1,6 +1,5 @@
+ 
+ .PATH: ${SRCTOP}/sys/crypto/aesni
+-.PATH: ${SRCTOP}/contrib/llvm-project/clang/lib/Headers
+ 
+ KMOD=	aesni
+ SRCS=	aesni.c
+@@ -39,8 +38,8 @@
+ aesni_ghash.o: aesni.h
+ aesni_wrap.o: aesni.h
+ aesni_ccm.o: aesni.h
+-intel_sha1.o: sha_sse.h immintrin.h shaintrin.h tmmintrin.h xmmintrin.h
+-intel_sha256.o: sha_sse.h immintrin.h shaintrin.h tmmintrin.h xmmintrin.h
++intel_sha1.o: sha_sse.h
++intel_sha256.o: sha_sse.h
+ 
+ .include <bsd.kmod.mk>
+ 
+diff --git a/sys/modules/blake2/Makefile b/sys/modules/blake2/Makefile
+index e4b3fb9f126..5bfd9c2ae02 100644
+--- a/sys/modules/blake2/Makefile
++++ b/sys/modules/blake2/Makefile
+@@ -3,7 +3,6 @@
+ .PATH:	${SRCTOP}/sys/contrib/libb2
+ .PATH:	${SRCTOP}/sys/crypto/blake2
+ .PATH:	${SRCTOP}/sys/opencrypto
+-.PATH:	${SRCTOP}/contrib/llvm-project/clang/lib/Headers
+ 
+ KMOD	= blake2
+ 
+@@ -64,8 +63,7 @@ ${src:S/.c/.o/}: ${src}
+ 	    -D_MM_MALLOC_H_INCLUDED -Wno-unused-function ${.IMPSRC}
+ 	${CTFCONVERT_CMD}
+ 
+-${src:S/.c/.o/}: intrin.h emmintrin.h tmmintrin.h smmintrin.h immintrin.h \
+-    x86intrin.h ${SRCS:M*.h}
++${src:S/.c/.o/}: ${SRCS:M*.h}
+ .endfor
+ 
+ # FreeBSD-specific sources:
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix
index 71ecef1bcae4..966489d9aef3 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix
@@ -1,7 +1,10 @@
 { buildPackages, freebsd-lib }:
 
 # Wrap NetBSD's install
-buildPackages.writeShellScriptBin "boot-install" (freebsd-lib.install-wrapper + ''
+buildPackages.writeShellScriptBin "boot-install" (
+  freebsd-lib.install-wrapper
+  + ''
 
-  ${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}"
-'')
+    ${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}"
+  ''
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix
index 5e4528fbf46a..f597d6e3705b 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix
@@ -1,102 +1,129 @@
-{ lib, stdenv, mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, boot-install
-, which
-, freebsd-lib
-, expat, zlib,
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  versionData,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  boot-install,
+  which,
+  freebsd-lib,
+  expat,
+  zlib,
 }:
 
 let
   inherit (freebsd-lib) mkBsdArch;
 in
 
-mkDerivation rec {
+mkDerivation {
   pname = "compat";
   path = "tools/build";
-  extraPaths = [
-    "lib/libc/db"
-    "lib/libc/stdlib" # getopt
-    "lib/libc/gen" # getcap
-    "lib/libc/locale" # rpmatch
-  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
-    "lib/libc/string" # strlcpy
-    "lib/libutil"
-  ] ++ [
-    "contrib/libc-pwcache"
-    "contrib/libc-vis"
-    "sys/libkern"
-    "sys/kern/subr_capability.c"
-
-    # Take only individual headers, or else we will clobber native libc, etc.
-
-    "sys/rpc/types.h"
-
-    # Listed in Makekfile as INC
-    "include/mpool.h"
-    "include/ndbm.h"
-    "include/err.h"
-    "include/stringlist.h"
-    "include/a.out.h"
-    "include/nlist.h"
-    "include/db.h"
-    "include/getopt.h"
-    "include/nl_types.h"
-    "include/elf.h"
-    "sys/sys/ctf.h"
-
-    # Listed in Makekfile as SYSINC
-
-    "sys/sys/capsicum.h"
-    "sys/sys/caprights.h"
-    "sys/sys/imgact_aout.h"
-    "sys/sys/nlist_aout.h"
-    "sys/sys/nv.h"
-    "sys/sys/dnv.h"
-    "sys/sys/cnv.h"
-
-    "sys/sys/elf32.h"
-    "sys/sys/elf64.h"
-    "sys/sys/elf_common.h"
-    "sys/sys/elf_generic.h"
-    "sys/${mkBsdArch stdenv}/include"
-  ] ++ lib.optionals stdenv.hostPlatform.isx86 [
-    "sys/x86/include"
-  ] ++ [
-
-    "sys/sys/queue.h"
-    "sys/sys/md5.h"
-    "sys/sys/sbuf.h"
-    "sys/sys/tree.h"
-    "sys/sys/font.h"
-    "sys/sys/consio.h"
-    "sys/sys/fnv_hash.h"
-
-    "sys/crypto/chacha20/_chacha.h"
-    "sys/crypto/chacha20/chacha.h"
-    # included too, despite ".c"
-    "sys/crypto/chacha20/chacha.c"
-
-    "sys/fs"
-    "sys/ufs"
-    "sys/sys/disk"
-
-    "lib/libcapsicum"
-    "lib/libcasper"
-  ];
-
-  patches = [
-    ./compat-install-dirs.patch
-    ./compat-fix-typedefs-locations.patch
-  ];
-
-  preBuild = ''
-    NIX_CFLAGS_COMPILE+=' -I../../include -I../../sys'
-
-    cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys
-    cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys/${mkBsdArch stdenv}
-  '' + lib.optionalString stdenv.hostPlatform.isx86 ''
-    cp ../../sys/x86/include/elf.h ../../sys/x86
-  '';
+  extraPaths =
+    [
+      "lib/libc/db"
+      "lib/libc/stdlib" # getopt
+      "lib/libc/gen" # getcap
+      "lib/libc/locale" # rpmatch
+    ]
+    ++ lib.optionals stdenv.hostPlatform.isLinux [
+      "lib/libc/string" # strlcpy
+      "lib/libutil"
+    ]
+    ++ [
+      "contrib/libc-pwcache"
+      "contrib/libc-vis"
+      "sys/libkern"
+      "sys/kern/subr_capability.c"
+
+      # Take only individual headers, or else we will clobber native libc, etc.
+
+      "sys/rpc/types.h"
+    ]
+    ++ lib.optionals (versionData.major == 14) [ "sys/sys/bitcount.h" ]
+    ++ [
+
+      # Listed in Makekfile as INC
+      "include/mpool.h"
+      "include/ndbm.h"
+      "include/err.h"
+      "include/stringlist.h"
+      "include/a.out.h"
+      "include/nlist.h"
+      "include/db.h"
+      "include/getopt.h"
+      "include/nl_types.h"
+      "include/elf.h"
+      "sys/sys/ctf.h"
+    ]
+    ++ lib.optionals (versionData.major == 14) [
+      "include/bitstring.h"
+      "sys/sys/bitstring.h"
+      "sys/sys/nv_namespace.h"
+    ]
+    ++ [
+
+      # Listed in Makekfile as SYSINC
+
+      "sys/sys/capsicum.h"
+      "sys/sys/caprights.h"
+      "sys/sys/imgact_aout.h"
+      "sys/sys/nlist_aout.h"
+      "sys/sys/nv.h"
+      "sys/sys/dnv.h"
+      "sys/sys/cnv.h"
+
+      "sys/sys/elf32.h"
+      "sys/sys/elf64.h"
+      "sys/sys/elf_common.h"
+      "sys/sys/elf_generic.h"
+      "sys/${mkBsdArch stdenv}/include"
+    ]
+    ++ lib.optionals stdenv.hostPlatform.isx86 [ "sys/x86/include" ]
+    ++ [
+
+      "sys/sys/queue.h"
+      "sys/sys/md5.h"
+      "sys/sys/sbuf.h"
+      "sys/sys/tree.h"
+      "sys/sys/font.h"
+      "sys/sys/consio.h"
+      "sys/sys/fnv_hash.h"
+      #"sys/sys/cdefs.h"
+      #"sys/sys/param.h"
+      "sys/sys/_null.h"
+      #"sys/sys/types.h"
+      "sys/sys/_pthreadtypes.h"
+      "sys/sys/_stdint.h"
+
+      "sys/crypto/chacha20/_chacha.h"
+      "sys/crypto/chacha20/chacha.h"
+      # included too, despite ".c"
+      "sys/crypto/chacha20/chacha.c"
+
+      "sys/fs"
+      "sys/ufs"
+      "sys/sys/disk"
+
+      "lib/libcapsicum"
+      "lib/libcasper"
+      "lib/libmd"
+
+      # idk bro
+      "sys/sys/kbio.h"
+    ];
+
+  preBuild =
+    ''
+      NIX_CFLAGS_COMPILE+=' -I../../include -I../../sys'
+
+      cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys
+      cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys/${mkBsdArch stdenv}
+    ''
+    + lib.optionalString stdenv.hostPlatform.isx86 ''
+      cp ../../sys/x86/include/elf.h ../../sys/x86
+    '';
 
   setupHooks = [
     ../../../../../build-support/setup-hooks/role.bash
@@ -109,13 +136,17 @@ mkDerivation rec {
   '';
 
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
+    bsdSetupHook
+    freebsdSetupHook
     makeMinimal
     boot-install
 
     which
   ];
-  buildInputs = [ expat zlib ];
+  buildInputs = [
+    expat
+    zlib
+  ];
 
   makeFlags = [
     "STRIP=-s" # flag to install, not command
@@ -124,12 +155,20 @@ mkDerivation rec {
     "INSTALL=boot-install"
   ];
 
-  preIncludes = ''
-    mkdir -p $out/{0,1}-include
-    cp --no-preserve=mode -r cross-build/include/common/* $out/0-include
-  '' + lib.optionalString stdenv.hostPlatform.isLinux ''
-    cp --no-preserve=mode -r cross-build/include/linux/* $out/1-include
-  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
-    cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include
-  '';
+  preIncludes =
+    ''
+      mkdir -p $out/{0,1}-include
+      cp --no-preserve=mode -r cross-build/include/common/* $out/0-include
+    ''
+    + lib.optionalString stdenv.hostPlatform.isLinux ''
+      cp --no-preserve=mode -r cross-build/include/linux/* $out/1-include
+    ''
+    + lib.optionalString stdenv.hostPlatform.isDarwin ''
+      cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include
+    '';
+
+  # Compat is for making other platforms look like FreeBSD (e.g. to
+  # build build-time dependencies for building FreeBSD packages). It is
+  # not needed when building for FreeBSD.
+  meta.broken = stdenv.hostPlatform.isFreeBSD;
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/config.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/config.nix
index 641cfc46b4e9..f7ba273ed558 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/config.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/config.nix
@@ -1,17 +1,35 @@
-{ mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
-, flex, byacc, file2c
-, compatIfNeeded, libnv, libsbuf
+{
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  flex,
+  byacc,
+  file2c,
+  compatIfNeeded,
+  libnv,
+  libsbuf,
 }:
 
 mkDerivation {
   path = "usr.sbin/config";
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
+    bsdSetupHook
+    freebsdSetupHook
+    makeMinimal
+    install
+    mandoc
+    groff
 
-    flex byacc file2c
+    flex
+    byacc
+    file2c
+  ];
+  buildInputs = compatIfNeeded ++ [
+    libnv
+    libsbuf
   ];
-  buildInputs = compatIfNeeded ++ [ libnv libsbuf ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix
index 0b17cb1c8481..0f74d78b1d13 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix
@@ -1,23 +1,32 @@
-{ lib, mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal
-, install
-, flex, byacc, gencat
-, include
+{
+  lib,
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  flex,
+  byacc,
+  gencat,
+  include,
 }:
 
 mkDerivation {
+  isStatic = true;
   path = "lib/csu";
   extraPaths = [
     "lib/Makefile.inc"
     "lib/libc/include/libc_private.h"
   ];
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
+    bsdSetupHook
+    freebsdSetupHook
     makeMinimal
     install
 
-    flex byacc gencat
+    flex
+    byacc
+    gencat
   ];
   buildInputs = [ include ];
   MK_TESTS = "no";
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix
index 0aebc9b3d0b9..9e653bb4f51e 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix
@@ -1,7 +1,10 @@
-{ lib, stdenv, mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
-, compatIfNeeded, libelf, libdwarf, zlib, libspl
+{
+  lib,
+  mkDerivation,
+  compatIfNeeded,
+  libdwarf,
+  zlib,
+  libspl,
 }:
 
 mkDerivation {
@@ -15,14 +18,18 @@ mkDerivation {
   ];
   OPENSOLARIS_USR_DISTDIR = "$(SRCTOP)/cddl/contrib/opensolaris";
   OPENSOLARIS_SYS_DISTDIR = "$(SRCTOP)/sys/cddl/contrib/opensolaris";
-  nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
 
-    # flex byacc file2c
+  makeFlags = [
+    "STRIP=-s"
+    "MK_WERROR=no"
+    "MK_TESTS=no"
   ];
+
   buildInputs = compatIfNeeded ++ [
-    libelf libdwarf zlib libspl
+    libdwarf
+    zlib
+    libspl
   ];
+
   meta.license = lib.licenses.cddl;
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix
new file mode 100644
index 000000000000..dc215c18aecb
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix
@@ -0,0 +1,23 @@
+{
+  lib,
+  pkgsBuildBuild,
+  runCommand,
+  writeText,
+  source,
+}:
+
+{
+  pname,
+  path,
+  extraPaths ? [ ],
+}:
+
+let
+  sortedPaths = lib.naturalSort ([ path ] ++ extraPaths);
+  filterText = writeText "${pname}-src-include" (
+    lib.concatMapStringsSep "\n" (path: "/${path}") sortedPaths
+  );
+in
+runCommand "${pname}-filtered-src" { nativeBuildInputs = [ pkgsBuildBuild.rsync ]; } ''
+  rsync -a -r --files-from=${filterText} ${source}/ $out
+''
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/package.nix
index 430c4c5c43ac..ef4a14ccf4aa 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/package.nix
@@ -1,5 +1,3 @@
 { makeSetupHook }:
 
-makeSetupHook {
-  name = "freebsd-setup-hook";
-} ./setup-hook.sh
+makeSetupHook { name = "freebsd-setup-hook"; } ./setup-hook.sh
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh
index 929782954ba7..96a3d14c80f7 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh
@@ -5,7 +5,18 @@ setFreeBSDSrcTop() {
 addFreeBSDMakeFlags() {
   makeFlags="SBINDIR=${!outputBin}/bin $makeFlags"
   makeFlags="LIBEXECDIR=${!outputLib}/libexec $makeFlags"
+  makeFlags="LIBDATADIR=${!outputLib}/data $makeFlags"
   makeFlags="INCLUDEDIR=${!outputDev}/include $makeFlags"
+  makeFlags="CONFDIR=${!outputBin}/etc $makeFlags"
+  makeFlags="MANDIR=${!outputMan}/share/man/man $makeFlags"
+
+  if [ -n "$debug" ]; then
+    makeFlags="DEBUGFILEDIR=${debug}/lib/debug $makeFlags"
+  else
+    makeFlags="DEBUGFILEDIR=${out}/lib/debug $makeFlags"
+  fi
+
+  echo $makeFlags
 }
 
 postUnpackHooks+=(setFreeBSDSrcTop)
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/gencat.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/gencat.nix
index e9ae9f27cc05..ea701b6404ec 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/gencat.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/gencat.nix
@@ -1,5 +1,3 @@
 { mkDerivation }:
 
-mkDerivation {
-  path = "usr.bin/gencat";
-}
+mkDerivation { path = "usr.bin/gencat"; }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix
index 73fa887c5123..70734226a54f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix
@@ -1,12 +1,13 @@
-{ lib, mkDerivation
-, buildPackages
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal
-, install
-, mandoc, groff, rsync /*, nbperf*/, rpcgen
+{
+  lib,
+  mkDerivation,
+  buildPackages,
+  rpcgen,
+  mtree,
 }:
 
 mkDerivation {
+  isStatic = true;
   path = "include";
 
   extraPaths = [
@@ -15,18 +16,9 @@ mkDerivation {
     "sys"
   ];
 
-  nativeBuildInputs =  [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal
-    install
-    mandoc groff rsync /*nbperf*/ rpcgen
-
-    # HACK use NetBSD's for now
-    buildPackages.netbsd.mtree
-  ];
-
-  patches = [
-    ./no-perms-BSD.include.dist.patch
+  extraNativeBuildInputs = [
+    rpcgen
+    mtree
   ];
 
   # The makefiles define INCSDIR per subdirectory, so we have to set
@@ -37,11 +29,10 @@ mkDerivation {
       sed -i -E \
         -e 's_/usr/include_''${INCSDIR0}_' \
         {} \;
+    sed -E -i -e "/_PATH_LOGIN/d" $BSDSRCDIR/include/paths.h
   '';
 
-  makeFlags = [
-    "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp"
-  ];
+  makeFlags = [ "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" ];
 
   # multiple header dirs, see above
   postConfigure = ''
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/install.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/install.nix
index 3db6cd3633d4..b8e59adb09c5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/install.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/install.nix
@@ -1,41 +1,67 @@
-{ lib, stdenv, mkDerivation, writeShellScript
-, freebsd-lib
-, mtree
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, mandoc, groff
-, boot-install, install
-, compatIfNeeded, libmd, libnetbsd
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  writeShellScript,
+  freebsd-lib,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  mandoc,
+  groff,
+  boot-install,
+  install,
+  compatIfNeeded,
+  libmd,
+  libnetbsd,
 }:
 
 # HACK: to ensure parent directories exist. This emulates GNU
 # install’s -D option. No alternative seems to exist in BSD install.
 let
-  binstall = writeShellScript "binstall" (freebsd-lib.install-wrapper + ''
+  binstall = writeShellScript "binstall" (
+    freebsd-lib.install-wrapper
+    + ''
 
-    @out@/bin/xinstall "''${args[@]}"
-  '');
-in mkDerivation {
+      @out@/bin/xinstall "''${args[@]}"
+    ''
+  );
+in
+mkDerivation {
   path = "usr.bin/xinstall";
-  extraPaths = [ mtree.path ];
+  extraPaths = [ "contrib/mtree" ];
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal mandoc groff
-    (if stdenv.hostPlatform == stdenv.buildPlatform
-     then boot-install
-     else install)
+    bsdSetupHook
+    freebsdSetupHook
+    makeMinimal
+    mandoc
+    groff
+    (if stdenv.hostPlatform == stdenv.buildPlatform then boot-install else install)
   ];
   skipIncludesPhase = true;
-  buildInputs = compatIfNeeded ++ [ libmd libnetbsd ];
-  makeFlags = [
-    "STRIP=-s" # flag to install, not command
-    "MK_WERROR=no"
-    "TESTSDIR=${builtins.placeholder "test"}"
-  ] ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) "INSTALL=boot-install";
+  buildInputs = compatIfNeeded ++ [
+    libmd
+    libnetbsd
+  ];
+  makeFlags =
+    [
+      "STRIP=-s" # flag to install, not command
+      "MK_WERROR=no"
+      "TESTSDIR=${builtins.placeholder "test"}"
+    ]
+    ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
+      "BOOTSTRAPPING=1"
+      "INSTALL=boot-install"
+    ];
   postInstall = ''
-    install -D -m 0550 ${binstall} $out/bin/binstall
+    install -C -m 0550 ${binstall} $out/bin/binstall
     substituteInPlace $out/bin/binstall --subst-var out
     mv $out/bin/install $out/bin/xinstall
     ln -s ./binstall $out/bin/install
   '';
-  outputs = [ "out" "man" "test" ];
+  outputs = [
+    "out"
+    "man"
+    "test"
+  ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix
index 0225d44be4c3..8f2cc976463e 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix
@@ -1,79 +1,145 @@
-{ lib, stdenv, mkDerivation
+{
+  lib,
+  buildPackages,
+  stdenv,
+  mkDerivation,
 
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal
-, install
-, flex, byacc, gencat, rpcgen
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  flex,
+  byacc,
+  gencat,
+  rpcgen,
+  mkcsmapper,
+  mkesdb,
 
-, csu, include
+  csu,
+  include,
+  versionData,
 }:
 
-mkDerivation rec {
+mkDerivation {
+  isStatic = true;
   pname = "libc";
   path = "lib/libc";
-  extraPaths = [
-    "etc/group"
-    "etc/master.passwd"
-    "etc/shells"
-    "lib/libmd"
-    "lib/libutil"
-    "lib/msun"
-    "sys/kern"
-    "sys/libkern"
-    "sys/sys"
-    "sys/crypto/chacha20"
-    "include/rpcsvc"
-    "contrib/jemalloc"
-    "contrib/gdtoa"
-    "contrib/libc-pwcache"
-    "contrib/libc-vis"
-    "contrib/tzcode/stdtime"
-
-    # libthr
-    "lib/libthr"
-    "lib/libthread_db"
-    "libexec/rtld-elf"
-
-    # librpcsvc
-    "lib/librpcsvc"
-
-    # librt
-    "lib/librt"
-
-    # libcrypt
-    "lib/libcrypt"
-    "lib/libmd"
-    "sys/crypto/sha2"
-  ];
+  extraPaths =
+    [
+      "lib/libc_nonshared"
+      "etc/group"
+      "etc/master.passwd"
+      "etc/shells"
+      "lib/libmd"
+      "lib/libutil"
+      "lib/msun"
+      "sys/kern"
+      "sys/libkern"
+      "sys/sys"
+      "sys/crypto/chacha20"
+      "include/rpcsvc"
+      "contrib/jemalloc"
+      "contrib/gdtoa"
+      "contrib/libc-pwcache"
+      "contrib/libc-vis"
+    ]
+    ++ lib.optionals (versionData.major == 13) [ "contrib/tzcode/stdtime" ]
+    ++ lib.optionals (versionData.major == 14) [ "contrib/tzcode" ]
+    ++ [
 
-  patches = [
-    # Hack around broken propogating MAKEFLAGS to submake, just inline logic
-    ./libc-msun-arch-subdir.patch
+      # libthr
+      "lib/libthr"
+      "lib/libthread_db"
+      "libexec/rtld-elf"
+      "lib/csu/common/crtbrand.S"
+      "lib/csu/common/notes.h"
 
-    # Don't force -lcompiler-rt, we don't actually call it that
-    ./libc-no-force--lcompiler-rt.patch
+      # librpcsvc
+      "lib/librpcsvc"
 
-    # Fix extra include dir to get rpcsvc headers.
-    ./librpcsvc-include-subdir.patch
-  ];
+      # librt
+      "lib/librt"
+
+      # libcrypt
+      "lib/libcrypt"
+      "lib/libmd"
+      "sys/crypto/sha2"
+      "sys/crypto/skein"
+
+      # libgcc and friends
+      "lib/libgcc_eh"
+      "lib/libgcc_s"
+      "lib/libcompiler_rt"
+      "contrib/llvm-project/libunwind"
+      "contrib/llvm-project/compiler-rt"
+      #"contrib/llvm-project/libcxx"
+
+      # terminfo
+      "lib/ncurses"
+      "contrib/ncurses"
+      "lib/Makefile.inc"
+    ]
+    ++ lib.optionals (stdenv.hostPlatform.isx86_32) [ "lib/libssp_nonshared" ]
+    ++ [
+      "lib/libexecinfo"
+      "contrib/libexecinfo"
+
+      "lib/libkvm"
+      "sys" # ummmmmmmmmm libkvm wants arch-specific headers from the kernel tree
+
+      "lib/libmemstat"
+
+      "lib/libprocstat"
+      "sys/contrib/openzfs"
+      "sys/contrib/pcg-c"
+      "sys/opencrypto"
+      "sys/contrib/ck"
+      "sys/crypto"
+
+      "lib/libdevstat"
+
+      "lib/libelf"
+      "contrib/elftoolchain"
+
+      "lib/libiconv_modules"
+      "share/i18n"
+      "include/paths.h"
+
+      "lib/libdl"
+    ];
 
   postPatch = ''
     substituteInPlace $COMPONENT_PATH/Makefile --replace '.include <src.opts.mk>' ""
+
+    substituteInPlace $BSDSRCDIR/include/paths.h \
+        --replace '/usr/lib/i18n' '${builtins.placeholder "out"}/lib/i18n' \
+        --replace '/usr/share/i18n' '${builtins.placeholder "out"}/share/i18n'
   '';
 
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
+    bsdSetupHook
+    freebsdSetupHook
     makeMinimal
     install
 
-    flex byacc gencat rpcgen
+    flex
+    byacc
+    gencat
+    rpcgen
+    mkcsmapper
+    mkesdb
+  ];
+  buildInputs = [
+    include
+    csu
+  ];
+  env.NIX_CFLAGS_COMPILE = toString [
+    "-B${csu}/lib"
+    # These are supposed to have _RTLD_COMPAT_LIB_SUFFIX so we can get things like "lib32"
+    # but that's unnecessary
+    "-DSTANDARD_LIBRARY_PATH=\"${builtins.placeholder "out"}/lib\""
+    "-D_PATH_RTLD=\"${builtins.placeholder "out"}/libexec/ld-elf.so.1\""
   ];
-  buildInputs = [ include csu ];
-  env.NIX_CFLAGS_COMPILE = "-B${csu}/lib";
-
-  # Suppress lld >= 16 undefined version errors
-  # https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638
-  env.NIX_LDFLAGS = lib.optionalString (stdenv.targetPlatform.linker == "lld") "--undefined-version";
 
   makeFlags = [
     "STRIP=-s" # flag to install, not command
@@ -84,7 +150,7 @@ mkDerivation rec {
   MK_SYMVER = "yes";
   MK_SSP = "yes";
   MK_NLS = "yes";
-  MK_ICONV = "no"; # TODO make srctop
+  MK_ICONV = "yes";
   MK_NS_CACHING = "yes";
   MK_INET6_SUPPORT = "yes";
   MK_HESIOD = "yes";
@@ -96,44 +162,125 @@ mkDerivation rec {
   MK_MALLOC_PRODUCTION = "yes";
 
   MK_TESTS = "no";
+  MACHINE_ABI = "";
+  MK_DETECT_TZ_CHANGES = "no";
+  MK_MACHDEP_OPTIMIZATIONS = "yes";
+  MK_ASAN = "no";
+  MK_UBSAN = "no";
+
+  NO_FSCHG = "yes";
+
+  preBuild = lib.optionalString (stdenv.hostPlatform.isx86_32) ''
+    make -C $BSDSRCDIR/lib/libssp_nonshared $makeFlags
+    make -C $BSDSRCDIR/lib/libssp_nonshared $makeFlags install
+  '';
+
+  postInstall =
+    ''
+      pushd ${include}
+      find . -type d -exec mkdir -p $out/\{} \;
+      find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
+      popd
+
+      pushd ${csu}
+      find . -type d -exec mkdir -p $out/\{} \;
+      find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
+      popd
+
+      mkdir $BSDSRCDIR/lib/libcompiler_rt/i386
+      make -C $BSDSRCDIR/lib/libcompiler_rt $makeFlags
+      make -C $BSDSRCDIR/lib/libcompiler_rt $makeFlags install
+
+      make -C $BSDSRCDIR/lib/libgcc_eh $makeFlags
+      make -C $BSDSRCDIR/lib/libgcc_eh $makeFlags install
+
+      ln -s $BSDSRCDIR/lib/libc/libc.so.7 $BSDSRCDIR/lib/libc/libc.so  # not sure
+      mkdir $BSDSRCDIR/lib/libgcc_s/i386
+      make -C $BSDSRCDIR/lib/libgcc_s $makeFlags
+      make -C $BSDSRCDIR/lib/libgcc_s $makeFlags install
+
+      NIX_CFLAGS_COMPILE+=" -B$out/lib"
+      NIX_CFLAGS_COMPILE+=" -I$out/include"
+      NIX_LDFLAGS+=" -L$out/lib"
+
+      make -C $BSDSRCDIR/lib/libc_nonshared $makeFlags
+      make -C $BSDSRCDIR/lib/libc_nonshared $makeFlags install
+
+      mkdir $BSDSRCDIR/lib/libmd/sys
+      make -C $BSDSRCDIR/lib/libmd $makeFlags
+      make -C $BSDSRCDIR/lib/libmd $makeFlags install
 
-  postInstall = ''
-    pushd ${include}
-    find . -type d -exec mkdir -p $out/\{} \;
-    find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
-    popd
+      make -C $BSDSRCDIR/lib/libthr $makeFlags
+      make -C $BSDSRCDIR/lib/libthr $makeFlags install
 
-    pushd ${csu}
-    find . -type d -exec mkdir -p $out/\{} \;
-    find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
-    popd
+      make -C $BSDSRCDIR/lib/msun $makeFlags
+      make -C $BSDSRCDIR/lib/msun $makeFlags install
 
-    sed -i -e 's| [^ ]*/libc_nonshared.a||' $out/lib/libc.so
+      make -C $BSDSRCDIR/lib/librpcsvc $makeFlags
+      make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install
 
-    $CC -nodefaultlibs -lgcc -shared -o $out/lib/libgcc_s.so
+      make -C $BSDSRCDIR/lib/libutil $makeFlags
+      make -C $BSDSRCDIR/lib/libutil $makeFlags install
 
-    NIX_CFLAGS_COMPILE+=" -B$out/lib"
-    NIX_CFLAGS_COMPILE+=" -I$out/include"
-    NIX_LDFLAGS+=" -L$out/lib"
+      make -C $BSDSRCDIR/lib/librt $makeFlags
+      make -C $BSDSRCDIR/lib/librt $makeFlags install
 
-    make -C $BSDSRCDIR/lib/libthr $makeFlags
-    make -C $BSDSRCDIR/lib/libthr $makeFlags install
+      make -C $BSDSRCDIR/lib/libcrypt $makeFlags
+      make -C $BSDSRCDIR/lib/libcrypt $makeFlags install
 
-    make -C $BSDSRCDIR/lib/msun $makeFlags
-    make -C $BSDSRCDIR/lib/msun $makeFlags install
+      make -C $BSDSRCDIR/lib/libelf $makeFlags
+      make -C $BSDSRCDIR/lib/libelf $makeFlags install
 
-    make -C $BSDSRCDIR/lib/librpcsvc $makeFlags
-    make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install
+      make -C $BSDSRCDIR/lib/libexecinfo $makeFlags
+      make -C $BSDSRCDIR/lib/libexecinfo $makeFlags install
 
-    make -C $BSDSRCDIR/lib/libutil $makeFlags
-    make -C $BSDSRCDIR/lib/libutil $makeFlags install
+      make -C $BSDSRCDIR/lib/libkvm $makeFlags
+      make -C $BSDSRCDIR/lib/libkvm $makeFlags install
 
-    make -C $BSDSRCDIR/lib/librt $makeFlags
-    make -C $BSDSRCDIR/lib/librt $makeFlags install
+      make -C $BSDSRCDIR/lib/libmemstat $makeFlags
+      make -C $BSDSRCDIR/lib/libmemstat $makeFlags install
 
-    make -C $BSDSRCDIR/lib/libcrypt $makeFlags
-    make -C $BSDSRCDIR/lib/libcrypt $makeFlags install
+      make -C $BSDSRCDIR/lib/libprocstat $makeFlags
+      make -C $BSDSRCDIR/lib/libprocstat $makeFlags install
+
+      make -C $BSDSRCDIR/lib/libdevstat $makeFlags
+      make -C $BSDSRCDIR/lib/libdevstat $makeFlags install
+
+      make -C $BSDSRCDIR/lib/libiconv_modules $makeFlags
+      make -C $BSDSRCDIR/lib/libiconv_modules $makeFlags SHLIBDIR=${builtins.placeholder "out"}/lib/i18n install
+
+      make -C $BSDSRCDIR/lib/libdl $makeFlags
+      make -C $BSDSRCDIR/lib/libdl $makeFlags install
+
+      make -C $BSDSRCDIR/share/i18n $makeFlags
+      make -C $BSDSRCDIR/share/i18n $makeFlags ESDBDIR=${builtins.placeholder "out"}/share/i18n/esdb CSMAPPERDIR=${builtins.placeholder "out"}/share/i18n/csmapper install
+
+    ''
+    + lib.optionalString stdenv.hostPlatform.isx86_32 ''
+      $CC -c $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.c -o $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.o
+      ORIG_NIX_LDFLAGS="$NIX_LDFLAGS"
+      NIX_LDFLAGS+=" $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.o"
+    ''
+    + ''
+      make -C $BSDSRCDIR/libexec/rtld-elf $makeFlags
+      make -C $BSDSRCDIR/libexec/rtld-elf $makeFlags install
+      rm -f $out/libexec/ld-elf.so.1
+      mv $out/bin/ld-elf.so.1 $out/libexec
+    '';
+
+  # libc should not be allowed to refer to anything other than itself
+  postFixup = ''
+    find $out -type f | xargs -n1 ${buildPackages.patchelf}/bin/patchelf --shrink-rpath --allowed-rpath-prefixes $out || true
   '';
 
   meta.platforms = lib.platforms.freebsd;
+
+  # definitely a bad idea to enable stack protection on the stack protection initializers
+  hardeningDisable = [ "stackprotector" ];
+
+  outputs = [
+    "out"
+    "man"
+    "debug"
+  ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix
index 9fc8fc5f9a62..ee4d57b021b1 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix
@@ -1,8 +1,8 @@
-{ lib, stdenv, mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
-, m4
-, compatIfNeeded, libelf
+{
+  mkDerivation,
+  m4,
+  compatIfNeeded,
+  zlib,
 }:
 
 mkDerivation {
@@ -14,14 +14,7 @@ mkDerivation {
     "sys/sys/elf64.h"
     "sys/sys/elf_common.h"
   ];
-  nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
-
-    m4
-  ];
-  buildInputs = compatIfNeeded ++ [
-    libelf
-  ];
+  extraNativeBuildInputs = [ m4 ];
+  buildInputs = compatIfNeeded ++ [ zlib ];
   MK_TESTS = "no";
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix
deleted file mode 100644
index a44ce1685e57..000000000000
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-{ lib, stdenv, mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
-, m4
-}:
-
-mkDerivation {
-  path = "lib/libelf";
-  extraPaths = [
-    "contrib/elftoolchain/libelf"
-    "contrib/elftoolchain/common"
-    "sys/sys/elf32.h"
-    "sys/sys/elf64.h"
-    "sys/sys/elf_common.h"
-  ];
-  BOOTSTRAPPING = !stdenv.isFreeBSD;
-  nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
-
-    m4
-  ];
-  MK_TESTS = "no";
-}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix
new file mode 100644
index 000000000000..71d0c1e50d5e
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix
@@ -0,0 +1,49 @@
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  freebsdSetupHook,
+  bsdSetupHook,
+  makeMinimal,
+}:
+mkDerivation {
+  path = "lib/libmd";
+  extraPaths = [
+    "sys/sys/md5.h"
+    "sys/crypto/sha2"
+    "sys/crypto/skein"
+  ];
+  nativeBuildInputs = [
+    makeMinimal
+    bsdSetupHook
+    freebsdSetupHook
+  ];
+
+  makeFlags = [
+    "STRIP=-s" # flag to install, not command
+    "RELDIR=."
+  ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no";
+
+  preBuild = ''
+    mkdir sys
+  '';
+
+  installPhase = ''
+    # libmd is used by install. do it yourself!
+    mkdir -p $out/include $out/lib $man/share/man
+    cp libmd.a $out/lib/libmd.a
+    for f in $(make $makeFlags -V INCS); do
+      if [ -e "$f" ]; then cp "$f" "$out/include/$f"; fi
+      if [ -e "$BSDSRCDIR/sys/crypto/sha2/$f" ]; then cp "$BSDSRCDIR/sys/crypto/sha2/$f" "$out/include/$f"; fi
+      if [ -e "$BSDSRCDIR/sys/crypto/skein/$f" ]; then cp "$BSDSRCDIR/sys/crypto/skein/$f" "$out/include/$f"; fi
+    done
+    for f in $(make $makeFlags -V MAN); do
+      cp "$f" "$man/share/man/$f"
+    done
+  '';
+
+  outputs = [
+    "out"
+    "man"
+  ];
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix
index 4011e4d8a649..82a9e140102f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix
@@ -1,26 +1,28 @@
-{ lib, stdenv
-, mkDerivation
-, bsdSetupHook, freebsdSetupHook, makeMinimal, mandoc, groff
-, boot-install, install
-, compatIfNeeded
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  mandoc,
+  groff,
+  boot-install,
+  install,
 }:
 
 mkDerivation {
   path = "lib/libnetbsd";
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal mandoc groff
-    (if stdenv.hostPlatform == stdenv.buildPlatform
-     then boot-install
-     else install)
-  ];
-  patches = lib.optionals (!stdenv.hostPlatform.isFreeBSD) [
-    ./libnetbsd-do-install.patch
-    #./libnetbsd-define-__va_list.patch
+    bsdSetupHook
+    freebsdSetupHook
+    makeMinimal
+    mandoc
+    groff
+    (if stdenv.hostPlatform == stdenv.buildPlatform then boot-install else install)
   ];
   makeFlags = [
     "STRIP=-s" # flag to install, not command
     "MK_WERROR=no"
   ] ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) "INSTALL=boot-install";
-  buildInputs = compatIfNeeded;
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libsbuf.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libsbuf.nix
index 719474dbb11a..242492a3f2f2 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libsbuf.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libsbuf.nix
@@ -2,8 +2,6 @@
 
 mkDerivation {
   path = "lib/libsbuf";
-  extraPaths = [
-    "sys/kern"
-  ];
+  extraPaths = [ "sys/kern" ];
   MK_TESTS = "no";
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix
index da5445a09fcd..c444975549ad 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix
@@ -3,19 +3,20 @@
 mkDerivation {
   path = "cddl/lib/libspl";
   extraPaths = [
-    "sys/contrib/openzfs/lib/libspl"
-    "sys/contrib/openzfs/include"
-
     "cddl/compat/opensolaris/include"
+    "sys/contrib/openzfs/include"
+    "sys/contrib/openzfs/lib/libspl"
     "sys/contrib/openzfs/module/icp/include"
-    "sys/modules/zfs"
+    "sys/modules/zfs/zfs_config.h"
   ];
-  # nativeBuildInputs = [
-  #   bsdSetupHook freebsdSetupHook
-  #   makeMinimal install mandoc groff
 
-  #   flex byacc file2c
-  # ];
-  # buildInputs = compatIfNeeded ++ [ libnv libsbuf ];
-  meta.license = lib.licenses.cddl;
+  # Without a prefix it will try to put object files in nonexistant directories
+  preBuild = ''
+    export MAKEOBJDIRPREFIX=$TMP/obj
+  '';
+
+  meta = with lib; {
+    platform = platforms.freebsd;
+    license = licenses.cddl;
+  };
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix
index c420d0daf852..6df6fa740f45 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix
@@ -1,7 +1,10 @@
-{ mkDerivation, lib, stdenv }:
+{
+  mkDerivation,
+  lib,
+  stdenv,
+}:
 mkDerivation {
   path = "lib/libutil";
-  extraPaths = ["lib/libc/gen"];
-  clangFixup = true;
+  extraPaths = [ "lib/libc/gen" ];
   MK_TESTS = "no";
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix
index d1fd86ab5e46..25e7f491a1c9 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix
@@ -1,8 +1,9 @@
-{ mkDerivation
-, bsdSetupHook, freebsdSetupHook
+{
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
 }:
-
-mkDerivation rec {
+mkDerivation {
   path = "usr.bin/lorder";
   noCC = true;
   dontBuild = true;
@@ -13,8 +14,12 @@ mkDerivation rec {
     mv "lorder.1" "$man/share/man"
   '';
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
+    bsdSetupHook
+    freebsdSetupHook
+  ];
+  buildInputs = [ ];
+  outputs = [
+    "out"
+    "man"
   ];
-  buildInputs = [];
-  outputs = [ "out" "man" ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/make.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/make.nix
index fa1722cfec22..ecf231c30414 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/make.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/make.nix
@@ -1,20 +1,25 @@
-{ lib, mkDerivation, stdenv }:
+{
+  lib,
+  mkDerivation,
+  stdenv,
+}:
 
 mkDerivation {
   path = "contrib/bmake";
   version = "9.2";
-  postPatch = ''
-    # make needs this to pick up our sys make files
-    export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
+  postPatch =
+    ''
+      # make needs this to pick up our sys make files
+      export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
 
-  '' + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
-      --replace '-Wl,--fatal-warnings' "" \
-      --replace '-Wl,--warn-shared-textrel' ""
-  '';
+    ''
+    + lib.optionalString stdenv.isDarwin ''
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
+        --replace '-Wl,--fatal-warnings' "" \
+        --replace '-Wl,--warn-shared-textrel' ""
+    '';
   postInstall = ''
     make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install
   '';
-  extraPaths = [ "share/mk" ]
-    ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "tools/build/mk";
+  extraPaths = [ "share/mk" ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "tools/build/mk";
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix
index e6a8e38a4ace..069e74474852 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix
@@ -1,25 +1,32 @@
-{ lib, stdenv, mkDerivation
-, make
-, bsdSetupHook, freebsdSetupHook
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  make,
+  bsdSetupHook,
+  freebsdSetupHook,
 }:
 
-mkDerivation rec {
+mkDerivation {
   inherit (make) path;
 
-  buildInputs = [];
+  buildInputs = [ ];
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
+    bsdSetupHook
+    freebsdSetupHook
   ];
 
   skipIncludesPhase = true;
 
-  makeFlags = [];
+  makeFlags = [ ];
 
   postPatch = ''
     patchShebangs configure
     ${make.postPatch}
   '';
 
+  configureFlags = [ "--with-filemon=no" ];
+
   buildPhase = ''
     runHook preBuild
 
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix
index 79428626b8ec..be195b3bc6fa 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix
@@ -1,78 +1,164 @@
-{ lib, stdenv, stdenvNoCC
-, compatIfNeeded
-, runCommand, rsync
-, freebsd-lib
-, source
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal
-, install, tsort, lorder, mandoc, groff
+{
+  lib,
+  stdenv,
+  stdenvNoCC,
+  versionData,
+  writeText,
+  patches,
+  compatIfNeeded,
+  freebsd-lib,
+  filterSource,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  mandoc,
+  groff,
 }:
 
-lib.makeOverridable (attrs: let
-  stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
-in stdenv'.mkDerivation (rec {
-  pname = "${attrs.pname or (baseNameOf attrs.path)}-freebsd";
-  inherit (freebsd-lib) version;
-  src = runCommand "${pname}-filtered-src" {
-    nativeBuildInputs = [ rsync ];
-  } ''
-    for p in ${lib.concatStringsSep " " ([ attrs.path ] ++ attrs.extraPaths or [])}; do
-      set -x
-      path="$out/$p"
-      mkdir -p "$(dirname "$path")"
-      src_path="${source}/$p"
-      if [[ -d "$src_path" ]]; then src_path+=/; fi
-      rsync --chmod="+w" -r "$src_path" "$path"
-      set +x
-    done
-  '';
+lib.makeOverridable (
+  attrs:
+  let
+    stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
+  in
+  stdenv'.mkDerivation (
+    rec {
+      inherit (freebsd-lib) version;
+      pname = "${attrs.pname or (baseNameOf attrs.path)}";
+      src = filterSource {
+        inherit pname;
+        inherit (attrs) path;
+        extraPaths = attrs.extraPaths or [ ];
+      };
 
-  extraPaths = [ ];
+      nativeBuildInputs = [
+        bsdSetupHook
+        freebsdSetupHook
+        makeMinimal
+        install
+        tsort
+        lorder
+        mandoc
+        groff
+      ] ++ attrs.extraNativeBuildInputs or [ ];
+      buildInputs = compatIfNeeded;
 
-  nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal
-    install tsort lorder mandoc groff #statHook
-  ];
-  buildInputs = compatIfNeeded;
+      HOST_SH = stdenv'.shell;
 
-  HOST_SH = stdenv'.shell;
+      # Since STRIP below is the flag
+      STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip";
 
-  # Since STRIP below is the flag
-  STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip";
+      makeFlags = [
+        "STRIP=-s" # flag to install, not command
+      ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no";
 
-  makeFlags = [
-    "STRIP=-s" # flag to install, not command
-  ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no";
+      # amd64 not x86_64 for this on unlike NetBSD
+      MACHINE_ARCH = freebsd-lib.mkBsdArch stdenv';
 
-  # amd64 not x86_64 for this on unlike NetBSD
-  MACHINE_ARCH = freebsd-lib.mkBsdArch stdenv';
+      MACHINE = freebsd-lib.mkBsdArch stdenv';
 
-  MACHINE = freebsd-lib.mkBsdArch stdenv';
+      MACHINE_CPUARCH = MACHINE_ARCH;
 
-  MACHINE_CPUARCH = MACHINE_ARCH;
+      COMPONENT_PATH = attrs.path or null;
 
-  COMPONENT_PATH = attrs.path or null;
+      strictDeps = true;
 
-  strictDeps = true;
-
-  meta = with lib; {
-    maintainers = with maintainers; [ ericson2314 ];
-    platforms = platforms.unix;
-    license = licenses.bsd2;
-  };
-} // lib.optionalAttrs stdenv'.hasCC {
-  # TODO should CC wrapper set this?
-  CPP = "${stdenv'.cc.targetPrefix}cpp";
-} // lib.optionalAttrs stdenv'.isDarwin {
-  MKRELRO = "no";
-} // lib.optionalAttrs (stdenv'.cc.isClang or false) {
-  HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
-} // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
-  HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
-} // lib.optionalAttrs (stdenv'.isx86_32) {
-  USE_SSP = "no";
-} // lib.optionalAttrs (attrs.headersOnly or false) {
-  installPhase = "includesPhase";
-  dontBuild = true;
-} // attrs))
+      meta =
+        with lib;
+        {
+          maintainers = with maintainers; [
+            rhelmot
+            artemist
+          ];
+          platforms = platforms.unix;
+          license = licenses.bsd2;
+        }
+        // attrs.meta or { };
+    }
+    // lib.optionalAttrs stdenv'.hasCC {
+      # TODO should CC wrapper set this?
+      CPP = "${stdenv'.cc.targetPrefix}cpp";
+    }
+    // lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
+    // lib.optionalAttrs (stdenv'.cc.isClang or false) {
+      HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
+    }
+    // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
+      HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
+    }
+    // lib.optionalAttrs (stdenv'.isx86_32) { USE_SSP = "no"; }
+    // lib.optionalAttrs (attrs.headersOnly or false) {
+      installPhase = "includesPhase";
+      dontBuild = true;
+    }
+    // attrs
+    // lib.optionalAttrs (stdenv'.hasCC && stdenv'.cc.isClang or false && attrs.clangFixup or true) {
+      preBuild =
+        ''
+          export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -D_SIZE_T_DECLARED -D_SIZE_T -Dsize_t=__SIZE_TYPE__ -D_WCHAR_T"
+        ''
+        + lib.optionalString (versionData.major == 13) ''
+          export NIX_LDFLAGS="$NIX_LDFLAGS --undefined-version"
+        ''
+        + (attrs.preBuild or "");
+    }
+    // {
+      patches =
+        let
+          isDir =
+            file:
+            let
+              base = baseNameOf file;
+              type = (builtins.readDir (dirOf file)).${base} or null;
+            in
+            file == /. || type == "directory";
+          consolidatePatches =
+            patches:
+            if (lib.isDerivation patches) then
+              [ patches ]
+            else if (builtins.isPath patches) then
+              (if (isDir patches) then (lib.filesystem.listFilesRecursive patches) else [ patches ])
+            else if (builtins.isList patches) then
+              (lib.flatten (builtins.map consolidatePatches patches))
+            else
+              throw "Bad patches - must be path or derivation or list thereof";
+          consolidated = consolidatePatches patches;
+          splitPatch =
+            patchFile:
+            let
+              foldFunc =
+                a: b:
+                if (lib.strings.hasPrefix "--- " b) then
+                  (a ++ [ [ b ] ])
+                else
+                  ((lib.lists.init a) ++ (lib.lists.singleton ((lib.lists.last a) ++ [ b ])));
+              partitionedPatches' = lib.lists.foldl foldFunc [ [ ] ] (
+                lib.strings.splitString "\n" (builtins.readFile patchFile)
+              );
+              partitionedPatches =
+                if (builtins.length partitionedPatches' > 1) then
+                  (lib.lists.drop 1 partitionedPatches')
+                else
+                  (throw "${patchFile} does not seem to be a unified patch (diff -u). this is required for FreeBSD.");
+              filterFunc =
+                patchLines:
+                let
+                  prefixedPath = builtins.elemAt (builtins.split " |\t" (builtins.elemAt patchLines 1)) 2;
+                  unfixedPath = lib.path.subpath.join (lib.lists.drop 1 (lib.path.subpath.components prefixedPath));
+                in
+                lib.lists.any (included: lib.path.hasPrefix (/. + ("/" + included)) (/. + ("/" + unfixedPath))) (
+                  (attrs.extraPaths or [ ]) ++ [ attrs.path ]
+                );
+              filteredLines = builtins.filter filterFunc partitionedPatches;
+              derive = patchLines: writeText "freebsd-patch" (lib.concatLines patchLines);
+              derivedPatches = builtins.map derive filteredLines;
+            in
+            derivedPatches;
+          picked = lib.lists.concatMap splitPatch consolidated;
+        in
+        picked ++ attrs.patches or [ ];
+    }
+  )
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix
new file mode 100644
index 000000000000..60cef347446e
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix
@@ -0,0 +1,22 @@
+{
+  stdenv,
+  mkDerivation,
+  byacc,
+  flex,
+}:
+
+mkDerivation {
+  path = "usr.bin/mkcsmapper";
+
+  extraPaths = [
+    "lib/libc/iconv"
+    "lib/libiconv_modules/mapper_std"
+  ];
+
+  BOOTSTRAPPING = !stdenv.hostPlatform.isFreeBSD;
+
+  extraNativeBuildInputs = [
+    byacc
+    flex
+  ];
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix
new file mode 100644
index 000000000000..a503af529f27
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix
@@ -0,0 +1,19 @@
+{
+  stdenv,
+  mkDerivation,
+  byacc,
+  flex,
+}:
+
+mkDerivation {
+  path = "usr.bin/mkesdb";
+
+  extraPaths = [ "lib/libc/iconv" ];
+
+  BOOTSTRAPPING = !stdenv.hostPlatform.isFreeBSD;
+
+  extraNativeBuildInputs = [
+    byacc
+    flex
+  ];
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mknod.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mknod.nix
index 56dff7d606bd..bf7d8b7db689 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mknod.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mknod.nix
@@ -1,5 +1,3 @@
 { mkDerivation }:
 
-mkDerivation {
-  path = "sbin/mknod";
-}
+mkDerivation { path = "sbin/mknod"; }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix
index 23a4672069e6..bbcaff3a1c6a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix
@@ -1,6 +1,39 @@
-{ mkDerivation, mknod }:
+{
+  lib,
+  stdenv,
+  mkDerivation,
+  compatIfNeeded,
+  compatIsNeeded,
+  libmd,
+  libnetbsd,
+  libutil,
+}:
 
 mkDerivation {
   path = "contrib/mtree";
-  extraPaths = [ mknod.path ];
+  extraPaths = [ "contrib/mknod" ];
+  buildInputs =
+    compatIfNeeded
+    ++ [
+      libmd
+      libnetbsd
+    ]
+    ++ lib.optional (stdenv.isFreeBSD) libutil;
+
+  postPatch = ''
+    ln -s $BSDSRCDIR/contrib/mknod/*.c $BSDSRCDIR/contrib/mknod/*.h $BSDSRCDIR/contrib/mtree
+  '';
+
+  preBuild = ''
+    export NIX_LDFLAGS="$NIX_LDFLAGS ${
+      toString (
+        [
+          "-lmd"
+          "-lnetbsd"
+        ]
+        ++ lib.optional compatIsNeeded "-legacy"
+        ++ lib.optional stdenv.isFreeBSD "-lutil"
+      )
+    }"
+  '';
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix
index 56141255af5e..e187cacbb0d0 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix
@@ -1,6 +1,11 @@
-{ lib, mkDerivation, stdenv }:
+{
+  lib,
+  mkDerivation,
+  stdenv,
+  patchesRoot,
+}:
 
-mkDerivation rec {
+mkDerivation {
   path = "usr.bin/rpcgen";
   patches = lib.optionals (stdenv.hostPlatform.libc == "glibc") [
     # `WUNTRACED` is defined privately `bits/waitflags.h` in glibc.
@@ -12,7 +17,7 @@ mkDerivation rec {
     # those headers ends up included other headers...which ends up
     # including the other one, this means by the first time we reach
     # `#include `<bits/waitflags.h>`, both `_SYS_WAIT_H` and
-    # `_STDLIB_H` are already defined! Thus, we never ned up including
+    # `_STDLIB_H` are already defined! Thus, we never end up including
     # `<bits/waitflags.h>` and defining `WUNTRACED`.
     #
     # This hacks around this by manually including `WUNTRACED` until
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix
index 07b55afe133f..ec5bfee17d2c 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix
@@ -1,7 +1,6 @@
-{ mkDerivation, source }:
+{ mkDerivation }:
 
 mkDerivation {
   path = "usr.bin/sed";
-  TESTSRC = "${source}/contrib/netbsd-tests";
   MK_TESTS = "no";
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/source.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/source.nix
index 5e31f900e821..c14d26559047 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/source.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/source.nix
@@ -4,7 +4,6 @@
 # If you want you could fetchgit from "https://git.FreeBSD.org/src.git" instead.
 # The update script still pulls directly from git.freebsd.org
 fetchFromGitHub {
-  name = "src"; # Want to rename this next rebuild
   owner = "freebsd";
   repo = "freebsd-src";
   inherit (sourceData) rev hash;
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/stat.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/stat.nix
index c730f00869f8..a801ab895441 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/stat.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/stat.nix
@@ -1,13 +1,22 @@
-{ mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
+{
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
 }:
 
 # Don't add this to nativeBuildInputs directly.  Use statHook instead.
 mkDerivation {
   path = "usr.bin/stat";
   nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
+    bsdSetupHook
+    freebsdSetupHook
+    makeMinimal
+    install
+    mandoc
+    groff
   ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/statHook.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/statHook.nix
index 07129938b095..4609c004e6f5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/statHook.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/statHook.nix
@@ -1,12 +1,16 @@
-{ makeSetupHook, writeText, stat }:
+{
+  makeSetupHook,
+  writeText,
+  stat,
+}:
 
 # stat isn't in POSIX, and NetBSD stat supports a completely
 # different range of flags than GNU stat, so including it in PATH
 # breaks stdenv.  Work around that with a hook that will point
 # NetBSD's build system and NetBSD stat without including it in
 # PATH.
-makeSetupHook {
-  name = "netbsd-stat-hook";
-} (writeText "netbsd-stat-hook-impl" ''
-  makeFlagsArray+=(TOOL_STAT=${stat}/bin/stat)
-'')
+makeSetupHook { name = "netbsd-stat-hook"; } (
+  writeText "netbsd-stat-hook-impl" ''
+    makeFlagsArray+=(TOOL_STAT=${stat}/bin/stat)
+  ''
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix
index 81cf4114e873..86f847cbd45c 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix
@@ -1,67 +1,85 @@
-{ lib, stdenv, mkDerivation, freebsd-lib
-, buildPackages
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
-, config, rpcgen, file2c, gawk, uudecode, xargs-j #, ctfconvert
+{
+  stdenv,
+  mkDerivation,
+  freebsd-lib,
+  buildPackages,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  config,
+  rpcgen,
+  file2c,
+  gawk,
+  uudecode,
+  xargs-j,
 }:
 
-mkDerivation (let
-  cfg = "MINIMAL";
-in rec {
-  path = "sys";
-
-  nativeBuildInputs = [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
-
-    config rpcgen file2c gawk uudecode xargs-j
-    #ctfconvert
-  ];
-
-  patches = [
-    ./sys-gnu-date.patch
-    ./sys-no-explicit-intrinsics-dep.patch
-  ];
-
-  # --dynamic-linker /red/herring is used when building the kernel.
-  NIX_ENFORCE_PURITY = 0;
-
-  AWK = "${buildPackages.gawk}/bin/awk";
-
-  CWARNEXTRA = "-Wno-error=shift-negative-value -Wno-address-of-packed-member";
-
-  MK_CTF = "no";
-
-  KODIR = "${builtins.placeholder "out"}/kernel";
-  KMODDIR = "${builtins.placeholder "out"}/kernel";
-  DTBDIR = "${builtins.placeholder"out"}/dbt";
-
-  KERN_DEBUGDIR = "${builtins.placeholder "out"}/debug";
-  KERN_DEBUGDIR_KODIR = "${KERN_DEBUGDIR}/kernel";
-  KERN_DEBUGDIR_KMODDIR = "${KERN_DEBUGDIR}/kernel";
-
-  skipIncludesPhase = true;
-
-  configurePhase = ''
-    runHook preConfigure
-
-    for f in conf/kmod.mk contrib/dev/acpica/acpica_prep.sh; do
-      substituteInPlace "$f" --replace 'xargs -J' 'xargs-j '
-    done
-
-    for f in conf/*.mk; do
-      substituteInPlace "$f" --replace 'KERN_DEBUGDIR}''${' 'KERN_DEBUGDIR_'
-    done
-
-    cd ${freebsd-lib.mkBsdArch stdenv}/conf
-    sed -i ${cfg} \
-      -e 's/WITH_CTF=1/WITH_CTF=0/' \
-      -e '/KDTRACE/d'
-    config ${cfg}
-
-    runHook postConfigure
-  '';
-  preBuild = ''
-    cd ../compile/${cfg}
-  '';
-})
+mkDerivation (
+  let
+    cfg = "MINIMAL";
+  in
+  rec {
+    path = "sys";
+
+    nativeBuildInputs = [
+      bsdSetupHook
+      freebsdSetupHook
+      makeMinimal
+      install
+      mandoc
+      groff
+
+      config
+      rpcgen
+      file2c
+      gawk
+      uudecode
+      xargs-j
+    ];
+
+    # --dynamic-linker /red/herring is used when building the kernel.
+    NIX_ENFORCE_PURITY = 0;
+
+    AWK = "${buildPackages.gawk}/bin/awk";
+
+    CWARNEXTRA = "-Wno-error=shift-negative-value -Wno-address-of-packed-member";
+
+    MK_CTF = "no";
+
+    KODIR = "${builtins.placeholder "out"}/kernel";
+    KMODDIR = "${builtins.placeholder "out"}/kernel";
+    DTBDIR = "${builtins.placeholder "out"}/dbt";
+
+    KERN_DEBUGDIR = "${builtins.placeholder "out"}/debug";
+    KERN_DEBUGDIR_KODIR = "${KERN_DEBUGDIR}/kernel";
+    KERN_DEBUGDIR_KMODDIR = "${KERN_DEBUGDIR}/kernel";
+
+    skipIncludesPhase = true;
+
+    configurePhase = ''
+      runHook preConfigure
+
+      for f in conf/kmod.mk contrib/dev/acpica/acpica_prep.sh; do
+        substituteInPlace "$f" --replace 'xargs -J' 'xargs-j '
+      done
+
+      for f in conf/*.mk; do
+        substituteInPlace "$f" --replace 'KERN_DEBUGDIR}''${' 'KERN_DEBUGDIR_'
+      done
+
+      cd ${freebsd-lib.mkBsdArch stdenv}/conf
+      sed -i ${cfg} \
+        -e 's/WITH_CTF=1/WITH_CTF=0/' \
+        -e '/KDTRACE/d'
+      config ${cfg}
+
+      runHook postConfigure
+    '';
+    preBuild = ''
+      cd ../compile/${cfg}
+    '';
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix
index cdc1b27ce8fe..04a45ff980cb 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix
@@ -1,12 +1,28 @@
-{ mkDerivation
-, bsdSetupHook, freebsdSetupHook
-, makeMinimal, install, mandoc, groff
+{
+  lib,
+  mkDerivation,
+  bsdSetupHook,
+  freebsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
 }:
 
 mkDerivation {
   path = "usr.bin/tsort";
-  nativeBuildInputs =  [
-    bsdSetupHook freebsdSetupHook
-    makeMinimal install mandoc groff
+  extraPaths = [ ];
+  outputs = [ "out" ];
+  MK_TESTS = "no";
+  makeFlags = [
+    "STRIP=-s" # flag to install, not command
+  ];
+  nativeBuildInputs = [
+    bsdSetupHook
+    freebsdSetupHook
+    makeMinimal
+    install
+    mandoc
+    groff
   ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/update.py b/nixpkgs/pkgs/os-specific/bsd/freebsd/update.py
index cd20f67148fa..533a871a4b04 100755
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/update.py
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/update.py
@@ -16,6 +16,7 @@ import typing
 import urllib.request
 
 _QUERY_VERSION_PATTERN = re.compile('^([A-Z]+)="(.+)"$')
+_RELEASE_PATCH_PATTERN = re.compile('^RELEASE-p([0-9]+)$')
 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
 MIN_VERSION = packaging.version.Version("13.0.0")
 MAIN_BRANCH = "main"
@@ -60,7 +61,16 @@ def query_version(repo: git.Repo) -> dict[str, typing.Any]:
             continue
         fields[m[1].lower()] = m[2]
 
-    fields["major"] = packaging.version.parse(fields["revision"]).major
+    parsed = packaging.version.parse(fields["revision"])
+    fields["major"] = parsed.major
+    fields["minor"] = parsed.minor
+
+    # Extract the patch number from `RELAESE-p<patch>`, which is used
+    # e.g. in the "releng" branches.
+    m = _RELEASE_PATCH_PATTERN.match(fields["branch"])
+    if m is not None:
+        fields["patch"] = m[1]
+
     return fields
 
 
@@ -95,7 +105,7 @@ def handle_commit(
         "ref": ref_name,
         "refType": ref_type,
         "supported": ref_name in supported_refs,
-        "version": query_version(repo),
+        "version": version,
     }
 
 
@@ -151,6 +161,14 @@ def main() -> None:
         result = handle_commit(
             repo, tag.commit, tag.name, "tag", supported_refs, old_versions
         )
+
+        # Hack in the patch version from parsing the tag, if we didn't
+        # get one from the "branch" field (from newvers). This is
+        # probably 0.
+        versionObj = result["version"]
+        if "patch" not in versionObj:
+            versionObj["patch"] = version.micro
+
         versions[tag.name] = result
 
     for branch in repo.remote("origin").refs:
diff --git a/nixpkgs/pkgs/os-specific/bsd/freebsd/versions.json b/nixpkgs/pkgs/os-specific/bsd/freebsd/versions.json
index 736c4c3a3e3c..3f781b4eeaf2 100644
--- a/nixpkgs/pkgs/os-specific/bsd/freebsd/versions.json
+++ b/nixpkgs/pkgs/os-specific/bsd/freebsd/versions.json
@@ -1,14 +1,15 @@
 {
   "main": {
-    "hash": "sha256-C5ucT9BK/eK8a9HNSDDi8S1uhpPmiqV22XEooxAqbPw=",
+    "hash": "sha256-3aUsD2yRqVvb12z2XPmhE5/u4d9bqyD2ZHH3xNmwYwU=",
     "ref": "main",
     "refType": "branch",
-    "rev": "125c4560bc70971b950d035cfcd2255b89984011",
+    "rev": "aa34b1d20e44141749ffdecf16908fc1e5db4db6",
     "supported": false,
     "version": {
       "branch": "CURRENT",
       "major": 15,
-      "reldate": "1500017",
+      "minor": 0,
+      "reldate": "1500018",
       "release": "15.0-CURRENT",
       "revision": "15.0",
       "type": "FreeBSD",
@@ -24,6 +25,8 @@
     "version": {
       "branch": "RELEASE",
       "major": 13,
+      "minor": 0,
+      "patch": 0,
       "reldate": "1300139",
       "release": "13.0-RELEASE",
       "revision": "13.0",
@@ -40,6 +43,8 @@
     "version": {
       "branch": "RELEASE",
       "major": 13,
+      "minor": 1,
+      "patch": 0,
       "reldate": "1301000",
       "release": "13.1-RELEASE",
       "revision": "13.1",
@@ -56,6 +61,8 @@
     "version": {
       "branch": "RELEASE",
       "major": 13,
+      "minor": 2,
+      "patch": 0,
       "reldate": "1302001",
       "release": "13.2-RELEASE",
       "revision": "13.2",
@@ -72,6 +79,8 @@
     "version": {
       "branch": "RELEASE",
       "major": 13,
+      "minor": 3,
+      "patch": 0,
       "reldate": "1303001",
       "release": "13.3-RELEASE",
       "revision": "13.3",
@@ -88,6 +97,8 @@
     "version": {
       "branch": "RELEASE",
       "major": 14,
+      "minor": 0,
+      "patch": 0,
       "reldate": "1400097",
       "release": "14.0-RELEASE",
       "revision": "14.0",
@@ -104,6 +115,8 @@
     "version": {
       "branch": "RELEASE-p13",
       "major": 13,
+      "minor": 0,
+      "patch": "13",
       "reldate": "1300139",
       "release": "13.0-RELEASE-p13",
       "revision": "13.0",
@@ -120,6 +133,8 @@
     "version": {
       "branch": "RELEASE-p9",
       "major": 13,
+      "minor": 1,
+      "patch": "9",
       "reldate": "1301000",
       "release": "13.1-RELEASE-p9",
       "revision": "13.1",
@@ -136,6 +151,8 @@
     "version": {
       "branch": "RELEASE-p11",
       "major": 13,
+      "minor": 2,
+      "patch": "11",
       "reldate": "1302001",
       "release": "13.2-RELEASE-p11",
       "revision": "13.2",
@@ -144,19 +161,21 @@
     }
   },
   "releng/13.3": {
-    "hash": "sha256-huzUiMZHfyK/mgLD3hW+DaSGgAaTUIuM51xDp+IE3qE=",
+    "hash": "sha256-g3i9q9XihesdfQxGy3oC7IMGtbWaLNwFlNzbdvS/4ng=",
     "ref": "releng/13.3",
     "refType": "branch",
-    "rev": "7a0d63c9093222938f26cd63ff742e555168de77",
+    "rev": "be4f1894ef399f421bab451e8cf8557e27e5a948",
     "supported": true,
     "version": {
-      "branch": "RELEASE-p1",
+      "branch": "RELEASE-p2",
       "major": 13,
+      "minor": 3,
+      "patch": "2",
       "reldate": "1303001",
-      "release": "13.3-RELEASE-p1",
+      "release": "13.3-RELEASE-p2",
       "revision": "13.3",
       "type": "FreeBSD",
-      "version": "FreeBSD 13.3-RELEASE-p1"
+      "version": "FreeBSD 13.3-RELEASE-p2"
     }
   },
   "releng/14.0": {
@@ -168,6 +187,8 @@
     "version": {
       "branch": "RELEASE-p6",
       "major": 14,
+      "minor": 0,
+      "patch": "6",
       "reldate": "1400097",
       "release": "14.0-RELEASE-p6",
       "revision": "14.0",
@@ -176,15 +197,16 @@
     }
   },
   "stable/13": {
-    "hash": "sha256-XateLKKs2A/HCP9Lx/nBm1cybB3otrbeXQvyCL40S0M=",
+    "hash": "sha256-ItC8haDdxMSZt1thpCrn8p0xxvs7Uqh/uNo1OwMalj8=",
     "ref": "stable/13",
     "refType": "branch",
-    "rev": "e0a58ef24a3baf5ed4cc09a798b9fe2d85408052",
+    "rev": "825cb4c850f2b97cfd1b24ed421d7938bf37eee7",
     "supported": true,
     "version": {
       "branch": "STABLE",
       "major": 13,
-      "reldate": "1303502",
+      "minor": 3,
+      "reldate": "1303503",
       "release": "13.3-STABLE",
       "revision": "13.3",
       "type": "FreeBSD",
@@ -192,19 +214,20 @@
     }
   },
   "stable/14": {
-    "hash": "sha256-tIKnK/SYBDk9UnE5AfhjeDpqHnzspYbor0678ye/mrs=",
+    "hash": "sha256-iAj75IXJi4Oium6BqFvsyQipDP2crBZIGg0Dac8Zf1g=",
     "ref": "stable/14",
     "refType": "branch",
-    "rev": "ab872ab0bf195e872ed8d955aab3b2a537a230cd",
+    "rev": "a3b8266f5420601e231bc08c5402d9a4929fbdc0",
     "supported": true,
     "version": {
-      "branch": "STABLE",
+      "branch": "PRERELEASE",
       "major": 14,
-      "reldate": "1400510",
-      "release": "14.0-STABLE",
-      "revision": "14.0",
+      "minor": 1,
+      "reldate": "1400511",
+      "release": "14.1-PRERELEASE",
+      "revision": "14.1",
       "type": "FreeBSD",
-      "version": "FreeBSD 14.0-STABLE"
+      "version": "FreeBSD 14.1-PRERELEASE"
     }
   }
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix
index fd5e24aa7102..e0d03108960c 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix
@@ -1,137 +1,187 @@
-{ stdenv, lib, stdenvNoCC
-, makeScopeWithSplicing', generateSplicesForMkScope
-, buildPackages
-, fetchcvs
+{
+  stdenv,
+  lib,
+  stdenvNoCC,
+  makeScopeWithSplicing',
+  generateSplicesForMkScope,
+  buildPackages,
+  fetchcvs,
 }:
 
 makeScopeWithSplicing' {
   otherSplices = generateSplicesForMkScope "netbsd";
-  f = (self: lib.packagesFromDirectoryRecursive {
-    callPackage = self.callPackage;
-    directory = ./pkgs;
-  } // (let inherit (self) mkDerivation; in {
-
-    fetchNetBSD = path: version: sha256: fetchcvs {
-      cvsRoot = ":pserver:anoncvs@anoncvs.NetBSD.org:/cvsroot";
-      module = "src/${path}";
-      inherit sha256;
-      tag = "netbsd-${lib.replaceStrings ["."] ["-"] version}-RELEASE";
-    };
-
-    defaultMakeFlags = [
-      "MKSOFTFLOAT=${if stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft"
-        then "yes"
-        else "no"}"
-    ];
-
-    compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat;
-
-    # The manual callPackages below should in principle be unnecessary because
-    # they're just selecting arguments that would be selected anyway. However,
-    # if we don't perform these manual calls, we get infinite recursion issues
-    # because of the splices.
-
-    mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
-      inherit stdenv stdenvNoCC;
-      inherit (buildPackages.netbsd) netbsdSetupHook makeMinimal install tsort lorder;
-      inherit (buildPackages) mandoc;
-      inherit (buildPackages.buildPackages) rsync;
-
-    };
-
-    makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
-      inherit (self) make;
-    };
-
-    compat = self.callPackage ./pkgs/compat/package.nix {
-      inherit (buildPackages) coreutils;
-      inherit (buildPackages.darwin) cctools-port;
-      inherit (buildPackages.buildPackages) rsync;
-      inherit (buildPackages.netbsd) makeMinimal;
-      inherit (self) install include libc libutil;
-    };
-
-    install = self.callPackage ./pkgs/install/package.nix {
-      inherit (self) fts mtree make compatIfNeeded;
-      inherit (buildPackages.buildPackages) rsync;
-      inherit (buildPackages.netbsd) makeMinimal;
-    };
-
-    # See note in pkgs/stat/package.nix
-    stat = self.callPackage ./pkgs/stat/package.nix {
-      inherit (buildPackages.netbsd) makeMinimal install;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    # See note in pkgs/stat/hook.nix
-    statHook = self.callPackage ./pkgs/stat/hook.nix {
-      inherit (self) stat;
-    };
-
-    tsort = self.callPackage ./pkgs/tsort.nix {
-      inherit (buildPackages.netbsd) makeMinimal install;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    lorder = self.callPackage ./pkgs/lorder.nix {
-      inherit (buildPackages.netbsd) makeMinimal install;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    config = self.callPackage ./pkgs/config.nix {
-      inherit (buildPackages.netbsd) makeMinimal install;
-      inherit (buildPackages.buildPackages) rsync;
-      inherit (self) cksum;
-    };
-
-    include = self.callPackage ./pkgs/include.nix {
-      inherit (buildPackages.netbsd)
-        makeMinimal install nbperf rpcgen;
-      inherit (buildPackages) stdenv;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    sys-headers = self.callPackage ./pkgs/sys/headers.nix {
-      inherit (buildPackages.netbsd)
-        makeMinimal install tsort lorder statHook uudecode config genassym;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    libutil = self.callPackage ./pkgs/libutil.nix {
-      inherit (self) libc sys;
-    };
-
-    libpthread-headers = self.callPackage ./pkgs/libpthread/headers.nix { };
-
-    csu = self.callPackage ./pkgs/csu.nix {
-      inherit (self) headers sys ld_elf_so;
-      inherit (buildPackages.netbsd)
-        netbsdSetupHook
-        makeMinimal
-        install
-        genassym gencat lorder tsort statHook;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    _mainLibcExtraPaths = with self; [
-        common i18n_module.src sys.src
-        ld_elf_so.src libpthread.src libm.src libresolv.src
-        librpcsvc.src libutil.src librt.src libcrypt.src
-    ];
-
-    libc = self.callPackage ./pkgs/libc.nix {
-      inherit (self) headers csu librt;
-      inherit (buildPackages.netbsd)
-        netbsdSetupHook
-        makeMinimal
-        install
-        genassym gencat lorder tsort statHook rpcgen;
-      inherit (buildPackages.buildPackages) rsync;
-    };
-
-    mtree = self.callPackage ./pkgs/mtree.nix {
-      inherit (self) mknod;
-    };
-
-  }));
+  f = (
+    self:
+    lib.packagesFromDirectoryRecursive {
+      callPackage = self.callPackage;
+      directory = ./pkgs;
+    }
+    // {
+
+      fetchNetBSD =
+        path: version: sha256:
+        fetchcvs {
+          cvsRoot = ":pserver:anoncvs@anoncvs.NetBSD.org:/cvsroot";
+          module = "src/${path}";
+          inherit sha256;
+          tag = "netbsd-${lib.replaceStrings [ "." ] [ "-" ] version}-RELEASE";
+        };
+
+      defaultMakeFlags = [
+        "MKSOFTFLOAT=${
+          if stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft" then
+            "yes"
+          else
+            "no"
+        }"
+      ];
+
+      compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat;
+
+      # The manual callPackages below should in principle be unnecessary because
+      # they're just selecting arguments that would be selected anyway. However,
+      # if we don't perform these manual calls, we get infinite recursion issues
+      # because of the splices.
+
+      mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
+        inherit stdenv stdenvNoCC;
+        inherit (buildPackages.netbsd)
+          netbsdSetupHook
+          makeMinimal
+          install
+          tsort
+          lorder
+          ;
+        inherit (buildPackages) mandoc;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; };
+
+      compat = self.callPackage ./pkgs/compat/package.nix {
+        inherit (buildPackages) coreutils;
+        inherit (buildPackages.darwin) cctools-port;
+        inherit (buildPackages.buildPackages) rsync;
+        inherit (buildPackages.netbsd) makeMinimal;
+        inherit (self)
+          install
+          include
+          libc
+          libutil
+          ;
+      };
+
+      install = self.callPackage ./pkgs/install/package.nix {
+        inherit (self)
+          fts
+          mtree
+          make
+          compatIfNeeded
+          ;
+        inherit (buildPackages.buildPackages) rsync;
+        inherit (buildPackages.netbsd) makeMinimal;
+      };
+
+      # See note in pkgs/stat/package.nix
+      stat = self.callPackage ./pkgs/stat/package.nix {
+        inherit (buildPackages.netbsd) makeMinimal install;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      # See note in pkgs/stat/hook.nix
+      statHook = self.callPackage ./pkgs/stat/hook.nix { inherit (self) stat; };
+
+      tsort = self.callPackage ./pkgs/tsort.nix {
+        inherit (buildPackages.netbsd) makeMinimal install;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      lorder = self.callPackage ./pkgs/lorder.nix {
+        inherit (buildPackages.netbsd) makeMinimal install;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      config = self.callPackage ./pkgs/config.nix {
+        inherit (buildPackages.netbsd) makeMinimal install;
+        inherit (buildPackages.buildPackages) rsync;
+        inherit (self) cksum;
+      };
+
+      include = self.callPackage ./pkgs/include.nix {
+        inherit (buildPackages.netbsd)
+          makeMinimal
+          install
+          nbperf
+          rpcgen
+          ;
+        inherit (buildPackages) stdenv;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      sys-headers = self.callPackage ./pkgs/sys/headers.nix {
+        inherit (buildPackages.netbsd)
+          makeMinimal
+          install
+          tsort
+          lorder
+          statHook
+          uudecode
+          config
+          genassym
+          ;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      libutil = self.callPackage ./pkgs/libutil.nix { inherit (self) libc sys; };
+
+      libpthread-headers = self.callPackage ./pkgs/libpthread/headers.nix { };
+
+      csu = self.callPackage ./pkgs/csu.nix {
+        inherit (self) headers sys ld_elf_so;
+        inherit (buildPackages.netbsd)
+          netbsdSetupHook
+          makeMinimal
+          install
+          genassym
+          gencat
+          lorder
+          tsort
+          statHook
+          ;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      _mainLibcExtraPaths = with self; [
+        common
+        i18n_module.src
+        sys.src
+        ld_elf_so.src
+        libpthread.src
+        libm.src
+        libresolv.src
+        librpcsvc.src
+        libutil.src
+        librt.src
+        libcrypt.src
+      ];
+
+      libc = self.callPackage ./pkgs/libc.nix {
+        inherit (self) headers csu librt;
+        inherit (buildPackages.netbsd)
+          netbsdSetupHook
+          makeMinimal
+          install
+          genassym
+          gencat
+          lorder
+          tsort
+          statHook
+          rpcgen
+          ;
+        inherit (buildPackages.buildPackages) rsync;
+      };
+
+      mtree = self.callPackage ./pkgs/mtree.nix { inherit (self) mknod; };
+    }
+  );
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/compat/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/compat/package.nix
index a1336ad52f6d..4c149e95c1ae 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/compat/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/compat/package.nix
@@ -1,21 +1,29 @@
-{ lib, mkDerivation, stdenv
-, zlib
-, defaultMakeFlags
-, coreutils
-, cctools-port
-, include, libc, libutil
-, install
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, rsync
-, fetchNetBSD
-, _mainLibcExtraPaths
+{
+  lib,
+  mkDerivation,
+  stdenv,
+  zlib,
+  defaultMakeFlags,
+  coreutils,
+  cctools-port,
+  include,
+  libc,
+  libutil,
+  install,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  rsync,
+  fetchNetBSD,
+  _mainLibcExtraPaths,
 }:
 
-mkDerivation (let
+mkDerivation (
+  let
     version = "9.2";
     commonDeps = [ zlib ];
-  in {
+  in
+  {
     path = "tools/compat";
     sha256 = "1vsxg7136nlhc72vpa664vs22874xh7ila95nkmsd8crn3z3cyn0";
     inherit version;
@@ -29,19 +37,23 @@ mkDerivation (let
       make include/.stamp configure nbtool_config.h.in defs.mk.in
     '';
 
-    configurePlatforms = [ "build" "host" ];
-    configureFlags = [
-      "--cache-file=config.cache"
-    ] ++ lib.optionals stdenv.hostPlatform.isMusl [
-      # We include this header in our musl package only for legacy
-      # compatibility, and compat works fine without it (and having it
-      # know about sys/cdefs.h breaks packages like glib when built
-      # statically).
-      "ac_cv_header_sys_cdefs_h=no"
+    configurePlatforms = [
+      "build"
+      "host"
     ];
+    configureFlags =
+      [ "--cache-file=config.cache" ]
+      ++ lib.optionals stdenv.hostPlatform.isMusl [
+        # We include this header in our musl package only for legacy
+        # compatibility, and compat works fine without it (and having it
+        # know about sys/cdefs.h breaks packages like glib when built
+        # statically).
+        "ac_cv_header_sys_cdefs_h=no"
+      ];
 
     nativeBuildInputs = commonDeps ++ [
-      bsdSetupHook netbsdSetupHook
+      bsdSetupHook
+      netbsdSetupHook
       makeMinimal
       rsync
     ];
@@ -50,22 +62,27 @@ mkDerivation (let
 
     # temporarily use gnuinstall for bootstrapping
     # bsdinstall will be built later
-    makeFlags = defaultMakeFlags ++ [
-      "INSTALL=${coreutils}/bin/install"
-      "DATADIR=$(out)/share"
-      # Can't sort object files yet
-      "LORDER=echo"
-      "TSORT=cat"
-      # Can't process man pages yet
-      "MKSHARE=no"
-    ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
-      # GNU objcopy produces broken .a libs which won't link into dependers.
-      # Makefiles only invoke `$OBJCOPY -x/-X`, so cctools strip works here.
-      "OBJCOPY=${cctools-port}/bin/strip"
-    ];
+    makeFlags =
+      defaultMakeFlags
+      ++ [
+        "INSTALL=${coreutils}/bin/install"
+        "DATADIR=$(out)/share"
+        # Can't sort object files yet
+        "LORDER=echo"
+        "TSORT=cat"
+        # Can't process man pages yet
+        "MKSHARE=no"
+      ]
+      ++ lib.optionals stdenv.hostPlatform.isDarwin [
+        # GNU objcopy produces broken .a libs which won't link into dependers.
+        # Makefiles only invoke `$OBJCOPY -x/-X`, so cctools strip works here.
+        "OBJCOPY=${cctools-port}/bin/strip"
+      ];
     RENAME = "-D";
 
-    passthru.tests = { netbsd-install = install; };
+    passthru.tests = {
+      netbsd-install = install;
+    };
 
     patches = [
       ./compat-cxx-safe-header.patch
@@ -79,42 +96,51 @@ mkDerivation (let
       makeFlagsArray+=('INSTALL_SYMLINK=''${INSTALL} ''${SYMLINK} ''${RENAME}')
     '';
 
-    postInstall = ''
-      # why aren't these installed by netbsd?
-      install -D compat_defs.h $out/include/compat_defs.h
-      install -D $BSDSRCDIR/include/cdbw.h $out/include/cdbw.h
-      install -D $BSDSRCDIR/sys/sys/cdbr.h $out/include/cdbr.h
-      install -D $BSDSRCDIR/sys/sys/featuretest.h \
-                 $out/include/sys/featuretest.h
-      install -D $BSDSRCDIR/sys/sys/md5.h $out/include/md5.h
-      install -D $BSDSRCDIR/sys/sys/rmd160.h $out/include/rmd160.h
-      install -D $BSDSRCDIR/sys/sys/sha1.h $out/include/sha1.h
-      install -D $BSDSRCDIR/sys/sys/sha2.h $out/include/sha2.h
-      install -D $BSDSRCDIR/sys/sys/queue.h $out/include/sys/queue.h
-      install -D $BSDSRCDIR/include/vis.h $out/include/vis.h
-      install -D $BSDSRCDIR/include/db.h $out/include/db.h
-      install -D $BSDSRCDIR/include/netconfig.h $out/include/netconfig.h
-      install -D $BSDSRCDIR/include/utmpx.h $out/include/utmpx.h
-      install -D $BSDSRCDIR/include/tzfile.h $out/include/tzfile.h
-      install -D $BSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h
-      install -D $BSDSRCDIR/include/nl_types.h $out/include/nl_types.h
-      install -D $BSDSRCDIR/include/stringlist.h $out/include/stringlist.h
+    postInstall =
+      ''
+        # why aren't these installed by netbsd?
+        install -D compat_defs.h $out/include/compat_defs.h
+        install -D $BSDSRCDIR/include/cdbw.h $out/include/cdbw.h
+        install -D $BSDSRCDIR/sys/sys/cdbr.h $out/include/cdbr.h
+        install -D $BSDSRCDIR/sys/sys/featuretest.h \
+                   $out/include/sys/featuretest.h
+        install -D $BSDSRCDIR/sys/sys/md5.h $out/include/md5.h
+        install -D $BSDSRCDIR/sys/sys/rmd160.h $out/include/rmd160.h
+        install -D $BSDSRCDIR/sys/sys/sha1.h $out/include/sha1.h
+        install -D $BSDSRCDIR/sys/sys/sha2.h $out/include/sha2.h
+        install -D $BSDSRCDIR/sys/sys/queue.h $out/include/sys/queue.h
+        install -D $BSDSRCDIR/include/vis.h $out/include/vis.h
+        install -D $BSDSRCDIR/include/db.h $out/include/db.h
+        install -D $BSDSRCDIR/include/netconfig.h $out/include/netconfig.h
+        install -D $BSDSRCDIR/include/utmpx.h $out/include/utmpx.h
+        install -D $BSDSRCDIR/include/tzfile.h $out/include/tzfile.h
+        install -D $BSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h
+        install -D $BSDSRCDIR/include/nl_types.h $out/include/nl_types.h
+        install -D $BSDSRCDIR/include/stringlist.h $out/include/stringlist.h
 
-      # Collapse includes slightly to fix dangling reference
-      install -D $BSDSRCDIR/common/include/rpc/types.h $out/include/rpc/types.h
-      sed -i '1s;^;#include "nbtool_config.h"\n;' $out/include/rpc/types.h
-   '' + lib.optionalString stdenv.isDarwin ''
-      mkdir -p $out/include/ssp
-      touch $out/include/ssp/ssp.h
-   '' + ''
-      mkdir -p $out/lib/pkgconfig
-      substitute ${./libbsd-overlay.pc} $out/lib/pkgconfig/libbsd-overlay.pc \
-        --subst-var-by out $out \
-        --subst-var-by version ${version}
-    '';
-    extraPaths = [ include.src libc.src libutil.src
+        # Collapse includes slightly to fix dangling reference
+        install -D $BSDSRCDIR/common/include/rpc/types.h $out/include/rpc/types.h
+        sed -i '1s;^;#include "nbtool_config.h"\n;' $out/include/rpc/types.h
+      ''
+      + lib.optionalString stdenv.isDarwin ''
+        mkdir -p $out/include/ssp
+        touch $out/include/ssp/ssp.h
+      ''
+      + ''
+        mkdir -p $out/lib/pkgconfig
+        substitute ${./libbsd-overlay.pc} $out/lib/pkgconfig/libbsd-overlay.pc \
+          --subst-var-by out $out \
+          --subst-var-by version ${version}
+      '';
+    extraPaths = [
+      include.src
+      libc.src
+      libutil.src
       (fetchNetBSD "external/bsd/flex" "9.2" "0h98jpfj7vx5zh7vd7bk6b1hmzgkcb757a8j6d9zgygxxv13v43m")
       (fetchNetBSD "sys/sys" "9.2" "0zawhw51klaigqqwkx0lzrx3mim2jywrc24cm7c66qsf1im9awgd")
-      (fetchNetBSD "common/include/rpc/types.h" "9.2" "0n2df12mlc3cbc48jxq35yzl1y7ghgpykvy7jnfh898rdhac7m9a")
+      (fetchNetBSD "common/include/rpc/types.h" "9.2"
+        "0n2df12mlc3cbc48jxq35yzl1y7ghgpykvy7jnfh898rdhac7m9a"
+      )
     ] ++ libutil.extraPaths ++ _mainLibcExtraPaths;
-  })
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/config.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/config.nix
index 277d70129e6f..c423f3ca8676 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/config.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/config.nix
@@ -1,8 +1,15 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal, install, mandoc, byacc, flex, rsync
-, compatIfNeeded
-, cksum
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  byacc,
+  flex,
+  rsync,
+  compatIfNeeded,
+  cksum,
 }:
 mkDerivation {
   path = "usr.bin/config";
@@ -10,8 +17,14 @@ mkDerivation {
   sha256 = "1yz3n4hncdkk6kp595fh2q5lg150vpqg8iw2dccydkyw4y3hgsjj";
   env.NIX_CFLAGS_COMPILE = toString [ "-DMAKE_BOOTSTRAP" ];
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
-    makeMinimal install mandoc byacc flex rsync
+    bsdSetupHook
+    netbsdSetupHook
+    makeMinimal
+    install
+    mandoc
+    byacc
+    flex
+    rsync
   ];
   buildInputs = compatIfNeeded;
   extraPaths = [ cksum.src ];
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/csu.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/csu.nix
index 2d13ced6d5ed..66443331490f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/csu.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/csu.nix
@@ -1,11 +1,23 @@
-{ lib, mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, flex
-, byacc, genassym, gencat, lorder, tsort, statHook, rsync
-, headers
-, sys
-, ld_elf_so
+{
+  lib,
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  flex,
+  byacc,
+  genassym,
+  gencat,
+  lorder,
+  tsort,
+  statHook,
+  rsync,
+  headers,
+  sys,
+  ld_elf_so,
 }:
 
 mkDerivation {
@@ -14,11 +26,24 @@ mkDerivation {
   sha256 = "0al5jfazvhlzn9hvmnrbchx4d0gm282hq5gp4xs2zmj9ycmf6d03";
   meta.platforms = lib.platforms.netbsd;
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff flex
-    byacc genassym gencat lorder tsort statHook rsync
+    install
+    mandoc
+    groff
+    flex
+    byacc
+    genassym
+    gencat
+    lorder
+    tsort
+    statHook
+    rsync
   ];
   buildInputs = [ headers ];
-  extraPaths = [ sys.src ld_elf_so.src ];
+  extraPaths = [
+    sys.src
+    ld_elf_so.src
+  ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/fts/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/fts/package.nix
index 0393d36357f6..7c64658bf2e5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/fts/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/fts/package.nix
@@ -1,7 +1,10 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook, rsync
-, compatIfNeeded
-, fetchNetBSD
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  rsync,
+  compatIfNeeded,
+  fetchNetBSD,
 }:
 
 mkDerivation {
@@ -10,12 +13,16 @@ mkDerivation {
   sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77";
   version = "9.2";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook rsync
+    bsdSetupHook
+    netbsdSetupHook
+    rsync
   ];
   propagatedBuildInputs = compatIfNeeded;
   extraPaths = [
     (fetchNetBSD "lib/libc/gen/fts.c" "9.2" "1a8hmf26242nmv05ipn3ircxb0jqmmi66rh78kkyi9vjwkfl3qn7")
-    (fetchNetBSD "lib/libc/include/namespace.h" "9.2" "0kksr3pdwdc1cplqf5z12ih4cml6l11lqrz91f7hjjm64y7785kc")
+    (fetchNetBSD "lib/libc/include/namespace.h" "9.2"
+      "0kksr3pdwdc1cplqf5z12ih4cml6l11lqrz91f7hjjm64y7785kc"
+    )
     (fetchNetBSD "lib/libc/gen/fts.3" "9.2" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1")
   ];
   skipIncludesPhase = true;
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/headers.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/headers.nix
index 646e5675130b..40615b2722d5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/headers.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/headers.nix
@@ -1,4 +1,10 @@
-{ lib, symlinkJoin, include, sys-headers, libpthread-headers }:
+{
+  lib,
+  symlinkJoin,
+  include,
+  sys-headers,
+  libpthread-headers,
+}:
 
 symlinkJoin {
   name = "netbsd-headers-9.2";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/i18n_module.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/i18n_module.nix
index 60b091ef0b71..c76ada865775 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/i18n_module.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/i18n_module.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, libc }:
+{
+  lib,
+  mkDerivation,
+  libc,
+}:
 
 mkDerivation {
   path = "lib/i18n_module";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/include.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/include.nix
index 1ecdec90ae09..ec316a63174f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/include.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/include.nix
@@ -1,10 +1,18 @@
-{ lib, mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, rsync, nbperf, rpcgen
-, common
-, defaultMakeFlags
-, stdenv
+{
+  lib,
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  rsync,
+  nbperf,
+  rpcgen,
+  common,
+  defaultMakeFlags,
+  stdenv,
 }:
 
 mkDerivation {
@@ -12,9 +20,15 @@ mkDerivation {
   version = "9.2";
   sha256 = "0nxnmj4c8s3hb9n3fpcmd0zl3l1nmhivqgi9a35sis943qvpgl9h";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff rsync nbperf rpcgen
+    install
+    mandoc
+    groff
+    rsync
+    nbperf
+    rpcgen
   ];
 
   # The makefiles define INCSDIR per subdirectory, so we have to set
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
index 991517ac2d48..69b0c073259e 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
@@ -1,10 +1,16 @@
-{ mkDerivation
-, writeShellScript
-, mtree, make
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, mandoc, groff, rsync
-, compatIfNeeded, fts
+{
+  mkDerivation,
+  writeShellScript,
+  mtree,
+  make,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  mandoc,
+  groff,
+  rsync,
+  compatIfNeeded,
+  fts,
 
 }:
 
@@ -18,32 +24,39 @@ let
     @out@/bin/xinstall "$@"
   '';
 in
-  mkDerivation {
-    path = "usr.bin/xinstall";
-    version = "9.2";
-    sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj";
-    extraPaths = [ mtree.src make.src ];
-    nativeBuildInputs = [
-      bsdSetupHook netbsdSetupHook
-      makeMinimal
-      mandoc groff rsync
-    ];
-    skipIncludesPhase = true;
-    buildInputs = compatIfNeeded
-      # fts header is needed. glibc already has this header, but musl doesn't,
-      # so make sure pkgsMusl.netbsd.install still builds in case you want to
-      # remove it!
-      ++ [ fts ];
-    installPhase = ''
-      runHook preInstall
+mkDerivation {
+  path = "usr.bin/xinstall";
+  version = "9.2";
+  sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj";
+  extraPaths = [
+    mtree.src
+    make.src
+  ];
+  nativeBuildInputs = [
+    bsdSetupHook
+    netbsdSetupHook
+    makeMinimal
+    mandoc
+    groff
+    rsync
+  ];
+  skipIncludesPhase = true;
+  buildInputs =
+    compatIfNeeded
+    # fts header is needed. glibc already has this header, but musl doesn't,
+    # so make sure pkgsMusl.netbsd.install still builds in case you want to
+    # remove it!
+    ++ [ fts ];
+  installPhase = ''
+    runHook preInstall
 
-      install -D install.1 $out/share/man/man1/install.1
-      install -D xinstall $out/bin/xinstall
-      install -D -m 0550 ${binstall} $out/bin/binstall
-      substituteInPlace $out/bin/binstall --subst-var out
-      ln -s $out/bin/binstall $out/bin/install
+    install -D install.1 $out/share/man/man1/install.1
+    install -D xinstall $out/bin/xinstall
+    install -D -m 0550 ${binstall} $out/bin/binstall
+    substituteInPlace $out/bin/binstall --subst-var out
+    ln -s $out/bin/binstall $out/bin/install
 
-      runHook postInstall
-    '';
-    setupHook = ./install-setup-hook.sh;
-  }
+    runHook postInstall
+  '';
+  setupHook = ./install-setup-hook.sh;
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/ld_elf_so.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/ld_elf_so.nix
index 1496ad6a0e88..a350e81d3206 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/ld_elf_so.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/ld_elf_so.nix
@@ -1,11 +1,12 @@
-{ lib
-, mkDerivation
-, libc
-, defaultMakeFlags
+{
+  lib,
+  mkDerivation,
+  libc,
+  defaultMakeFlags,
 }:
 
 mkDerivation {
-  path  = "libexec/ld.elf_so";
+  path = "libexec/ld.elf_so";
   version = "9.2";
   sha256 = "0ia9mqzdljly0vqfwflm5mzz55k7qsr4rw2bzhivky6k30vgirqa";
   meta.platforms = lib.platforms.netbsd;
@@ -13,6 +14,9 @@ mkDerivation {
   # Hack to prevent a symlink being installed here for compatibility.
   SHLINKINSTALLDIR = "/usr/libexec";
   USE_FORT = "yes";
-  makeFlags = defaultMakeFlags ++ [ "BINDIR=$(out)/libexec" "CLIBOBJ=${libc}/lib" ];
+  makeFlags = defaultMakeFlags ++ [
+    "BINDIR=$(out)/libexec"
+    "CLIBOBJ=${libc}/lib"
+  ];
   extraPaths = [ libc.src ] ++ libc.extraPaths;
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libc.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libc.nix
index ebc01a11668a..d755e4b6870a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libc.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libc.nix
@@ -1,14 +1,27 @@
-{ lib
-, mkDerivation
-, defaultMakeFlags
-, _mainLibcExtraPaths
-, fetchNetBSD
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, flex
-, byacc, genassym, gencat, lorder, tsort, statHook, rsync, rpcgen
-, csu, headers
-, librt
+{
+  lib,
+  mkDerivation,
+  defaultMakeFlags,
+  _mainLibcExtraPaths,
+  fetchNetBSD,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  flex,
+  byacc,
+  genassym,
+  gencat,
+  lorder,
+  tsort,
+  statHook,
+  rsync,
+  rpcgen,
+  csu,
+  headers,
+  librt,
 }:
 
 mkDerivation {
@@ -21,18 +34,32 @@ mkDerivation {
     (fetchNetBSD "external/bsd/jemalloc" "9.2" "0cq704swa0h2yxv4gc79z2lwxibk9k7pxh3q5qfs7axx3jx3n8kb")
   ];
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff flex
-    byacc genassym gencat lorder tsort statHook rsync rpcgen
+    install
+    mandoc
+    groff
+    flex
+    byacc
+    genassym
+    gencat
+    lorder
+    tsort
+    statHook
+    rsync
+    rpcgen
+  ];
+  buildInputs = [
+    headers
+    csu
   ];
-  buildInputs = [ headers csu ];
   env.NIX_CFLAGS_COMPILE = "-B${csu}/lib -fcommon";
   meta.platforms = lib.platforms.netbsd;
   SHLIBINSTALLDIR = "$(out)/lib";
   MKPICINSTALL = "yes";
   NLSDIR = "$(out)/share/nls";
-  makeFlags = defaultMakeFlags ++ [ "FILESDIR=$(out)/var/db"];
+  makeFlags = defaultMakeFlags ++ [ "FILESDIR=$(out)/var/db" ];
   postInstall = ''
     pushd ${headers}
     find . -type d -exec mkdir -p $out/\{} \;
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libcurses.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libcurses.nix
index 2409879640a9..5072821db911 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libcurses.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libcurses.nix
@@ -1,7 +1,10 @@
-{ lib, mkDerivation, stdenv
-, libterminfo
-, compatIfNeeded
-, defaultMakeFlags
+{
+  lib,
+  mkDerivation,
+  stdenv,
+  libterminfo,
+  compatIfNeeded,
+  defaultMakeFlags,
 }:
 
 mkDerivation {
@@ -9,11 +12,14 @@ mkDerivation {
   version = "9.2";
   sha256 = "0pd0dggl3w4bv5i5h0s1wrc8hr66n4hkv3zlklarwfdhc692fqal";
   buildInputs = [ libterminfo ];
-  env.NIX_CFLAGS_COMPILE = toString ([
-    "-D__scanflike(a,b)="
-    "-D__va_list=va_list"
-    "-D__warn_references(a,b)="
-  ] ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)=");
+  env.NIX_CFLAGS_COMPILE = toString (
+    [
+      "-D__scanflike(a,b)="
+      "-D__va_list=va_list"
+      "-D__warn_references(a,b)="
+    ]
+    ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)="
+  );
   propagatedBuildInputs = compatIfNeeded;
   MKDOC = "no"; # missing vfontedpr
   makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${libterminfo}/lib" ];
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libedit.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libedit.nix
index eb734f34c3d4..ee1e7bf79f96 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libedit.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libedit.nix
@@ -1,26 +1,32 @@
-{ lib, mkDerivation
-, libterminfo, libcurses
-, compatIfNeeded
-, defaultMakeFlags
+{
+  lib,
+  mkDerivation,
+  libterminfo,
+  libcurses,
+  compatIfNeeded,
+  defaultMakeFlags,
 }:
 
 mkDerivation {
-    path = "lib/libedit";
-    version = "9.2";
-    sha256 = "1wqhngraxwqk4jgrf5f18jy195yrp7c06n1gf31pbplq79mg1bcj";
-    buildInputs = [ libterminfo libcurses ];
-    propagatedBuildInputs = compatIfNeeded;
-    SHLIBINSTALLDIR = "$(out)/lib";
-    makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${libterminfo}/lib" ];
-    postPatch = ''
-      sed -i '1i #undef bool_t' $COMPONENT_PATH/el.h
-      substituteInPlace $COMPONENT_PATH/config.h \
-        --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
-      substituteInPlace $COMPONENT_PATH/readline/Makefile --replace /usr/include "$out/include"
-    '';
-    env.NIX_CFLAGS_COMPILE = toString [
-      "-D__noinline="
-      "-D__scanflike(a,b)="
-      "-D__va_list=va_list"
-    ];
-  }
+  path = "lib/libedit";
+  version = "9.2";
+  sha256 = "1wqhngraxwqk4jgrf5f18jy195yrp7c06n1gf31pbplq79mg1bcj";
+  buildInputs = [
+    libterminfo
+    libcurses
+  ];
+  propagatedBuildInputs = compatIfNeeded;
+  SHLIBINSTALLDIR = "$(out)/lib";
+  makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${libterminfo}/lib" ];
+  postPatch = ''
+    sed -i '1i #undef bool_t' $COMPONENT_PATH/el.h
+    substituteInPlace $COMPONENT_PATH/config.h \
+      --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
+    substituteInPlace $COMPONENT_PATH/readline/Makefile --replace /usr/include "$out/include"
+  '';
+  env.NIX_CFLAGS_COMPILE = toString [
+    "-D__noinline="
+    "-D__scanflike(a,b)="
+    "-D__va_list=va_list"
+  ];
+}
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libm.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libm.nix
index 86990088adf2..f36e97f8e6ae 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libm.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libm.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, sys }:
+{
+  lib,
+  mkDerivation,
+  sys,
+}:
 
 mkDerivation {
   path = "lib/libm";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpci.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpci.nix
index 21ca0f62fd4e..b0be4a2da723 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpci.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpci.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, sys }:
+{
+  lib,
+  mkDerivation,
+  sys,
+}:
 
 mkDerivation {
   pname = "libpci";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/base.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/base.nix
index 485a12837bcb..d8ea7c553eba 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/base.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/base.nix
@@ -3,4 +3,3 @@
   version = "9.2";
   sha256 = "0mlmc31k509dwfmx5s2x010wxjc44mr6y0cbmk30cfipqh8c962h";
 }
-
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/headers.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/headers.nix
index 3896562501fc..c3cc899017ee 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/headers.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/headers.nix
@@ -1,9 +1,12 @@
 { lib, mkDerivation }:
 
-mkDerivation (import ./base.nix // {
-  pname = "libpthread-headers";
-  installPhase = "includesPhase";
-  dontBuild = true;
-  noCC = true;
-  meta.platforms = lib.platforms.netbsd;
-})
+mkDerivation (
+  import ./base.nix
+  // {
+    pname = "libpthread-headers";
+    installPhase = "includesPhase";
+    dontBuild = true;
+    noCC = true;
+    meta.platforms = lib.platforms.netbsd;
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix
index c2a0d407718e..88d392e20b4a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libpthread/package.nix
@@ -1,15 +1,28 @@
-{ lib, mkDerivation
-, headers
-, common, libc, librt, sys
+{
+  lib,
+  mkDerivation,
+  headers,
+  common,
+  libc,
+  librt,
+  sys,
 }:
 
-mkDerivation (import ./base.nix // {
-  pname = "libpthread";
-  installPhase = null;
-  noCC = false;
-  dontBuild = false;
-  buildInputs = [ headers ];
-  SHLIBINSTALLDIR = "$(out)/lib";
-  extraPaths = [ common libc.src librt.src sys.src ];
-  meta.platforms = lib.platforms.netbsd;
-})
+mkDerivation (
+  import ./base.nix
+  // {
+    pname = "libpthread";
+    installPhase = null;
+    noCC = false;
+    dontBuild = false;
+    buildInputs = [ headers ];
+    SHLIBINSTALLDIR = "$(out)/lib";
+    extraPaths = [
+      common
+      libc.src
+      librt.src
+      sys.src
+    ];
+    meta.platforms = lib.platforms.netbsd;
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libresolv.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libresolv.nix
index 2427592e4aa9..24bc4f2f9e00 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libresolv.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libresolv.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, libc }:
+{
+  lib,
+  mkDerivation,
+  libc,
+}:
 
 mkDerivation {
   path = "lib/libresolv";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librpcsvc.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librpcsvc.nix
index 87524339e268..8d757a8a8430 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librpcsvc.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librpcsvc.nix
@@ -1,9 +1,15 @@
-{ lib
-, mkDerivation
-, defaultMakeFlags
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, tsort, lorder, rpcgen, statHook
+{
+  lib,
+  mkDerivation,
+  defaultMakeFlags,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  rpcgen,
+  statHook,
 }:
 
 mkDerivation {
@@ -13,9 +19,13 @@ mkDerivation {
   makeFlags = defaultMakeFlags ++ [ "INCSDIR=$(out)/include/rpcsvc" ];
   meta.platforms = lib.platforms.netbsd;
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install tsort lorder rpcgen statHook
+    install
+    tsort
+    lorder
+    rpcgen
+    statHook
   ];
 }
-
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librt.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librt.nix
index 2ffe0787004a..fa0229953b66 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librt.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/librt.nix
@@ -1,4 +1,9 @@
-{ lib, mkDerivation, libc, headers }:
+{
+  lib,
+  mkDerivation,
+  libc,
+  headers,
+}:
 
 mkDerivation {
   path = "lib/librt";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libterminfo.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libterminfo.nix
index b9268cc7ba33..6ac573d865b1 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libterminfo.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libterminfo.nix
@@ -1,8 +1,18 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal, install, tsort, lorder, mandoc, statHook, nbperf, tic, rsync
-, compatIfNeeded
-, fetchNetBSD
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  mandoc,
+  statHook,
+  nbperf,
+  tic,
+  rsync,
+  compatIfNeeded,
+  fetchNetBSD,
 }:
 
 mkDerivation {
@@ -10,8 +20,17 @@ mkDerivation {
   version = "9.2";
   sha256 = "0pq05k3dj0dfsczv07frnnji92mazmy2qqngqbx2zgqc1x251414";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
-    makeMinimal install tsort lorder mandoc statHook nbperf tic rsync
+    bsdSetupHook
+    netbsdSetupHook
+    makeMinimal
+    install
+    tsort
+    lorder
+    mandoc
+    statHook
+    nbperf
+    tic
+    rsync
   ];
   buildInputs = compatIfNeeded;
   SHLIBINSTALLDIR = "$(out)/lib";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix
index 4aaf8f0e7ab6..fdc57df9c231 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/libutil.nix
@@ -1,20 +1,41 @@
-{ mkDerivation
-, common, libc, sys
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, byacc, install, tsort, lorder, mandoc, statHook, rsync
-, headers
+{
+  mkDerivation,
+  common,
+  libc,
+  sys,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  byacc,
+  install,
+  tsort,
+  lorder,
+  mandoc,
+  statHook,
+  rsync,
+  headers,
 }:
 
 mkDerivation {
   path = "lib/libutil";
   version = "9.2";
   sha256 = "02gm5a5zhh8qp5r5q5r7x8x6x50ir1i0ncgsnfwh1vnrz6mxbq7z";
-  extraPaths = [ common libc.src sys.src ];
+  extraPaths = [
+    common
+    libc.src
+    sys.src
+  ];
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    byacc install tsort lorder mandoc statHook rsync
+    byacc
+    install
+    tsort
+    lorder
+    mandoc
+    statHook
+    rsync
   ];
   buildInputs = [ headers ];
   SHLIBINSTALLDIR = "$(out)/lib";
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/lorder.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/lorder.nix
index d3109601382a..0b99a794b07a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/lorder.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/lorder.nix
@@ -1,7 +1,12 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, rsync
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  rsync,
 }:
 
 mkDerivation {
@@ -9,8 +14,12 @@ mkDerivation {
   version = "9.2";
   sha256 = "0rjf9blihhm0n699vr2bg88m4yjhkbxh6fxliaay3wxkgnydjwn2";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff rsync
+    install
+    mandoc
+    groff
+    rsync
   ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/make.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/make.nix
index dcd80ef00467..381e30916407 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/make.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/make.nix
@@ -1,56 +1,63 @@
-{ lib, mkDerivation, fetchNetBSD, stdenv }:
+{
+  lib,
+  mkDerivation,
+  fetchNetBSD,
+  stdenv,
+}:
 
 mkDerivation {
   path = "usr.bin/make";
   sha256 = "0vi73yicbmbp522qzqvd979cx6zm5jakhy77xh73c1kygf8klccs";
   version = "9.2";
 
- postPatch = ''
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
-     --replace '-o ''${DOCOWN}' "" \
-     --replace '-g ''${DOCGRP}' ""
-   for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
-     substituteInPlace $mk \
-       --replace '-o ''${BINOWN}' "" \
-       --replace '-g ''${BINGRP}' ""
-   done
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
-     --replace '-o ''${KMODULEOWN}' "" \
-     --replace '-g ''${KMODULEGRP}' ""
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
-     --replace '-o ''${LIBOWN}' "" \
-     --replace '-g ''${LIBGRP}' "" \
-     --replace '-o ''${DEBUGOWN}' "" \
-     --replace '-g ''${DEBUGGRP}' ""
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
-     --replace '-o ''${LIBOWN}' "" \
-     --replace '-g ''${LIBGRP}' ""
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
-     --replace '-o ''${MANOWN}' "" \
-     --replace '-g ''${MANGRP}' ""
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
-     --replace '-o ''${NLSOWN}' "" \
-     --replace '-g ''${NLSGRP}' ""
-   substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
-     --replace '-o ''${BINOWN}' "" \
-     --replace '-g ''${BINGRP}' "" \
-     --replace '-o ''${RUMPBINOWN}' "" \
-     --replace '-g ''${RUMPBINGRP}' "" \
-     --replace '-o ''${DEBUGOWN}' "" \
-     --replace '-g ''${DEBUGGRP}' ""
+  postPatch =
+    ''
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
+        --replace '-o ''${DOCOWN}' "" \
+        --replace '-g ''${DOCGRP}' ""
+      for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
+        substituteInPlace $mk \
+          --replace '-o ''${BINOWN}' "" \
+          --replace '-g ''${BINGRP}' ""
+      done
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
+        --replace '-o ''${KMODULEOWN}' "" \
+        --replace '-g ''${KMODULEGRP}' ""
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
+        --replace '-o ''${LIBOWN}' "" \
+        --replace '-g ''${LIBGRP}' "" \
+        --replace '-o ''${DEBUGOWN}' "" \
+        --replace '-g ''${DEBUGGRP}' ""
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
+        --replace '-o ''${LIBOWN}' "" \
+        --replace '-g ''${LIBGRP}' ""
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
+        --replace '-o ''${MANOWN}' "" \
+        --replace '-g ''${MANGRP}' ""
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
+        --replace '-o ''${NLSOWN}' "" \
+        --replace '-g ''${NLSGRP}' ""
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
+        --replace '-o ''${BINOWN}' "" \
+        --replace '-g ''${BINGRP}' "" \
+        --replace '-o ''${RUMPBINOWN}' "" \
+        --replace '-g ''${RUMPBINGRP}' "" \
+        --replace '-o ''${DEBUGOWN}' "" \
+        --replace '-g ''${DEBUGGRP}' ""
 
-    # make needs this to pick up our sys make files
-    export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
+       # make needs this to pick up our sys make files
+       export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
 
-    substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
-      --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
-    substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
-      --replace /bin/rm rm
-  '' + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
-      --replace '-Wl,--fatal-warnings' "" \
-      --replace '-Wl,--warn-shared-textrel' ""
-  '';
+       substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
+         --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
+       substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
+         --replace /bin/rm rm
+    ''
+    + lib.optionalString stdenv.isDarwin ''
+      substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
+        --replace '-Wl,--fatal-warnings' "" \
+        --replace '-Wl,--warn-shared-textrel' ""
+    '';
   postInstall = ''
     make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install
   '';
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix
index 18655b3bf863..585c72bd1798 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/makeMinimal.nix
@@ -1,6 +1,9 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook, rsync
-, make
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  rsync,
+  make,
 }:
 
 mkDerivation {
@@ -8,9 +11,11 @@ mkDerivation {
   sha256 = "0fh0nrnk18m613m5blrliq2aydciv51qhc0ihsj4k63incwbk90n";
   version = "9.2";
 
-  buildInputs = [];
+  buildInputs = [ ];
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook rsync
+    bsdSetupHook
+    netbsdSetupHook
+    rsync
   ];
 
   skipIncludesPhase = true;
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/mkDerivation.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/mkDerivation.nix
index 82e8889f6cf4..849d2b1da3fb 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/mkDerivation.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/mkDerivation.nix
@@ -1,82 +1,113 @@
-{ lib
-, stdenvNoCC, stdenv
-, fetchNetBSD
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, tsort, lorder
-, mandoc, groff, statHook, rsync
-, compatIfNeeded
-, defaultMakeFlags
+{
+  lib,
+  stdenvNoCC,
+  stdenv,
+  fetchNetBSD,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  mandoc,
+  groff,
+  statHook,
+  rsync,
+  compatIfNeeded,
+  defaultMakeFlags,
 }:
 
-lib.makeOverridable (attrs: let
-  stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
-in stdenv'.mkDerivation ({
-  pname = "${attrs.pname or (baseNameOf attrs.path)}-netbsd";
-  inherit (attrs) version;
-  src = fetchNetBSD attrs.path attrs.version attrs.sha256;
+lib.makeOverridable (
+  attrs:
+  let
+    stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
+  in
+  stdenv'.mkDerivation (
+    {
+      pname = "${attrs.pname or (baseNameOf attrs.path)}-netbsd";
+      inherit (attrs) version;
+      src = fetchNetBSD attrs.path attrs.version attrs.sha256;
 
-  extraPaths = [ ];
+      extraPaths = [ ];
 
-  nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
-    makeMinimal
-    install tsort lorder mandoc groff statHook rsync
-  ];
-  buildInputs = compatIfNeeded;
+      nativeBuildInputs = [
+        bsdSetupHook
+        netbsdSetupHook
+        makeMinimal
+        install
+        tsort
+        lorder
+        mandoc
+        groff
+        statHook
+        rsync
+      ];
+      buildInputs = compatIfNeeded;
 
-  HOST_SH = stdenv'.shell;
+      HOST_SH = stdenv'.shell;
 
-  MACHINE_ARCH = {
-    i486 = "i386";
-    i586 = "i386";
-    i686 = "i386";
-  }.${stdenv'.hostPlatform.parsed.cpu.name}
-    or stdenv'.hostPlatform.parsed.cpu.name;
+      MACHINE_ARCH =
+        {
+          i486 = "i386";
+          i586 = "i386";
+          i686 = "i386";
+        }
+        .${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
 
-  MACHINE = {
-    x86_64 = "amd64";
-    aarch64 = "evbarm64";
-    i486 = "i386";
-    i586 = "i386";
-    i686 = "i386";
-  }.${stdenv'.hostPlatform.parsed.cpu.name}
-    or stdenv'.hostPlatform.parsed.cpu.name;
+      MACHINE =
+        {
+          x86_64 = "amd64";
+          aarch64 = "evbarm64";
+          i486 = "i386";
+          i586 = "i386";
+          i686 = "i386";
+        }
+        .${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
 
-  COMPONENT_PATH = attrs.path;
+      COMPONENT_PATH = attrs.path;
 
-  makeFlags = defaultMakeFlags;
+      makeFlags = defaultMakeFlags;
 
-  strictDeps = true;
+      strictDeps = true;
 
-  meta = with lib; {
-    maintainers = with maintainers; [ matthewbauer qyliss ];
-    platforms = platforms.unix;
-    license = licenses.bsd2;
-  };
-
-} // lib.optionalAttrs stdenv'.hasCC {
-  # TODO should CC wrapper set this?
-  CPP = "${stdenv'.cc.targetPrefix}cpp";
-} // lib.optionalAttrs stdenv'.isDarwin {
-  MKRELRO = "no";
-} // lib.optionalAttrs (stdenv'.cc.isClang or false) {
-  HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
-} // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
-  HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
-} // lib.optionalAttrs (stdenv'.isx86_32) {
-  USE_SSP = "no";
-} // lib.optionalAttrs (attrs.headersOnly or false) {
-  installPhase = "includesPhase";
-  dontBuild = true;
-} // attrs // {
-  # Files that use NetBSD-specific macros need to have nbtool_config.h
-  # included ahead of them on non-NetBSD platforms.
-  postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
-    set +e
-    grep -Zlr "^__RCSID
-    ^__BEGIN_DECLS" $COMPONENT_PATH | xargs -0r grep -FLZ nbtool_config.h |
-        xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
-    set -e
-  '' + attrs.postPatch or "";
-}))
+      meta = with lib; {
+        maintainers = with maintainers; [
+          matthewbauer
+          qyliss
+        ];
+        platforms = platforms.unix;
+        license = licenses.bsd2;
+      };
+    }
+    // lib.optionalAttrs stdenv'.hasCC {
+      # TODO should CC wrapper set this?
+      CPP = "${stdenv'.cc.targetPrefix}cpp";
+    }
+    // lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
+    // lib.optionalAttrs (stdenv'.cc.isClang or false) {
+      HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
+    }
+    // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
+      HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
+    }
+    // lib.optionalAttrs (stdenv'.isx86_32) { USE_SSP = "no"; }
+    // lib.optionalAttrs (attrs.headersOnly or false) {
+      installPhase = "includesPhase";
+      dontBuild = true;
+    }
+    // attrs
+    // {
+      # Files that use NetBSD-specific macros need to have nbtool_config.h
+      # included ahead of them on non-NetBSD platforms.
+      postPatch =
+        lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
+          set +e
+          grep -Zlr "^__RCSID
+          ^__BEGIN_DECLS" $COMPONENT_PATH | xargs -0r grep -FLZ nbtool_config.h |
+              xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
+          set -e
+        ''
+        + attrs.postPatch or "";
+    }
+  )
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/nbperf.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/nbperf.nix
index 02ce7cf6ce5e..a23c5dddfc9f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/nbperf.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/nbperf.nix
@@ -5,4 +5,3 @@ mkDerivation {
   version = "9.2";
   sha256 = "1nxc302vgmjhm3yqdivqyfzslrg0vjpbss44s74rcryrl19mma9r";
 }
-
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/package.nix
index e80571f2bf9a..31368523ee6f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/package.nix
@@ -1,5 +1,3 @@
 { makeSetupHook }:
 
-makeSetupHook {
-    name = "netbsd-setup-hook";
-  } ./setup-hook.sh
+makeSetupHook { name = "netbsd-setup-hook"; } ./setup-hook.sh
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh
index fa8b19e7d8ce..ef00ea418e53 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh
@@ -9,6 +9,7 @@ mergeNetBSDSourceDir() {
 
 addNetBSDMakeFlags() {
   makeFlags="INCSDIR=${!outputDev}/include $makeFlags"
+  makeFlags="MANDIR=${!outputMan}/share/man $makeFlags"
 }
 
 postUnpackHooks+=(mergeNetBSDSourceDir)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/hook.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/hook.nix
index 78186f55cd45..e38c53a3aac5 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/hook.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/hook.nix
@@ -1,4 +1,8 @@
-{ makeSetupHook, writeText, stat }:
+{
+  makeSetupHook,
+  writeText,
+  stat,
+}:
 
 # stat isn't in POSIX, and NetBSD stat supports a completely
 # different range of flags than GNU stat, so including it in PATH
@@ -6,9 +10,8 @@
 # NetBSD's build system and NetBSD stat without including it in
 # PATH.
 
-makeSetupHook {
-  name = "netbsd-stat-hook";
-} (writeText "netbsd-stat-hook-impl" ''
-  makeFlagsArray+=(TOOL_STAT=${stat}/bin/stat)
-'')
-
+makeSetupHook { name = "netbsd-stat-hook"; } (
+  writeText "netbsd-stat-hook-impl" ''
+    makeFlagsArray+=(TOOL_STAT=${stat}/bin/stat)
+  ''
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/package.nix
index fa4d5cb3e21f..397b1f5303c1 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/stat/package.nix
@@ -1,7 +1,12 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, rsync
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  rsync,
 }:
 
 # Don't add this to nativeBuildInputs directly.
@@ -12,8 +17,12 @@ mkDerivation {
   version = "9.2";
   sha256 = "18nqwlndfc34qbbgqx5nffil37jfq9aw663ippasfxd2hlyc106x";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff rsync
+    install
+    mandoc
+    groff
+    rsync
   ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix
index ba458ef5c712..4c140fa3bdef 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix
@@ -1,9 +1,20 @@
-{ lib, mkDerivation
-, include
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal, install, tsort, lorder, statHook, rsync, uudecode, config, genassym
-, defaultMakeFlags
-, common
+{
+  lib,
+  mkDerivation,
+  include,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  statHook,
+  rsync,
+  uudecode,
+  config,
+  genassym,
+  defaultMakeFlags,
+  common,
 }:
 {
   path = "sys";
@@ -29,23 +40,34 @@
     ''
       substituteInPlace sys/arch/i386/stand/efiboot/Makefile.efiboot \
         --replace "-nocombreloc" "-z nocombreloc"
-    '' +
-    # multiple header dirs, see above
-    include.postPatch;
+    ''
+    +
+      # multiple header dirs, see above
+      include.postPatch;
 
   CONFIG = "GENERIC";
 
   propagatedBuildInputs = [ include ];
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
-    makeMinimal install tsort lorder statHook rsync uudecode config genassym
+    bsdSetupHook
+    netbsdSetupHook
+    makeMinimal
+    install
+    tsort
+    lorder
+    statHook
+    rsync
+    uudecode
+    config
+    genassym
   ];
 
-  postConfigure = ''
-    pushd arch/$MACHINE/conf
-    config $CONFIG
-    popd
-  ''
+  postConfigure =
+    ''
+      pushd arch/$MACHINE/conf
+      config $CONFIG
+      popd
+    ''
     # multiple header dirs, see above
     + include.postConfigure;
 
@@ -68,5 +90,4 @@
 
   meta.platforms = lib.platforms.netbsd;
   extraPaths = [ common ];
-
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/headers.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/headers.nix
index a3f20d772a3e..2df35efc199a 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/headers.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/headers.nix
@@ -1,21 +1,49 @@
-{ lib, mkDerivation
-, include
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal, install, tsort, lorder, statHook, rsync, uudecode, config, genassym
-, defaultMakeFlags
-, common
+{
+  lib,
+  mkDerivation,
+  include,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  statHook,
+  rsync,
+  uudecode,
+  config,
+  genassym,
+  defaultMakeFlags,
+  common,
 }:
 let
   base = import ./base.nix {
     inherit
-      lib mkDerivation include bsdSetupHook netbsdSetupHook makeMinimal install
-      tsort lorder statHook rsync uudecode config genassym defaultMakeFlags
-      common;
+      lib
+      mkDerivation
+      include
+      bsdSetupHook
+      netbsdSetupHook
+      makeMinimal
+      install
+      tsort
+      lorder
+      statHook
+      rsync
+      uudecode
+      config
+      genassym
+      defaultMakeFlags
+      common
+      ;
   };
 in
-  mkDerivation (base // {
+mkDerivation (
+  base
+  // {
     pname = "sys-headers";
     installPhase = "includesPhase";
     dontBuild = true;
     noCC = true;
-  })
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/package.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/package.nix
index 87031a50346e..c8e6edab5f48 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/package.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/sys/package.nix
@@ -1,21 +1,49 @@
-{ lib, mkDerivation
-, include
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal, install, tsort, lorder, statHook, rsync, uudecode, config, genassym
-, defaultMakeFlags
-, common
+{
+  lib,
+  mkDerivation,
+  include,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  tsort,
+  lorder,
+  statHook,
+  rsync,
+  uudecode,
+  config,
+  genassym,
+  defaultMakeFlags,
+  common,
 }:
 let
   base = import ./base.nix {
     inherit
-      lib mkDerivation include bsdSetupHook netbsdSetupHook makeMinimal install
-      tsort lorder statHook rsync uudecode config genassym defaultMakeFlags
-      common;
+      lib
+      mkDerivation
+      include
+      bsdSetupHook
+      netbsdSetupHook
+      makeMinimal
+      install
+      tsort
+      lorder
+      statHook
+      rsync
+      uudecode
+      config
+      genassym
+      defaultMakeFlags
+      common
+      ;
   };
 in
-  mkDerivation (base // {
+mkDerivation (
+  base
+  // {
     pname = "sys";
     installPhase = null;
     noCC = false;
     dontBuild = false;
-  })
+  }
+)
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tic.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tic.nix
index 2a7e3644b6be..e0900652108f 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tic.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tic.nix
@@ -1,11 +1,17 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, nbperf, rsync
-, compatIfNeeded
-, defaultMakeFlags
-, libterminfo
-, fetchNetBSD
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  nbperf,
+  rsync,
+  compatIfNeeded,
+  defaultMakeFlags,
+  libterminfo,
+  fetchNetBSD,
 }:
 
 mkDerivation {
@@ -15,9 +21,14 @@ mkDerivation {
   HOSTPROG = "tic";
   buildInputs = compatIfNeeded;
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff nbperf rsync
+    install
+    mandoc
+    groff
+    nbperf
+    rsync
   ];
   makeFlags = defaultMakeFlags ++ [ "TOOLDIR=$(out)" ];
   extraPaths = [
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tsort.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tsort.nix
index 334eccc64c55..9200bc57a73e 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tsort.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/tsort.nix
@@ -1,7 +1,12 @@
-{ mkDerivation
-, bsdSetupHook, netbsdSetupHook
-, makeMinimal
-, install, mandoc, groff, rsync
+{
+  mkDerivation,
+  bsdSetupHook,
+  netbsdSetupHook,
+  makeMinimal,
+  install,
+  mandoc,
+  groff,
+  rsync,
 }:
 
 mkDerivation {
@@ -9,8 +14,12 @@ mkDerivation {
   version = "9.2";
   sha256 = "1dqvf9gin29nnq3c4byxc7lfd062pg7m84843zdy6n0z63hnnwiq";
   nativeBuildInputs = [
-    bsdSetupHook netbsdSetupHook
+    bsdSetupHook
+    netbsdSetupHook
     makeMinimal
-    install mandoc groff rsync
+    install
+    mandoc
+    groff
+    rsync
   ];
 }
diff --git a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/uudecode.nix b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/uudecode.nix
index dac9674f9d6f..7592db3eaf18 100644
--- a/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/uudecode.nix
+++ b/nixpkgs/pkgs/os-specific/bsd/netbsd/pkgs/uudecode.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, stdenv }:
+{
+  lib,
+  mkDerivation,
+  stdenv,
+}:
 
 mkDerivation {
   path = "usr.bin/uudecode";
@@ -7,4 +11,3 @@ mkDerivation {
   env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isLinux "-DNO_BASE64";
   NIX_LDFLAGS = lib.optional stdenv.isDarwin "-lresolv";
 }
-
diff --git a/nixpkgs/pkgs/os-specific/bsd/setup-hook.sh b/nixpkgs/pkgs/os-specific/bsd/setup-hook.sh
index e0afefcd73f7..f9453708ab5d 100644
--- a/nixpkgs/pkgs/os-specific/bsd/setup-hook.sh
+++ b/nixpkgs/pkgs/os-specific/bsd/setup-hook.sh
@@ -49,7 +49,6 @@ addMakeFlags() {
   makeFlags="LIBDIR=${!outputLib}/lib $makeFlags"
   makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags"
   makeFlags="SHAREDIR=${!outputLib}/share $makeFlags"
-  makeFlags="MANDIR=${!outputMan}/share/man $makeFlags"
   makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags"
   makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags"
   makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags"
diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/default.nix b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/default.nix
index 1bd574fe46a4..d44e67ac5969 100644
--- a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/default.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/default.nix
@@ -11,7 +11,6 @@ let
     };
     "osx-10.12.6" = {
       xnu           = "3789.70.16";
-      libiconv      = "50";
       Libnotify     = "165.20.1";
       objc4         = "709.1";
       dyld          = "433.5";
@@ -38,7 +37,6 @@ let
       dtrace        = "168";
       xnu           = "3248.60.10";
       libpthread    = "138.10.4";
-      libiconv      = "44";
       Libnotify     = "150.40.1";
       objc4         = "680";
       eap8021x      = "222.40.1";
@@ -272,7 +270,6 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
     };
     libclosure      = applePackage "libclosure"        "osx-10.11.6"     "sha256-L5rQ+UBpf3B+W1U+gZKk7fXulslHsc8lxnCsplV+nr0=" {};
     libdispatch     = applePackage "libdispatch"       "osx-10.10.5"     "sha256-jfAEk0OLrJa9AIZVikIoHomd+l+4rCfc320Xh50qK5M=" {};
-    libiconv        = applePackage "libiconv"          "osx-10.12.6"     "sha256-ZzPFkchK3EU95UQUVVrR0t8iilhi/VnIkjjtP6KT2oI=" {};
     Libinfo         = applePackage "Libinfo"           "osx-10.11.6"     "sha256-6F7wiwerv4nz/xXHtp1qCHSaFzZgzcRN+jbmXA5oWOQ=" {};
     Libm            = applePackage "Libm"              "osx-10.7.4"      "sha256-KjMETfT4qJm0m0Ux/F6Rq8bI4Q4UVnFx6IKbKxXd+Es=" {};
     Libnotify       = applePackage "Libnotify"         "osx-10.12.6"     "sha256-6wvMBxAUfiYcQtmlfYCj1d3kFmFM/jdboTd7hRvi3e4=" {};
diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
deleted file mode 100644
index 6a3bddc211e9..000000000000
--- a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-{ stdenv, appleDerivation, lib
-, enableStatic ? stdenv.hostPlatform.isStatic
-, enableShared ? !stdenv.hostPlatform.isStatic
-}:
-
-appleDerivation {
-  postUnpack = "sourceRoot=$sourceRoot/libiconv";
-
-  preConfigure = lib.optionalString stdenv.hostPlatform.isiOS ''
-    sed -i 's/darwin\*/ios\*/g' configure libcharset/configure
-  '';
-
-  configureFlags = [
-    (lib.enableFeature enableStatic "static")
-    (lib.enableFeature enableShared "shared")
-  ];
-
-  postInstall = lib.optionalString enableShared ''
-    mv $out/lib/libiconv.dylib $out/lib/libiconv-nocharset.dylib
-    ${stdenv.cc.bintools.targetPrefix}install_name_tool -id $out/lib/libiconv-nocharset.dylib $out/lib/libiconv-nocharset.dylib
-
-    # re-export one useless symbol; ld will reject a dylib that only reexports other dylibs
-    echo 'void dont_use_this(){}' | ${stdenv.cc.bintools.targetPrefix}clang -dynamiclib -x c - -current_version 2.4.0 \
-      -compatibility_version 7.0.0 -current_version 7.0.0 -o $out/lib/libiconv.dylib \
-      -Wl,-reexport_library -Wl,$out/lib/libiconv-nocharset.dylib \
-      -Wl,-reexport_library -Wl,$out/lib/libcharset.dylib
-  '';
-
-  setupHooks = [
-    ../../../../build-support/setup-hooks/role.bash
-    ../../../../development/libraries/libiconv/setup-hook.sh
-  ];
-
-  meta = {
-    mainProgram = "iconv";
-    platforms = lib.platforms.darwin;
-  };
-}
diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/macos-11.0.1.nix b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/macos-11.0.1.nix
index b4a7bbc4df24..2de90a023676 100644
--- a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/macos-11.0.1.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/macos-11.0.1.nix
@@ -27,7 +27,6 @@ file_cmds = applePackage' "file_cmds" "321.40.3" "macos-11.0.1" "0p077lnbcy8266m
 hfs = applePackage' "hfs" "556.41.1" "macos-11.0.1" "0a0s6b12b0q07wslfifna0bj51dml9v098i4crr2m1vivnx4xj75" {};
 libclosure = applePackage' "libclosure" "78" "macos-11.0.1" "0vf9n0k3m8dbprv1bf45zqg0g43bidy2i5z1v9a826bsf8lv7am7" {};
 libdispatch = applePackage' "libdispatch" "1271.40.12" "macos-11.0.1" "1ck5srcjapg18vqb8wl08gacs7ndc6xr067qjn3ngx39q1jdcywz" {};
-libiconv = applePackage' "libiconv" "59" "macos-11.0.1" "0lwa4brdwm4lvrdnxylzsn1yph4m7csgri2zkc4xb4xiisz32pwp" {};
 libmalloc = applePackage' "libmalloc" "317.40.8" "macos-11.0.1" "sha256-Tdhb0mq3w4Hwvp3xHB79Vr22hCOQK6h28HCsd7jvITI=" {};
 libplatform = applePackage' "libplatform" "254.40.4" "macos-11.0.1" "1qf3ri0yd8b1xjln1j1gyx7ks6k3a2jhd63blyvfby75y9s7flky" {};
 libpthread = applePackage' "libpthread" "454.40.3" "macos-11.0.1" "0zljbw8mpb80n1if65hhi9lkgwbgjr8vc9wvf7q1nl3mzyl35f8p" {};
diff --git a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/system_cmds/meson.build b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/system_cmds/meson.build
index de73e88f5d4d..af08b5074bef 100644
--- a/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/system_cmds/meson.build
+++ b/nixpkgs/pkgs/os-specific/darwin/apple-source-releases/system_cmds/meson.build
@@ -88,6 +88,7 @@ install_man('accton/accton.8')
 executable(
     'arch',
     build_by_default : sdk_version.version_compare('>=11'),
+    dependencies : [ core_foundation ],
     install : sdk_version.version_compare('>=11'),
     sources : 'arch/arch.c'
 )
@@ -145,7 +146,7 @@ install_man('chkpasswd/chkpasswd.8')
 
 executable(
     'chpass',
-    dependencies : [ cfopen_directory, directory_service, open_directory ],
+    dependencies : [ core_foundation, cfopen_directory, directory_service, open_directory ],
     install : true,
     sources : [
         'chpass/chpass.c',
@@ -358,7 +359,7 @@ install_man(
 executable(
     'nvram',
     c_args : '-DTARGET_OS_BRIDGE=0',
-    dependencies : [ iokit, libc_private, xnu_private ],
+    dependencies : [ core_foundation, iokit, libc_private, xnu_private ],
     install : true,
     sources : 'nvram/nvram.c'
 )
@@ -377,7 +378,7 @@ install_man('pagesize/pagesize.1')
 
 executable(
     'passwd',
-    dependencies : [ cfopen_directory, directory_service, open_directory, pam ],
+    dependencies : [ core_foundation, cfopen_directory, directory_service, open_directory, pam ],
     install : true,
     sources : [
         'passwd/file_passwd.c',
@@ -521,7 +522,7 @@ executable(
     'zlog',
     build_by_default : sdk_version.version_compare('>=11'),
     c_args : '-DKERN_NOT_FOUND=56',
-    dependencies : core_symbolication,
+    dependencies : [ core_foundation, core_symbolication ],
     install : sdk_version.version_compare('>=11'),
     sources : [
         'zlog/SymbolicationHelper.c',
diff --git a/nixpkgs/pkgs/os-specific/darwin/openwith/default.nix b/nixpkgs/pkgs/os-specific/darwin/openwith/default.nix
index eb78f7a1344c..d28ed4942821 100644
--- a/nixpkgs/pkgs/os-specific/darwin/openwith/default.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/openwith/default.nix
@@ -1,6 +1,7 @@
-{ lib, stdenv, fetchFromGitHub, swift, AppKit, Foundation, UniformTypeIdentifiers }:
+{ lib, swiftPackages, fetchFromGitHub }:
 
 let
+  inherit (swiftPackages) apple_sdk stdenv swift;
   arch = if stdenv.isAarch64 then "arm64" else "x86_64";
 in
 stdenv.mkDerivation rec {
@@ -16,7 +17,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ swift ];
 
-  buildInputs = [ AppKit Foundation UniformTypeIdentifiers ];
+  buildInputs = with apple_sdk.frameworks; [ AppKit Foundation UniformTypeIdentifiers ];
 
   makeFlags = [ "openwith_${arch}" ];
 
@@ -32,6 +33,5 @@ stdenv.mkDerivation rec {
     license = licenses.unlicense;
     maintainers = with maintainers; [ zowoq ];
     platforms = [ "aarch64-darwin" "x86_64-darwin" ];
-    broken = stdenv.isx86_64; # https://hydra.nixos.org/build/219354133/nixlog/3
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/darwin/raycast/default.nix b/nixpkgs/pkgs/os-specific/darwin/raycast/default.nix
index b6626c4d4ead..da73099da861 100644
--- a/nixpkgs/pkgs/os-specific/darwin/raycast/default.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/raycast/default.nix
@@ -10,12 +10,12 @@
 
 stdenvNoCC.mkDerivation (finalAttrs: {
   pname = "raycast";
-  version = "1.72.0";
+  version = "1.74.0";
 
   src = fetchurl {
     name = "Raycast.dmg";
     url = "https://releases.raycast.com/releases/${finalAttrs.version}/download?build=universal";
-    hash = "sha256-L6CXWRmBfit+uWODEWt7u71shFAadPOqtNifMnSp0BU=";
+    hash = "sha256-aPpxPjEhy1uLekHMLyI18mlSozffMA+HB1OdqpULVnw=";
   };
 
   dontPatch = true;
diff --git a/nixpkgs/pkgs/os-specific/darwin/rectangle/default.nix b/nixpkgs/pkgs/os-specific/darwin/rectangle/default.nix
index ca83bb7db4c0..af7bb58e54a1 100644
--- a/nixpkgs/pkgs/os-specific/darwin/rectangle/default.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/rectangle/default.nix
@@ -7,11 +7,11 @@
 
 stdenvNoCC.mkDerivation rec {
   pname = "rectangle";
-  version = "0.77";
+  version = "0.79";
 
   src = fetchurl {
     url = "https://github.com/rxhanson/Rectangle/releases/download/v${version}/Rectangle${version}.dmg";
-    hash = "sha256-wViFngw6iwlOG7KsW+zqxjm9ZRJahscX0TYz7/7T5nw=";
+    hash = "sha256-XczwgLONTt7wL+oW1ruw6wBwZTMd5VyN+79xJy0NUIg=";
   };
 
   sourceRoot = ".";
diff --git a/nixpkgs/pkgs/os-specific/darwin/utm/default.nix b/nixpkgs/pkgs/os-specific/darwin/utm/default.nix
index 50f84a254dfc..4915b9b54d78 100644
--- a/nixpkgs/pkgs/os-specific/darwin/utm/default.nix
+++ b/nixpkgs/pkgs/os-specific/darwin/utm/default.nix
@@ -7,11 +7,11 @@
 
 stdenvNoCC.mkDerivation rec {
   pname = "utm";
-  version = "4.4.5";
+  version = "4.5.2";
 
   src = fetchurl {
     url = "https://github.com/utmapp/UTM/releases/download/v${version}/UTM.dmg";
-    hash = "sha256-FlIPSWqY2V1akd/InS6BPEBfc8pomJ8jgDns7wvaOm8=";
+    hash = "sha256-pBRmtHXnw9BoFeaCCokk5hulChdEFl9dENbL8zzXMzs=";
   };
 
   nativeBuildInputs = [ undmg makeWrapper ];
@@ -57,7 +57,7 @@ stdenvNoCC.mkDerivation rec {
       See https://docs.getutm.app/ for more information.
     '';
     homepage = "https://mac.getutm.app/";
-    changelog = "https://github.com/utmapp/${pname}/releases/tag/v${version}";
+    changelog = "https://github.com/utmapp/utm/releases/tag/v${version}";
     mainProgram = "UTM";
     license = licenses.asl20;
     platforms = platforms.darwin; # 11.3 is the minimum supported version as of UTM 4.
diff --git a/nixpkgs/pkgs/os-specific/linux/batman-adv/version.nix b/nixpkgs/pkgs/os-specific/linux/batman-adv/version.nix
index 545285a6cf42..6292552dd554 100644
--- a/nixpkgs/pkgs/os-specific/linux/batman-adv/version.nix
+++ b/nixpkgs/pkgs/os-specific/linux/batman-adv/version.nix
@@ -1,16 +1,16 @@
 {
-  version = "2024.0";
+  version = "2024.1";
 
   # To get these, run:
   #
   # ```
   # for tool in alfred batctl batman-adv; do
-  #   nix-prefetch-url https://downloads.open-mesh.org/batman/releases/batman-adv-2024.0/$tool-2024.0.tar.gz --type sha256 | xargs nix hash to-sri --type sha256
+  #   nix-prefetch-url https://downloads.open-mesh.org/batman/releases/batman-adv-2024.1/$tool-2024.1.tar.gz --type sha256 | xargs nix hash to-sri --type sha256
   # done
   # ```
   sha256 = {
-    alfred = "sha256-0CmkNjirFnceX3HhNLyEPRcT10BBxlvNoYox0Y9VMb0=";
-    batctl = "sha256-doU+hyAa9jxBHbFS/QxiWnKalzMRWJfRMxYE4sWmfH0=";
-    batman-adv = "sha256-YREGl7V5n2RqKoKk3Pl/rtS7EqfMQ79Gg9LE3k9rQOc=";
+    alfred = "sha256-Ji2tOcm+EirH8GFwXIo+O21GJ4K74zcubfyazgw4Tbk=";
+    batctl = "sha256-aD3anWBU6yYKGsACLGQnmP9ASNbFOmcuoLMXjmt1egk=";
+    batman-adv = "sha256-pxQynGJR9IMOnPA/U8v7IoDwZ4RxtUxdRvrmGngtQyU=";
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/bcc/absolute-ausyscall.patch b/nixpkgs/pkgs/os-specific/linux/bcc/absolute-ausyscall.patch
deleted file mode 100644
index 7480e9c5d97b..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/bcc/absolute-ausyscall.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 01e793163231c5085afced37471df32b94a313f5 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
-Date: Thu, 30 Dec 2021 06:34:41 +0100
-Subject: [PATCH] absolute ausyscall
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
----
- libbpf-tools/syscall_helpers.c | 2 +-
- src/python/bcc/syscall.py      | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/libbpf-tools/syscall_helpers.c b/libbpf-tools/syscall_helpers.c
-index e114a08f..62adea78 100644
---- a/libbpf-tools/syscall_helpers.c
-+++ b/libbpf-tools/syscall_helpers.c
-@@ -47,7 +47,7 @@ void init_syscall_names(void)
- 	int err;
- 	FILE *f;
- 
--	f = popen("ausyscall --dump 2>/dev/null", "r");
-+	f = popen("@ausyscall@ --dump 2>/dev/null", "r");
- 	if (!f) {
- 		warn("popen: ausyscall --dump: %s\n", strerror(errno));
- 		return;
-diff --git a/src/python/bcc/syscall.py b/src/python/bcc/syscall.py
-index 1346b4e8..e7e29a11 100644
---- a/src/python/bcc/syscall.py
-+++ b/src/python/bcc/syscall.py
-@@ -376,7 +376,7 @@ def _parse_syscall(line):
- try:
-     # Skip the first line, which is a header. The rest of the lines are simply
-     # SYSCALL_NUM\tSYSCALL_NAME pairs.
--    out = subprocess.check_output(['ausyscall', '--dump'], stderr=subprocess.STDOUT)
-+    out = subprocess.check_output(['@ausyscall@', '--dump'], stderr=subprocess.STDOUT)
-     # remove the first line of expected output
-     out = out.split(b'\n',1)[1]
-     syscalls = dict(map(_parse_syscall, out.strip().split(b'\n')))
--- 
-2.34.0
-
diff --git a/nixpkgs/pkgs/os-specific/linux/bcc/default.nix b/nixpkgs/pkgs/os-specific/linux/bcc/default.nix
deleted file mode 100644
index 3cf9b26f4fdd..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/bcc/default.nix
+++ /dev/null
@@ -1,122 +0,0 @@
-{ audit
-, bash
-, bison
-, cmake
-, elfutils
-, fetchFromGitHub
-, flex
-, iperf
-, lib
-, libbpf
-, llvmPackages
-, luajit
-, makeWrapper
-, netperf
-, nixosTests
-, python3
-, stdenv
-, zip
-}:
-
-python3.pkgs.buildPythonApplication rec {
-  pname = "bcc";
-  version = "0.30.0";
-
-  disabled = !stdenv.isLinux;
-
-  src = fetchFromGitHub {
-    owner = "iovisor";
-    repo = "bcc";
-    rev = "v${version}";
-    hash = "sha256-ngGLGfLv2prnjhgaRPf8ea3oyy4129zGodR0Yz1QtCw=";
-  };
-  format = "other";
-
-  buildInputs = with llvmPackages; [
-    llvm llvm.dev libclang
-    elfutils luajit netperf iperf
-    flex bash libbpf
-  ];
-
-  patches = [
-    # This is needed until we fix
-    # https://github.com/NixOS/nixpkgs/issues/40427
-    ./fix-deadlock-detector-import.patch
-  ];
-
-  propagatedBuildInputs = [ python3.pkgs.netaddr ];
-  nativeBuildInputs = [
-    bison
-    cmake
-    flex
-    llvmPackages.llvm.dev
-    makeWrapper
-    python3.pkgs.setuptools
-    zip
-  ];
-
-  cmakeFlags = [
-    "-DBCC_KERNEL_MODULES_DIR=/run/booted-system/kernel-modules/lib/modules"
-    "-DREVISION=${version}"
-    "-DENABLE_USDT=ON"
-    "-DENABLE_CPP_API=ON"
-    "-DCMAKE_USE_LIBBPF_PACKAGE=ON"
-    "-DENABLE_LIBDEBUGINFOD=OFF"
-  ];
-
-  # to replace this executable path:
-  # https://github.com/iovisor/bcc/blob/master/src/python/bcc/syscall.py#L384
-  ausyscall = "${audit}/bin/ausyscall";
-
-  postPatch = ''
-    substituteAll ${./libbcc-path.patch} ./libbcc-path.patch
-    patch -p1 < libbcc-path.patch
-
-    substituteAll ${./absolute-ausyscall.patch} ./absolute-ausyscall.patch
-    patch -p1 < absolute-ausyscall.patch
-
-    # https://github.com/iovisor/bcc/issues/3996
-    substituteInPlace src/cc/libbcc.pc.in \
-      --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
-  '';
-
-  preInstall = ''
-    # required for setuptool during install
-    export PYTHONPATH=$out/${python3.sitePackages}:$PYTHONPATH
-  '';
-  postInstall = ''
-    mkdir -p $out/bin $out/share
-    rm -r $out/share/bcc/tools/old
-    mv $out/share/bcc/tools/doc $out/share
-    mv $out/share/bcc/man $out/share/
-
-    find $out/share/bcc/tools -type f -executable -print0 | \
-    while IFS= read -r -d ''$'\0' f; do
-      bin=$out/bin/$(basename $f)
-      if [ ! -e $bin ]; then
-        ln -s $f $bin
-      fi
-      substituteInPlace "$f" \
-        --replace '$(dirname $0)/lib' "$out/share/bcc/tools/lib"
-    done
-
-    sed -i -e "s!lib=.*!lib=$out/bin!" $out/bin/{java,ruby,node,python}gc
-  '';
-
-  postFixup = ''
-    wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
-  '';
-
-  outputs = [ "out" "man" ];
-
-  passthru.tests = {
-    bpf = nixosTests.bpf;
-  };
-
-  meta = with lib; {
-    description = "Dynamic Tracing Tools for Linux";
-    homepage    = "https://iovisor.github.io/bcc/";
-    license     = licenses.asl20;
-    maintainers = with maintainers; [ ragge mic92 thoughtpolice martinetd ];
-  };
-}
diff --git a/nixpkgs/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch b/nixpkgs/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch
deleted file mode 100644
index 1c422635f4fe..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- source.org/tools/deadlock.py	1980-01-02 00:00:00.000000000 +0000
-+++ source/tools/deadlock.py	2018-05-29 13:57:11.807126673 +0100
-@@ -44,9 +44,8 @@
- #
- # 01-Feb-2017   Kenny Yu   Created this.
- 
--from __future__ import (
--    absolute_import, division, unicode_literals, print_function
--)
-+from __future__ import absolute_import, division, unicode_literals, print_function
-+
- from bcc import BPF
- from collections import defaultdict
- import argparse
diff --git a/nixpkgs/pkgs/os-specific/linux/bcc/libbcc-path.patch b/nixpkgs/pkgs/os-specific/linux/bcc/libbcc-path.patch
deleted file mode 100644
index 187bb3aadd00..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/bcc/libbcc-path.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- source.org/src/python/bcc/libbcc.py	2018-05-13 08:35:06.850522883 +0100
-+++ source/src/python/bcc/libbcc.py	2018-05-13 08:36:24.602733151 +0100
-@@ -14,7 +14,7 @@
- 
- import ctypes as ct
- 
--lib = ct.CDLL("libbcc.so.0", use_errno=True)
-+lib = ct.CDLL("@out@/lib/libbcc.so.0", use_errno=True)
- 
- # keep in sync with bpf_common.h
- lib.bpf_module_create_b.restype = ct.c_void_p
diff --git a/nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix b/nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix
deleted file mode 100644
index 068f4532451b..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix
+++ /dev/null
@@ -1,71 +0,0 @@
-{ lib, stdenv, fetchFromGitHub, fetchpatch
-, llvmPackages, elfutils, bcc
-, libbpf, libbfd, libopcodes
-, cereal, asciidoctor
-, cmake, pkg-config, flex, bison
-, util-linux
-, nixosTests
-}:
-
-stdenv.mkDerivation rec {
-  pname = "bpftrace";
-  version = "0.20.3";
-
-  src = fetchFromGitHub {
-    owner = "iovisor";
-    repo  = "bpftrace";
-    rev   = "v${version}";
-    hash  = "sha256-B4BxoZSPSpDWLUgcYgQEmuhVr2mX04hrFCLu04vp1so=";
-  };
-
-
-  buildInputs = with llvmPackages; [
-    llvm libclang
-    elfutils bcc
-    libbpf libbfd libopcodes
-    cereal asciidoctor
-  ];
-
-  nativeBuildInputs = [
-    cmake pkg-config flex bison
-    llvmPackages.llvm.dev
-    util-linux
-  ];
-
-  # tests aren't built, due to gtest shenanigans. see:
-  #
-  #     https://github.com/iovisor/bpftrace/issues/161#issuecomment-453606728
-  #     https://github.com/iovisor/bpftrace/pull/363
-  #
-  cmakeFlags = [
-    "-DBUILD_TESTING=FALSE"
-    "-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
-    "-DINSTALL_TOOL_DOCS=OFF"
-    "-DUSE_SYSTEM_BPF_BCC=ON"
-  ];
-
-
-  # Pull BPF scripts into $PATH (next to their bcc program equivalents), but do
-  # not move them to keep `${pkgs.bpftrace}/share/bpftrace/tools/...` working.
-  postInstall = ''
-    ln -sr $out/share/bpftrace/tools/*.bt $out/bin/
-    # do not use /usr/bin/env for shipped tools
-    # If someone can get patchShebangs to work here please fix.
-    sed -i -e "1s:#!/usr/bin/env bpftrace:#!$out/bin/bpftrace:" $out/share/bpftrace/tools/*.bt
-  '';
-
-  outputs = [ "out" "man" ];
-
-  passthru.tests = {
-    bpf = nixosTests.bpf;
-  };
-
-  meta = with lib; {
-    description = "High-level tracing language for Linux eBPF";
-    homepage    = "https://github.com/iovisor/bpftrace";
-    changelog   = "https://github.com/iovisor/bpftrace/releases/tag/v${version}";
-    mainProgram = "bpftrace";
-    license     = licenses.asl20;
-    maintainers = with maintainers; [ rvl thoughtpolice martinetd mfrw ];
-  };
-}
diff --git a/nixpkgs/pkgs/os-specific/linux/cpupower-gui/default.nix b/nixpkgs/pkgs/os-specific/linux/cpupower-gui/default.nix
index 02a781d1f0cf..754f8e139615 100644
--- a/nixpkgs/pkgs/os-specific/linux/cpupower-gui/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/cpupower-gui/default.nix
@@ -19,7 +19,7 @@
 , pygobject3
 , pyxdg
 , systemd
-, wrapGAppsHook
+, wrapGAppsHook3
 }:
 
 buildPythonApplication rec {
@@ -55,7 +55,7 @@ buildPythonApplication rec {
     meson
     ninja
     pkg-config
-    wrapGAppsHook
+    wrapGAppsHook3
 
     # Python packages
     dbus-python
diff --git a/nixpkgs/pkgs/os-specific/linux/cryptodev/default.nix b/nixpkgs/pkgs/os-specific/linux/cryptodev/default.nix
index cacef99afd74..bb3c0cdd3891 100644
--- a/nixpkgs/pkgs/os-specific/linux/cryptodev/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/cryptodev/default.nix
@@ -1,4 +1,10 @@
-{ fetchFromGitHub, lib, stdenv, kernel ? false }:
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  fetchpatch,
+  kernel ? false,
+}:
 
 stdenv.mkDerivation rec {
   pname = "cryptodev-linux-1.13";
@@ -11,6 +17,13 @@ stdenv.mkDerivation rec {
     hash = "sha256-EzTPoKYa+XWOAa/Dk7ru02JmlymHeXVX7RMmEoJ1OT0=";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/cryptodev-linux/cryptodev-linux/compare/cryptodev-linux-1.13...5e7121e45ff283d30097da381fd7e97c4bb61364.patch";
+      hash = "sha256-GLWpiInBrUcVhpvEjTmD5KLCrrFZnlJGnmLU0QYz+4A=";
+    })
+  ];
+
   nativeBuildInputs = kernel.moduleBuildDependencies;
   hardeningDisable = [ "pic" ];
 
diff --git a/nixpkgs/pkgs/os-specific/linux/ddcci/default.nix b/nixpkgs/pkgs/os-specific/linux/ddcci/default.nix
index ce435b3874f3..4d1c9bd93558 100644
--- a/nixpkgs/pkgs/os-specific/linux/ddcci/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ddcci/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitLab, kernel }:
+{ lib, stdenv, fetchFromGitLab, kernel, fetchpatch }:
 
 stdenv.mkDerivation rec {
   pname = "ddcci-driver";
@@ -12,6 +12,15 @@ stdenv.mkDerivation rec {
     hash = "sha256-4pCfXJcteWwU6cK8OOSph4XlhKTk289QqLxsSWY7cac=";
   };
 
+  patches = [
+    # See https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/-/merge_requests/15
+    (fetchpatch {
+      name = "fix-build-with-linux68.patch";
+      url = "https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/-/commit/3eb20df68a545d07b8501f13fa9d20e9c6f577ed.patch";
+      hash = "sha256-Y1ktYaJTd9DtT/mwDqtjt/YasW9cVm0wI43wsQhl7Bg=";
+    })
+  ];
+
   hardeningDisable = [ "pic" ];
 
   nativeBuildInputs = kernel.moduleBuildDependencies;
@@ -36,7 +45,7 @@ stdenv.mkDerivation rec {
     description = "Kernel module driver for DDC/CI monitors";
     homepage = "https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux";
     license = licenses.gpl2Plus;
-    maintainers = with maintainers; [ ];
+    maintainers = with maintainers; [ kiike ];
     platforms = platforms.linux;
     broken = kernel.kernelOlder "5.1";
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/digimend/default.nix b/nixpkgs/pkgs/os-specific/linux/digimend/default.nix
index 11756dcbe85c..a30d7cbe3a32 100644
--- a/nixpkgs/pkgs/os-specific/linux/digimend/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/digimend/default.nix
@@ -1,14 +1,19 @@
-{ lib, stdenv, fetchFromGitHub, kernel }:
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  kernel,
+}:
 
 stdenv.mkDerivation rec {
   pname = "digimend";
-  version = "unstable-2023-05-03";
+  version = "13";
 
   src = fetchFromGitHub {
     owner = "digimend";
     repo = "digimend-kernel-drivers";
-    rev = "eca6e1b701bffb80a293234a485ebf6b4bc85562";
-    hash = "sha256-0mjIUgHvbNcVQVzU3xzaloe5R41a4eknDhdhruJH+6c=";
+    rev = "v${version}";
+    hash = "sha256-YYCxTyoZGMnqC2nKkRi5Z1uofldGvJDGY2/sO9iMNIo=";
   };
 
   postPatch = ''
diff --git a/nixpkgs/pkgs/os-specific/linux/ena/default.nix b/nixpkgs/pkgs/os-specific/linux/ena/default.nix
index b6ed869a71f5..9ce71745cdcf 100644
--- a/nixpkgs/pkgs/os-specific/linux/ena/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ena/default.nix
@@ -1,14 +1,14 @@
 { lib, stdenv, fetchFromGitHub, kernel }:
 
 stdenv.mkDerivation rec {
-  version = "2.8.9";
+  version = "2.12.0";
   name = "ena-${version}-${kernel.version}";
 
   src = fetchFromGitHub {
     owner = "amzn";
     repo = "amzn-drivers";
     rev = "ena_linux_${version}";
-    hash = "sha256-9Csrq9wM7Q99qPj7+NlnQgP6KcciNHMbAAb+Wg7eYAU=";
+    hash = "sha256-Z/eeIUY7Yl2l/IqK3Z2nxPhn+JLvP976IZ9ZXPBqoSo=";
   };
 
   hardeningDisable = [ "pic" ];
@@ -19,6 +19,12 @@ stdenv.mkDerivation rec {
   # linux 3.12
   env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
 
+  patches = [
+    # Use kernel version checks instead of API feature detection
+    # See https://github.com/NixOS/nixpkgs/pull/310680
+    ./override-features-api-detection.patch
+  ];
+
   configurePhase = ''
     runHook preConfigure
     cd kernel/linux/ena
diff --git a/nixpkgs/pkgs/os-specific/linux/ena/override-features-api-detection.patch b/nixpkgs/pkgs/os-specific/linux/ena/override-features-api-detection.patch
new file mode 100644
index 000000000000..099530b12171
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/linux/ena/override-features-api-detection.patch
@@ -0,0 +1,55 @@
+diff --git a/kernel/linux/ena/kcompat.h b/kernel/linux/ena/kcompat.h
+index 32a9cc5..8d39362 100644
+--- a/kernel/linux/ena/kcompat.h
++++ b/kernel/linux/ena/kcompat.h
+@@ -888,21 +888,6 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
+ #define ENA_XDP_XMIT_FREES_FAILED_DESCS_INTERNALLY
+ #endif
+ 
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) && \
+-	!(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 188) && \
+-	 LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)) && \
+-	!(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 251) && \
+-	 LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0))) && \
+-	!(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 6)) && \
+-	!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 4)) && \
+-	!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL == 3) && \
+-	  ENA_KERNEL_VERSION_GTE(5, 3, 18, 150300, 59, 43))
+-static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
+-{
+-	memcpy(dev->dev_addr, addr, ETH_ALEN);
+-}
+-#endif
+-
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || \
+ 	(defined(RHEL_RELEASE_CODE) && \
+ 	RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 6) && \
+@@ -1112,7 +1097,7 @@ static inline void ena_dma_unmap_page_attrs(struct device *dev,
+ #define pci_dev_id(pdev) ((((u16)(pdev->bus->number)) << 8) | (pdev->devfn))
+ #endif /* ENA_HAVE_PCI_DEV_ID */
+ 
+-#ifndef ENA_HAVE_XDP_DO_FLUSH
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
+ #define xdp_do_flush xdp_do_flush_map
+ #endif /* ENA_HAVE_XDP_DO_FLUSH */
+ 
+@@ -1147,15 +1132,15 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
+ }
+ #endif /* ENA_HAVE_CPUMASK_LOCAL_SPREAD */
+ 
+-#ifndef ENA_HAVE_UPDATE_AFFINITY_HINT
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
+ static inline int irq_update_affinity_hint(unsigned int irq, const struct cpumask *m)
+ {
+ 	return 0;
+ }
+-#endif /* ENA_HAVE_UPDATE_AFFINITY_HINT */
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5.17.0) */
+ 
+-#ifndef ENA_HAVE_ETHTOOL_PUTS
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+ #define ethtool_puts ethtool_sprintf
+-#endif /* ENA_HAVE_ETHTOOL_PUTS */
++#endif
+ 
+ #endif /* _KCOMPAT_H_ */
diff --git a/nixpkgs/pkgs/os-specific/linux/ffado/default.nix b/nixpkgs/pkgs/os-specific/linux/ffado/default.nix
index dfa974e3e683..610f9d31353e 100644
--- a/nixpkgs/pkgs/os-specific/linux/ffado/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ffado/default.nix
@@ -8,7 +8,6 @@
 , fetchurl
 , fetchpatch
 , glibmm
-, kernel
 , libavc1394
 , libconfig
 , libiec61883
@@ -22,7 +21,6 @@
 }:
 
 let
-  inherit (python3.pkgs) pyqt5 dbus-python;
   python = python3.withPackages (pkgs: with pkgs; [ pyqt5 dbus-python ]);
 in
 mkDerivation rec {
@@ -61,7 +59,7 @@ mkDerivation rec {
     pkg-config
     which
     python
-    pyqt5
+    python3.pkgs.pyqt5
     wrapQtAppsHook
   ];
 
diff --git a/nixpkgs/pkgs/os-specific/linux/firmware/firmware-manager/default.nix b/nixpkgs/pkgs/os-specific/linux/firmware/firmware-manager/default.nix
index af455e7ef61f..1682f16c3903 100644
--- a/nixpkgs/pkgs/os-specific/linux/firmware/firmware-manager/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/firmware/firmware-manager/default.nix
@@ -8,7 +8,7 @@
 , openssl
 , udev
 , gtk3
-, wrapGAppsHook
+, wrapGAppsHook3
 }:
 
 stdenv.mkDerivation rec {
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     rustc
     pkg-config
     rustPlatform.cargoSetupHook
-    wrapGAppsHook
+    wrapGAppsHook3
   ];
 
   buildInputs = [
@@ -53,7 +53,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Graphical frontend for firmware management";
     homepage = "https://github.com/pop-os/firmware-manager";
-    license = lib.licenses.gpl3;
+    license = with lib.licenses; [ gpl3Plus cc0 ];
+    mainProgram = "com.system76.FirmwareManager";
     maintainers = [ lib.maintainers.shlevy ];
     platforms = lib.platforms.linux;
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/firmware/fwupd-efi/default.nix b/nixpkgs/pkgs/os-specific/linux/firmware/fwupd-efi/default.nix
index d89c4a7b140a..1c6cc0e57e09 100644
--- a/nixpkgs/pkgs/os-specific/linux/firmware/fwupd-efi/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/firmware/fwupd-efi/default.nix
@@ -1,8 +1,7 @@
 { lib
 , stdenv
 , fetchurl
-, fetchFromGitHub
-, substituteAll
+, fetchpatch
 , pkg-config
 , meson
 , ninja
@@ -20,6 +19,14 @@ stdenv.mkDerivation rec {
     hash = "sha256-r9CAWirQgafK/y71vABM46AUe1OAFejsqWY0FxaxJg4=";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/fwupd/fwupd-efi/commit/26c6ec5c1e7765fb5dc6a4df511ab21ee6c6e67a.patch";
+      revert = true;
+      hash = "sha256-vTdYExd7OlrrZ/LhlEO1zcvpKzeT5OeOeosD8/LUkMg=";
+    })
+  ];
+
   nativeBuildInputs = [
     meson
     ninja
diff --git a/nixpkgs/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix b/nixpkgs/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix
index 71a7cd9e947b..31ac23df3960 100644
--- a/nixpkgs/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/firmware/ipu6-camera-bins/default.nix
@@ -52,9 +52,7 @@ stdenv.mkDerivation (finalAttrs: {
     sourceProvenance = with sourceTypes; [
       binaryFirmware
     ];
-    maintainers = with maintainers; [
-      hexa
-    ];
+    maintainers = with maintainers; [ ];
     platforms = [ "x86_64-linux" ];
   };
 })
diff --git a/nixpkgs/pkgs/os-specific/linux/firmware/ivsc-firmware/default.nix b/nixpkgs/pkgs/os-specific/linux/firmware/ivsc-firmware/default.nix
index e2f2fd4f9fee..3ad52b314537 100644
--- a/nixpkgs/pkgs/os-specific/linux/firmware/ivsc-firmware/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/firmware/ivsc-firmware/default.nix
@@ -40,9 +40,7 @@ stdenv.mkDerivation {
     sourceProvenance = with sourceTypes; [
       binaryFirmware
     ];
-    maintainers = with maintainers; [
-      hexa
-    ];
+    maintainers = with maintainers; [ ];
     platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/firmware/linux-firmware/source.nix b/nixpkgs/pkgs/os-specific/linux/firmware/linux-firmware/source.nix
index 3739c1dc3e46..7098f1f3203e 100644
--- a/nixpkgs/pkgs/os-specific/linux/firmware/linux-firmware/source.nix
+++ b/nixpkgs/pkgs/os-specific/linux/firmware/linux-firmware/source.nix
@@ -1,7 +1,7 @@
 # This file is autogenerated! Run ./update.sh to regenerate.
 {
-  version = "20240410";
-  revision = "20240410";
-  sourceHash = "sha256-Qo4f5kdHlBYKlzdFOtoKoCPHXxgDeCawSE3tnRwfC4U=";
-  outputHash = "sha256-pOYDdb0A1sESiT0kfA4DbWxKJ3+pog54+S3KcQB3BsA=";
+  version = "20240513";
+  revision = "20240513";
+  sourceHash = "sha256-8yzs8lgPHG3zbUvlsWSuP1O/4s28dRFbju2c9kbaFsg=";
+  outputHash = "sha256-LDd6FU1/16X7KoCCDq0yPvwJzK4H9NxHgrEdhEfaUGY=";
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/fnotifystat/default.nix b/nixpkgs/pkgs/os-specific/linux/fnotifystat/default.nix
index 18afaaa6d29b..4961450fa36e 100644
--- a/nixpkgs/pkgs/os-specific/linux/fnotifystat/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/fnotifystat/default.nix
@@ -5,13 +5,13 @@
 
 stdenv.mkDerivation rec {
   pname = "fnotifystat";
-  version = "0.02.11";
+  version = "0.03.00";
 
   src = fetchFromGitHub {
     owner = "ColinIanKing";
     repo = pname;
     rev = "V${version}";
-    hash = "sha256-CwjaDL5pt2HMUhq0Q3s6Ssp3jr9uwCdVhT1JzlKcQQw=";
+    hash = "sha256-UGww0/m+JMftQyAguc8UpPrtIphjCq9TINabFaAKN0A=";
   };
 
   installFlags = [
diff --git a/nixpkgs/pkgs/os-specific/linux/fscrypt/default.nix b/nixpkgs/pkgs/os-specific/linux/fscrypt/default.nix
index 8b54a1f9a745..2cf5243422e1 100644
--- a/nixpkgs/pkgs/os-specific/linux/fscrypt/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/fscrypt/default.nix
@@ -4,13 +4,13 @@
 
 buildGoModule rec {
   pname = "fscrypt";
-  version = "0.3.4";
+  version = "0.3.5";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "fscrypt";
     rev = "v${version}";
-    hash = "sha256-4Im3YWhLs5Q+o4DtpSuSMuKtKqXaICL9/EB0q5um6mQ=";
+    hash = "sha256-US1jw0XK1BcP037XPhttzBloDU62m4BVSIbsGs9LaJU=";
   };
 
   postPatch = ''
@@ -19,7 +19,7 @@ buildGoModule rec {
       --replace "/usr/local" "$out"
   '';
 
-  vendorHash = "sha256-APW0XM6fTQOCw4tE1NA5VNN3fBUmsvn99NqqJnB3Q0s=";
+  vendorHash = "sha256-FuVWV3Rimhd+Pm9wrKGLWQWtbP1hWvoWa22pQT+m2go=";
 
   doCheck = false;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/fw-ectool/default.nix b/nixpkgs/pkgs/os-specific/linux/fw-ectool/default.nix
index a73cc1896ecd..dd24730104f3 100644
--- a/nixpkgs/pkgs/os-specific/linux/fw-ectool/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/fw-ectool/default.nix
@@ -1,38 +1,43 @@
 { stdenv
 , lib
-, fetchFromGitHub
+, fetchFromGitLab
+, cmake
 , pkg-config
-, hostname
+, libusb1
+, libftdi1
 }:
 
 stdenv.mkDerivation {
   pname = "fw-ectool";
-  version = "unstable-2022-12-03";
+  version = "0-unstable-2024-04-23";
 
-  src = fetchFromGitHub {
+  src = fetchFromGitLab {
+    domain = "gitlab.howett.net";
     owner = "DHowett";
-    repo = "fw-ectool";
-    rev = "54c140399bbc3e6a3dce6c9f842727c4128367be";
-    hash = "sha256-2teJFz4zcA+USpbVPXMEIHLdmMLem8ik7YrmrSxr/n0=";
+    repo = "ectool";
+    rev = "abdd574ebe3640047988cb928bb6789a15dd1390";
+    hash = "sha256-j0Z2Uo1LBXlHZVHPm4Xjx3LZaI6Qq0nSdViyC/CjWC8=";
   };
 
   nativeBuildInputs = [
+    cmake
     pkg-config
-    hostname
   ];
 
-  buildPhase = ''
-    patchShebangs util
-    make out=out utils
-  '';
+  buildInputs = [
+    libusb1
+    libftdi1
+  ];
 
   installPhase = ''
-    install -D out/util/ectool $out/bin/ectool
+    runHook preInstall
+    install -Dm555 src/ectool "$out/bin/ectool"
+    runHook postInstall
   '';
 
   meta = with lib; {
     description = "EC-Tool adjusted for usage with framework embedded controller";
-    homepage = "https://github.com/DHowett/framework-ec";
+    homepage = "https://gitlab.howett.net/DHowett/ectool";
     license = licenses.bsd3;
     maintainers = [ maintainers.mkg20001 ];
     platforms = platforms.linux;
diff --git a/nixpkgs/pkgs/os-specific/linux/fwts/default.nix b/nixpkgs/pkgs/os-specific/linux/fwts/default.nix
index f04b8fcd2108..5a06fac5d6c1 100644
--- a/nixpkgs/pkgs/os-specific/linux/fwts/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/fwts/default.nix
@@ -3,11 +3,11 @@
 
 stdenv.mkDerivation rec {
   pname = "fwts";
-  version = "24.01.00";
+  version = "24.03.00";
 
   src = fetchzip {
     url = "https://fwts.ubuntu.com/release/${pname}-V${version}.tar.gz";
-    sha256 = "sha256-MXWmKxcxgSVCSeeGlWsa8JTBa5hLyvGPZ0811w+s+yA=";
+    sha256 = "sha256-UKL5q5sURSVXvEOzoZdG+wWBSS5f9YWo5stViY3F2vg=";
     stripRoot = false;
   };
 
diff --git a/nixpkgs/pkgs/os-specific/linux/game-devices-udev-rules/default.nix b/nixpkgs/pkgs/os-specific/linux/game-devices-udev-rules/default.nix
index daaf23db6ce2..ca2ef7a4498e 100644
--- a/nixpkgs/pkgs/os-specific/linux/game-devices-udev-rules/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/game-devices-udev-rules/default.nix
@@ -6,20 +6,20 @@
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "game-devices-udev-rules";
-  version = "0.22";
+  version = "0.23";
 
   src = fetchFromGitea {
     domain = "codeberg.org";
     owner = "fabiscafe";
     repo = "game-devices-udev";
     rev = finalAttrs.version;
-    hash = "sha256-1aOb8pJxB+/PM7spcvZcy/cwdEolHQ4+lwBLij+6iDk=";
+    hash = "sha256-dWWo3qXnxdLP68NuFKM4/Cw5yE6uAsWzj0vZa9UTT0U=";
   };
 
   postInstall = ''
     install -Dm444 -t "$out/lib/udev/rules.d" *.rules
     substituteInPlace $out/lib/udev/rules.d/71-powera-controllers.rules \
-    --replace "/bin/sh" "${bash}/bin/bash"
+    --replace-fail "/bin/sh" "${bash}/bin/bash"
   '';
 
   meta = with lib; {
diff --git a/nixpkgs/pkgs/os-specific/linux/guvcview/default.nix b/nixpkgs/pkgs/os-specific/linux/guvcview/default.nix
index e08203873011..d274c375fb42 100644
--- a/nixpkgs/pkgs/os-specific/linux/guvcview/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/guvcview/default.nix
@@ -21,7 +21,7 @@
 # can be turned off if used as a library
 , useGtk ? true
 , gtk3 ? null
-, wrapGAppsHook ? null
+, wrapGAppsHook3 ? null
 }:
 
 assert pulseaudioSupport -> libpulseaudio != null;
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     intltool
     pkg-config
   ]
-    ++ lib.optionals (useGtk) [ wrapGAppsHook ]
+    ++ lib.optionals (useGtk) [ wrapGAppsHook3 ]
     ++ lib.optionals (useQt) [ wrapQtAppsHook ]
   ;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/hwdata/default.nix b/nixpkgs/pkgs/os-specific/linux/hwdata/default.nix
index 83519d7f2a7a..320f10d55138 100644
--- a/nixpkgs/pkgs/os-specific/linux/hwdata/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/hwdata/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "hwdata";
-  version = "0.381";
+  version = "0.382";
 
   src = fetchFromGitHub {
     owner = "vcrhonek";
     repo = "hwdata";
     rev = "v${version}";
-    hash = "sha256-FD1p4qyO+ZsBdMXRa9u6CpO07RewWH8OxULLxcYAsyk=";
+    hash = "sha256-j7ITcLilcnV8QCUFC/Ybv1dX6Kl36P0G9vBlrzifhFQ=";
   };
 
   configureFlags = [ "--datadir=${placeholder "out"}/share" ];
diff --git a/nixpkgs/pkgs/os-specific/linux/iproute/default.nix b/nixpkgs/pkgs/os-specific/linux/iproute/default.nix
index 031dbfa700bc..597989c5a064 100644
--- a/nixpkgs/pkgs/os-specific/linux/iproute/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/iproute/default.nix
@@ -23,6 +23,10 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
+  configureFlags = [
+    "--color" "auto"
+  ];
+
   makeFlags = [
     "PREFIX=$(out)"
     "SBINDIR=$(out)/sbin"
@@ -46,7 +50,9 @@ stdenv.mkDerivation rec {
 
   depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
   nativeBuildInputs = [ bison flex pkg-config ];
-  buildInputs = [ db iptables elfutils libmnl ];
+  buildInputs = [ db iptables libmnl ]
+    # needed to uploaded bpf programs
+    ++ lib.optionals (!stdenv.hostPlatform.isStatic) [ elfutils ];
 
   enableParallelBuilding = true;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/ipu6-drivers/default.nix b/nixpkgs/pkgs/os-specific/linux/ipu6-drivers/default.nix
index fe9cb1da018c..276926fef8aa 100644
--- a/nixpkgs/pkgs/os-specific/linux/ipu6-drivers/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ipu6-drivers/default.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation {
     homepage = "https://github.com/intel/ipu6-drivers";
     description = "IPU6 kernel driver";
     license = lib.licenses.gpl2;
-    maintainers = with lib.maintainers; [ hexa ];
+    maintainers = with lib.maintainers; [ ];
     platforms = [ "x86_64-linux" ];
     # requires 6.1.7 https://github.com/intel/ipu6-drivers/pull/84
     broken = kernel.kernelOlder "6.1.7";
diff --git a/nixpkgs/pkgs/os-specific/linux/ivsc-driver/default.nix b/nixpkgs/pkgs/os-specific/linux/ivsc-driver/default.nix
index 72173de49baa..5612c9170abd 100644
--- a/nixpkgs/pkgs/os-specific/linux/ivsc-driver/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ivsc-driver/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
     homepage = "https://github.com/intel/ivsc-driver";
     description = "Intel Vision Sensing Controller kernel driver";
     license = lib.licenses.gpl2;
-    maintainers = with lib.maintainers; [ hexa ];
+    maintainers = with lib.maintainers; [ ];
     platforms = [ "x86_64-linux" ];
     broken = kernel.kernelOlder "5.15";
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/common-config.nix b/nixpkgs/pkgs/os-specific/linux/kernel/common-config.nix
index c213bd4e6ffe..84090cba867e 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/common-config.nix
@@ -871,12 +871,14 @@ let
     };
 
     zram = {
-      ZRAM            = module;
-      ZRAM_WRITEBACK  = option yes;
-      ZRAM_MULTI_COMP = whenAtLeast "6.2" yes;
-      ZSWAP           = option yes;
-      ZPOOL           = yes;
-      ZBUD            = option yes;
+      ZRAM                          = module;
+      ZRAM_WRITEBACK                = option yes;
+      ZRAM_MULTI_COMP               = whenAtLeast "6.2" yes;
+      ZRAM_DEF_COMP_ZSTD            = whenAtLeast "5.11" yes;
+      ZSWAP                         = option yes;
+      ZSWAP_COMPRESSOR_DEFAULT_ZSTD = whenAtLeast "5.7" (mkOptionDefault yes);
+      ZPOOL                         = yes;
+      ZSMALLOC                      = option yes;
     };
 
     brcmfmac = {
@@ -948,8 +950,8 @@ let
       THRUSTMASTER_FF    = yes;
       ZEROPLUS_FF        = yes;
 
-      MODULE_COMPRESS    = whenOlder "5.13" yes;
-      MODULE_COMPRESS_XZ = yes;
+      MODULE_COMPRESS      = whenOlder "5.13" yes;
+      MODULE_COMPRESS_XZ   = yes;
 
       SYSVIPC            = yes;  # System-V IPC
 
@@ -1124,6 +1126,7 @@ let
       FW_LOADER_USER_HELPER_FALLBACK = option no;
 
       FW_LOADER_COMPRESS = whenAtLeast "5.3" yes;
+      FW_LOADER_COMPRESS_ZSTD = whenAtLeast "5.19" yes;
 
       HOTPLUG_PCI_ACPI = yes; # PCI hotplug using ACPI
       HOTPLUG_PCI_PCIE = yes; # PCI-Expresscard hotplug support
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix b/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix
index 631217735d8f..37c138402d00 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix
@@ -221,7 +221,7 @@ let
     config = {
       CONFIG_MODULES = "y";
       CONFIG_FW_LOADER = "m";
-      CONFIG_RUST = lib.mkIf withRust "y";
+      CONFIG_RUST = if withRust then "y" else "n";
     };
   });
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/hardened/patches.json b/nixpkgs/pkgs/os-specific/linux/kernel/hardened/patches.json
index 21772b2e03eb..ada6932dc85f 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/hardened/patches.json
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/hardened/patches.json
@@ -2,81 +2,71 @@
     "4.19": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-4.19.309-hardened1.patch",
-            "sha256": "1hww72w5anmfr9czqbl31glzl70s34492k9qz9zax141zg1sf6sp",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/4.19.309-hardened1/linux-hardened-4.19.309-hardened1.patch"
+            "name": "linux-hardened-4.19.313-hardened1.patch",
+            "sha256": "1fa30s98cbk64315y7vwz7pc2ba0rcs2msaiiib8p85kid5c80v8",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/4.19.313-hardened1/linux-hardened-4.19.313-hardened1.patch"
         },
-        "sha256": "1yc45kfiwdqsqa11sxafs82b0day6qvgjcll8rx9vipidsmagbcm",
-        "version": "4.19.309"
+        "sha256": "1j1r4mrdh1ray468jr5i8d2afiswb653bhq0ck8bcdw4rwp5w558",
+        "version": "4.19.313"
     },
     "5.10": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-5.10.212-hardened1.patch",
-            "sha256": "0h04i94vshhcli5m4qpnqg4vsi5v1ifvdhhklk7c0bvkfk35cbml",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.10.212-hardened1/linux-hardened-5.10.212-hardened1.patch"
+            "name": "linux-hardened-5.10.216-hardened1.patch",
+            "sha256": "1hj59x5wrh8bkgxp1f5sh8h5rirh4878gywanjmf7qjq6w2wj5rh",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.10.216-hardened1/linux-hardened-5.10.216-hardened1.patch"
         },
-        "sha256": "14vll2bghd52wngjxy78hgglydcxka59yziji0w56dcdpmky9wqc",
-        "version": "5.10.212"
+        "sha256": "0lg1zfb9y4ps86q85mlnyalb3s90zix003z62jb9bw139f65h473",
+        "version": "5.10.216"
     },
     "5.15": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-5.15.151-hardened1.patch",
-            "sha256": "040jc5n9qsdz2wv5ksfvc28vd72nmya2i2f0ps0jiras6l2wlhjz",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.15.151-hardened1/linux-hardened-5.15.151-hardened1.patch"
+            "name": "linux-hardened-5.15.158-hardened1.patch",
+            "sha256": "1q37hdac1mk91rrl2p3j4d69wiphzm1mfbvl6cxlsrc42pjbapz3",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.15.158-hardened1/linux-hardened-5.15.158-hardened1.patch"
         },
-        "sha256": "0jby224ncdardjwmf8c59s5j71inpvdlzah984ilf2b6y85pc7la",
-        "version": "5.15.151"
+        "sha256": "1inmdpif3qf1blmvjj4i7y42bylvhv0wyj3b0apq12zxlj1iq1zr",
+        "version": "5.15.158"
     },
     "5.4": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-5.4.271-hardened1.patch",
-            "sha256": "0rw5il7885d0d3k2hmh46541svib6rp32g00fcl5bw37ydmq3z8b",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.4.271-hardened1/linux-hardened-5.4.271-hardened1.patch"
+            "name": "linux-hardened-5.4.275-hardened1.patch",
+            "sha256": "10fw4hkavnj6nhjqz186sqxbvjz6g62mhyjmlnlxik322nbh6jk6",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/5.4.275-hardened1/linux-hardened-5.4.275-hardened1.patch"
         },
-        "sha256": "0l2qv4xlhnry9crs90rkihsxyny6jz8kxw08bfad7nys9hrn3g6d",
-        "version": "5.4.271"
+        "sha256": "0k1hyknx854k8z27j4rq1gcp8l0xc0bspmrhc41a033gjilb1lns",
+        "version": "5.4.275"
     },
     "6.1": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-6.1.81-hardened1.patch",
-            "sha256": "0af9dxdsa858zyqc0vsrzg098afhg5vpb2wpr6gj2ykwc13iaf07",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.1.81-hardened1/linux-hardened-6.1.81-hardened1.patch"
+            "name": "linux-hardened-6.1.90-hardened1.patch",
+            "sha256": "1wjckrv0p7phai6ian39kl0rpmzvrzz10bi92xgdq8hhsbp2p3fk",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.1.90-hardened1/linux-hardened-6.1.90-hardened1.patch"
         },
-        "sha256": "0arl96yrqplbmp2gjyqcfma1lgc30kbn95m0sflv0yyldwf8dg8f",
-        "version": "6.1.81"
-    },
-    "6.5": {
-        "patch": {
-            "extra": "-hardened1",
-            "name": "linux-hardened-6.5.13-hardened1.patch",
-            "sha256": "1fj6yaq2gdjlj2h19vkm13jrx0yiczj6pvric1kq1r6cprqrkkki",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.5.13-hardened1/linux-hardened-6.5.13-hardened1.patch"
-        },
-        "sha256": "1dfbbydmayfj9npx3z0g38p574pmcx3qgs49dv0npigl48wd9yvq",
-        "version": "6.5.13"
+        "sha256": "07cfg0chssvpc4mqls3aln6s4lqjp6k4x2n63wndmkjgfqpdg8w3",
+        "version": "6.1.90"
     },
     "6.6": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-6.6.21-hardened1.patch",
-            "sha256": "0k35s5pj92lvfp6kw3isg78zc3gijsg0xbzcyvxdkmhzaq8j6i1i",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.6.21-hardened1/linux-hardened-6.6.21-hardened1.patch"
+            "name": "linux-hardened-6.6.30-hardened1.patch",
+            "sha256": "0q6x7prx1ncf3ni5zvpjav9jcq1n50fq0wcarw022bis1rmrhczy",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.6.30-hardened1/linux-hardened-6.6.30-hardened1.patch"
         },
-        "sha256": "0mz420w99agr7jv1jgqfr4fjhzbv005xif086sqx556s900l62zf",
-        "version": "6.6.21"
+        "sha256": "1ilwmgpgvddwkd9nx5999cb6z18scjyq7jklid26k1hg7f35nsmn",
+        "version": "6.6.30"
     },
-    "6.7": {
+    "6.8": {
         "patch": {
             "extra": "-hardened1",
-            "name": "linux-hardened-6.7.6-hardened1.patch",
-            "sha256": "063yrs3g0knlz37aq979jhng9k6l19873nbi1jy167xfqmpqqajr",
-            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.7.6-hardened1/linux-hardened-6.7.6-hardened1.patch"
+            "name": "linux-hardened-6.8.9-hardened1.patch",
+            "sha256": "115d1fgddfcffmfg5f31w50lf2cskkwakngb343didrwfa28nrxf",
+            "url": "https://github.com/anthraxx/linux-hardened/releases/download/6.8.9-hardened1/linux-hardened-6.8.9-hardened1.patch"
         },
-        "sha256": "1lrp7pwnxnqyy8c2l4n4nz997039gbnssrfm8ss8kl3h2c7fr2g4",
-        "version": "6.7.6"
+        "sha256": "1dn9bgmf03bdfbmgq98d043702g808rjikxs2i9yia57iqiz21gr",
+        "version": "6.8.9"
     }
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/hardened/update.py b/nixpkgs/pkgs/os-specific/linux/kernel/hardened/update.py
index cb624ebe86b9..1e34ca209aa9 100755
--- a/nixpkgs/pkgs/os-specific/linux/kernel/hardened/update.py
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/hardened/update.py
@@ -211,6 +211,7 @@ with open(NIXPKGS_KERNEL_PATH / "kernels-org.json") as kernel_versions_json:
 
 # Remove patches for unpackaged kernel versions.
 for kernel_key in sorted(patches.keys() - kernel_versions.keys()):
+    del patches[kernel_key]
     commit_patches(kernel_key=kernel_key, message="remove")
 
 g = Github(os.environ.get("GITHUB_TOKEN"))
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/htmldocs.nix b/nixpkgs/pkgs/os-specific/linux/kernel/htmldocs.nix
index dad377db06ab..eb22645d2e9e 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/htmldocs.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/htmldocs.nix
@@ -6,8 +6,8 @@
 , makeFontsConf
 , perl
 , python3
-, sphinx
 , which
+, fetchpatch
 }:
 
 stdenv.mkDerivation {
@@ -15,6 +15,16 @@ stdenv.mkDerivation {
 
   inherit (linux_latest) version src;
 
+  patches = [
+    # docutils 0.21 has removed nodes.reprunicode
+    # fixes the `AttributeError` thrown when building docs.
+    (fetchpatch {
+      name = "docutils_fix.patch";
+      url = "https://lore.kernel.org/linux-doc/faf5fa45-2a9d-4573-9d2e-3930bdc1ed65@gmail.com/raw";
+      hash = "sha256-JuV1B/8iDysbH0tl+wr/rdXvoC34uUq25ejMFmD0hio=";
+    })
+  ];
+
   postPatch = ''
     patchShebangs \
       Documentation/sphinx/parse-headers.pl \
@@ -48,11 +58,11 @@ stdenv.mkDerivation {
     cp -r Documentation/* $out/share/doc/linux-doc/
   '';
 
-  meta = with lib; {
+  meta = {
     description = "Linux kernel html documentation";
     homepage = "https://www.kernel.org/doc/htmldocs/";
-    platforms = platforms.linux;
+    platforms = lib.platforms.linux;
     inherit (linux_latest.meta) license;
-    maintainers = with maintainers; [ ];
+    maintainers = with lib.maintainers; [ sigmanificient ];
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/kernels-org.json b/nixpkgs/pkgs/os-specific/linux/kernel/kernels-org.json
index b69c0f9c6003..bcf3560c2077 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/kernels-org.json
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/kernels-org.json
@@ -4,31 +4,35 @@
         "hash": "sha256:075l5vhk8zmwln4jks7gr5n5k67s65qvs07l2rpbc7a75fdp6c14"
     },
     "6.1": {
-        "version": "6.1.90",
-        "hash": "sha256:07cfg0chssvpc4mqls3aln6s4lqjp6k4x2n63wndmkjgfqpdg8w3"
+        "version": "6.1.91",
+        "hash": "sha256:1v2d5syxwwqlhvjzxk003qz9sr18r0n8dgg976vbi492r9iww2l8"
     },
     "5.15": {
-        "version": "5.15.158",
-        "hash": "sha256:1inmdpif3qf1blmvjj4i7y42bylvhv0wyj3b0apq12zxlj1iq1zr"
+        "version": "5.15.159",
+        "hash": "sha256:1ia1nfci2wkx4nhnldfczpcq47mp7y7g657ikkh8i72y498gwy1l"
     },
     "5.10": {
-        "version": "5.10.216",
-        "hash": "sha256:0lg1zfb9y4ps86q85mlnyalb3s90zix003z62jb9bw139f65h473"
+        "version": "5.10.217",
+        "hash": "sha256:0qhzqrjci45vcbzjch7vq75i6hpyap6yb7jw6g71phcnqgzw2ay5"
     },
     "5.4": {
-        "version": "5.4.275",
-        "hash": "sha256:0k1hyknx854k8z27j4rq1gcp8l0xc0bspmrhc41a033gjilb1lns"
+        "version": "5.4.276",
+        "hash": "sha256:01vfx19n8rv9fgjjzvi78125md71zgn5jrinbarabzr18jyjwwg2"
     },
     "4.19": {
-        "version": "4.19.313",
-        "hash": "sha256:1j1r4mrdh1ray468jr5i8d2afiswb653bhq0ck8bcdw4rwp5w558"
+        "version": "4.19.314",
+        "hash": "sha256:0nvrpg5aj2q4h2drmczprqaprcc2zhcrijfri77b830ms8rg4y2a"
     },
     "6.6": {
-        "version": "6.6.30",
-        "hash": "sha256:1ilwmgpgvddwkd9nx5999cb6z18scjyq7jklid26k1hg7f35nsmn"
+        "version": "6.6.31",
+        "hash": "sha256:080wwrc231fbf43hvvygddmdxdspyw23jc5vnd6fr5ccdybgzv6n"
     },
     "6.8": {
-        "version": "6.8.9",
-        "hash": "sha256:1dn9bgmf03bdfbmgq98d043702g808rjikxs2i9yia57iqiz21gr"
+        "version": "6.8.10",
+        "hash": "sha256:0xjirg2w5fc2w2q6wr702akszq32m31lk4q5nbjq10zqhbcr5fxh"
+    },
+    "6.9": {
+        "version": "6.9.1",
+        "hash": "sha256:0jn0qp22vx7xf2mgaj7cwf8agqhahvrwlda4ak6rw67xk2x19d01"
     }
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.10.nix b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.10.nix
index b013c7f1bf18..e19b0699a33f 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.10.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.10.nix
@@ -6,7 +6,7 @@
 , ... } @ args:
 
 let
-  version = "5.10.215-rt107"; # updated by ./update-rt.sh
+  version = "5.10.216-rt108"; # updated by ./update-rt.sh
   branch = lib.versions.majorMinor version;
   kversion = builtins.elemAt (lib.splitString "-" version) 0;
 in buildLinux (args // {
@@ -17,14 +17,14 @@ in buildLinux (args // {
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";
-    sha256 = "1af6h86flx96pszg006agpak2f9dkk2jqaazfykd7aafqdcs3747";
+    sha256 = "0lg1zfb9y4ps86q85mlnyalb3s90zix003z62jb9bw139f65h473";
   };
 
   kernelPatches = let rt-patch = {
     name = "rt";
     patch = fetchurl {
       url = "mirror://kernel/linux/kernel/projects/rt/${branch}/older/patch-${version}.patch.xz";
-      sha256 = "0lnnpnfmypafzfzhcmaxqqc18nna4fr236v6hrcyabnxmxam79xj";
+      sha256 = "0p0qmyz3g7fqlz4f638dlcp37az8lpq5yqw2fy5zqqs3qagy018j";
     };
   }; in [ rt-patch ] ++ kernelPatches;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.15.nix b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.15.nix
index 91774ba38dbd..5e43eca364d4 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.15.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-5.15.nix
@@ -6,7 +6,7 @@
 , ... } @ args:
 
 let
-  version = "5.15.153-rt75"; # updated by ./update-rt.sh
+  version = "5.15.158-rt76"; # updated by ./update-rt.sh
   branch = lib.versions.majorMinor version;
   kversion = builtins.elemAt (lib.splitString "-" version) 0;
 in buildLinux (args // {
@@ -18,14 +18,14 @@ in buildLinux (args // {
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";
-    sha256 = "1g44gjcwcdq5552vwinljqwiy90bxax72jjvdasp71x88khv3pfp";
+    sha256 = "1inmdpif3qf1blmvjj4i7y42bylvhv0wyj3b0apq12zxlj1iq1zr";
   };
 
   kernelPatches = let rt-patch = {
     name = "rt";
     patch = fetchurl {
       url = "mirror://kernel/linux/kernel/projects/rt/${branch}/older/patch-${version}.patch.xz";
-      sha256 = "04i22p0ap4dsqybf9jbbmrbzva11qknilnyk46z18gzrr0msjldl";
+      sha256 = "17kw7cs1p0qgqf911prn3472c1j7r01g0mzqxsxpkdvhawxps7wy";
     };
   }; in [ rt-patch ] ++ kernelPatches;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix
index 06028d209779..ac0f7d6d9d88 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix
@@ -6,7 +6,7 @@
 , ... } @ args:
 
 let
-  version = "6.1.83-rt28"; # updated by ./update-rt.sh
+  version = "6.1.90-rt30"; # updated by ./update-rt.sh
   branch = lib.versions.majorMinor version;
   kversion = builtins.elemAt (lib.splitString "-" version) 0;
 in buildLinux (args // {
@@ -18,14 +18,14 @@ in buildLinux (args // {
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v6.x/linux-${kversion}.tar.xz";
-    sha256 = "145iw3wii7znhrqdmgnwhswk235g6gw8axjjji2cw4rn148rddl8";
+    sha256 = "07cfg0chssvpc4mqls3aln6s4lqjp6k4x2n63wndmkjgfqpdg8w3";
   };
 
   kernelPatches = let rt-patch = {
     name = "rt";
     patch = fetchurl {
       url = "mirror://kernel/linux/kernel/projects/rt/${branch}/older/patch-${version}.patch.xz";
-      sha256 = "07wv3zd7n5378k8ywdavrp5ndqkdcis923dwpswfv7062xm34y5h";
+      sha256 = "0sgwxdy4bzjqr74nrmsyw1f2lcqpapxmkj5yywf7jkqa20jkdvgr";
     };
   }; in [ rt-patch ] ++ kernelPatches;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.6.nix b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.6.nix
index eb85f9c3cd09..5a2e8959090f 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.6.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/linux-rt-6.6.nix
@@ -6,7 +6,7 @@
 , ... } @ args:
 
 let
-  version = "6.6.25-rt29"; # updated by ./update-rt.sh
+  version = "6.6.30-rt30"; # updated by ./update-rt.sh
   branch = lib.versions.majorMinor version;
   kversion = builtins.elemAt (lib.splitString "-" version) 0;
 in buildLinux (args // {
@@ -18,14 +18,14 @@ in buildLinux (args // {
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v6.x/linux-${kversion}.tar.xz";
-    sha256 = "0i0zvqlj02rm6wpbidji0rn9559vrpfc1b8gbfjk70lhhyz11llr";
+    sha256 = "1ilwmgpgvddwkd9nx5999cb6z18scjyq7jklid26k1hg7f35nsmn";
   };
 
   kernelPatches = let rt-patch = {
     name = "rt";
     patch = fetchurl {
       url = "mirror://kernel/linux/kernel/projects/rt/${branch}/older/patch-${version}.patch.xz";
-      sha256 = "15mb4zycv86yp1cbs5svgs3pnmh8jihjhf4jxc4h4ywlzglkb1za";
+      sha256 = "05n6fyy5c0f18v4n1rfkcvqj8s0p5x6s16qq5mnmya86rhdr6gn7";
     };
   }; in [ rt-patch ] ++ kernelPatches;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/xanmod-kernels.nix b/nixpkgs/pkgs/os-specific/linux/kernel/xanmod-kernels.nix
index b7840b554bee..de33ff75d82f 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/xanmod-kernels.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/xanmod-kernels.nix
@@ -6,14 +6,14 @@ let
   # NOTE: When updating these, please also take a look at the changes done to
   # kernel config in the xanmod version commit
   ltsVariant = {
-    version = "6.6.29";
-    hash = "sha256-Be2VaW0DQDS0FJUwXM627QaNgrn1B3Hbyq+PiKb7b+k=";
+    version = "6.6.30";
+    hash = "sha256-fQATjYekxV/+24mqyel3bYfgUMN4NhOHR9yyL6L5bl0=";
     variant = "lts";
   };
 
   mainVariant = {
-    version = "6.8.8";
-    hash = "sha256-6fT9vRjHw775m4ySUAUWU9R0dz/cWYYdZsPCwZjGiXM=";
+    version = "6.8.9";
+    hash = "sha256-OUlT/fiwLGTPnr/7gneyZBio/l8KAWopcJqTpSjBMl0=";
     variant = "main";
   };
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kernel/zen-kernels.nix b/nixpkgs/pkgs/os-specific/linux/kernel/zen-kernels.nix
index 1f36e36c2335..d2e32e4b09a7 100644
--- a/nixpkgs/pkgs/os-specific/linux/kernel/zen-kernels.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kernel/zen-kernels.nix
@@ -84,8 +84,8 @@ let
       SCHED_PDS = yes;
 
       # Swap storage is compressed with LZ4 using zswap
-      ZSWAP_COMPRESSOR_DEFAULT_LZ4 = yes;
-      ZSWAP_COMPRESSOR_DEFAULT = freeform "lz4";
+      ZSWAP_COMPRESSOR_DEFAULT_LZ4  = lib.mkOptionDefault yes;
+      ZSWAP_COMPRESSOR_DEFAULT_ZSTD = lib.mkDefault no;
 
       # Fix error: unused option: XXX.
       CFS_BANDWIDTH = lib.mkForce (option no);
diff --git a/nixpkgs/pkgs/os-specific/linux/kvmfr/default.nix b/nixpkgs/pkgs/os-specific/linux/kvmfr/default.nix
index a77d1290ca80..3224fc137db1 100644
--- a/nixpkgs/pkgs/os-specific/linux/kvmfr/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/kvmfr/default.nix
@@ -6,9 +6,6 @@ stdenv.mkDerivation {
 
   src = looking-glass-client.src;
   sourceRoot = "${looking-glass-client.src.name}/module";
-  patches = lib.optional (kernel.kernelAtLeast "6.4") [
-    ./linux-6-4-compat.patch
-  ];
   hardeningDisable = [ "pic" "format" ];
   nativeBuildInputs = kernel.moduleBuildDependencies;
 
diff --git a/nixpkgs/pkgs/os-specific/linux/kvmfr/linux-6-4-compat.patch b/nixpkgs/pkgs/os-specific/linux/kvmfr/linux-6-4-compat.patch
deleted file mode 100644
index e57d1d27c36c..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/kvmfr/linux-6-4-compat.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/kvmfr.c b/kvmfr.c
-index 121aae5b..2f4c9e1a 100644
---- a/kvmfr.c
-+++ b/kvmfr.c
-@@ -539,7 +539,11 @@ static int __init kvmfr_module_init(void)
-   if (kvmfr->major < 0)
-     goto out_free;
- 
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
-   kvmfr->pClass = class_create(THIS_MODULE, KVMFR_DEV_NAME);
-+#else
-+  kvmfr->pClass = class_create(KVMFR_DEV_NAME);
-+#endif
-   if (IS_ERR(kvmfr->pClass))
-     goto out_unreg;
- 
diff --git a/nixpkgs/pkgs/os-specific/linux/ledger-udev-rules/default.nix b/nixpkgs/pkgs/os-specific/linux/ledger-udev-rules/default.nix
index 3a6bf9e5d51c..8201f12480c3 100644
--- a/nixpkgs/pkgs/os-specific/linux/ledger-udev-rules/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/ledger-udev-rules/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation {
   pname = "ledger-udev-rules";
-  version = "unstable-2021-09-10";
+  version = "0-unstable-2024-02-12";
 
   src = fetchFromGitHub {
     owner = "LedgerHQ";
     repo = "udev-rules";
-    rev = "2776324af6df36c2af4d2e8e92a1c98c281117c9";
-    sha256 = "sha256-yTYI81PXMc32lMfI5uhD14nP20zAI7ZF33V1LRDWg2Y=";
+    rev = "f474382e370c9fa2a2207e6e675b9b364441aed7";
+    sha256 = "sha256-5jN9xy3+kk540PAyfsxIqck9hdI3t2CNpgqKxLbAsDg=";
   };
 
   dontBuild = true;
@@ -22,7 +22,7 @@ stdenv.mkDerivation {
   meta = with lib; {
     description = "udev rules for Ledger devices";
     license = licenses.asl20;
-    maintainers = with maintainers; [ asymmetric ];
+    maintainers = with maintainers; [ asymmetric toasteruwu ];
     platforms = platforms.linux;
     homepage = "https://github.com/LedgerHQ/udev-rules";
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/libbpf/0.x.nix b/nixpkgs/pkgs/os-specific/linux/libbpf/0.x.nix
index 480e78d0803a..b34cca4a51af 100644
--- a/nixpkgs/pkgs/os-specific/linux/libbpf/0.x.nix
+++ b/nixpkgs/pkgs/os-specific/linux/libbpf/0.x.nix
@@ -14,13 +14,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libbpf";
-  version = "0.8.1";
+  version = "0.8.3";
 
   src = fetchFromGitHub {
     owner = "libbpf";
     repo = "libbpf";
     rev = "v${version}";
-    sha256 = "sha256-daVS+TErmDU8ksThOvcepg1A61iD8N8GIkC40cmc9/8=";
+    sha256 = "sha256-J5cUvfUYc+uLdkFa2jx/2bqBoZg/eSzc6SWlgKqcfIc=";
   };
 
   nativeBuildInputs = [ pkg-config ];
diff --git a/nixpkgs/pkgs/os-specific/linux/libbpf/default.nix b/nixpkgs/pkgs/os-specific/linux/libbpf/default.nix
index 99454beb4187..e910835ea0d7 100644
--- a/nixpkgs/pkgs/os-specific/linux/libbpf/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/libbpf/default.nix
@@ -14,13 +14,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libbpf";
-  version = "1.4.0";
+  version = "1.4.1";
 
   src = fetchFromGitHub {
     owner = "libbpf";
     repo = "libbpf";
     rev = "v${version}";
-    sha256 = "sha256-3TCsIlr28vO6Zu9lDaEq6J4J+D5sHP7SSo1O/M0ZzUo=";
+    sha256 = "sha256-dAyUBcOItDZNe2xBWoegCAmOnTugc1C7+k/hj20icJA=";
   };
 
   nativeBuildInputs = [ pkg-config ];
diff --git a/nixpkgs/pkgs/os-specific/linux/libcap-ng/default.nix b/nixpkgs/pkgs/os-specific/linux/libcap-ng/default.nix
index 59aa5bbc0e5d..478b5fa8ac2c 100644
--- a/nixpkgs/pkgs/os-specific/linux/libcap-ng/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/libcap-ng/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   pname = "libcap-ng";
-  version = "0.8.4";
+  version = "0.8.5";
 
   src = fetchurl {
     url = "https://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${version}.tar.gz";
-    sha256 = "sha256-aFgdOzjnVTy29t33gTsfyZ5ShW8hQh97R3zlq9JgWoo=";
+    hash = "sha256-O6UpTRy9+pivqs+8ALavntK4PoohgXGF39hEzIx6xv8=";
   };
 
   outputs = [ "out" "dev" "man" ];
diff --git a/nixpkgs/pkgs/os-specific/linux/libsepol/default.nix b/nixpkgs/pkgs/os-specific/linux/libsepol/default.nix
index 548d5222c7a2..41d8a724e53c 100644
--- a/nixpkgs/pkgs/os-specific/linux/libsepol/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/libsepol/default.nix
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     description = "SELinux binary policy manipulation library";
     homepage = "http://userspace.selinuxproject.org";
     platforms = platforms.linux;
-    maintainers = [ ];
+    maintainers = with maintainers; [ RossComputerGuy ];
     license = lib.licenses.gpl2Plus;
     pkgConfigModules = [ "libselinux" ];
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/libzbc/default.nix b/nixpkgs/pkgs/os-specific/linux/libzbc/default.nix
index 79a4277a8560..e2da36d9dc79 100644
--- a/nixpkgs/pkgs/os-specific/linux/libzbc/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/libzbc/default.nix
@@ -10,13 +10,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libzbc";
-  version = "5.13.0";
+  version = "5.14.0";
 
   src = fetchFromGitHub {
     owner = "westerndigitalcorporation";
     repo = "libzbc";
     rev = "v${version}";
-    sha256 = "6xkA96bgQ2Ik1vEwkw7hwjMbjMSlopzv5ziTh60Mjx0=";
+    sha256 = "sha256-+MBk2ZUr3Vt6pZFb4gTXMOzKBlf1EXMF8y/c1iDrIZM=";
   };
 
   nativeBuildInputs = [
diff --git a/nixpkgs/pkgs/os-specific/linux/microcode/intel.nix b/nixpkgs/pkgs/os-specific/linux/microcode/intel.nix
index 6953bbca8963..f099cea8ed7b 100644
--- a/nixpkgs/pkgs/os-specific/linux/microcode/intel.nix
+++ b/nixpkgs/pkgs/os-specific/linux/microcode/intel.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "microcode-intel";
-  version = "20240312";
+  version = "20240514";
 
   src = fetchFromGitHub {
     owner = "intel";
     repo = "Intel-Linux-Processor-Microcode-Data-Files";
     rev = "microcode-${version}";
-    hash = "sha256-4ZSA+LVczfjZINXhImmFOCc/6kKNrrUQvrXPdOvMM8g=";
+    hash = "sha256-6XHlAtQzHtlRs3Zy4+CC/XGJS/PkDPtTg/Y2bX7PJek=";
   };
 
   nativeBuildInputs = [ iucode-tool libarchive ];
diff --git a/nixpkgs/pkgs/os-specific/linux/vm-tools/default.nix b/nixpkgs/pkgs/os-specific/linux/mm-tools/default.nix
index c5981bfc2713..38f16ca4e7d2 100644
--- a/nixpkgs/pkgs/os-specific/linux/vm-tools/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/mm-tools/default.nix
@@ -1,12 +1,12 @@
 { lib, stdenv, linux }:
 
 stdenv.mkDerivation {
-  pname = "vm-tools";
+  pname = "mm-tools";
   inherit (linux) version src;
 
   makeFlags = [ "sbindir=${placeholder "out"}/bin" ];
 
-  preConfigure = "cd tools/vm";
+  preConfigure = "cd tools/mm";
 
   meta = with lib; {
     inherit (linux.meta) license platforms;
diff --git a/nixpkgs/pkgs/os-specific/linux/mstflint_access/default.nix b/nixpkgs/pkgs/os-specific/linux/mstflint_access/default.nix
index 6e29e27ccbf2..95168249122f 100644
--- a/nixpkgs/pkgs/os-specific/linux/mstflint_access/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/mstflint_access/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://github.com/Mellanox/mstflint/releases/download/v${version}/kernel-mstflint-${version}.tar.gz";
-    hash = "sha256-rfZts0m8x6clVazpbAa2xK+dYgRU9Us5rbcWa0uHJ1M=";
+    hash = "sha256-bWYglHJUNCPT13N7aBdjbLPMZIk7vjvF+o9W3abDNr0=";
   };
 
   nativeBuildInputs = [ kmod ] ++ kernel.moduleBuildDependencies;
@@ -18,10 +18,6 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  preConfigure = lib.optionals (lib.versionAtLeast kernel.version "6.4") ''
-    sed -i "s/class_create(THIS_MODULE, dev->name)/class_create(dev->name)/g" mst_main.c
-  '';
-
   installPhase = ''
     runHook preInstall
 
diff --git a/nixpkgs/pkgs/os-specific/linux/nftables/default.nix b/nixpkgs/pkgs/os-specific/linux/nftables/default.nix
index 3680cd43efb7..95e4183a2fb6 100644
--- a/nixpkgs/pkgs/os-specific/linux/nftables/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/nftables/default.nix
@@ -5,7 +5,6 @@
 , autoreconfHook
 , withDebugSymbols ? false
 , withCli ? true, libedit
-, withPython ? false, python3
 , withXtables ? true, iptables
 , nixosTests
 }:
@@ -29,25 +28,12 @@ stdenv.mkDerivation rec {
     libmnl libnftnl libpcap
     gmp jansson
   ] ++ lib.optional withCli libedit
-    ++ lib.optional withXtables iptables
-    ++ lib.optionals withPython [
-      python3
-      python3.pkgs.setuptools
-    ];
-
-  patches = [ ./fix-py-libnftables.patch ];
-
-  postPatch = ''
-    substituteInPlace "py/src/nftables.py" \
-      --subst-var-by "out" "$out"
-  '';
+    ++ lib.optional withXtables iptables;
 
   configureFlags = [
     "--with-json"
     (lib.withFeatureAs withCli "cli" "editline")
   ] ++ lib.optional (!withDebugSymbols) "--disable-debug"
-    ++ lib.optional (!withPython) "--disable-python"
-    ++ lib.optional withPython "--enable-python"
     ++ lib.optional withXtables "--with-xtables";
 
   passthru.tests = {
diff --git a/nixpkgs/pkgs/os-specific/linux/nftables/fix-py-libnftables.patch b/nixpkgs/pkgs/os-specific/linux/nftables/fix-py-libnftables.patch
deleted file mode 100644
index 3ab1e5363019..000000000000
--- a/nixpkgs/pkgs/os-specific/linux/nftables/fix-py-libnftables.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/py/src/nftables.py b/py/src/nftables.py
-index f1e43ade..9adcd1be 100644
---- a/py/src/nftables.py
-+++ b/py/src/nftables.py
-@@ -69,7 +69,7 @@ class Nftables:
- 
-     validator = None
- 
--    def __init__(self, sofile="libnftables.so.1"):
-+    def __init__(self, sofile="@out@/lib/libnftables.so.1"):
-         """Instantiate a new Nftables class object.
- 
-         Accepts a shared object file to open, by default standard search path
diff --git a/nixpkgs/pkgs/os-specific/linux/nftables/python.nix b/nixpkgs/pkgs/os-specific/linux/nftables/python.nix
new file mode 100644
index 000000000000..7980b8ff6de6
--- /dev/null
+++ b/nixpkgs/pkgs/os-specific/linux/nftables/python.nix
@@ -0,0 +1,26 @@
+{ lib
+, buildPythonPackage
+, setuptools
+, nftables
+}:
+
+buildPythonPackage {
+  pname = "nftables";
+  inherit (nftables) version src;
+  pyproject = true;
+
+  postPatch = ''
+    substituteInPlace "src/nftables.py" \
+      --replace-fail "libnftables.so.1" "${nftables}/lib/libnftables.so.1"
+  '';
+
+  setSourceRoot = "sourceRoot=$(echo */py)";
+
+  build-system = [ setuptools ];
+
+  pythonImportsCheck = [ "nftables" ];
+
+  meta = {
+    inherit (nftables.meta) description homepage license platforms maintainers;
+  };
+}
diff --git a/nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
index f3ee49a8c395..fb7c8b2322a7 100755
--- a/nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
+++ b/nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
@@ -391,7 +391,7 @@ if [[ -n $flake ]]; then
        flakeAttr="${BASH_REMATCH[2]}"
     fi
     if [[ -z $flakeAttr ]]; then
-        read -r hostname < /proc/sys/kernel/hostname
+        hostname="$(targetHostCmd cat /proc/sys/kernel/hostname)"
         if [[ -z $hostname ]]; then
             hostname=default
         fi
diff --git a/nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix b/nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix
index b11dc06c85eb..2d9dfd81829e 100644
--- a/nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix
+++ b/nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix
@@ -16,7 +16,7 @@ nvidia_x11: sha256:
 , libXxf86vm
 , libvdpau
 , librsvg
-, wrapGAppsHook
+, wrapGAppsHook3
 , addOpenGLRunpath
 , withGtk2 ? false
 , withGtk3 ? true
@@ -96,7 +96,7 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ pkg-config m4 addOpenGLRunpath ];
 
   buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 gtk2 dbus ]
-    ++ lib.optionals withGtk3 [ gtk3 librsvg wrapGAppsHook ];
+    ++ lib.optionals withGtk3 [ gtk3 librsvg wrapGAppsHook3 ];
 
   installFlags = [ "PREFIX=$(out)" ];
 
diff --git a/nixpkgs/pkgs/os-specific/linux/pam/default.nix b/nixpkgs/pkgs/os-specific/linux/pam/default.nix
index 2b0c327fbc2e..e5f8fec5acb1 100644
--- a/nixpkgs/pkgs/os-specific/linux/pam/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/pam/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, buildPackages, fetchurl, fetchpatch
+{ lib, stdenv, buildPackages, fetchurl
 , flex, cracklib, db4, gettext, audit, libxcrypt
 , nixosTests
 , autoreconfHook269, pkg-config-unwrapped
@@ -6,31 +6,15 @@
 
 stdenv.mkDerivation rec {
   pname = "linux-pam";
-  version = "1.6.0";
+  version = "1.6.1";
 
   src = fetchurl {
     url = "https://github.com/linux-pam/linux-pam/releases/download/v${version}/Linux-PAM-${version}.tar.xz";
-    hash = "sha256-//SjTlu+534ujxmS8nYx4jKby/igVj3etcM4m04xaa0=";
+    hash = "sha256-+JI8dAFZBS1xnb/CovgZQtaN00/K9hxwagLJuA/u744=";
   };
 
   patches = [
     ./suid-wrapper-path.patch
-
-    # Backport fix for missing include breaking musl builds.
-    (fetchpatch {
-      name = "pam_namespace-stdint.h.patch";
-      url = "https://github.com/linux-pam/linux-pam/commit/cc9d40b7cdbd3e15ccaa324a0dda1680ef9dea13.patch";
-      hash = "sha256-tCnH2yPO4dBbJOZA0fP2gm1EavHRMEJyfzB5Vy7YjAA=";
-    })
-
-    # Resotre handling of empty passwords:
-    #   https://github.com/linux-pam/linux-pam/pull/784
-    # TODO: drop upstreamed patch on 1.6.1 update.
-    (fetchpatch {
-      name = "revert-unconditional-helper.patch";
-      url = "https://github.com/linux-pam/linux-pam/commit/8d0c575336ad301cd14e16ad2fdec6fe621764b8.patch";
-      hash = "sha256-z9KfMxxqXQVnmNaixaVjLnQqaGsH8MBHhHbiP/8fvhE=";
-    })
   ];
 
   # Case-insensitivity workaround for https://github.com/linux-pam/linux-pam/issues/569
diff --git a/nixpkgs/pkgs/os-specific/linux/piper/default.nix b/nixpkgs/pkgs/os-specific/linux/piper/default.nix
index b1508dcb6a3e..dcdc7a363e30 100644
--- a/nixpkgs/pkgs/os-specific/linux/piper/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/piper/default.nix
@@ -1,5 +1,5 @@
 { lib, meson, ninja, pkg-config, gettext, fetchFromGitHub, python3
-, wrapGAppsHook, gtk3, glib, desktop-file-utils, appstream-glib, gnome
+, wrapGAppsHook3, gtk3, glib, desktop-file-utils, appstream-glib, gnome
 , gobject-introspection, librsvg }:
 
 python3.pkgs.buildPythonApplication rec {
@@ -15,7 +15,7 @@ python3.pkgs.buildPythonApplication rec {
     sha256 = "0jsvfy0ihdcgnqljfgs41lys1nlz18qvsa0a8ndx3pyr41f8w8wf";
   };
 
-  nativeBuildInputs = [ meson ninja gettext pkg-config wrapGAppsHook desktop-file-utils appstream-glib gobject-introspection ];
+  nativeBuildInputs = [ meson ninja gettext pkg-config wrapGAppsHook3 desktop-file-utils appstream-glib gobject-introspection ];
   buildInputs = [
     gtk3 glib gnome.adwaita-icon-theme python3 librsvg
   ];
diff --git a/nixpkgs/pkgs/os-specific/linux/power-profiles-daemon/default.nix b/nixpkgs/pkgs/os-specific/linux/power-profiles-daemon/default.nix
index 11f26e5013a8..f7145bc02ebe 100644
--- a/nixpkgs/pkgs/os-specific/linux/power-profiles-daemon/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/power-profiles-daemon/default.nix
@@ -11,6 +11,7 @@
 , polkit
 , dbus
 , gobject-introspection
+, wrapGAppsNoGuiHook
 , gettext
 , gtk-doc
 , docbook-xsl-nons
@@ -49,6 +50,7 @@ stdenv.mkDerivation rec {
     libxml2 # for xmllint for stripping GResources
     libxslt # for xsltproc for building docs
     gobject-introspection
+    wrapGAppsNoGuiHook
     # checkInput but cheked for during the configuring
     (python3.pythonOnBuildForHost.withPackages (ps: with ps; [
       pygobject3
@@ -95,6 +97,9 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
+  # Only need to wrap the Python tool (powerprofilectl)
+  dontWrapGApps = true;
+
   PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions";
 
   postPatch = ''
@@ -106,6 +111,10 @@ stdenv.mkDerivation rec {
       src/powerprofilesctl
   '';
 
+  postFixup = ''
+    wrapGApp "$out/bin/powerprofilesctl"
+  '';
+
   passthru = {
     tests = {
       nixos = nixosTests.power-profiles-daemon;
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8189es/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8189es/default.nix
index e31a54f56c31..553c6a309682 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8189es/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8189es/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "rtl8189es-${kernel.version}-${version}";
-  version = "2023-03-14";
+  version = "2024-01-21";
 
   src = fetchFromGitHub {
     owner = "jwrdegoede";
     repo = "rtl8189ES_linux";
-    rev = "ae7b31e55526ca0e01d2a3310118530bff4f1055";
-    sha256 = "sha256-l/xUxs63Y5LVT6ZafuRc+iaCXCSt2HwysYJLJ5hg3RM=";
+    rev = "eb51e021b0e1b6f94a4b49da3f4ee5c5fb20b715";
+    sha256 = "sha256-n7Bsstr1H1RvguAyJnVqk/JgEx8WEZWaVg7ZfEYykR0=";
   };
 
   nativeBuildInputs = [ bc nukeReferences ] ++ kernel.moduleBuildDependencies;
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8189fs/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8189fs/default.nix
index 67642f11d322..0405fc8561a9 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8189fs/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8189fs/default.nix
@@ -3,13 +3,13 @@
 # rtl8189fs is a branch of the rtl8189es driver
 rtl8189es.overrideAttrs (drv: rec {
   name = "rtl8189fs-${kernel.version}-${version}";
-  version = "2023-03-27";
+  version = "2024-01-22";
 
   src = fetchFromGitHub {
     owner = "jwrdegoede";
     repo = "rtl8189ES_linux";
-    rev = "c223a25b1000d64432eca4201a8f012414dfc7ce";
-    sha256 = "sha256-5b5IshLbWxvmzcKy/xLsqKa3kZpwDQXTQtjqZLHyOCo=";
+    rev = "5d523593f41c0b8d723c6aa86b217ee1d0965786";
+    sha256 = "sha256-pziaUM6XfF4Tt9yfWUnLUiTw+sw6uZrr1HcaXdRQ31E=";
   };
 
   meta = with lib; {
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8192eu/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8192eu/default.nix
index 32b97b59c52e..529f16fc1db4 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8192eu/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8192eu/default.nix
@@ -4,15 +4,15 @@ with lib;
 
 let modDestDir = "$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/net/wireless/realtek/rtl8192eu";
 
-in stdenv.mkDerivation rec {
+in stdenv.mkDerivation {
   pname = "rtl8192eu";
-  version = "${kernel.version}-4.4.1.20230613";
+  version = "${kernel.version}-4.4.1.20240507";
 
   src = fetchFromGitHub {
     owner = "Mange";
     repo = "rtl8192eu-linux-driver";
-    rev = "f2fc8af7ab58d2123eed1aa4428e713cdfc27976";
-    sha256 = "sha256-OgsxBcXoIP8h9Z0bLsG91/s/+r89Tdn2dPOt4p3sx8k=";
+    rev = "27410641da6926eb1ac565068ff89d35f7496328";
+    sha256 = "sha256-/BztTE3yKw35Oo7KkzHMtD+8qpJNXWiSwR3YjrotR0I=";
   };
 
   hardeningDisable = [ "pic" ];
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8723ds/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8723ds/default.nix
index be4b954c1b61..a9c1f18de0c2 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8723ds/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8723ds/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation {
   pname = "rtl8723ds";
-  version = "${kernel.version}-unstable-2022-12-01";
+  version = "${kernel.version}-unstable-2023-11-14";
 
   src = fetchFromGitHub {
     owner = "lwfinger";
     repo = "rtl8723ds";
-    rev = "a638cc8639015b8b9390af3350fab0366b6c87e7";
-    sha256 = "sha256-qfVE7k71NPzw3FwoOaUxH66PnDjbpMAF6CyOyUVdSMA=";
+    rev = "52e593e8c889b68ba58bd51cbdbcad7fe71362e4";
+    sha256 = "sha256-SszvDuWN9opkXyVQAOLjnNtPp93qrKgnGvzK0y7Y9b0=";
   };
 
   hardeningDisable = [ "pic" ];
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8812au/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8812au/default.nix
index ed330fc24637..d9fd92c4a9f0 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8812au/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8812au/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation {
   pname = "rtl8812au";
-  version = "${kernel.version}-unstable-2024-01-19";
+  version = "${kernel.version}-unstable-2024-03-20";
 
   src = fetchFromGitHub {
     owner = "morrownr";
     repo = "8812au-20210629";
-    rev = "3b921c0beda8583c1d2d1b0b7e4692d11e7ea772";
-    hash = "sha256-Ji61Y23uGSTyj3Z5ia9iev5rVzSOv7XY/IfAClhz7Q8=";
+    rev = "8be3a1d7acf60f77c5d9c33b690b8d7301bdf127";
+    hash = "sha256-HchnRezJNzimOB72Sv5BwL4oXuxPxloAHVuaL+warj8=";
   };
 
   nativeBuildInputs = [ bc nukeReferences ] ++ kernel.moduleBuildDependencies;
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8821cu/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8821cu/default.nix
index 806df9f6dd4d..9d83d4b4c28a 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8821cu/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8821cu/default.nix
@@ -1,14 +1,14 @@
 { lib, stdenv, fetchFromGitHub, kernel, bc }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   pname = "rtl8821cu";
-  version = "${kernel.version}-unstable-2023-09-10";
+  version = "${kernel.version}-unstable-2024-05-03";
 
   src = fetchFromGitHub {
     owner = "morrownr";
     repo = "8821cu-20210916";
-    rev = "f6d4598290c5e9c8e545130e8a31d130f6d135f4";
-    hash = "sha256-jpMf8K9diJ3mbEkP9Cp+VwairK+pwiEGU/AtUIouCqM=";
+    rev = "3eacc28b721950b51b0249508cc31e6e54988a0c";
+    hash = "sha256-JP7mvwhnKqmkb/B0l4vhc11TBjjUA1Ubzbj/IVEXvBM=";
   };
 
   hardeningDisable = [ "pic" ];
diff --git a/nixpkgs/pkgs/os-specific/linux/rtl8852au/default.nix b/nixpkgs/pkgs/os-specific/linux/rtl8852au/default.nix
index d154fbe86a20..e7b682893f85 100644
--- a/nixpkgs/pkgs/os-specific/linux/rtl8852au/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/rtl8852au/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation {
   pname = "rtl8852au";
-  version = "${kernel.version}-unstable-2023-11-24";
+  version = "${kernel.version}-unstable-2024-04-16";
 
   src = fetchFromGitHub {
     owner = "lwfinger";
     repo = "rtl8852au";
-    rev = "70bdde265b9ab002daf11d4bea1a42baa8da4325";
-    hash = "sha256-6ARS7/0iKYajpMH+f+jWDxIkPY9ZixJkk864oKom4l4=";
+    rev = "5894bc6fed2bcaa525d13fcee1edada8aba67f2b";
+    hash = "sha256-R4Yb/jbh3nMgM41ByFjtkCMbsh/mmMRJ7CcvCRUvKu8=";
   };
 
   nativeBuildInputs = [ bc nukeReferences ] ++ kernel.moduleBuildDependencies;
diff --git a/nixpkgs/pkgs/os-specific/linux/semodule-utils/default.nix b/nixpkgs/pkgs/os-specific/linux/semodule-utils/default.nix
index 70de3cc6b60c..013a9ecb9034 100644
--- a/nixpkgs/pkgs/os-specific/linux/semodule-utils/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/semodule-utils/default.nix
@@ -22,6 +22,6 @@ stdenv.mkDerivation rec {
     description = "SELinux policy core utilities (packaging additions)";
     license = licenses.gpl2;
     inherit (libsepol.meta) homepage platforms;
-    maintainers = [ ];
+    maintainers = with maintainers; [ RossComputerGuy ];
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/sysdig/default.nix b/nixpkgs/pkgs/os-specific/linux/sysdig/default.nix
index 25b788104a4c..59b48eeb7f71 100644
--- a/nixpkgs/pkgs/os-specific/linux/sysdig/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/sysdig/default.nix
@@ -3,11 +3,11 @@
 , protobuf, grpc, yaml-cpp, nlohmann_json, re2, zstd, uthash }:
 
 let
-  # Compare with https://github.com/draios/sysdig/blob/0.36.0/cmake/modules/falcosecurity-libs.cmake
-  libsRev = "0.15.1";
-  libsHash = "sha256-CsKa5ybRj7Mjb71xNwd8FtDprOMfpJMrm3mvkeqZE3o=";
+  # Compare with https://github.com/draios/sysdig/blob/0.37.1/cmake/modules/falcosecurity-libs.cmake
+  libsRev = "0.16.0";
+  libsHash = "sha256-aduO2pLj91tRdZ1dW1F1JFEg//SopialXWPd6Oav/u8=";
 
-  # Compare with https://github.com/falcosecurity/libs/blob/0.15.1/cmake/modules/valijson.cmake
+  # Compare with https://github.com/falcosecurity/libs/blob/0.16.0/cmake/modules/valijson.cmake
   valijson = fetchFromGitHub {
     owner = "tristanpenman";
     repo = "valijson";
@@ -15,22 +15,24 @@ let
     hash = "sha256-wvFdjsDtKH7CpbEpQjzWtLC4RVOU9+D2rSK0Xo1cJqo=";
   };
 
-  # https://github.com/draios/sysdig/blob/0.36.0/cmake/modules/driver.cmake
+  # https://github.com/draios/sysdig/blob/0.37.1/cmake/modules/driver.cmake
   driver = fetchFromGitHub {
     owner = "falcosecurity";
     repo = "libs";
-    rev = "7.0.0+driver";
-    hash = "sha256-kXqvfM7HbGh2wEGaO4KBkFDW+m5gpOShJZKJLu9McKk=";
+    rev = "7.1.0+driver";
+    hash = "sha256-FIlnJsNgofGo4HETEEpW28wpC3U9z5AZprwFR5AgFfA=";
   };
-in stdenv.mkDerivation rec {
+
+  version = "0.37.1";
+in stdenv.mkDerivation {
   pname = "sysdig";
-  version = "0.36.0";
+  inherit version;
 
   src = fetchFromGitHub {
     owner = "draios";
     repo = "sysdig";
     rev = version;
-    hash = "sha256-EQnmtxByTsSawQPFmTe2pBMcv5rFaNtST+2KXZSFuoo=";
+    hash = "sha256-V1rvQ6ZznL9UiUFW2lyW6gvdoGttOd5kgT2KPQCjmvQ=";
   };
 
   nativeBuildInputs = [ cmake perl installShellFiles pkg-config ];
@@ -73,12 +75,6 @@ in stdenv.mkDerivation rec {
     cp -r ${driver} driver-src
     chmod -R +w driver-src
 
-    # Hacky but needed until https://github.com/draios/sysdig/issues/2077 is resolved for kernel >= 6.8 as strlcpy got removed and build fails
-    ${lib.optionalString
-    (kernel != null && lib.versionAtLeast kernel.version "6.8") ''
-      substituteInPlace libs/driver/ppm_events.c driver-src/driver/ppm_events.c --replace-fail "strlcpy" "strscpy"
-    ''}
-
     cmakeFlagsArray+=(
       "-DFALCOSECURITY_LIBS_SOURCE_DIR=$(pwd)/libs"
       "-DDRIVER_SOURCE_DIR=$(pwd)/driver-src/driver"
@@ -98,8 +94,6 @@ in stdenv.mkDerivation rec {
   ] ++ lib.optional (kernel == null) "-DBUILD_DRIVER=OFF";
 
   env.NIX_CFLAGS_COMPILE =
-    # needed since luajit-2.1.0-beta3
-    "-DluaL_reg=luaL_Reg -DluaL_getn(L,i)=((int)lua_objlen(L,i)) " +
     # fix compiler warnings been treated as errors
     "-Wno-error";
 
@@ -138,13 +132,13 @@ in stdenv.mkDerivation rec {
     fi
   '';
 
-  meta = with lib; {
+  meta = {
     description =
       "A tracepoint-based system tracing tool for Linux (with clients for other OSes)";
-    license = with licenses; [ asl20 gpl2 mit ];
-    maintainers = [ maintainers.raskin ];
-    platforms = [ "x86_64-linux" ] ++ platforms.darwin;
-    broken = kernel != null && ((versionOlder kernel.version "4.14") || kernel.isHardened || kernel.isZen);
+    license = with lib.licenses; [ asl20 gpl2 mit ];
+    maintainers = with lib.maintainers; [ raskin ];
+    platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
+    broken = kernel != null && ((lib.versionOlder kernel.version "4.14") || kernel.isHardened || kernel.isZen);
     homepage = "https://sysdig.com/opensource/";
     downloadPage = "https://github.com/draios/sysdig/releases";
   };
diff --git a/nixpkgs/pkgs/os-specific/linux/systemd/default.nix b/nixpkgs/pkgs/os-specific/linux/systemd/default.nix
index 9cdc5dcd9d44..2d1f033920bd 100644
--- a/nixpkgs/pkgs/os-specific/linux/systemd/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/systemd/default.nix
@@ -925,8 +925,9 @@ stdenv.mkDerivation (finalAttrs: {
     maintainers = with lib.maintainers; [ flokli kloenk ];
     platforms = lib.platforms.linux;
     priority = 10;
-    badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
-    # https://github.com/systemd/systemd/issues/20600#issuecomment-912338965
-    broken = stdenv.hostPlatform.isStatic;
+    badPlatforms = [
+      # https://github.com/systemd/systemd/issues/20600#issuecomment-912338965
+      lib.systems.inspect.platformPatterns.isStatic
+    ];
   };
 })
diff --git a/nixpkgs/pkgs/os-specific/linux/tbs/default.nix b/nixpkgs/pkgs/os-specific/linux/tbs/default.nix
index 5805a400c1e2..4d4a1a96ce5f 100644
--- a/nixpkgs/pkgs/os-specific/linux/tbs/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/tbs/default.nix
@@ -5,22 +5,22 @@ let
     name = repo;
     owner = "tbsdtv";
     repo = "linux_media";
-    rev = "d0a7e44358f28064697e0eed309db03166dcd83b";
-    hash = "sha256-BTHlnta5qv2bdPjD2bButwYGpwR/bq99/AUoZqTHHYw=";
+    rev = "d8d1ff33c0c47e34fe3e860b52b4d6c457520866";
+    hash = "sha256-1Z9itZ5GFpfUeRtp5xTnS+I91LUZLDhsEcF2v8ThaCs=";
   };
 
   build = fetchFromGitHub rec {
     name = repo;
     owner = "tbsdtv";
     repo = "media_build";
-    rev = "88764363a3e3d36b3c59a0a2bf2244e262035d47";
-    hash = "sha256-LFTxYVPudflxqYTSBIDNkTrGs09MOuYBXwpGYqWfEFQ=";
+    rev = "8cd12a6e90999f3a341018812a5d66d7e6b30913";
+    hash = "sha256-+I0NrML54ni37qgDHbRUQiLmmw/UZgXmoFoiDNDeH5A=";
   };
 
 in
 stdenv.mkDerivation {
   pname = "tbs";
-  version = "20231210-${kernel.version}";
+  version = "20240506-${kernel.version}";
 
   srcs = [ media build ];
   sourceRoot = build.name;
@@ -66,6 +66,6 @@ stdenv.mkDerivation {
     license = licenses.gpl2;
     maintainers = with maintainers; [ ck3d ];
     priority = -1;
-    broken = kernel.kernelOlder "4.14" || kernel.kernelAtLeast "6.6";
+    broken = kernel.kernelOlder "4.14" || kernel.kernelAtLeast "6.9";
   };
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/tiscamera/default.nix b/nixpkgs/pkgs/os-specific/linux/tiscamera/default.nix
index 600655c447f7..8847a83d53d7 100644
--- a/nixpkgs/pkgs/os-specific/linux/tiscamera/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/tiscamera/default.nix
@@ -18,7 +18,7 @@
 , glib
 , gobject-introspection
 , gst_all_1
-, wrapGAppsHook
+, wrapGAppsHook3
   # needs pkg_resources
 , withDoc ? false
 , sphinx
@@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [
     cmake
     pkg-config
-    wrapGAppsHook
+    wrapGAppsHook3
     gobject-introspection
   ] ++ lib.optionals withDoc [
     sphinx
@@ -112,7 +112,7 @@ stdenv.mkDerivation rec {
   # gstreamer tests requires, besides gst-plugins-bad, plugins installed by this expression.
   checkPhase = "ctest --force-new-ctest-process -E gstreamer";
 
-  # wrapGAppsHook: make sure we add ourselves to the introspection
+  # wrapGAppsHook3: make sure we add ourselves to the introspection
   # and gstreamer paths.
   GI_TYPELIB_PATH = "${placeholder "out"}/lib/girepository-1.0";
   GST_PLUGIN_SYSTEM_PATH_1_0 = "${placeholder "out"}/lib/gstreamer-1.0";
diff --git a/nixpkgs/pkgs/os-specific/linux/tuna/default.nix b/nixpkgs/pkgs/os-specific/linux/tuna/default.nix
index b57169369ca7..3b527c8b534f 100644
--- a/nixpkgs/pkgs/os-specific/linux/tuna/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/tuna/default.nix
@@ -9,7 +9,7 @@
 , gtk3
 , python-linux-procfs
 , python-ethtool
-, wrapGAppsHook
+, wrapGAppsHook3
 }:
 
 buildPythonApplication rec {
@@ -37,7 +37,7 @@ buildPythonApplication rec {
     glib.dev
     gobject-introspection
     gtk3
-    wrapGAppsHook
+    wrapGAppsHook3
   ];
 
   propagatedBuildInputs = [ pygobject3 python-linux-procfs python-ethtool ];
diff --git a/nixpkgs/pkgs/os-specific/linux/uhk-agent/default.nix b/nixpkgs/pkgs/os-specific/linux/uhk-agent/default.nix
index 0d6b3ccd515c..553e471faaff 100644
--- a/nixpkgs/pkgs/os-specific/linux/uhk-agent/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/uhk-agent/default.nix
@@ -12,12 +12,12 @@
 
 let
   pname = "uhk-agent";
-  version = "4.0.2";
+  version = "4.1.0";
 
   src = fetchurl {
     url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v${version}/UHK.Agent-${version}-linux-x86_64.AppImage";
     name = "${pname}-${version}.AppImage";
-    sha256 = "sha256-yx5hOmb1la+vNh8x0PM3edcMn4ojdwzNmGBUg/BH7wE=";
+    sha256 = "sha256-5VzUSuq+yc8HXSILMg24w/hbwasf4jq0H0wte9Mw+nY=";
   };
 
   appimageContents = appimageTools.extract {
diff --git a/nixpkgs/pkgs/os-specific/linux/waydroid/default.nix b/nixpkgs/pkgs/os-specific/linux/waydroid/default.nix
index ae42c206280d..5e29b911ca54 100644
--- a/nixpkgs/pkgs/os-specific/linux/waydroid/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/waydroid/default.nix
@@ -12,7 +12,7 @@
 , iproute2
 , iptables
 , util-linux
-, wrapGAppsHook
+, wrapGAppsHook3
 , wl-clipboard
 , runtimeShell
 }:
@@ -39,7 +39,7 @@ python3Packages.buildPythonApplication rec {
 
   nativeBuildInputs = [
     gobject-introspection
-    wrapGAppsHook
+    wrapGAppsHook3
   ];
 
   buildInputs = [
diff --git a/nixpkgs/pkgs/os-specific/linux/zenmonitor/default.nix b/nixpkgs/pkgs/os-specific/linux/zenmonitor/default.nix
index e8fce959c8dc..8101f47c6a24 100644
--- a/nixpkgs/pkgs/os-specific/linux/zenmonitor/default.nix
+++ b/nixpkgs/pkgs/os-specific/linux/zenmonitor/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, pkg-config, gtk3, wrapGAppsHook }:
+{ lib, stdenv, fetchFromGitHub, pkg-config, gtk3, wrapGAppsHook3 }:
 
 stdenv.mkDerivation rec {
   pname = "zenmonitor";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ gtk3 ];
-  nativeBuildInputs = [ pkg-config wrapGAppsHook ];
+  nativeBuildInputs = [ pkg-config wrapGAppsHook3 ];
 
   makeFlags = [ "PREFIX=${placeholder "out"}" ];
 
diff --git a/nixpkgs/pkgs/os-specific/linux/zfs/2_2.nix b/nixpkgs/pkgs/os-specific/linux/zfs/2_2.nix
index 455c17383604..14c88f195dbf 100644
--- a/nixpkgs/pkgs/os-specific/linux/zfs/2_2.nix
+++ b/nixpkgs/pkgs/os-specific/linux/zfs/2_2.nix
@@ -14,17 +14,17 @@ callPackage ./generic.nix args {
   # this attribute is the correct one for this package.
   kernelModuleAttribute = "zfs_2_2";
   # check the release notes for compatible kernels
-  kernelCompatible = kernel.kernelOlder "6.8";
+  kernelCompatible = kernel.kernelOlder "6.9";
 
-  latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_6;
+  latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_8;
 
   # this package should point to the latest release.
-  version = "2.2.3";
+  version = "2.2.4";
 
   tests = [
     nixosTests.zfs.installer
     nixosTests.zfs.series_2_2
   ];
 
-  hash = "sha256-Bzkow15OitUUQ+mTYhCXgTrQl+ao/B4feleHY/rSSjg=";
+  hash = "sha256-SSp/1Tu1iGx5UDcG4j0k2fnYxK05cdE8gzfSn8DU5Z4=";
 }
diff --git a/nixpkgs/pkgs/os-specific/linux/zfs/unstable.nix b/nixpkgs/pkgs/os-specific/linux/zfs/unstable.nix
index c8db9c5c5df9..1d8ced4dd5d7 100644
--- a/nixpkgs/pkgs/os-specific/linux/zfs/unstable.nix
+++ b/nixpkgs/pkgs/os-specific/linux/zfs/unstable.nix
@@ -16,19 +16,19 @@ callPackage ./generic.nix args {
   # check the release notes for compatible kernels
   kernelCompatible = kernel.kernelOlder "6.9";
 
-  latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_6;
+  latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_8;
 
   # this package should point to a version / git revision compatible with the latest kernel release
   # IMPORTANT: Always use a tagged release candidate or commits from the
   # zfs-<version>-staging branch, because this is tested by the OpenZFS
   # maintainers.
-  version = "2.2.3-unstable-2024-04-09";
-  rev = "28520cad2500b60ce8653e431990e33f77ff08f7";
+  version = "2.2.4";
+  # rev = "";
 
   isUnstable = true;
   tests = [
     nixosTests.zfs.unstable
   ];
 
-  hash = "sha256-lGoiTmCWOxqACSYY0WA0gN6CN/1FyYhSVHmtYC1Izhg=";
+  hash = "sha256-SSp/1Tu1iGx5UDcG4j0k2fnYxK05cdE8gzfSn8DU5Z4=";
 }