You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.0 KiB
Nix

3 months ago
# applicable to all hosts running on bare hardware
{ config
, lib
, pkgs
, ...
}:
let
cfg = config.x-banananetwork.hwCommon;
cpu = config.hardware.cpu;
3 months ago
in
{
options = {
hardware.cpu = {
3 months ago
type = lib.mkOption {
3 months ago
description = ''
Configures the CPU type to expect this configuration to run on.
This setting is required when using generalizing options
like option{hardware.cpu.updateMicrocode}.
3 months ago
'';
type = with lib.types; nullOr enum [
"amd"
"intel"
];
3 months ago
# required
};
updateMicrocode = lib.mkEnableOption ''
microcode updates for CPU type selected in option{hardware.cpu.type}.
Because this module is not yet part of upstream,
it requires option{x-banananetwork.hwCommon.enable} to be enabled.
'';
3 months ago
};
x-banananetwork.hwCommon = {
enable = lib.mkEnableOption ''
settings common to all bare hardware-based hosts
'';
};
3 months ago
};
config = lib.mkIf cfg.enable {
hardware = {
cpu = lib.mkMerge [
# TODO maybe upstream?
3 months ago
(
let
type = config.hardware.cpu.type;
opts = isType: {
updateMicrocode = lib.mkDefault (isType && config.hardware.cpu.updateMicrocode);
};
in
{
amd = opts (type == "amd");
intel = opts (type == "intel");
}
3 months ago
)
{
updateMicrocode = lib.mkDefault true;
}
3 months ago
];
enableRedistributableFirmware = true;
};
powerManagement = {
cpuFreqGovernor = "ondemand";
enable = true;
powertop.enable = true;
scsiLinkPolicy = "med_power_with_dipm";
};
services = {
fwupd = {
enable = true;
};
smartd = {
enable = true;
};
};
x-banananetwork = {
allCommon.enable = true;
vmCommon.enable = false;
usuable.enable = lib.mkDefault true; # add docs & tools for emergencies
};
};
}