{ config, lib, ... }:
  let
    inherit (lib)
      mkOption
      types
    ;

    cfg = config.valhalla;
    capitalize = (import ../text.nix { inherit lib; }).capitalize;

    linuxOptions = {
      defaultShell = mkOption {
        type = types.nullOr types.str;
        description = "The default shell of the user.";
        default = null;
      };

      rclone = {
        configurations = mkOption {
          type = types.attrsOf syncType;
          description = "The configurations of the rclone mounts.";
          default = {};
        };
      };
    };

    syncType = types.submodule (
      { ... }: {
        options = {
          dirName = mkOption {
            type = types.str;
            description = "The name of the directory to sync the remote files to.";
          };

          cacheDuration = mkOption {
            type = types.nullOr types.str;
            description = "The amount of time to keep cached files.";
            default = null;
          };
        };
      });

    mkUserType = { options }: (
      types.submodule (
        { ... }: {
          options = {
            displayName = mkOption {
              type = types.nullOr types.str;
              description = "The human-readable name of the user.";
              default = null;
            };

            mailAddress = mkOption {
              type = types.nullOr types.str;
              description = "The mail address of the user.";
              default = null;
            };

            groups = mkOption {
              type = types.listOf types.str;
              description = "The additional groups of the user.";
              default = [];
            };

            git = (import ./git/options.nix) { inherit lib; };
          } // options;
        }));

    userType = mkUserType {
      options = linuxOptions;
    };

    winUserType = mkUserType {
      options = {
        microsoftAccount = mkOption {
          type = types.bool;
          description = "A value indicating whether this user is a Microsoft Account.";
          default = false;
        };
      };
    };
  in {
    options = {
      valhalla = {
        users = mkOption {
          type = types.attrsOf userType;
          description = "The users to create on the machine.";
          default = {};
        };

        windows.users = mkOption {
          type = types.attrsOf winUserType;
          description = "The users to create on the Windows machine.";
          default = (lib.attrsets.concatMapAttrs (
              name: options:
                if builtins.elem name (builtins.attrNames linuxOptions)
                then {}
                else {
                  ${capitalize name} = (lib.attrsets.concatMapAttrs (
                    name: value:
                      if builtins.elem name (builtins.attrNames linuxOptions)
                      then {}
                      else {
                        ${name} = value;
                      }
                  ) options) // {
                    groups = [];
                  };
                }) cfg.users);
        };
      };
    };
  }