From c42398347dc6d7421fea9a03802ce912d14a6aa2 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 31 Oct 2023 18:52:53 +0100 Subject: [PATCH] pinwheel: Add `vm` module --- hosts/pinwheel/configuration.nix | 3 +-- hosts/pinwheel/modules/vm/default.nix | 33 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 hosts/pinwheel/modules/vm/default.nix diff --git a/hosts/pinwheel/configuration.nix b/hosts/pinwheel/configuration.nix index 981ad5d..a874864 100644 --- a/hosts/pinwheel/configuration.nix +++ b/hosts/pinwheel/configuration.nix @@ -56,8 +56,6 @@ LC_TIME = "en_US.UTF-8"; }; - programs.dconf.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.alex = { isNormalUser = true; @@ -90,6 +88,7 @@ keyboard.enable = true; docker.enable = true; podman.enable = false; + vm.enable = true; scripts.enable = true; }; diff --git a/hosts/pinwheel/modules/vm/default.nix b/hosts/pinwheel/modules/vm/default.nix new file mode 100644 index 0000000..f766938 --- /dev/null +++ b/hosts/pinwheel/modules/vm/default.nix @@ -0,0 +1,33 @@ +{ pkgs, lib, config, ... }: +let + enabled = config.mod.vm.enable; +in +{ + options = { + mod.vm = { + enable = lib.mkEnableOption "add vm module"; + }; + }; + + config = lib.mkIf enabled { + virtualisation.libvirtd.enable = true; + + users.users.alex = { + extraGroups = [ "libvirtd" ]; + }; + + environment.systemPackages = with pkgs; [ virt-manager ]; + + # virt-manager requires dconf to remember settings + programs.dconf.enable = true; + + home-manager.users.alex = { + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = ["qemu:///system"]; + uris = ["qemu:///system"]; + }; + }; + }; + }; +}