From cfb4fd54501fd0527eb5097cbf1015f17adff28d Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 17 Mar 2025 21:05:47 +0100 Subject: [PATCH] linux/common-config: Overhaul Rust for Linux enabling logic The table with kernel version and compiler requirements only starts from Linux 6.12 now (the previous default), so update the force-enable logic to accommodate users that don't want to follow those suggestions. This includes printing warnings instead of asserting and allowing the force-enable to override both the compiler check and the version (or architecture) check. --- pkgs/os-specific/linux/kernel/common-config.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 019be333e89b..30ce57a9e351 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -45,7 +45,7 @@ let forceRust = features.rust or false; # Architecture support collected from HAVE_RUST Kconfig definitions and the following table: # https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/rust/arch-support.rst - kernelSupportsRust = ( + rustByDefault = ( lib.versionAtLeast version "6.12" && ( stdenv.hostPlatform.isx86_64 @@ -55,14 +55,13 @@ let ) ); - # Currently only enabling Rust by default on kernel 6.12+, - # which actually has features that use Rust that we want. - defaultRust = lib.versionAtLeast version "6.12" && rustAvailable; withRust = - assert lib.assertMsg (!(forceRust && !kernelSupportsRust)) '' - Kernel ${version} is not declared as supporting Rust on this host platform and compiler. - ''; - (forceRust || defaultRust) && kernelSupportsRust; + lib.warnIfNot (forceRust -> rustAvailable) + "force-enabling Rust for Linux without an available rustc" + lib.warnIfNot + (forceRust -> rustByDefault) + "force-enabling Rust for Linux on an unsupported kernel version, host platform or compiler" + (forceRust || (rustAvailable && rustByDefault)); options = {