create qemu module

This commit is contained in:
Max Känner 2024-12-28 23:32:52 +01:00
parent 1a478ba01e
commit 7a8597cdef
3 changed files with 39 additions and 22 deletions

View File

@ -86,27 +86,6 @@
security.polkit.enable = true; security.polkit.enable = true;
environment.sessionVariables.NIXOS_OZONE_WL = "1"; environment.sessionVariables.NIXOS_OZONE_WL = "1";
virtualisation = {
libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
runAsRoot = true;
swtpm.enable = true;
ovmf = {
enable = true;
packages = [
(pkgs.OVMF.override {
secureBoot = true;
tpmSupport = true;
})
.fd
];
};
};
};
};
# List services that you want to enable: # List services that you want to enable:
# fingerprint unlock # fingerprint unlock

View File

@ -1,11 +1,12 @@
{ {
lib, lib,
config, config,
system,
... ...
}: let }: let
cfg = config.myConfig; cfg = config.myConfig;
in { in {
imports = [./bootloader.nix ./locale.nix ./greetd.nix ./rebuild.nix ./sops.nix ./sway.nix ./wifi.nix ./music.nix ./cups.nix ./gpu/amd.nix ./touch.nix ./cache.nix ./nix.nix ./update.nix ./podman.nix]; imports = [./bootloader.nix ./locale.nix ./greetd.nix ./rebuild.nix ./sops.nix ./sway.nix ./wifi.nix ./music.nix ./cups.nix ./gpu/amd.nix ./touch.nix ./cache.nix ./nix.nix ./update.nix ./podman.nix ./qemu.nix];
options.myConfig = { options.myConfig = {
enable = lib.mkEnableOption "my custom config"; enable = lib.mkEnableOption "my custom config";
@ -27,6 +28,8 @@ in {
cache.enable = true; cache.enable = true;
autoUpdate.enable = true; autoUpdate.enable = true;
podman.enable = true; podman.enable = true;
qemu.enable = true;
qemu.kvm = lib.mkIf (system == "x86_64-linux") true;
greetd.enable = lib.mkIf cfg.desktop true; greetd.enable = lib.mkIf cfg.desktop true;
sway.enable = lib.mkIf cfg.desktop true; sway.enable = lib.mkIf cfg.desktop true;

35
modules/nixos/qemu.nix Normal file
View File

@ -0,0 +1,35 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.myConfig.qemu;
in {
options.myConfig.qemu = {
enable = lib.mkEnableOption "qemu";
kvm = lib.mkEnableOption "kvm for faster emulation of x86";
};
config = lib.mkIf cfg.enable {
virtualisation.
libvirtd = {
enable = true;
qemu = {
package = lib.mkIf cfg.kvm pkgs.qemu_kvm;
runAsRoot = true;
swtpm.enable = true;
ovmf = {
enable = true;
packages = [
(pkgs.OVMF.override {
secureBoot = true;
tpmSupport = true;
})
.fd
];
};
};
};
};
}