add kvm supports and add quickemu

This commit is contained in:
ulic-youthlic 2025-01-18 15:59:06 +08:00
parent 2842a89b60
commit d159fed672
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
6 changed files with 65 additions and 0 deletions

View file

@ -30,6 +30,7 @@
starship.enable = true;
sops.enable = true;
mpv.enable = true;
kvm.enable = true;
};
david = {

View file

@ -24,6 +24,7 @@
./wluma.nix
./waybar.nix
./mpv.nix
./kvm.nix
];
options = {

21
home/modules/kvm.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, lib, ... }:
let
cfg = config.youthlic.programs.kvm;
in
{
options = {
youthlic.programs.kvm = {
enable = lib.mkEnableOption "kvm";
};
};
config = lib.mkIf cfg.enable {
dconf = {
settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];
uris = [ "qemu:///system" ];
};
};
};
};
}

View file

@ -31,6 +31,10 @@
steam.enable = true;
tailscale.enable = true;
kanata.enable = true;
kvm = {
enable = true;
unixName = "david";
};
};
gui.enabled = "cosmic";
};

View file

@ -25,6 +25,7 @@
./steam.nix
./tailscale.nix
./kanata.nix
./kvm.nix
];
config = {

37
nixos/modules/kvm.nix Normal file
View file

@ -0,0 +1,37 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.youthlic.programs.kvm;
in
{
options = {
youthlic.programs.kvm = {
enable = lib.mkEnableOption "kvm";
unixName = lib.mkOption {
type = lib.types.str;
example = "david";
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
quickemu
];
programs.virt-manager = {
enable = true;
};
users.groups.libvirtd.members = [ cfg.unixName ];
virtualisation = {
libvirtd = {
enable = true;
};
spiceUSBRedirection = {
enable = true;
};
};
};
}