From d2bfbc77b401758c6013c536f6c784dc414cddfd Mon Sep 17 00:00:00 2001 From: Zastian Pretorius Date: Mon, 23 Jun 2025 19:23:30 +0100 Subject: [PATCH] feat: combined laptop and PC hatdware-config.nix --- hardware-configuration.nix | 96 +++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 18 deletions(-) diff --git a/hardware-configuration.nix b/hardware-configuration.nix index 5aced16..bee0065 100644 --- a/hardware-configuration.nix +++ b/hardware-configuration.nix @@ -1,36 +1,89 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + systemName, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ ] + ++ (lib.optionals (systemName == "pc") [ + "xhci_pci" + "ahci" + "nvme" + "usb_storage" + "usbhid" + "sd_mod" + ]) + ++ (lib.optionals (systemName == "laptop") [ + "vmd" + "xhci_pci" + "nvme" + "usb_storage" + "sd_mod" + ]); boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; + boot.kernelModules = + [ ] + ++ (lib.optionals (systemName == "pc") [ "kvm-amd" ]) + ++ (lib.optionals (systemName == "laptop") [ "kvm-intel" ]); boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/fdcbb840-4b35-4023-a048-599b0c5161d6"; + fileSystems."/" = lib.mkMerge [ + (lib.mkIf (systemName == "pc") { + device = "/dev/disk/by-uuid/fdcbb840-4b35-4023-a048-599b0c5161d6"; fsType = "btrfs"; - }; + }) + (lib.mkIf (systemName == "laptop") { + device = "/dev/disk/by-uuid/6aa7c67d-a0a5-4928-b16b-9c7991fee7ab"; + fsType = "ext4"; + }) + ]; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/E1B6-9089"; + fileSystems."/boot" = lib.mkMerge [ + (lib.mkIf (systemName == "pc") { + device = "/dev/disk/by-uuid/E1B6-9089"; fsType = "vfat"; - }; + }) + (lib.mkIf (systemName == "laptop") { + device = "/dev/disk/by-uuid/A4F3-8038"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }) + ]; - fileSystems."/home" = - { device = "/dev/disk/by-uuid/d226a8ed-10eb-452e-9284-1ff994a7f179"; + fileSystems."/home" = lib.mkMerge [ + (lib.mkIf (systemName == "pc") { + device = "/dev/disk/by-uuid/d226a8ed-10eb-452e-9284-1ff994a7f179"; fsType = "btrfs"; - }; + }) + ]; swapDevices = - [ { device = "/dev/disk/by-uuid/ccf41b96-c45f-47e0-8541-cd865f5d2ec6"; } - ]; + [ ] + ++ (lib.optionals (systemName == "pc") [ + { + device = "/dev/disk/by-uuid/ccf41b96-c45f-47e0-8541-cd865f5d2ec6"; + } + ]) + ++ (lib.optionals (systemName == "laptop") [ + { + device = "/dev/disk/by-uuid/b416c3bd-861b-4b0c-aa84-6962b2e6a47d"; + } + ]); # 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 @@ -41,5 +94,12 @@ # networking.interfaces.wlp4s0f0u8.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware = lib.mkMerge [ + (lib.mkIf (systemName == "pc") { + cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }) + (lib.mkIf (systemName == "laptop") { + cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }) + ]; }