From f39613a82271e3228c184278752376e740d53237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Bori?= Date: Sat, 25 Jan 2025 18:36:18 +0100 Subject: [PATCH] :sparkles: Added git aliases --- .../home/cli/programs/git-cliff/default.nix | 82 ++--------------- modules/home/cli/programs/git/default.nix | 91 +++++++++++++++++-- 2 files changed, 91 insertions(+), 82 deletions(-) diff --git a/modules/home/cli/programs/git-cliff/default.nix b/modules/home/cli/programs/git-cliff/default.nix index f10cb42..d5a63c6 100644 --- a/modules/home/cli/programs/git-cliff/default.nix +++ b/modules/home/cli/programs/git-cliff/default.nix @@ -1,94 +1,24 @@ { config, lib, - pkgs, namespace, ... }: let - inherit (lib) mkIf types; - inherit (lib.${namespace}) mkOpt mkBoolOpt enabled; - inherit (config.${namespace}) user; + inherit (lib) mkIf; + inherit (lib.${namespace}) mkBoolOpt; - cfg = config.${namespace}.cli.programs.git; + cfg = config.${namespace}.cli.programs.git-cliff; in { - options.${namespace}.cli.programs.git = with types; { - enable = mkBoolOpt false "Whether or not to enable git."; + options.${namespace}.cli.programs.git-cliff = { + enable = mkBoolOpt false "Whether or not to enable git-cliff."; - signByDefault = mkOpt bool true "Whether to sign commits by default."; - signingKey = - mkOpt str "EEFBCC3AC529CFD1943DA75CBDD57BE99D555965" - "The GnuPG signing key fingerprint sign commits with."; - userName = mkOpt str user.fullName "The name to configure git with."; - userEmail = mkOpt str user.email "The email to configure git with."; }; config = mkIf cfg.enable { - ${namespace}.editors.emacs = enabled; - - programs.git = { + programs.git-cliff = { enable = true; - package = pkgs.gitFull; - inherit (cfg) userName userEmail; - - signing = { - key = cfg.signingKey; - inherit (cfg) signByDefault; - }; - - extraConfig = { - commit.gpgsign = true; - - core = { - editor = "emacs"; - pager = "delta"; - filemode = "false"; - }; - - color = { - ui = true; - }; - - fetch = { - prune = true; - }; - - interactive = { - diffFitler = "delta --color-only"; - }; - - delta = { - enable = true; - navigate = true; - light = false; - side-by-side = false; - line-numbers = true; - options.syntax-theme = "dracula"; - }; - - pull = { - ff = "only"; - }; - - push = { - default = "current"; - autoSetupRemote = true; - }; - - safe = { - directory = [ - "~/${namespace}/" - "/etc/nixos" - ]; - }; - - init = { - defaultBranch = "main"; - }; - }; }; - - home.packages = with pkgs; [ gitmoji-cli ]; }; } diff --git a/modules/home/cli/programs/git/default.nix b/modules/home/cli/programs/git/default.nix index d5a63c6..9e0cd68 100644 --- a/modules/home/cli/programs/git/default.nix +++ b/modules/home/cli/programs/git/default.nix @@ -1,24 +1,103 @@ { config, lib, + pkgs, namespace, ... }: let - inherit (lib) mkIf; - inherit (lib.${namespace}) mkBoolOpt; + inherit (lib) mkIf types; + inherit (lib.${namespace}) mkOpt mkBoolOpt enabled; + inherit (config.${namespace}) user; - cfg = config.${namespace}.cli.programs.git-cliff; + cfg = config.${namespace}.cli.programs.git; in { - options.${namespace}.cli.programs.git-cliff = { - enable = mkBoolOpt false "Whether or not to enable git-cliff."; + options.${namespace}.cli.programs.git = with types; { + enable = mkBoolOpt false "Whether or not to enable git."; + signByDefault = mkOpt bool true "Whether to sign commits by default."; + signingKey = + mkOpt str "EEFBCC3AC529CFD1943DA75CBDD57BE99D555965" + "The GnuPG signing key fingerprint sign commits with."; + userName = mkOpt str user.fullName "The name to configure git with."; + userEmail = mkOpt str user.email "The email to configure git with."; }; config = mkIf cfg.enable { - programs.git-cliff = { + ${namespace}.editors.emacs = enabled; + + programs.git = { enable = true; + package = pkgs.gitFull; + inherit (cfg) userName userEmail; + + signing = { + key = cfg.signingKey; + inherit (cfg) signByDefault; + }; + + aliases = { + dlc = "diff --cached HEAD^"; + incoming = "log HEAD..@{upstream}"; + outgoing = "log @{upstream}..HEAD"; + cam = "commit --amend"; + graph = "log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order"; + stashes = "stash list"; + }; + + extraConfig = { + commit.gpgsign = true; + + core = { + editor = "emacs"; + pager = "delta"; + filemode = "false"; + }; + + color = { + ui = true; + }; + + fetch = { + prune = true; + }; + + interactive = { + diffFitler = "delta --color-only"; + }; + + delta = { + enable = true; + navigate = true; + light = false; + side-by-side = false; + line-numbers = true; + options.syntax-theme = "dracula"; + }; + + pull = { + ff = "only"; + }; + + push = { + default = "current"; + autoSetupRemote = true; + }; + + safe = { + directory = [ + "~/${namespace}/" + "/etc/nixos" + ]; + }; + + init = { + defaultBranch = "main"; + }; + }; }; + + home.packages = with pkgs; [ gitmoji-cli ]; }; }