{ lib, self, pkgs, config, namespace, ... }: let inherit (lib) mkEnableOption mkIf; inherit (self.lib.options) mkBool; inherit (config.${namespace}) profile; cfg = config.${namespace}.cli.git; in { options.${namespace}.cli.git = { enable = mkEnableOption "the git CLI."; enableSshSigning = mkBool true "Sign commits with your configured SSH key by default."; enableCredentialOauth = mkBool true "Allow authentication via web OAuth for select git hosting providers, like GitHub, Gitea, Forgejo, Bitbucket and Gitlab."; }; config = mkIf cfg.enable { programs.git = { enable = true; package = pkgs.git; # Define git config file options settings = { # Set basic user information user = { inherit (profile) email; name = profile.fullName; }; }; # Enable signing through SSH keys signing = mkIf cfg.enableSshSigning { format = "ssh"; key = profile.sshKeyFile; signByDefault = true; }; }; # Add package for git OAuth support home.packages = mkIf cfg.enableCredentialOauth ( with pkgs; [ git-credential-oauth ] ); }; }