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

  gitOption = {
    enable = mkEnableOption "git";

    defaultBranch = mkOption {
      type = types.nullOr types.str;
      description = "The name of the default branch in newly created repositories.";
      default = null;
    };

    flow = {
      mainBranch = mkOption {
        type = types.nullOr types.str;
        description = "The name of the stable branch in git flow.";
        default = null;
      };

      devBranch = mkOption {
        type = types.nullOr types.str;
        description = "The name of the development branch in git flow.";
        default = null;
      };
    };

    aliases = mkOption {
      type = types.attrsOf types.str;
      description = "The git command aliases to install.";
      default = { };
    };
  };
in {
  options = {
    valhalla = {
      programs.git = gitOption;

      users = mkOption {
        type = types.attrsOf (types.submodule (
          { ... }: {
            options = {
              programs.git = gitOption;
            };
          }));
      };
    };
  };
}