lmao perhaps

This commit is contained in:
mjallen18
2026-03-10 10:51:32 -05:00
parent c13ce86810
commit 1616c6766e
4 changed files with 131 additions and 11 deletions

View File

@@ -33,6 +33,9 @@ let
suffix = vars.suffix or "";
linux = {
inherit (s.linux) version hash;
}
// lib.optionalAttrs (s.linux ? fetcher && s.linux.fetcher == "github") {
inherit (s.linux) owner repo rev;
};
config = {
rev = s.config.rev;
@@ -236,6 +239,9 @@ let
withNTSync = false;
withHDR = false;
# Enable Rust — required for DRM_ASAHI (AGX GPU) and APPLE_SEP
withRust = true;
# Disable module building extras that don't apply to aarch64 targets
packagesExtend =
_kernel: _final: prev:

View File

@@ -0,0 +1,9 @@
# Resolve the Rust toolchain packages needed for CONFIG_RUST=y kernel builds.
# Uses buildPackages so cross-compilation works correctly (the compiler runs on
# the build machine but produces code for the host/target).
{ pkgs, ... }:
{
rustc = pkgs.buildPackages.rustc-unwrapped;
rustBindgen = pkgs.buildPackages.rust-bindgen-unwrapped;
rustLibSrc = pkgs.buildPackages.rustPlatform.rustLibSrc;
}

View File

@@ -30,6 +30,7 @@
withHDR ? true,
withoutDebug ? false,
pageSize ? "4k",
withRust ? false,
description ? "Linux EEVDF-BORE scheduler Kernel by CachyOS with other patches and improvements",
# For flakes
inputs ? { },
@@ -86,6 +87,7 @@ let
description
withUpdateScript
pageSize
withRust
;
};
@@ -93,15 +95,22 @@ let
# - First we apply the changes fromt their PKGBUILD using kconfig;
# - Then we NIXify it (in the update-script);
# - Last state is importing the NIXified version for building.
preparedConfigfile = callPackage ./prepare.nix {
inherit
cachyConfig
stdenv
kernel
ogKernelConfigfile
commonMakeFlags
;
};
rustPkgs = lib.optionalAttrs withRust (import ./lib/rust-pkgs.nix { inherit pkgs; });
preparedConfigfile = callPackage ./prepare.nix (
{
inherit
cachyConfig
stdenv
kernel
ogKernelConfigfile
commonMakeFlags
;
}
// lib.optionalAttrs withRust {
inherit (rustPkgs) rustc rustBindgen rustLibSrc;
}
);
kconfigToNix = callPackage ./lib/kconfig-to-nix.nix {
configfile = preparedConfigfile;
};

View File

@@ -7,6 +7,10 @@
kernel,
ogKernelConfigfile,
commonMakeFlags,
# Rust toolchain — only injected when cachyConfig.withRust is true
rustc ? null,
rustBindgen ? null,
rustLibSrc ? null,
}:
let
version =
@@ -148,7 +152,8 @@ let
++ ntSyncConfig
++ hdrConfig
++ disableDebug
++ pageSizeConfig;
++ pageSizeConfig
++ asahiPlatformConfig;
# _cachy_config, defaults to "y"
basicCachyConfig = lib.optional cachyConfig.basicCachy "-e CACHY";
@@ -406,6 +411,84 @@ let
else
throw "Unsupported cachyos _hugepage";
# Apple Silicon (Asahi) platform drivers
# Mirrors the options set in the asahi-alarm/PKGBUILDs linux-asahi config.
# ARCH_APPLE is the root Kconfig symbol; everything else gates on it.
# olddefconfig will auto-select most sub-options once ARCH_APPLE is on,
# but the hardware-specific drivers are listed explicitly so they aren't
# left as =m when we want them built-in, or omitted entirely.
asahiPlatformConfig = lib.optionals (cachyConfig.taste == "linux-cachyos-asahi") [
# Rust support — must come before any symbol that depends on it
"-e RUST"
# SoC platform — root symbol; must come first
"-e ARCH_APPLE"
# Interrupt controller
"-e APPLE_AIC"
# IOMMU (required for PCIe, GPU, and NVMe)
"-e APPLE_DART"
# RTKit coprocessor framework (required by GPU, audio, SEP)
"-e APPLE_RTKIT"
"-e APPLE_RTKIT_HELPER"
"-e APPLE_MAILBOX"
# Rust-based mailbox/rtkit (present in 6.18 Asahi tree)
"-e RUST_APPLE_MAILBOX"
"-e RUST_APPLE_RTKIT"
# Power management
"-e APPLE_PMGR_PWRSTATE"
"-e APPLE_PMGR_MISC"
# DMA controller (required by audio)
"-e APPLE_ADMAC"
# Security / SART (required by NVMe)
"-e APPLE_SART"
"-e APPLE_SEP"
# Storage
"-e NVME_APPLE"
# PCIe
"-e PCIE_APPLE"
# CPU frequency / idle
"-e ARM_APPLE_SOC_CPUFREQ"
"-e ARM_APPLE_CPUIDLE"
# Pin control
"-e PINCTRL_APPLE_GPIO"
# Display (DCP)
"-m DRM_APPLE"
"-e DRM_APPLE_AUDIO"
# GPU (Asahi AGX Rust driver)
"-e DRM_ASAHI"
# Audio
"-m SND_SOC_APPLE_MCA"
"-m SND_SOC_APPLE_MACAUDIO"
"-m SND_SOC_APPLE_AOP_AUDIO"
# Misc Apple SoC peripherals
"-e APPLE_DOCKCHANNEL"
"-e APPLE_WATCHDOG"
"-m APPLE_SIO"
"-m APPLE_AOP"
"-e APPLE_M1_CPU_PMU"
# 16K pages — Apple Silicon runs with 16K page granule
"-d ARM64_4K_PAGES"
"-e ARM64_16K_PAGES"
# NR_CPUS: Apple Silicon has at most ~16 cores; 64 is the Asahi default
"--set-val NR_CPUS 64"
];
# _damon, defaults to empty
damonConfig = lib.optionals cachyConfig.withDAMON [
"-e DAMON"
@@ -449,11 +532,19 @@ let
configTaste =
if cachyConfig.taste == "linux-cachyos-asahi" then "linux-cachyos-lts" else cachyConfig.taste;
# Rust toolchain — needed so `make olddefconfig` can probe rustc and set
# RUSTC_VERSION correctly, which gates CONFIG_RUST and all rust-dependent
# symbols (DRM_ASAHI, APPLE_SEP, etc.)
rustNativeBuildInputs = lib.optionals cachyConfig.withRust [
rustc
rustBindgen
];
in
stdenv.mkDerivation (finalAttrs: {
inherit src patches;
name = "linux-cachyos-config";
nativeBuildInputs = kernel.nativeBuildInputs ++ kernel.buildInputs;
nativeBuildInputs = kernel.nativeBuildInputs ++ kernel.buildInputs ++ rustNativeBuildInputs;
# Apply each patch with --forward (skip already-applied/reversed hunks) and
# --fuzz=3 (tolerate minor context differences due to kernel version skew).
@@ -470,6 +561,11 @@ stdenv.mkDerivation (finalAttrs: {
makeFlags = commonMakeFlags;
env = lib.optionalAttrs cachyConfig.withRust {
RUST_LIB_SRC = rustLibSrc;
KRUSTFLAGS = "--remap-path-prefix ${rustLibSrc}=/";
};
postPhase = ''
${finalAttrs.passthru.extraVerPatch}
'';