Convert git from nixosModule to homeModule

This commit is contained in:
Alejandro Angulo 2024-07-28 20:27:04 -07:00
parent fe55849333
commit 7dfe9f87be
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
6 changed files with 94 additions and 92 deletions

View file

@ -11,5 +11,9 @@
apps = {
tmux.enable = true;
};
tools = {
git.enable = true;
};
};
}

View file

@ -0,0 +1,87 @@
{
config,
pkgs,
lib,
namespace,
...
}: let
inherit (lib) mkIf mkEnableOption mkDefault;
cfg = config.${namespace}.tools.git;
in {
options.${namespace}.tools.git = {
enable = mkEnableOption "git";
userName = lib.options.mkOption {
type = lib.types.str;
default = "alejandro-angulo";
description = "The name to use for git commits.";
};
userEmail = lib.options.mkOption {
type = lib.types.str;
default = "iam@alejandr0angul0.dev";
description = "The email to use for git commits.";
};
signingKey = lib.options.mkOption {
type = lib.types.str;
default = "0xE1B13CCEFDEDDFB7";
description = "The key ID used to sign commits.";
};
};
config = mkIf cfg.enable {
programs.zsh.shellAliases = {
"gco" = "${pkgs.git}/bin/git checkout $(${pkgs.git}/bin/git branch | ${pkgs.fzf}/bin/fzf)";
};
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 = mkDefault true;
};
ignores = [
# PyCharm
".idea/"
# Vim artifacts
"*.swp"
"*.swo"
"tags"
".vimspector.json"
".vimlocal"
"Session.vim*"
# direnv
".envrc"
".direnv"
];
extraConfig = {
init = {
defaultBranch = "main";
};
pull = {
rebase = true;
};
};
};
};
}

View file

@ -16,7 +16,6 @@ in {
tools = {
direnv.enable = true;
eza.enable = true;
git.enable = true;
gpg.enable = true;
zsh.enable = true;
};
@ -27,9 +26,10 @@ in {
};
environment.systemPackages = with pkgs; [
pre-commit
minio-client
awscli2
minio-client
pre-commit
git
];
};
}

View file

@ -1,88 +0,0 @@
{
options,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.aa.tools.git;
gpg = config.aa.tools.gpg;
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 = mkIf config.aa.tools.gpg.enable true;
};
ignores = [
# PyCharm
".idea/"
# Vim artifacts
"*.swp"
"*.swo"
"tags"
".vimspector.json"
".vimlocal"
"Session.vim*"
# direnv
".envrc"
".direnv"
];
extraConfig = {
init = {
defaultBranch = "main";
};
pull = {
rebase = true;
};
};
};
};
};
}

View file

@ -18,7 +18,6 @@ with lib; {
nix.enable = true;
suites.desktop.enable = true;
tools.git.enable = true;
tools.zsh.enable = true;
tools.eza.enable = true;
apps.neovim.enable = true;