feat(modules/dgn-harware): Refactor hardware config

This commit is contained in:
Tom Hubrecht 2023-11-29 15:33:45 +01:00
parent 73239b2f5c
commit 18b6b0f605
6 changed files with 76 additions and 102 deletions

View file

@ -28,6 +28,8 @@ lib.extra.mkConfig {
"sshd-bruteforce"
"sshd-timeout"
];
dgn-hardware.useZfs = true;
};
root = ./.;

View file

@ -1,42 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ modulesPath, ... }:
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "ahci" "ehci_pci" "megaraid_sas" "usb_storage" "usbhid" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.forceImportRoot = false;
boot.zfs.extraPools = [ "fast01" "work01" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{
fileSystems."/" = {
device = "/dev/disk/by-uuid/c83f6978-fd26-44a8-a86a-b0e971bb0c8c";
fsType = "ext4";
};
fileSystems."/boot" =
{
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/55DB-056F";
fsType = "vfat";
};
swapDevices =
[{ device = "/dev/disk/by-uuid/30547280-00e9-4ee1-8a07-d116590d9fbf"; }];
# networking.interfaces.eno2.useDHCP = lib.mkDefault true;
# networking.interfaces.eno3.useDHCP = lib.mkDefault true;
# networking.interfaces.eno4.useDHCP = lib.mkDefault true;
# networking.interfaces.idrac.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -14,5 +14,9 @@ lib.extra.mkConfig {
"peertube"
];
extraConfig = {
dgn-hardware.useZfs = true;
};
root = ./.;
}

View file

@ -1,58 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, modulesPath, ... }:
{ modulesPath, ... }:
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "ahci" "ehci_pci" "megaraid_sas" "usb_storage" "usbhid" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.forceImportRoot = false;
boot.zfs.extraPools = [ "fast01" "work01" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{
fileSystems."/" = {
device = "/dev/disk/by-uuid/278cb2a2-47b9-4ec5-8b68-a5a6d037d59e";
fsType = "ext4";
};
fileSystems."/boot" =
{
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/8BD2-C908";
fsType = "vfat";
};
swapDevices =
[{ device = "/dev/disk/by-uuid/65a6f6e4-e996-4718-a4d0-cd0c78dcb15b"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
# networking.interfaces.eno1 = {
# useDHCP = true;
# ipv4 = {
# addresses = [
# { address = "129.199.146.148"; prefixLength = 24; }
# { address = "192.168.1.148"; prefixLength = 24; }
# ];
#
# routes = [
# { address = "192.168.1.0"; prefixLength = 24; }
# ];
# };
# };
# networking.interfaces.eno2.useDHCP = lib.mkDefault true;
# networking.interfaces.eno3.useDHCP = lib.mkDefault true;
# networking.interfaces.eno4.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,7 +1,7 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ modulesPath, ... }:
{
imports = [
@ -9,13 +9,4 @@
(let sources = import ../../npins; in sources.disko + "/module.nix")
./disko.nix
];
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "ehci_pci" "virtio_pci" "ahci" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,23 +1,36 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkEnableOption
mkIf
mkMerge;
inherit (lib) mkEnableOption mkIf mkMerge;
cfg = config.dgn-hardware;
in
{
in {
options.dgn-hardware = {
enable = mkEnableOption "default hardware configuration." // { default = true; };
enable = mkEnableOption "default hardware configuration." // {
default = true;
};
useSystemd = mkEnableOption "sytemd boot and configuration." // { default = true; };
useSystemd = mkEnableOption "sytemd boot and configuration." // {
default = true;
};
useZfs = mkEnableOption "zfs configuration.";
};
config = mkIf cfg.enable (mkMerge [
{ hardware.enableRedistributableFirmware = true; }
{
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" ];
};
}
(mkIf cfg.useSystemd {
boot.loader = {
@ -25,5 +38,27 @@ in
efi.canTouchEfiVariables = true;
};
})
(mkIf cfg.useZfs {
boot = {
initrd.availableKernelModules = [
"ahci"
"ehci_pci"
"megaraid_sas"
"usb_storage"
"usbhid"
"sd_mod"
"sr_mod"
];
kernelModules = [ "kvm-intel" ];
supportedFilesystems = [ "zfs" ];
zfs = {
forceImportRoot = false;
extraPools = [ "fast01" "work01" ];
package = pkgs.zfs_2_1;
};
};
})
]);
}