mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
[Boot+Refactoring] Add a cmdline config option for cleaner boot option config
This commit is contained in:
parent
8457628ee6
commit
7e26d25066
6 changed files with 43 additions and 22 deletions
24
boot.nix
24
boot.nix
|
|
@ -22,6 +22,13 @@ let
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
toCmdlineValue = v: if (isBool v) then (if v then "y" else "n")
|
||||
else if (isInt v || isString v) then (toString v)
|
||||
else throw "Invalid value for kernel cmdline parameter";
|
||||
|
||||
toCmdlineList = set: mapAttrsToList (key: value: "${key}=${toCmdlineValue value}") set;
|
||||
|
||||
cfg = config.aviallon.boot;
|
||||
generalCfg = config.aviallon.general;
|
||||
allowUnfree = (types.isType types.attrs config.nixpkgs.config)
|
||||
|
|
@ -58,6 +65,13 @@ in
|
|||
example = null;
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
cmdline = mkOption {
|
||||
description = "Kernel params as attributes (instead of list)";
|
||||
default = { };
|
||||
example = { "i915.fastboot" = true; };
|
||||
type = types.attrsOf (types.oneOf [ types.bool types.int types.str ]);
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
@ -65,14 +79,16 @@ in
|
|||
hardware.enableAllFirmware = allowUnfree;
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
|
||||
aviallon.boot.cmdline = {
|
||||
"syscall.x32" = cfg.x32abi.enable;
|
||||
};
|
||||
|
||||
boot = {
|
||||
initrd.kernelModules = [ ];
|
||||
initrd.availableKernelModules = [ "ehci_pci" ];
|
||||
|
||||
kernelParams = concatLists [
|
||||
(optional cfg.x32abi.enable "syscall.x32=y")
|
||||
];
|
||||
|
||||
kernelParams = toCmdlineList cfg.cmdline;
|
||||
|
||||
kernelPatches = concatLists [
|
||||
(optional cfg.x32abi.enable customKernelPatches.enableX32ABI)
|
||||
];
|
||||
|
|
|
|||
|
|
@ -70,10 +70,11 @@ in {
|
|||
|
||||
|
||||
boot.plymouth.enable = mkDefault true;
|
||||
boot.kernelParams = concatLists [
|
||||
(optionals (!generalCfg.debug) [ "splash" "udev.log_level=3" ])
|
||||
["preempt=full"]
|
||||
];
|
||||
aviallon.boot.cmdline = {
|
||||
splash = mkIf (!generalCfg.debug) true;
|
||||
"udev.log_level" = mkIf (!generalCfg.debug) 3;
|
||||
preempt = "full";
|
||||
};
|
||||
boot.initrd.verbose = generalCfg.debug;
|
||||
boot.consoleLogLevel = mkIf (!generalCfg.debug) 1;
|
||||
|
||||
|
|
|
|||
10
general.nix
10
general.nix
|
|
@ -94,10 +94,12 @@ in
|
|||
font = "Lat2-Terminus16";
|
||||
};
|
||||
|
||||
boot.kernelParams = concatLists [
|
||||
(optional cfg.unsafeOptimizations "mitigations=off")
|
||||
(optionals cfg.unsafeOptimizations [ "i915.mitigations=off" "i915.enable_dc=4" "i915.fastboot=1" ] )
|
||||
];
|
||||
aviallon.boot.cmdline = mkIf cfg.unsafeOptimizations {
|
||||
mitigations = "off";
|
||||
"i915.mitigations" = "off";
|
||||
"i915.enable_dc" = 4;
|
||||
"i915.fastboot" = 1;
|
||||
};
|
||||
|
||||
powerManagement.cpuFreqGovernor = mkDefault "schedutil";
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ in
|
|||
services.dbus.apparmor = "enabled";
|
||||
|
||||
|
||||
boot.kernelParams = concatLists [
|
||||
boot.kernelParams = mkAfter (concatLists [
|
||||
# Slab/slub sanity checks, redzoning, and poisoning
|
||||
(optional cfg.expensive "slub_debug=FZP")
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ in
|
|||
|
||||
# Apparmor https://wiki.archlinux.org/title/AppArmor#Installation
|
||||
(optional cfg.expensive "lsm=landlock,lockdown,yama,apparmor,bpf")
|
||||
];
|
||||
]);
|
||||
|
||||
boot.kernel.sysctl = {
|
||||
"kernel.yama.ptrace_scope" = mkOverride 500 1;
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ in
|
|||
config = mkIf (hardwareCfg.gpuVendor == "amd") {
|
||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||
|
||||
boot.kernelParams = concatLists [
|
||||
aviallon.boot.cmdline = {}
|
||||
# for Southern Islands (SI ie. GCN 1) cards
|
||||
[ "radeon.si_support=0" "amdgpu.si_support=1" ]
|
||||
// { "radeon.si_support" = 0;
|
||||
"amdgpu.si_support" = 1; }
|
||||
# for Sea Islands (CIK ie. GCN 2) cards
|
||||
[ "radeon.cik_support=0" "amdgpu.cik_support=1" ]
|
||||
];
|
||||
// { "radeon.cik_support" = 0;
|
||||
"amdgpu.cik_support" = 1; }
|
||||
;
|
||||
|
||||
hardware.opengl.extraPackages = with pkgs; [
|
||||
rocm-opencl-icd
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ in {
|
|||
|
||||
hardware.sensor.iio.enable = mkDefault true;
|
||||
|
||||
boot.kernelParams = [
|
||||
"i915.enable_fbc=1"
|
||||
"i915.enable_gvt=1"
|
||||
];
|
||||
aviallon.boot.cmdline = {
|
||||
"i915.enable_fbc" = 1;
|
||||
"i915.enable_gvt" = 1;
|
||||
};
|
||||
|
||||
services.tlp.enable = (cfg.power-manager == "tlp");
|
||||
services.power-profiles-daemon.enable = (cfg.power-manager == "power-profiles-daemon");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue