{ config, lib, pkgs, ... }: let cfg = config.myOptions.programs.git; inherit (config.myOptions.other.system) username; inherit (lib) mkEnableOption mkIf mkOption; inherit (lib.types) nullOr str; in { options.myOptions.programs.git = { enable = mkEnableOption "git"; userName = mkOption { type = nullOr str; default = null; description = "git username"; }; userEmail = mkOption { type = nullOr str; default = null; description = "git email"; }; signingKey = mkOption { type = nullOr str; default = null; description = "git commit signing key"; }; editor = mkOption { type = str; default = "$EDITOR"; description = "commit message editor"; }; defaultBranch = mkOption { type = str; default = "master"; description = "default git branch"; }; }; config = mkIf cfg.enable { home-manager.users.${username} = { programs.git = { enable = true; inherit (cfg) userName userEmail; extraConfig = { core = { inherit (cfg) editor; pager = "${pkgs.delta}/bin/delta"; }; init.defaultBranch = cfg.defaultBranch; push.autoSetupRemote = true; commit = { verbose = true; gpgsign = cfg.signingKey != null; }; gpg.format = "ssh"; user.signingkey = mkIf (cfg.signingKey != null) "key::${cfg.signingKey}"; merge.conflictstyle = "zdiff3"; interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only"; diff.algorithm = "histogram"; transfer.fsckobjects = true; fetch.fsckobjects = true; receive.fsckobjects = true; }; }; }; }; }