2024-02-02 10:51:31 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2023-07-18 17:03:01 +02:00
|
|
|
|
|
|
|
let
|
2024-02-21 17:17:40 +01:00
|
|
|
inherit (lib)
|
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
mkMerge
|
|
|
|
mkOption
|
|
|
|
;
|
|
|
|
inherit (lib.types) listOf str;
|
2023-07-18 17:03:01 +02:00
|
|
|
|
2023-07-18 17:07:14 +02:00
|
|
|
cfg = config.dgn-hardware;
|
2024-02-02 10:51:31 +01:00
|
|
|
in
|
|
|
|
{
|
2023-07-18 17:03:01 +02:00
|
|
|
options.dgn-hardware = {
|
2023-11-29 15:33:45 +01:00
|
|
|
enable = mkEnableOption "default hardware configuration." // {
|
|
|
|
default = true;
|
|
|
|
};
|
2023-07-18 17:03:01 +02:00
|
|
|
|
2023-11-29 15:33:45 +01:00
|
|
|
useSystemd = mkEnableOption "sytemd boot and configuration." // {
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
useZfs = mkEnableOption "zfs configuration.";
|
2024-01-11 12:58:27 +01:00
|
|
|
useBcachefs = mkEnableOption "bcachefs configuration";
|
2024-02-21 17:17:40 +01:00
|
|
|
|
|
|
|
zfsPools = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [
|
|
|
|
"fast01"
|
|
|
|
"work01"
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
ZFS pools present on the machine
|
|
|
|
'';
|
|
|
|
};
|
2023-07-18 17:03:01 +02:00
|
|
|
};
|
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
2024-02-20 21:25:04 +01:00
|
|
|
(mkIf cfg.useBcachefs {
|
|
|
|
boot.supportedFilesystems = [ "bcachefs" ];
|
|
|
|
boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_7;
|
|
|
|
})
|
2024-02-02 10:51:31 +01:00
|
|
|
|
|
|
|
(mkIf cfg.useZfs {
|
|
|
|
boot = {
|
|
|
|
supportedFilesystems = [ "zfs" ];
|
|
|
|
|
|
|
|
zfs = {
|
|
|
|
forceImportRoot = false;
|
2024-02-21 17:17:40 +01:00
|
|
|
extraPools = cfg.zfsPools;
|
2024-02-02 10:51:31 +01:00
|
|
|
package = pkgs.zfs_2_1;
|
|
|
|
};
|
2023-11-29 15:33:45 +01:00
|
|
|
};
|
2024-02-02 10:51:31 +01:00
|
|
|
})
|
|
|
|
]
|
|
|
|
);
|
2023-07-18 17:03:01 +02:00
|
|
|
}
|