forked from DGNum/infrastructure
95 lines
1.9 KiB
Nix
95 lines
1.9 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib)
|
|
mkEnableOption
|
|
mkIf
|
|
mkMerge
|
|
mkOption
|
|
;
|
|
inherit (lib.types) listOf str;
|
|
|
|
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";
|
|
|
|
zfsPools = mkOption {
|
|
type = listOf str;
|
|
default = [
|
|
"fast01"
|
|
"work01"
|
|
];
|
|
description = ''
|
|
ZFS pools present on the machine
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
{
|
|
microvm.host.enable = lib.mkDefault false;
|
|
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 = cfg.zfsPools;
|
|
package = pkgs.zfs_2_1;
|
|
};
|
|
};
|
|
})
|
|
]);
|
|
}
|