From 43fcffba37964f98c88232d9a87b291b64b148df Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sun, 24 Mar 2024 21:02:39 -0400 Subject: [PATCH] Switchable Hardware Configuration - Move generated hardware-configuration.nix files to hardware folder - Add flake.nix option to select which hardware configuration to use --- flake.nix | 1 + .../proxmox-vm.nix | 0 hardware/qemu-vm.nix | 24 +++++++++++++++++++ profiles/personal/configuration.nix | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) rename system/hardware-configuration.nix => hardware/proxmox-vm.nix (100%) create mode 100644 hardware/qemu-vm.nix diff --git a/flake.nix b/flake.nix index db1cf61..0790c0b 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,7 @@ locale = "en_US.UTF-8"; # Locale diskoConfig = "luks-btrfs-subvolumes"; # Select the disko config that was used to partition drive desktopEnvironment = "gnome"; # Window Manager / Desktop Environment to use + hardwareConfiguration = "qemu-vm"; # Select the hardware config from hardware directory }; # --- USER SETTINGS --- # diff --git a/system/hardware-configuration.nix b/hardware/proxmox-vm.nix similarity index 100% rename from system/hardware-configuration.nix rename to hardware/proxmox-vm.nix diff --git a/hardware/qemu-vm.nix b/hardware/qemu-vm.nix new file mode 100644 index 0000000..0759c10 --- /dev/null +++ b/hardware/qemu-vm.nix @@ -0,0 +1,24 @@ +# 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, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + # 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..useDHCP'. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/profiles/personal/configuration.nix b/profiles/personal/configuration.nix index a0c24d1..4ee592a 100644 --- a/profiles/personal/configuration.nix +++ b/profiles/personal/configuration.nix @@ -6,7 +6,7 @@ { imports = [ - ../../system/hardware-configuration.nix + (./. + "../../hardware" + ("/" + systemSettings.hardwareConfiguration) + ".nix") ../../system/hardware/kernel.nix ../../system/hardware/bluetooth.nix ../../system/hardware/opengl.nix