nixos-configs/homeManagerModules/shell/git/default.nix

108 lines
2.9 KiB
Nix
Raw Normal View History

self: {
config,
lib,
pkgs,
...
2024-06-23 13:21:02 -04:00
}: let
2025-01-24 18:38:07 -05:00
inherit (lib) getExe mkIf;
cfg = config.programs.bash;
2024-06-23 13:21:02 -04:00
mkRemoteConf = remote: email: name: {
condition = "hasconfig:remote.*.url:${remote}*/**";
2024-06-23 13:21:02 -04:00
contents.user = {inherit email name;};
};
mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432";
2025-01-24 18:38:07 -05:00
mkGitAlias = script: "!${getExe script}";
2024-06-23 13:21:02 -04:00
in {
config.programs = mkIf cfg.enable {
2023-10-15 16:41:34 -04:00
git = {
enable = true;
2024-08-10 21:53:54 -04:00
package = pkgs.gitFull;
2023-10-15 16:41:34 -04:00
lfs.enable = true;
includes = [
{path = toString self.scopedPackages.${pkgs.system}.dracula.git;}
2024-06-23 13:21:02 -04:00
(mkDefaultRemote "https://github.com")
(mkDefaultRemote "git@github.com")
(mkDefaultRemote "git@git.nelim.org")
2024-06-23 13:21:02 -04:00
(mkRemoteConf "git@gitlab.info.uqam.ca" "gj591944@ens.uqam.ca" "Mathis Hurtubise")
2023-10-15 16:41:34 -04:00
];
delta = {
enable = true;
options = {
side-by-side = true;
2024-08-10 21:53:54 -04:00
line-numbers-zero-style = "#E6EDF3";
};
};
2024-03-01 01:34:59 -05:00
extraConfig = {
2025-01-24 18:38:07 -05:00
alias = {
2025-01-24 19:24:35 -05:00
diff-clean = "-c delta.side-by-side=false diff";
2025-01-24 18:38:07 -05:00
# https://stackoverflow.com/a/18317425
ignore = "update-index --assume-unchanged";
unignore = "update-index --no-assume-unchanged";
ignored = "!git ls-files -v | ${getExe pkgs.gnugrep} \"^[[:lower:]]\"";
untracked-ignore = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-ignore";
text = ''
if [ $# -eq 0 ]; then
echo "No file names provided"
exit 1
fi
for arg in "$@"; do
echo -e "$arg\n" >> .git/info/exclude
done
'';
});
untracked-unignore = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-unignore";
text = ''
if [ $# -eq 0 ]; then
echo "No file names provided"
exit 1
fi
for arg in "$@"; do
sed -i "s/$arg//" .git/info/exclude
done
'';
});
untracked-ignored = mkGitAlias (pkgs.writeShellApplication {
name = "untracked-ignored";
text = ''
while IFS= read -r line; do
if [[ "$line" != "" ]] && [[ "$line" != "#"* ]]; then
echo "$line"
fi
done < .git/info/exclude
'';
});
};
diff.sopsdiffer.textconv = "sops decrypt";
2024-03-01 01:34:59 -05:00
2024-08-10 21:53:54 -04:00
sendemail = {
smtpserver = "127.0.0.1";
smtpuser = "matt@nelim.org";
smtpencryption = "tls";
smtpserverport = 1025;
smtpsslcertpath = "";
};
};
2023-10-15 16:41:34 -04:00
};
# https://github.com/dandavison/delta/issues/630#issuecomment-2003149860
bash.sessionVariables.LESS = "-R --mouse";
2023-10-15 16:41:34 -04:00
};
# For accurate stack trace
_file = ./default.nix;
2023-10-15 16:41:34 -04:00
}