about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-06 06:37:34 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-06 06:37:34 -0700
commit19cf9d640d1e7c3cdab01ad362945a051721d9b1 (patch)
treeef614d306967aefb1c170a9a6c4074c02611cbab
parentrefactor intel related configuration (diff)
downloadworld-19cf9d640d1e7c3cdab01ad362945a051721d9b1.tar.gz
refactor configuration for AMD
Diffstat (limited to '')
-rw-r--r--hosts/carmel/hardware-configuration.nix54
-rw-r--r--hosts/tahoe/hardware-configuration.nix77
-rw-r--r--modules/hardware/amd/default.nix13
-rw-r--r--modules/hardware/default.nix2
4 files changed, 79 insertions, 67 deletions
diff --git a/hosts/carmel/hardware-configuration.nix b/hosts/carmel/hardware-configuration.nix
index 17aba16..e342c9a 100644
--- a/hosts/carmel/hardware-configuration.nix
+++ b/hosts/carmel/hardware-configuration.nix
@@ -4,45 +4,43 @@
 { config, lib, pkgs, modulesPath, ... }:
 
 {
-  imports =
-    [ (modulesPath + "/installer/scan/not-detected.nix")
-    ];
+  imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
 
-  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
+  boot.initrd.availableKernelModules =
+    [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
   boot.initrd.kernelModules = [ ];
-  boot.kernelModules = [ "kvm-amd" ];
   boot.extraModulePackages = [ ];
 
-  fileSystems."/" =
-    { device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
-      fsType = "btrfs";
-      options = [ "subvol=nixos" ];
-    };
+  fileSystems."/" = {
+    device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
+    fsType = "btrfs";
+    options = [ "subvol=nixos" ];
+  };
 
-  boot.initrd.luks.devices."system".device = "/dev/disk/by-uuid/dd1b3673-ece0-49f8-bf71-8cc4e1a06634";
+  boot.initrd.luks.devices."system".device =
+    "/dev/disk/by-uuid/dd1b3673-ece0-49f8-bf71-8cc4e1a06634";
 
-  fileSystems."/home" =
-    { device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
-      fsType = "btrfs";
-      options = [ "subvol=home" ];
-    };
+  fileSystems."/home" = {
+    device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
+    fsType = "btrfs";
+    options = [ "subvol=home" ];
+  };
 
-  fileSystems."/.snapshots" =
-    { device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
-      fsType = "btrfs";
-      options = [ "subvol=snapshots" ];
-    };
+  fileSystems."/.snapshots" = {
+    device = "/dev/disk/by-uuid/7d4e07d8-1104-4ab8-8ead-8ca28da2d344";
+    fsType = "btrfs";
+    options = [ "subvol=snapshots" ];
+  };
 
-  fileSystems."/boot" =
-    { device = "/dev/disk/by-uuid/7430-1C58";
-      fsType = "vfat";
-    };
+  fileSystems."/boot" = {
+    device = "/dev/disk/by-uuid/7430-1C58";
+    fsType = "vfat";
+  };
 
   swapDevices =
-    [ { device = "/dev/disk/by-uuid/ebcb04f3-4227-4ec3-af52-bd775ef38027"; }
-    ];
+    [{ device = "/dev/disk/by-uuid/ebcb04f3-4227-4ec3-af52-bd775ef38027"; }];
 
-  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
+  my.hardware.amd = true;
   # high-resolution display
   hardware.video.hidpi.enable = lib.mkDefault true;
 }
diff --git a/hosts/tahoe/hardware-configuration.nix b/hosts/tahoe/hardware-configuration.nix
index f7b0a73..d32ef0a 100644
--- a/hosts/tahoe/hardware-configuration.nix
+++ b/hosts/tahoe/hardware-configuration.nix
@@ -4,59 +4,60 @@
 { config, lib, pkgs, modulesPath, ... }:
 
 {
-  imports =
-    [ (modulesPath + "/installer/scan/not-detected.nix")
-    ];
+  imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
 
-  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
+  boot.initrd.availableKernelModules =
+    [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
   boot.initrd.kernelModules = [ ];
-  boot.kernelModules = [ "kvm-amd" ];
   boot.extraModulePackages = [ ];
 
-  fileSystems."/" =
-    { device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
-      fsType = "btrfs";
-      options = [ "subvol=nixos" ];
-    };
+  fileSystems."/" = {
+    device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
+    fsType = "btrfs";
+    options = [ "subvol=nixos" ];
+  };
 
-  boot.initrd.luks.devices."system".device = "/dev/disk/by-uuid/0d11e090-d88f-4313-8a41-8ef52eea0870";
+  boot.initrd.luks.devices."system".device =
+    "/dev/disk/by-uuid/0d11e090-d88f-4313-8a41-8ef52eea0870";
 
-  fileSystems."/home" =
-    { device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
-      fsType = "btrfs";
-      options = [ "subvol=home" ];
-    };
+  fileSystems."/home" = {
+    device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
+    fsType = "btrfs";
+    options = [ "subvol=home" ];
+  };
 
-  fileSystems."/.snapshots" =
-    { device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
-      fsType = "btrfs";
-      options = [ "subvol=snapshots" ];
-    };
+  fileSystems."/.snapshots" = {
+    device = "/dev/disk/by-uuid/128c2a5e-48f6-4d94-b196-fb5db500b36d";
+    fsType = "btrfs";
+    options = [ "subvol=snapshots" ];
+  };
 
-  fileSystems."/boot" =
-    { device = "/dev/disk/by-uuid/CBB9-B788";
-      fsType = "vfat";
-    };
+  fileSystems."/boot" = {
+    device = "/dev/disk/by-uuid/CBB9-B788";
+    fsType = "vfat";
+  };
 
-  fileSystems."/data/fast" =
-    { device = "/dev/disk/by-uuid/b9290b55-8ff6-4bd0-843d-a9e6f7a4df59";
-      fsType = "btrfs";
-    };
+  fileSystems."/data/fast" = {
+    device = "/dev/disk/by-uuid/b9290b55-8ff6-4bd0-843d-a9e6f7a4df59";
+    fsType = "btrfs";
+  };
 
-  boot.initrd.luks.devices."raid-fast".device = "/dev/disk/by-uuid/66c58a92-45fe-4b03-9be0-214ff67c177c";
+  boot.initrd.luks.devices."raid-fast".device =
+    "/dev/disk/by-uuid/66c58a92-45fe-4b03-9be0-214ff67c177c";
 
-  fileSystems."/data/slow" =
-    { device = "/dev/disk/by-uuid/0f16db51-0ee7-48d8-9e48-653b85ecbf0a";
-      fsType = "btrfs";
-    };
+  fileSystems."/data/slow" = {
+    device = "/dev/disk/by-uuid/0f16db51-0ee7-48d8-9e48-653b85ecbf0a";
+    fsType = "btrfs";
+  };
 
-  boot.initrd.luks.devices."raid-slow".device = "/dev/disk/by-uuid/d8b21267-d457-4522-91d9-5481b44dd0a5";
+  boot.initrd.luks.devices."raid-slow".device =
+    "/dev/disk/by-uuid/d8b21267-d457-4522-91d9-5481b44dd0a5";
 
   swapDevices =
-    [ { device = "/dev/disk/by-uuid/0f54b5ab-4fca-4c5a-a9eb-622553145163"; }
-    ];
+    [{ device = "/dev/disk/by-uuid/0f54b5ab-4fca-4c5a-a9eb-622553145163"; }];
+
+  my.hardware.amd = true;
 
-  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
   # high-resolution display
   hardware.video.hidpi.enable = lib.mkDefault true;
 }
diff --git a/modules/hardware/amd/default.nix b/modules/hardware/amd/default.nix
new file mode 100644
index 0000000..05362db
--- /dev/null
+++ b/modules/hardware/amd/default.nix
@@ -0,0 +1,13 @@
+{ config, lib, ... }:
+let cfg = config.my.hardware.amd;
+in {
+  options.my.hardware.amd = with lib; {
+    enable = mkEnableOption "AMD related configuration";
+  };
+
+  config = lib.mkIf cfg.enable {
+    # Enable microcode update
+    hardware.cpu.amd.updateMicrocode = true;
+    boot.kernelModules = [ "kvm-amd" ];
+  };
+}
diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix
index 62208c1..843c1f5 100644
--- a/modules/hardware/default.nix
+++ b/modules/hardware/default.nix
@@ -1,5 +1,5 @@
 { ... }:
 
 {
-  imports = [ ./intel ./ssd ./sound ./networking ];
+  imports = [ ./amd ./intel ./ssd ./sound ./networking ];
 }