]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/git.nix
heartwood: add as input
[julm/julm-nix.git] / home-manager / profiles / git.nix
1 { pkgs, lib, config, ... }:
2 {
3 home.packages = lib.mkIf config.programs.git.enable [
4 pkgs.b4
5 pkgs.delta
6 pkgs.difftastic
7 pkgs.git-absorb
8 pkgs.git-bug
9 pkgs.git-chglog
10 pkgs.git-cliff
11 pkgs.git-crypt
12 pkgs.git-extras
13 pkgs.git-filter-repo
14 #pkgs.git-publish
15 pkgs.git-quick-stats
16 pkgs.gitui
17 pkgs.tig
18 ];
19 programs.git = {
20 enable = lib.mkDefault true;
21 ignores = [ "*~" "*.swp" ];
22 package = lib.mkDefault pkgs.gitMinimal;
23 aliases = {
24 a = "add";
25 ab = "absorb";
26 abr = "absorb -r";
27 ap = "add -p";
28 au = "add -u";
29 authors = "shortlog -s -n";
30 b = "branch";
31 bl = "git log -p -M --follow --stat --";
32 c = "commit";
33 ca = "commit --amend";
34 caa = "commit --amend -C@";
35 caaa = "commit --amend -C@ -a";
36 cf = "commit --fixup";
37 co = "checkout";
38 d = "diff";
39 dc = "diff --cached";
40 dcw = "diff --cached --word-diff=color";
41 dh = "diff --histogram";
42 dp = "diff --patience";
43 dt = "difftool --patience";
44 dtc = "difftool --cached";
45 dw = "diff --word-diff=color";
46 g = "grep";
47 ign = "ls-files -o -i --exclude-standard";
48 l = "log";
49 ll = "log --graph --decorate --pretty=oneline --abbrev-commit";
50 lp = "log -p --pretty=fuller";
51 lpg = "log -p --pretty=fuller -g";
52 p = "push -v";
53 pa = "patch";
54 patch = "push rad HEAD:refs/patches";
55 pf = "push -vf";
56 pl = "pull";
57 r = "reset";
58 rh = "reset --hard";
59 ri = "rebase -i";
60 rp = "reset -p";
61 s = "status";
62 spull = "!git-svn fetch && git-svn rebase";
63 spush = "!git-svn dcommit";
64 ss = "status -s";
65 st = "status -uno";
66 sw = "switch";
67 fetch-local = "!git fetch local && git tag -d $(git describe --exact-match 2>/dev/null >/dev/null) && git fetch --tags local";
68 pull-local = "!git fetch-local && git checkout -B master local/master";
69 pull-local-old = "!git fetch-local && git checkout HEAD'^' && git branch -f master local/master && git checkout master";
70 root = ''!git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"'';
71 has-tag-version = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]\\(\\^{}\\)\\?\"'';
72 tag-version = ''"!git has-tag-version && return; v=$(TZ=UTC date +v%Y-%m-%d) && name=$(git rev-parse --show-toplevel | sed -e 's:^.*/work::') && set -x && git tag -s -m \"$name $v\" $v"'';
73 has-tag-majordate = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9]\\+.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\(\\^{}\\)\\?\"'';
74 tag-majordate = ''"!git has-tag-majordate && return; name=$(basename $(dirname $(git rev-parse --show-toplevel))); major=$(basename $(git rev-parse --show-toplevel)); version=''${version:-$(TZ=UTC date +\"v$major.%Y%m%d\")} && set -x && git tag -s -m \"$name $version\" $version"'';
75 tag-cabal = ''"!set -x; for cabal in $(git ls-files | grep '.*\\.cabal$'); do name=$(sed -ne 's/^name: *\\(.*\\)/\\1/p' \"$cabal\"); version=$(sed -ne 's/^version: *\\(.*\\)/\\1/p' \"$cabal\"); git tag --merged | grep -Fqx \"$name-$version\" || git tag -f -s -m \"$name v$version\" $name-$version; done"'';
76 cl = "notes --ref=changelog append";
77 cl-bug = "notes --ref=changelogs/bugs append";
78 cl-feature = "notes --ref=changelogs/features append";
79 wip = "for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads";
80 };
81 extraConfig = {
82 browser.elinks.cmd = "elinks";
83 color.branch = "auto";
84 color.diff = "auto";
85 #color.diff.whitespace = "red reverse";
86 color.status = "auto";
87 core.commentChar = "auto";
88 core.quotepath = "false";
89 core.whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
90 diff.algorithm = "histogram";
91 diff.sqldiff.command = "sqldiff";
92 format.pretty = "oneline";
93 gui.fontdiff = ''-family "DejaVu Sans Mono" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
94 gui.fontui = ''-family "DejaVu Sans" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
95 gui.spellingdictionary = "en_US";
96 gui.tabsize = 4;
97 guitool."Rebase interactive" = {
98 cmd = "EDITOR=gvim git rebase -i $REVISION";
99 revprompt = true;
100 };
101 init.defaultBranch = "main";
102 merge.tool = "vimdiff";
103 merge.conflictStyle = "zdiff3";
104 protocol.version = 2;
105 pull.rebase = true;
106 push.default = "simple";
107 rebase.autosquash = "true";
108 sendemail.chainReplyTo = "false";
109 sendemail.composeencoding = "UTF-8";
110 sendemail.confirm = "always";
111 sendemail.envelopeSender = "auto";
112 sendemail.multiedit = "yes";
113 sendemail.suppressFrom = "false";
114 sendemail.suppresscc = "self";
115 sendemail.thread = "true";
116 sendemail.validate = "true";
117 web.browser = "elinks";
118 };
119 iniContent = {
120 /*
121 diff.external = lib.concatStringsSep " " [
122 "${pkgs.difftastic}/bin/difft"
123 "--color auto"
124 "--background dark"
125 "--display side-by-side"
126 ];
127 */
128 # difftastic
129 /*
130 diff.tool = "difftastic";
131 difftool.prompt = false;
132 difftool.difftastic.cmd = ''${pkgs.difftastic}/bin/difft "$LOCAL" "$REMOTE"'';
133 pager.difftool = true;
134 */
135
136 # delta
137 /*
138 core.pager = "delta --grep-separator-symbol keep";
139 interactive.diffFilter = "delta --color-only --features=interactive";
140 delta.features = "decorations";
141 delta.interactive = {
142 keep-plus-minus-markers = false;
143 };
144 delta.decorations = {
145 commit-decoration-style = "blue ol";
146 commit-style = "raw";
147 file-style = "omit";
148 hunk-header-decoration-style = "blue box";
149 hunk-header-file-style = "red";
150 hunk-header-line-number-style = "#067a00";
151 hunk-header-style = "file line-number syntax";
152 };
153 */
154 };
155 };
156 programs.bash = lib.mkIf config.programs.git.enable {
157 shellAliases = {
158 g = "git";
159 ge = "git-edit-commit";
160 gg = "git grep";
161 gge = "git-grep-edit";
162 gui = "gitui";
163 };
164 initExtra = ''
165 git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
166 git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }
167 '';
168 };
169 }