{ lib, config, ... }: with lib; { options.features.git = { enable = mkEnableOption "enable git defaults"; userName = mkOption { type = types.str; default = "fwastring"; description = "Default git user.name."; }; userEmail = mkOption { type = types.str; default = "fredrik@wastring.com"; description = "Default git user.email."; }; pullRebase = mkOption { type = types.bool; default = true; description = "Enable pull.rebase by default."; }; githubSshInsteadOfHttps = mkOption { type = types.bool; default = true; description = "Use SSH for GitHub remotes when cloning with HTTPS URLs."; }; }; config = mkIf config.features.git.enable { programs.git = { enable = true; config = { user = { name = config.features.git.userName; email = config.features.git.userEmail; }; pull = { rebase = config.features.git.pullRebase; }; } // optionalAttrs config.features.git.githubSshInsteadOfHttps { url."git@github.com:".insteadOf = "https://github.com/"; }; }; }; }