about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/generic.nix
diff options
context:
space:
mode:
authorYureka <yuka@yuka.dev>2023-12-14 13:58:59 +0100
committerAlyssa Ross <hi@alyssa.is>2024-01-12 20:28:46 +0100
commit8a5f6594daa32af3686d13eb2efa5092598f9bbe (patch)
tree7655dece915f7e546d227ed93a4bfb6d65f92453 /pkgs/os-specific/linux/kernel/generic.nix
parentcc34adbe66751ea28c20af94e4c3c27e52f047f5 (diff)
linux_latest: optionally build Linux 6.7 and onwards with rust support
With the current patching situation around enabling Linux to build
with whatever rustc/bindgen version we have in nixpkgs, it feels like
supporting a Rust-by-default build at this time is not fully
justified.

Co-authored-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
Diffstat (limited to 'pkgs/os-specific/linux/kernel/generic.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index df67005dd8165..7fc90ace2624f 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -9,6 +9,9 @@
 , pahole
 , lib
 , stdenv
+, rustc
+, rustPlatform
+, rust-bindgen
 
 , # The kernel source tarball.
   src
@@ -117,6 +120,8 @@ let
         map ({extraConfig ? "", ...}: extraConfig) kernelPatches;
     in lib.concatStringsSep "\n" ([baseConfigStr] ++ configFromPatches);
 
+  withRust = ((configfile.moduleStructuredConfig.settings.RUST or {}).tristate or null) == "y";
+
   configfile = stdenv.mkDerivation {
     inherit ignoreConfigErrors autoModules preferBuiltin kernelArch extraMakeFlags;
     pname = "linux-config";
@@ -130,7 +135,11 @@ let
     depsBuildBuild = [ buildPackages.stdenv.cc ];
     nativeBuildInputs = [ perl gmp libmpc mpfr ]
       ++ lib.optionals (lib.versionAtLeast version "4.16") [ bison flex ]
-      ++ lib.optional (lib.versionAtLeast version "5.2") pahole;
+      ++ lib.optional (lib.versionAtLeast version "5.2") pahole
+      ++ lib.optionals withRust [ rust-bindgen rustc ]
+    ;
+
+    RUST_LIB_SRC = lib.optionalString withRust rustPlatform.rustLibSrc;
 
     platformName = stdenv.hostPlatform.linux-kernel.name;
     # e.g. "defconfig"
@@ -202,7 +211,7 @@ let
     inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile;
     pos = builtins.unsafeGetAttrPos "version" args;
 
-    config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
+    config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; } // lib.optionalAttrs withRust { CONFIG_RUST = "y"; };
   } // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; });
 
   passthru = basicArgs // {