2023-07-15 22:37:43 +08:00
|
|
|
inputs:
|
2023-07-14 17:10:53 +08:00
|
|
|
{
|
|
|
|
options.nixos.kernel = let inherit (inputs.lib) mkOption types; in
|
|
|
|
{
|
2023-07-27 19:01:58 +08:00
|
|
|
patches = mkOption { type = types.listOf (types.enum [ "cjktty" "preempt" ]); default = []; };
|
2023-07-22 12:30:37 +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 = []; };
|
|
|
|
};
|
2023-07-14 17:10:53 +08:00
|
|
|
};
|
2023-07-22 00:22:32 +08:00
|
|
|
config = let inherit (inputs.lib) mkMerge mkIf; inherit (inputs.localLib) mkConditional; in mkMerge
|
|
|
|
[
|
|
|
|
# generic
|
2023-07-15 22:12:29 +08:00
|
|
|
{
|
2023-07-22 00:22:32 +08:00
|
|
|
boot =
|
2023-07-16 14:23:48 +08:00
|
|
|
{
|
2023-07-22 18:03:09 +08:00
|
|
|
kernelModules = [ "br_netfilter" ];
|
2023-07-22 14:06:41 +08:00
|
|
|
initrd.availableKernelModules =
|
|
|
|
[
|
2023-08-03 17:57:38 +08:00
|
|
|
"ahci" "ata_piix" "bfq" "failover" "net_failover" "nls_cp437" "nls_iso8859-1" "nvme" "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-07-22 14:06:41 +08:00
|
|
|
];
|
2023-07-22 00:22:32 +08:00
|
|
|
kernelParams = [ "delayacct" "acpi_osi=Linux" ];
|
|
|
|
kernelPackages = inputs.pkgs.linuxPackagesFor (inputs.pkgs.linuxPackages_xanmod.kernel.override rec
|
2023-07-16 14:23:48 +08:00
|
|
|
{
|
2023-07-22 00:22:32 +08:00
|
|
|
src = inputs.pkgs.fetchFromGitHub
|
|
|
|
{
|
|
|
|
owner = "xanmod";
|
|
|
|
repo = "linux";
|
|
|
|
rev = modDirVersion;
|
|
|
|
sha256 = "sha256-ab4AQx1ApJ9o1oqgNoJBL64tI0qpyVBm5XUC8l1yT6Q=";
|
|
|
|
};
|
|
|
|
version = "6.3.12";
|
|
|
|
modDirVersion = "6.3.12-xanmod1";
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
# patches
|
|
|
|
{
|
|
|
|
boot.kernelPatches =
|
2023-07-15 22:37:43 +08:00
|
|
|
(
|
|
|
|
let
|
|
|
|
patches =
|
|
|
|
{
|
2023-07-22 12:52:28 +08:00
|
|
|
cjktty =
|
2023-07-15 22:37:43 +08:00
|
|
|
{
|
|
|
|
patch = inputs.pkgs.fetchurl
|
|
|
|
{
|
2023-07-16 14:23:48 +08:00
|
|
|
url = "https://raw.githubusercontent.com/zhmars/cjktty-patches/master/v6.x/cjktty-6.3.patch";
|
|
|
|
sha256 = "sha256-QnsWruzhtiZnqzTUXkPk9Hb19Iddr4VTWXyV4r+iLvE=";
|
2023-07-15 22:37:43 +08:00
|
|
|
};
|
|
|
|
extraStructuredConfig =
|
|
|
|
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
|
|
|
|
};
|
2023-07-22 12:52:28 +08:00
|
|
|
preempt =
|
|
|
|
{
|
|
|
|
patch = null;
|
|
|
|
extraStructuredConfig =
|
|
|
|
{
|
|
|
|
PREEMPT_VOLUNTARY = inputs.lib.mkForce inputs.lib.kernel.no;
|
|
|
|
PREEMPT = inputs.lib.mkForce inputs.lib.kernel.yes;
|
|
|
|
HZ_500 = inputs.lib.mkForce inputs.lib.kernel.no;
|
|
|
|
HZ_1000 = inputs.lib.mkForce inputs.lib.kernel.yes;
|
|
|
|
HZ = inputs.lib.mkForce (inputs.lib.kernel.freeform "1000");
|
|
|
|
};
|
|
|
|
};
|
2023-07-15 22:37:43 +08:00
|
|
|
};
|
|
|
|
in
|
|
|
|
builtins.map (name: { inherit name; } // patches.${name}) inputs.config.nixos.kernel.patches
|
|
|
|
);
|
2023-07-22 00:22:32 +08:00
|
|
|
}
|
2023-07-22 12:30:37 +08:00
|
|
|
# modules
|
|
|
|
{
|
|
|
|
boot =
|
|
|
|
{
|
|
|
|
extraModulePackages = inputs.config.nixos.kernel.modules.install;
|
|
|
|
kernelModules = inputs.config.nixos.kernel.modules.load;
|
|
|
|
initrd.availableKernelModules = inputs.config.nixos.kernel.modules.initrd;
|
|
|
|
extraModprobeConfig = builtins.concatStringsSep "\n" inputs.config.nixos.kernel.modules.modprobeConfig;
|
|
|
|
};
|
|
|
|
}
|
2023-07-22 00:22:32 +08:00
|
|
|
];
|
2023-07-14 17:10:53 +08:00
|
|
|
}
|
2023-07-22 14:06:41 +08:00
|
|
|
|
|
|
|
# modprobe --show-depends
|