From e62903e640e8cae97970fd4bb6641d2ef20a70ac Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Sun, 19 Mar 2023 08:46:23 -0700 Subject: [PATCH] Added git config --- modules/tools/git/default.nix | 87 ++++++++++++++++++++++++++++++ modules/user/default.nix | 10 ++++ systems/x86_64-vm/virt/default.nix | 1 + 3 files changed, 98 insertions(+) create mode 100644 modules/tools/git/default.nix diff --git a/modules/tools/git/default.nix b/modules/tools/git/default.nix new file mode 100644 index 0000000..5e889cc --- /dev/null +++ b/modules/tools/git/default.nix @@ -0,0 +1,87 @@ +{ + options, + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.aa.tools.git; + user = config.aa.user; +in { + options.aa.tools.git = with types; { + enable = mkEnableOption "git"; + userName = mkOption { + type = str; + default = user.fullName; + description = "The name to use for git commits."; + }; + userEmail = mkOption { + type = str; + default = user.email; + description = "The email to use for git commits."; + }; + signingKey = mkOption { + type = str; + default = "0xE1B13CCEFDEDDFB7"; + description = "The key ID used to sign commits."; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [git]; + + aa.home.extraOptions = { + programs.git = { + delta = { + enable = true; + options = { + line-numbers = true; + navigate = true; + }; + }; + + enable = true; + userName = cfg.userName; + userEmail = cfg.userEmail; + + aliases = { + lol = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"; + pushup = "push -u origin HEAD"; + }; + + signing = { + key = cfg.signingKey; + signByDefault = false; # TODO: Only set if gpg is enabled + }; + + ignores = [ + # PyCharm + ".idea/" + + # Vim artifacts + "*.swp" + "*.swo" + "tags" + ".vimspector.json" + ".vimlocal" + "Session.vim*" + + # direnv + ".envrc" + ".direnv" + ]; + + extraConfig = { + init = { + defaultBranch = "main"; + }; + + pull = { + rebase = true; + }; + }; + }; + }; + }; +} diff --git a/modules/user/default.nix b/modules/user/default.nix index 093ff0e..f7821cc 100644 --- a/modules/user/default.nix +++ b/modules/user/default.nix @@ -14,6 +14,16 @@ in { default = "alejandro"; description = "The name to use for the user account."; }; + fullName = mkOption { + type = str; + default = "Alejandro Angulo"; + description = "The full name of the user."; + }; + email = mkOption { + type = str; + default = "iam@alejandr0angul0.dev"; + description = "The email of the user."; + }; extraGroups = mkOption { type = listOf str; default = ["video" "networkmanager" "docker"]; diff --git a/systems/x86_64-vm/virt/default.nix b/systems/x86_64-vm/virt/default.nix index e7d51f7..049cb8b 100644 --- a/systems/x86_64-vm/virt/default.nix +++ b/systems/x86_64-vm/virt/default.nix @@ -18,6 +18,7 @@ with lib; { nix.enable = true; suites.desktop.enable = true; + tools.git.enable = true; }; users.users.virt = {