diff --git a/flake.nix b/flake.nix index 6b9b49dc..ed581b90 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,7 @@ # nixos-rebuild switch --flake /etc/nixos#hostname nixosConfigurations = { tower = mkNix [ ./hosts/tower ]; # Main Desktop + qemu = mkNix [ ./hosts/qemu ]; # Virtualization Testing envy = mkNix [ ./hosts/envy ]; # HP Convertable pear = mkNix [ ./hosts/pear ]; # MacBook Pro diff --git a/hosts/qemu/boot/default.nix b/hosts/qemu/boot/default.nix new file mode 100644 index 00000000..a9254f85 --- /dev/null +++ b/hosts/qemu/boot/default.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + boot = { + kernelPackages = pkgs.linuxPackages_latest; + loader.grub = { + enable = true; + device = "/dev/vda"; + }; + }; +} diff --git a/hosts/qemu/default.nix b/hosts/qemu/default.nix new file mode 100644 index 00000000..beec3a19 --- /dev/null +++ b/hosts/qemu/default.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: +{ + imports = [ + ./boot + ./disko + ./hardware + ./users + ../../modules/system + ]; + + networking.hostName = "qemu"; + system.stateVersion = "24.11"; +} diff --git a/hosts/qemu/disko/default.nix b/hosts/qemu/disko/default.nix new file mode 100644 index 00000000..8c7a5613 --- /dev/null +++ b/hosts/qemu/disko/default.nix @@ -0,0 +1,90 @@ +{ config, disko, ... }: +{ + imports = [ disko.nixosModules.disko ]; + + disko.devices = { + disk = { + "${config.networking.hostName}" = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + priority = 1; + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "${config.networking.hostName}-disk"; + settings.allowDiscards = true; + passwordFile = "/tmp/secret.key"; + content = { + type = "lvm_pv"; + vg = "${config.networking.hostName}"; + }; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + "${config.networking.hostName}" = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" "ssd" ]; + }; + "/prev" = { + mountpoint = "/prev"; + mountOptions = [ "compress=zstd" "noatime" "ssd" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" "ssd" ]; + }; + + # Impermanence + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" "ssd" ]; + }; + "/persist/.snapshots" = { }; + "/persist/home" = { }; + "/persist/home/.snapshots" = { }; + }; + }; + }; + swap = { + size = "4G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; + }; + }; + }; + }; + + # Needed for impermanence + fileSystems."/persist".neededForBoot = true; +} diff --git a/hosts/qemu/hardware/default.nix b/hosts/qemu/hardware/default.nix new file mode 100644 index 00000000..71b977b5 --- /dev/null +++ b/hosts/qemu/hardware/default.nix @@ -0,0 +1,13 @@ +{ config, lib, modulesPath, ... }: +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (modulesPath + "/virtualisation/qemu-vm.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "sr_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/qemu/id_ed25519.pub b/hosts/qemu/id_ed25519.pub new file mode 100644 index 00000000..ae651e2c --- /dev/null +++ b/hosts/qemu/id_ed25519.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAb+aqIyTDcXDH8vMK697zQnYYUjgbUD2tJyknlztE3j diff --git a/hosts/qemu/users/default.nix b/hosts/qemu/users/default.nix new file mode 100644 index 00000000..57e7f20b --- /dev/null +++ b/hosts/qemu/users/default.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + imports = [ ./main ]; +} diff --git a/hosts/qemu/users/main/default.nix b/hosts/qemu/users/main/default.nix new file mode 100644 index 00000000..9366cadc --- /dev/null +++ b/hosts/qemu/users/main/default.nix @@ -0,0 +1,6 @@ +{ config, lib, ... }: +{ + home-manager.users."${config.sysusers.main}".home = { + stateVersion = lib.mkForce config.system.stateVersion; + }; +}