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

with lib;

let
  cfg = config.roles.users;
in
{
  options.roles.users = {
    enable = mkEnableOption "Enable default users";
    extraGroups = mkOption {
      default = [];
    };
    kids = mkOption {
      type = types.bool;
      default = false;
    };
  };

  config = let
    kidsPackages = with pkgs; [
      firefox
    ];
  in mkIf cfg.enable {
    users.users.johno = {
      isNormalUser = true;
      description = "John Ogle";
      extraGroups = [ "wheel" "networkmanager" "audio" "video" "i2c" ] ++ cfg.extraGroups;
    };

    users.users.eli = mkIf cfg.kids {
      isNormalUser = true;
      description = "Eli";
      home = "/home/eli";
      packages = kidsPackages;
    };

    users.users.andrew = mkIf cfg.kids {
      isNormalUser = true;
      description = "Andrew";
      home = "/home/andrew";
      packages = kidsPackages;
    };

    users.users.jules = mkIf cfg.kids {
      isNormalUser = true;
      description = "Jules";
      home = "/home/jules";
      packages = kidsPackages;
    };
  };
}
