infrastructure/modules/dgn-hardware.nix
Tom Hubrecht 54ec4a6b18
All checks were successful
lint / check (push) Successful in 32s
build configuration / build_vault01 (push) Successful in 1m2s
build configuration / build_web02 (push) Successful in 1m2s
build configuration / build_storage01 (push) Successful in 1m6s
build configuration / build_compute01 (push) Successful in 1m9s
build configuration / build_web01 (push) Successful in 1m25s
feat(dgn-hardware): Factorize bcachefs setup
2024-02-20 21:25:04 +01:00

82 lines
1.7 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkIf mkMerge;
cfg = config.dgn-hardware;
in
{
options.dgn-hardware = {
enable = mkEnableOption "default hardware configuration." // {
default = true;
};
useSystemd = mkEnableOption "sytemd boot and configuration." // {
default = true;
};
useZfs = mkEnableOption "zfs configuration.";
useBcachefs = mkEnableOption "bcachefs configuration";
};
config = mkIf cfg.enable (
mkMerge [
{
hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
boot = {
initrd.availableKernelModules = [
"ata_piix"
"uhci_hcd"
"ehci_pci"
"virtio_pci"
"ahci"
"virtio_blk"
];
kernelModules = [ "kvm-intel" ];
kernelParams = [
"cgroup_enable=cpu"
"cgroup_enable=cpuset"
"cgroup_enable=memory"
"cgroup_memory=1"
];
};
}
(mkIf cfg.useSystemd {
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
})
(mkIf cfg.useBcachefs {
boot.supportedFilesystems = [ "bcachefs" ];
boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_7;
})
(mkIf cfg.useZfs {
boot = {
supportedFilesystems = [ "zfs" ];
zfs = {
forceImportRoot = false;
extraPools = [
"fast01"
"work01"
];
package = pkgs.zfs_2_1;
};
};
})
]
);
}