nixos/modules/system/kernel.nix

70 lines
2.9 KiB
Nix
Raw Normal View History

2023-09-02 15:25:05 +08:00
inputs:
{
options.nixos.system.kernel = let inherit (inputs.lib) mkOption types; in
{
2023-10-18 21:10:23 +08:00
useLts = mkOption { type = types.bool; default = false; };
2023-11-27 02:22:08 +08:00
patches = mkOption { type = types.listOf (types.enum [ "cjktty" ]); 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 = []; };
};
};
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) mkConditional;
inherit (inputs.config.nixos.system) kernel;
in { boot =
{
kernelModules = [ "br_netfilter" ] ++ kernel.modules.load;
# modprobe --show-depends
initrd.availableKernelModules =
[
"ahci" "ata_piix" "bfq" "failover" "net_failover" "nls_cp437" "nls_iso8859-1" "nvme" "sdhci_acpi" "sd_mod"
"sr_mod" "usbcore" "usbhid" "usbip-core" "usb-common" "usb_storage" "vhci-hcd" "virtio" "virtio_blk"
"virtio_net" "virtio_pci" "xhci_pci" "virtio_ring" "virtio_scsi" "cryptd" "crypto_simd" "libaes"
2023-10-02 14:10:23 +08:00
# networking for nas
"igb"
2023-12-12 23:30:43 +08:00
# yoga
"lenovo_yogabook"
] ++ kernel.modules.initrd ++ (if (!kernel.useLts) then [ "lenovo-yogabook" ] else []);
2023-09-05 01:31:27 +08:00
extraModulePackages = (with inputs.config.boot.kernelPackages; [ v4l2loopback ]) ++ kernel.modules.install;
2023-09-02 15:25:05 +08:00
extraModprobeConfig = builtins.concatStringsSep "\n" kernel.modules.modprobeConfig;
kernelParams = [ "delayacct" ];
2023-10-18 21:10:23 +08:00
kernelPackages = inputs.pkgs."linuxPackages_xanmod${if kernel.useLts then "" else "_latest"}";
2023-09-02 15:25:05 +08:00
kernelPatches =
let
patches =
{
cjktty =
{
2023-10-18 21:10:23 +08:00
patch =
let
version = builtins.splitVersion inputs.config.boot.kernelPackages.kernel.version;
major = builtins.elemAt version 0;
minor = builtins.elemAt version 1;
in inputs.pkgs.fetchurl
{
url = "https://raw.githubusercontent.com/zhmars/cjktty-patches/master/"
2023-10-09 12:08:54 +08:00
+ "v${major}.x/cjktty-${major}.${minor}.patch";
2023-10-18 21:10:23 +08:00
sha256 =
let
hashes =
{
"6.1" = "11ddiammvjxx2m9v32p25l1ai759a1d6xhdpszgnihv7g2fzigf5";
2023-12-19 12:53:43 +08:00
"6.6" = "19ib0syj3207ifr315gdrnpv6nhh435fmgl05c7k715nng40i827";
2023-10-18 21:10:23 +08:00
};
in hashes."${major}.${minor}";
};
2023-09-02 15:25:05 +08:00
extraStructuredConfig =
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
};
};
in
builtins.map (name: { inherit name; } // patches.${name}) kernel.patches;
};};
}