# System user accounts, built from the registry (users/registry.nix) for the
# host's `hostUsers` set. See README "Users".
{
  config,
  pkgs,
  lib,
  hostUsers,
  userRegistry,
  ...
}:

{
  programs.zsh.enable = true;

  users.users = lib.mapAttrs (
    name: spec:
    let
      id = userRegistry.${name};
    in
    {
      isNormalUser = true;
      home = "/home/${name}";
      description = id.fullName;
      inherit (id) extraGroups;
      openssh.authorizedKeys.keys = id.sshAuthorizedKeys;
      shell = pkgs.zsh;
    }
    # linger opt-in (host table); left unmanaged when unset.
    // lib.optionalAttrs (spec ? linger) { inherit (spec) linger; }
  ) hostUsers;

  programs.firefox = lib.mkIf (config.features.swayDesktop.enable == true) {
    enable = true;
  };
  programs.thunderbird = lib.mkIf (config.features.swayDesktop.enable == true) {
    enable = true;
  };
}
