{ config, lib, ... }:

with lib;

let
  cfg = config.roles.virtualisation;
in
{
  options.roles.virtualisation = {
    enable = mkEnableOption "Enable virtualisation";
    dockerUsers = mkOption {
      type = types.listOf types.str;
      default = [ "johno" ];
      description = "List of users to add to the docker group";
    };
    waydroid = mkOption {
      type = types.bool;
      default = false;
      description = "Enable waydroid support";
    };
  };

  config = mkIf cfg.enable
    {
      virtualisation.libvirtd.enable = true;
      programs.virt-manager.enable = true;
      virtualisation.docker.enable = true;
      users.extraGroups.docker.members = cfg.dockerUsers;
      virtualisation.waydroid.enable = cfg.waydroid;
    };
}
