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