From 2d0ba1f54b3421e7df79c53098bb006f4b49b93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 3 Dec 2020 18:21:25 +0900 Subject: [PATCH 1/4] kernel/manual-config: simplify ld-version sed with patchShebangs. --- pkgs/os-specific/linux/kernel/manual-config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 9edc0ced4120e8..d00ad8ee4677c3 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,5 +1,5 @@ { buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl -, libelf, cpio, elfutils +, libelf, cpio, elfutils, gawk , writeTextFile }: @@ -120,7 +120,7 @@ let # See also https://kernelnewbies.org/BuildId sed -i Makefile -e 's|--build-id|--build-id=none|' - sed -i scripts/ld-version.sh -e "s|/usr/bin/awk|${buildPackages.gawk}/bin/awk|" + patchShebangs scripts/ld-version.sh ''; postPatch = '' @@ -306,7 +306,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches enableParallelBuilding = true; depsBuildBuild = [ buildPackages.stdenv.cc ]; - nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr ] + nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr gawk ] ++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools ++ optional (stdenv.lib.versionAtLeast version "4.14" && stdenv.lib.versionOlder version "5.8") libelf # Removed util-linuxMinimal since it should not be a dependency. From 9fee546667db6da9cf896420abddd564ddfae238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 3 Dec 2020 18:27:03 +0900 Subject: [PATCH 2/4] kernel/manual-config: add zstd to nativeBuildDeps. Required to build with zstd compression. Refs #101108 --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index d00ad8ee4677c3..c2f137183082fd 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,5 +1,5 @@ { buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl -, libelf, cpio, elfutils, gawk +, libelf, cpio, elfutils, zstd, gawk , writeTextFile }: @@ -306,7 +306,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches enableParallelBuilding = true; depsBuildBuild = [ buildPackages.stdenv.cc ]; - nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr gawk ] + nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr gawk zstd ] ++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools ++ optional (stdenv.lib.versionAtLeast version "4.14" && stdenv.lib.versionOlder version "5.8") libelf # Removed util-linuxMinimal since it should not be a dependency. From 9461f0a73432f9d124b96f65884efba788f5c0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 12 Dec 2020 13:56:33 +0900 Subject: [PATCH 3/4] kernel: use zstd compression on 5.9+. --- pkgs/os-specific/linux/kernel/common-config.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 47e49dbe01d7a2..0fb83014662bd7 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -654,7 +654,10 @@ let MODULE_COMPRESS = yes; MODULE_COMPRESS_XZ = yes; - KERNEL_XZ = yes; + + # use zstd for kernel compression if newer than 5.9, else xz. + KERNEL_XZ = whenOlder "5.9" yes; + KERNEL_ZSTD = whenAtLeast "5.9" yes; SYSVIPC = yes; # System-V IPC From a6b5693a71fa2b8d8e50621162cd45e27fb0d5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 16 Dec 2020 12:37:09 +0900 Subject: [PATCH 4/4] nixos/stage-1: set zstd as the default compressor when supported Co-authored-by: Atemu --- nixos/modules/system/boot/stage-1.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 86bfde6349c3d4..1fe1bb14eaf49a 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -513,7 +513,12 @@ in }; boot.initrd.compressor = mkOption { - default = "gzip"; + default = ( + if lib.versionAtLeast config.boot.kernelPackages.kernel.version "5.9" + then "zstd" + else "gzip" + ); + defaultText = "zstd if the kernel supports it (5.9+), gzip if not."; type = types.unspecified; # We don't have a function type... description = '' The compressor to use on the initrd image. May be any of: