From 611cd25502ea19e3985d91ab9809041a17df75b5 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Sat, 29 Jun 2024 18:40:38 -0500 Subject: [PATCH] add vm --- flake.nix | 4 +++ hosts/vm/default.nix | 11 ++++++++ hosts/vm/hardware-configuration.nix | 39 +++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 hosts/vm/default.nix create mode 100644 hosts/vm/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index d783588..b549ea2 100644 --- a/flake.nix +++ b/flake.nix @@ -85,6 +85,10 @@ modules = [ ./hosts/fred ]; specialArgs = { inherit inputs outputs; }; }; + vm = lib.nixosSystem { + modules = [ ./hosts/vm ]; + specialArgs = { inherit inputs outputs; }; + }; harper2 = lib.nixosSystem { modules = [ ./hosts/harper2 ]; specialArgs = { inherit inputs outputs; }; diff --git a/hosts/vm/default.nix b/hosts/vm/default.nix new file mode 100644 index 0000000..06e71e3 --- /dev/null +++ b/hosts/vm/default.nix @@ -0,0 +1,11 @@ +{ inputs, outputs, lib, config, pkgs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ../server + ../themes.nix + ]; + networking.hostName = "vm"; +} diff --git a/hosts/vm/hardware-configuration.nix b/hosts/vm/hardware-configuration.nix new file mode 100644 index 0000000..1d40b30 --- /dev/null +++ b/hosts/vm/hardware-configuration.nix @@ -0,0 +1,39 @@ +# 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 = [ ]; + + fileSystems."/" = + { device = "/dev/vda3"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/vda1"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/vda2"; } + ]; + + # 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"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}