2023-09-02 15:25:05 +08:00
|
|
|
inputs:
|
|
|
|
{
|
|
|
|
options.nixos.system.kernel = let inherit (inputs.lib) mkOption types; in
|
|
|
|
{
|
2024-04-20 10:57:00 +08:00
|
|
|
variant = mkOption
|
2024-03-17 13:05:05 +08:00
|
|
|
{
|
2024-08-17 23:37:40 +08:00
|
|
|
type = types.enum [ "nixos" "xanmod-lts" "xanmod-latest" "cachyos" "cachyos-lto" "cachyos-server" "zen" ];
|
2024-06-01 08:07:14 +08:00
|
|
|
default = "xanmod-latest";
|
2024-03-17 13:05:05 +08:00
|
|
|
};
|
2024-07-29 22:51:06 +08:00
|
|
|
patches = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
|
2023-09-02 15:25:05 +08:00
|
|
|
modules =
|
|
|
|
{
|
|
|
|
install = mkOption { type = types.listOf types.str; default = []; };
|
|
|
|
load = mkOption { type = types.listOf types.str; default = []; };
|
|
|
|
initrd = mkOption { type = types.listOf types.str; default = []; };
|
|
|
|
modprobeConfig = mkOption { type = types.listOf types.str; default = []; };
|
|
|
|
};
|
|
|
|
};
|
2024-03-17 15:24:16 +08:00
|
|
|
config = let inherit (inputs.config.nixos.system) kernel; in inputs.lib.mkMerge
|
|
|
|
[
|
2023-09-02 15:25:05 +08:00
|
|
|
{
|
2024-03-17 15:24:16 +08:00
|
|
|
boot =
|
2024-03-03 19:15:04 +08:00
|
|
|
{
|
2024-03-17 15:24:16 +08:00
|
|
|
kernelModules = [ "br_netfilter" ] ++ kernel.modules.load;
|
|
|
|
# modprobe --show-depends
|
|
|
|
initrd.availableKernelModules =
|
|
|
|
[
|
2024-03-25 17:49:35 +08:00
|
|
|
"bfq" "failover" "net_failover" "nls_cp437" "nls_iso8859-1" "sd_mod"
|
2024-03-17 15:24:16 +08:00
|
|
|
"sr_mod" "usbcore" "usbhid" "usbip-core" "usb-common" "usb_storage" "vhci-hcd" "virtio" "virtio_blk"
|
2024-03-25 17:49:35 +08:00
|
|
|
"virtio_net" "virtio_ring" "virtio_scsi" "cryptd" "libaes"
|
2024-03-28 20:50:48 +08:00
|
|
|
"ahci" "ata_piix" "nvme" "sdhci_acpi" "virtio_pci" "xhci_pci"
|
|
|
|
# networking for nas
|
|
|
|
"igb"
|
2024-09-15 13:15:48 +08:00
|
|
|
# disk for srv1
|
|
|
|
"megaraid_sas"
|
2024-09-16 17:56:59 +08:00
|
|
|
# disks for cluster
|
2024-09-17 10:06:56 +08:00
|
|
|
"nfs" "nfsv4"
|
2024-09-16 18:50:19 +08:00
|
|
|
# netowrk for srv1
|
|
|
|
"bnx2x" "tg3"
|
2024-03-25 17:49:35 +08:00
|
|
|
]
|
2024-04-20 10:57:00 +08:00
|
|
|
++ (inputs.lib.optionals (kernel.variant != "nixos") [ "crypto_simd" ])
|
2024-03-28 21:50:13 +08:00
|
|
|
# for pi3b to show message over hdmi while boot
|
2024-04-20 10:57:00 +08:00
|
|
|
++ (inputs.lib.optionals (kernel.variant == "nixos") [ "vc4" "bcm2835_dma" "i2c_bcm2835" ]);
|
2024-03-17 15:24:16 +08:00
|
|
|
extraModulePackages = (with inputs.config.boot.kernelPackages; [ v4l2loopback ]) ++ kernel.modules.install;
|
|
|
|
extraModprobeConfig = builtins.concatStringsSep "\n" kernel.modules.modprobeConfig;
|
2024-06-11 13:07:35 +08:00
|
|
|
kernelParams = [ "delayacct" ];
|
2024-03-17 15:24:16 +08:00
|
|
|
kernelPackages =
|
|
|
|
{
|
2024-03-28 20:50:48 +08:00
|
|
|
nixos = inputs.pkgs.linuxPackages;
|
2024-03-17 15:24:16 +08:00
|
|
|
xanmod-lts = inputs.pkgs.linuxPackages_xanmod;
|
|
|
|
xanmod-latest = inputs.pkgs.linuxPackages_xanmod_latest;
|
|
|
|
cachyos = inputs.pkgs.linuxPackages_cachyos;
|
|
|
|
cachyos-lto = inputs.pkgs.linuxPackages_cachyos-lto;
|
2024-04-20 10:55:18 +08:00
|
|
|
cachyos-server = inputs.pkgs.linuxPackages_cachyos-server;
|
2024-03-25 17:49:35 +08:00
|
|
|
rpi3 = inputs.pkgs.linuxPackages_rpi3;
|
2024-08-17 23:37:40 +08:00
|
|
|
zen = inputs.pkgs.linuxPackages_zen;
|
2024-04-20 10:57:00 +08:00
|
|
|
}.${kernel.variant};
|
2024-03-17 15:24:16 +08:00
|
|
|
kernelPatches =
|
|
|
|
let
|
|
|
|
patches =
|
|
|
|
{
|
|
|
|
cjktty =
|
|
|
|
[{
|
|
|
|
name = "cjktty";
|
|
|
|
patch =
|
2024-05-24 11:21:07 +08:00
|
|
|
let version = inputs.lib.versions.majorMinor inputs.config.boot.kernelPackages.kernel.version;
|
2024-05-22 10:44:41 +08:00
|
|
|
in "${inputs.topInputs.cjktty}/v6.x/cjktty-${version}.patch";
|
2024-03-17 15:24:16 +08:00
|
|
|
extraStructuredConfig =
|
|
|
|
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
|
|
|
|
}];
|
|
|
|
lantian =
|
|
|
|
[{
|
|
|
|
name = "lantian";
|
|
|
|
patch = null;
|
|
|
|
# pick from xddxdd/nur-packages dce93a
|
|
|
|
extraStructuredConfig = with inputs.lib.kernel;
|
2023-10-18 21:10:23 +08:00
|
|
|
{
|
2024-03-17 15:24:16 +08:00
|
|
|
ACPI_PCI_SLOT = yes;
|
|
|
|
ENERGY_MODEL = yes;
|
|
|
|
PARAVIRT_TIME_ACCOUNTING = yes;
|
|
|
|
PM_AUTOSLEEP = yes;
|
|
|
|
WQ_POWER_EFFICIENT_DEFAULT = yes;
|
|
|
|
PREEMPT_VOLUNTARY = inputs.lib.mkForce no;
|
|
|
|
PREEMPT = inputs.lib.mkForce yes;
|
|
|
|
NO_HZ_FULL = yes;
|
|
|
|
HZ_1000 = inputs.lib.mkForce yes;
|
|
|
|
HZ_250 = inputs.lib.mkForce no;
|
|
|
|
HZ = inputs.lib.mkForce (freeform "1000");
|
2023-10-18 21:10:23 +08:00
|
|
|
};
|
2024-03-17 15:24:16 +08:00
|
|
|
}];
|
2024-08-17 08:29:51 +08:00
|
|
|
surface =
|
|
|
|
let
|
|
|
|
version =
|
|
|
|
let versionArray = builtins.splitVersion inputs.config.boot.kernelPackages.kernel.version;
|
|
|
|
in "${builtins.elemAt versionArray 0}.${builtins.elemAt versionArray 1}";
|
|
|
|
kernelPatches = builtins.map
|
|
|
|
(file:
|
|
|
|
{
|
|
|
|
name = "surface-${file.name}";
|
|
|
|
patch = "${inputs.topInputs.linux-surface}/patches/${version}/${file.name}";
|
|
|
|
})
|
|
|
|
(builtins.filter
|
|
|
|
(file: file.value == "regular")
|
|
|
|
(inputs.localLib.attrsToList (builtins.readDir
|
|
|
|
"${inputs.topInputs.linux-surface}/patches/${version}")));
|
|
|
|
kernelConfig = builtins.removeAttrs
|
|
|
|
(builtins.listToAttrs (builtins.concatLists (builtins.map
|
|
|
|
(configString:
|
|
|
|
if builtins.match "CONFIG_.*=." configString == [] then
|
|
|
|
(
|
|
|
|
let match = builtins.match "CONFIG_(.*)=(.)" configString; in with inputs.lib.kernel;
|
|
|
|
[{
|
|
|
|
name = builtins.elemAt match 0;
|
|
|
|
value = { m = module; y = yes; }.${builtins.elemAt match 1};
|
|
|
|
}]
|
|
|
|
)
|
|
|
|
else if builtins.match "# CONFIG_.* is not set" configString == [] then
|
|
|
|
[{
|
|
|
|
name = builtins.elemAt (builtins.match "# CONFIG_(.*) is not set" configString) 0;
|
|
|
|
value = inputs.lib.kernel.unset;
|
|
|
|
}]
|
|
|
|
else if builtins.match "#.*" configString == [] then []
|
|
|
|
else if configString == "" then []
|
|
|
|
else throw "could not parse: ${configString}"
|
|
|
|
)
|
|
|
|
(inputs.lib.strings.splitString "\n"
|
|
|
|
(builtins.readFile "${inputs.topInputs.linux-surface}/configs/surface-${version}.config")))))
|
|
|
|
[ "VIDEO_IPU3_IMGU" ];
|
|
|
|
in kernelPatches ++ [{ name = "surface-config"; patch = null; extraStructuredConfig = kernelConfig; }];
|
2024-05-24 11:21:07 +08:00
|
|
|
hibernate-progress =
|
|
|
|
[{
|
|
|
|
name = "hibernate-progress";
|
|
|
|
patch =
|
|
|
|
let version = inputs.lib.versions.majorMinor inputs.config.boot.kernelPackages.kernel.version;
|
|
|
|
in ./hibernate-progress-${version}.patch;
|
|
|
|
}];
|
2024-03-17 15:24:16 +08:00
|
|
|
};
|
2024-09-26 09:52:38 +08:00
|
|
|
in builtins.concatLists (builtins.map (name: patches.${name}) kernel.patches);
|
2024-03-17 15:24:16 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
(
|
2024-08-03 17:40:11 +08:00
|
|
|
inputs.lib.mkIf (inputs.lib.strings.hasPrefix "cachyos" kernel.variant)
|
|
|
|
{ nixos.packages.packages._packages = [ inputs.pkgs.scx ]; }
|
2024-03-17 15:24:16 +08:00
|
|
|
)
|
2024-03-25 17:49:35 +08:00
|
|
|
(
|
2024-04-20 10:57:00 +08:00
|
|
|
inputs.lib.mkIf (kernel.variant == "rpi3")
|
2024-03-25 17:49:35 +08:00
|
|
|
{ boot.initrd = { systemd.enableTpm2 = false; includeDefaultModules = false; }; }
|
|
|
|
)
|
2024-03-17 15:24:16 +08:00
|
|
|
];
|
2023-09-02 15:25:05 +08:00
|
|
|
}
|