Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions pkgs/os-specific/linux/kernel/common-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,25 @@ let
);

forceRust = features.rust or false;
kernelSupportsRust = lib.versionAtLeast version "6.7";
# 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
rustByDefault = (
lib.versionAtLeast version "6.12"
&& (
stdenv.hostPlatform.isx86_64
|| stdenv.hostPlatform.isLoongArch64
|| stdenv.hostPlatform.isAarch64
|| (stdenv.hostPlatform.isRiscV64 && !stdenv.cc.isGNU)
)
);

# 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)) ''
Kernels below 6.7 (the kernel being built is ${version}) don't support Rust.
'';
(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 = {

Expand Down Expand Up @@ -1054,7 +1063,7 @@ let
HIDRAW = yes;

# Enable loading HID fixups as eBPF from userspace
HID_BPF = whenAtLeast "6.3" yes;
HID_BPF = whenAtLeast "6.3" (whenPlatformHasEBPFJit yes);

HID_ACRUX_FF = yes;
DRAGONRISE_FF = yes;
Expand Down Expand Up @@ -1281,7 +1290,7 @@ let
LIRC = yes;

SCHED_CORE = whenAtLeast "5.14" yes;
SCHED_CLASS_EXT = whenAtLeast "6.12" yes;
SCHED_CLASS_EXT = whenAtLeast "6.12" (whenPlatformHasEBPFJit yes);

LRU_GEN = whenAtLeast "6.1" yes;
LRU_GEN_ENABLED = whenAtLeast "6.1" yes;
Expand Down
6 changes: 1 addition & 5 deletions pkgs/os-specific/linux/kernel/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ let

commonStructuredConfig = import ./common-config.nix {
inherit lib stdenv version;
rustAvailable =
lib.any (lib.meta.platformMatch stdenv.hostPlatform) rustc.targetPlatforms
&& lib.all (p: !lib.meta.platformMatch stdenv.hostPlatform p) rustc.badTargetPlatforms
# Known to be broken: https://lore.kernel.org/lkml/31885EDD-EF6D-4EF1-94CA-276BA7A340B7@kernel.org/T/
&& !(stdenv.hostPlatform.isRiscV && stdenv.cc.isGNU);
rustAvailable = lib.meta.availableOn stdenv.hostPlatform rustc;

features = kernelFeatures; # Ensure we know of all extra patches, etc.
};
Expand Down