{
  pkgs,
  config,
  lib,
  ...
}:
let
  inherit (lib) mkOption;
  inherit (lib.types)
    attrsOf
    submodule
    str
    package
    either
    ;

  cfg = config.modules.system.users;
  file = submodule (
    { name, config, ... }:
    {
      options = {
        path = mkOption {
          type = either package null;
          default = null;
        };

        content = mkOption {
          type = either str null;
          default = null;
        };
      };
    }
  );
in
{
  options.modules.system.users = mkOption {
    default = { };
    type = attrsOf (
      submodule (
        { name, config, ... }:
        {
          options = {
            name = mkOption {
              type = str;
              default = name;
            };

            files = mkOption {
              type = attrsOf file;
              default = { };
            };
          };
        }
      )
    );
  };

  config =
    let
      toDeriv =
        b: a: if a.content != null then pkgs.writers.writeText (lib.my.slugify b) a.content else a.path;
    in
    {
      systemd.tmpfiles.rules = lib.flatten (
        lib.mapAttrsToList (
          name: value:
          lib.mapAttrsToList (target: value: [
            "L+ /home/${name}/${target} - - - - ${toDeriv target value}"
          ]) value.files
        ) cfg
      );
    };
}
