mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-23 05:39:05 +08:00
整理 system.kernel
This commit is contained in:
parent
e1e88dfdba
commit
e6969fb0c2
12
flake.nix
12
flake.nix
@ -124,12 +124,12 @@
|
||||
};
|
||||
march = "alderlake";
|
||||
gui.enable = true;
|
||||
};
|
||||
kernel =
|
||||
{
|
||||
patches = [ "cjktty" "preempt" ];
|
||||
modules.modprobeConfig = [ "options iwlmvm power_scheme=1" "options iwlwifi uapsd_disable=1" ];
|
||||
};
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "intel" ];
|
||||
@ -255,6 +255,7 @@
|
||||
network.enable = true;
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
kernel.patches = [ "preempt" ];
|
||||
};
|
||||
packages.packageSet = "server";
|
||||
services =
|
||||
@ -320,6 +321,7 @@
|
||||
network.enable = true;
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
kernel.patches = [ "preempt" ];
|
||||
};
|
||||
packages.packageSet = "server";
|
||||
services =
|
||||
@ -364,6 +366,7 @@
|
||||
network.enable = true;
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
kernel.patches = [ "preempt" ];
|
||||
};
|
||||
packages =
|
||||
{
|
||||
@ -416,6 +419,7 @@
|
||||
network.enable = true;
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
kernel.patches = [ "preempt" ];
|
||||
};
|
||||
packages.packageSet = "server";
|
||||
services =
|
||||
@ -473,12 +477,12 @@
|
||||
substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};
|
||||
gui.enable = true;
|
||||
};
|
||||
kernel =
|
||||
{
|
||||
patches = [ "cjktty" "preempt" ];
|
||||
modules.modprobeConfig = [ "options iwlmvm power_scheme=1" "options iwlwifi uapsd_disable=1" ];
|
||||
};
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "intel" ];
|
||||
@ -575,8 +579,8 @@
|
||||
gui.enable = true;
|
||||
grub.installDevice = "efi";
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};
|
||||
kernel.patches = [ "cjktty" "preempt" ];
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "intel" ];
|
||||
@ -631,8 +635,8 @@
|
||||
grub.installDevice = "efiRemovable";
|
||||
gui.enable = true;
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};
|
||||
kernel.patches = [ "cjktty" "preempt" ];
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "intel" ];
|
||||
|
@ -30,6 +30,6 @@ inputs:
|
||||
deploy-rs = { inherit (prev) deploy-rs; inherit ((topInputs.deploy-rs.overlay final prev).deploy-rs) lib; };
|
||||
})
|
||||
];})
|
||||
./kernel ./hardware ./packages ./system ./virtualization ./services ./bugs ./users
|
||||
./hardware ./packages ./system ./virtualization ./services ./bugs ./users
|
||||
];
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.kernel = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
patches = mkOption { type = types.listOf (types.enum [ "cjktty" "preempt" ]); default = []; };
|
||||
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; in mkMerge
|
||||
[
|
||||
# generic
|
||||
{
|
||||
boot =
|
||||
{
|
||||
kernelModules = [ "br_netfilter" ];
|
||||
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"
|
||||
];
|
||||
kernelParams = [ "delayacct" "acpi_osi=Linux" ];
|
||||
kernelPackages = inputs.pkgs.linuxPackagesFor (inputs.pkgs.linuxPackages_xanmod.kernel.override rec
|
||||
{
|
||||
src = inputs.pkgs.fetchFromGitHub
|
||||
{
|
||||
owner = "xanmod";
|
||||
repo = "linux";
|
||||
rev = modDirVersion;
|
||||
sha256 = "sha256-rvSQJb9MIOXkGEjHOPt3x+dqp1AysvQg7n5yYsg95fk=";
|
||||
};
|
||||
version = "6.4.12";
|
||||
modDirVersion = "6.4.12-xanmod1";
|
||||
});
|
||||
};
|
||||
}
|
||||
# patches
|
||||
{
|
||||
boot.kernelPatches =
|
||||
(
|
||||
let
|
||||
patches =
|
||||
{
|
||||
cjktty =
|
||||
{
|
||||
patch = inputs.pkgs.fetchurl
|
||||
{
|
||||
url = "https://raw.githubusercontent.com/zhmars/cjktty-patches/master/v6.x/cjktty-6.3.patch";
|
||||
sha256 = "sha256-QnsWruzhtiZnqzTUXkPk9Hb19Iddr4VTWXyV4r+iLvE=";
|
||||
};
|
||||
extraStructuredConfig =
|
||||
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
|
||||
};
|
||||
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");
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
builtins.map (name: { inherit name; } // patches.${name}) inputs.config.nixos.kernel.patches
|
||||
);
|
||||
}
|
||||
# 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;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
# modprobe --show-depends
|
@ -6,6 +6,7 @@ inputs:
|
||||
./fileSystems.nix
|
||||
./grub.nix
|
||||
./initrd.nix
|
||||
./kernel.nix
|
||||
];
|
||||
options.nixos.system = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
|
74
modules/system/kernel.nix
Normal file
74
modules/system/kernel.nix
Normal file
@ -0,0 +1,74 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.kernel = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
patches = mkOption { type = types.listOf (types.enum [ "cjktty" "preempt" ]); default = []; };
|
||||
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"
|
||||
] ++ kernel.modules.initrd;
|
||||
extraModulePackages = kernel.modules.install;
|
||||
extraModprobeConfig = builtins.concatStringsSep "\n" kernel.modules.modprobeConfig;
|
||||
kernelParams = [ "delayacct" "acpi_osi=Linux" ];
|
||||
kernelPackages = inputs.pkgs.linuxPackagesFor (inputs.pkgs.linuxPackages_xanmod.kernel.override rec
|
||||
{
|
||||
src = inputs.pkgs.fetchFromGitHub
|
||||
{
|
||||
owner = "xanmod";
|
||||
repo = "linux";
|
||||
rev = modDirVersion;
|
||||
sha256 = "sha256-rvSQJb9MIOXkGEjHOPt3x+dqp1AysvQg7n5yYsg95fk=";
|
||||
};
|
||||
version = "6.4.12";
|
||||
modDirVersion = "6.4.12-xanmod1";
|
||||
});
|
||||
kernelPatches =
|
||||
let
|
||||
patches =
|
||||
{
|
||||
cjktty =
|
||||
{
|
||||
patch = inputs.pkgs.fetchurl
|
||||
{
|
||||
url = "https://raw.githubusercontent.com/zhmars/cjktty-patches/master/v6.x/cjktty-6.3.patch";
|
||||
sha256 = "sha256-QnsWruzhtiZnqzTUXkPk9Hb19Iddr4VTWXyV4r+iLvE=";
|
||||
};
|
||||
extraStructuredConfig =
|
||||
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
|
||||
};
|
||||
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");
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
builtins.map (name: { inherit name; } // patches.${name}) kernel.patches;
|
||||
};};
|
||||
}
|
Loading…
Reference in New Issue
Block a user