# Home manager is used separately from this deploy, but we still need to create
# user accounts in the system config
{ base, pkgs, lib, config, ... }:
let
  mkUser = username: {
    isSystemUser = true;
    linger = true;
    createHome = true;
    home = "/services/${username}";
    group = "clicks";
    shell = pkgs.bashInteractive;
  } // (
    if builtins.pathExists "${../services}/${username}/system.nix"
    then import "${../services}/${username}/system.nix"
    else { }
  );
in
{
  users.users = lib.pipe ../services [
    builtins.readDir
    (lib.filterAttrs (_name: value: value == "directory"))
    builtins.attrNames
    (map (name: { inherit name; value = mkUser name; }))
    builtins.listToAttrs
  ];
} // (
  if (base != null)
  then {
    /*    users.groups = lib.mapAttrs'
      (_: user: {
        name = user.group;
        value = { };
      })
      base.config.users.users;*/
  } else { }
)
