From 872c0b719d7429373b5bcaa4eb6d21aeb5759c02 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Thu, 7 Oct 2021 09:59:54 +0200 Subject: [PATCH] Cleaned up some stuff --- flake.nix | 60 ++++++++++++--------------------- modules/system/boot/default.nix | 16 +++++---- modules/system/default.nix | 9 ++--- 3 files changed, 33 insertions(+), 52 deletions(-) diff --git a/flake.nix b/flake.nix index 7c80554..c5a742c 100644 --- a/flake.nix +++ b/flake.nix @@ -30,15 +30,23 @@ system = "x86_64-linux"; - nixosConfig = { + vm1BiosConfig = { boot = { - type = "qemu-bios"; + type = "bios"; qemu = true; grubInstallDevice = "/dev/vda"; }; core.enable = true; }; + vm1UefiConfig = { + boot = { + type = "uefi"; + qemu = true; + }; + core.enable = true; + }; + vm2Config = { boot = { type = "uefi"; @@ -76,22 +84,10 @@ name = "vm1"; NICs = [ "enp1s0" ]; kernelPackage = pkgs.linuxPackages; - initrdMods = [ - "ahci" - "xhci_pci" - "virtio_pci" - "sr_mod" - "virtio_blk" - "virtio_net" - "virtio_mmio" - "virtio_scsi" - "9p" - "9pnet_virtio" - ]; - kernelMods = - [ "kvm-amd" "virtio_balloon" "virtio_console" "virtio_rng" ]; + initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; + kernelMods = [ "kvm-amd" ]; kernelParams = [ ]; - systemConfig = nixosConfig; + systemConfig = vm1UefiConfig; users = nixosUsers; @@ -102,20 +98,8 @@ name = "vm2"; NICs = [ "enp1s0" ]; kernelPackage = pkgs.linuxPackages; - initrdMods = [ - "ahci" - "xhci_pci" - "virtio_pci" - "sr_mod" - "virtio_blk" - "virtio_net" - "virtio_mmio" - "virtio_scsi" - "9p" - "9pnet_virtio" - ]; - kernelMods = - [ "kvm-amd" "virtio_balloon" "virtio_console" "virtio_rng" ]; + initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; + kernelMods = [ "kvm-amd" ]; kernelParams = [ ]; systemConfig = vm2Config; @@ -124,13 +108,13 @@ cpuCores = 4; }; - loki = host.mkHost { - name = "loki"; - NICs = [ "enp4s0" ]; - kernelPackage = pkgs.linuxPackages; - initrdMods = [ "nvme" "xhci_pci" "ahci" ]; - kernelMods = [ "kvm-amd" ]; - }; + # loki = host.mkHost { + # name = "loki"; + # NICs = [ "enp4s0" ]; + # kernelPackage = pkgs.linuxPackages; + # initrdMods = [ "nvme" "xhci_pci" "ahci" ]; + # kernelMods = [ "kvm-amd" ]; + # }; }; }; } diff --git a/modules/system/boot/default.nix b/modules/system/boot/default.nix index 5ee6a5c..6738554 100644 --- a/modules/system/boot/default.nix +++ b/modules/system/boot/default.nix @@ -1,4 +1,4 @@ -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, modulesPath, ... }: with lib; let cfg = config.eb.boot; @@ -70,12 +70,14 @@ in { }; }) (mkIf (cfg.qemu) { - boot.initrd.postDeviceCommands = '' - # Set the system time from the hardware clock to work around a - # bug in qemu-kvm > 1.5.2 where the VM clock is initialized - # to the *boot time* of the host. - hwclock -s - ''; + boot.initrd = { + availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_scsi" "9p" "9pnet_virtio" ]; + kernelModules = [ "virtio_balloon" "virtio_console" "virtio_rng" ]; + postDeviceCommands = + '' + hwclock -s + ''; + }; services.qemuGuest.enable = true; }) diff --git a/modules/system/default.nix b/modules/system/default.nix index 467a211..e2aa347 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -1,8 +1,3 @@ -{ pkgs, config, lib, ... }: -{ - imports = [ - ./boot - ./core - ./nixos - ]; +{ pkgs, config, lib, modulesPath, ... }: { + imports = [ ./boot ./core ./nixos ]; }