{ config
, lib
, pkgs
, ...
}:

with lib;
let
  cfg = config.my.virtualisation.libvirtd;
in
{
  options.my.virtualisation.libvirtd.enable = mkEnableOption "libvirtd";

  config = mkIf cfg.enable {
    virtualisation.libvirtd = {
      enable = true;
      package = pkgs.libvirt;
    };

    users.users.moritz = {
      extraGroups = [ "libvirtd" ];
      packages = with pkgs; [ virt-manager ];
    };
  };
}
