nixos configs
1{ lib, pkgs, ... }:
2{
3 programs.git = {
4 enable = true;
5 settings = {
6 user.name = "Alex Bates";
7 user.email = lib.mkDefault "alex@bates64.com";
8 aliases = {
9 pu = "push";
10 co = "checkout";
11 cm = "commit";
12 sync = "submodule update --init --recursive";
13 };
14 core = {
15 excludesfile = "~/.config/git/gitignore";
16 fsmonitor = true;
17 untrackedCache = true;
18 };
19 init = {
20 defaultBranch = "main";
21 };
22 url = {
23 "ssh://git@github/" = {
24 insteadOf = "https://github/";
25 };
26 };
27 pull = {
28 rebase = true;
29 };
30 push = {
31 autoSetupRemote = true;
32 followTags = true;
33 };
34 fetch = {
35 prune = true;
36 pruneTags = true;
37 all = false;
38 };
39 rebase = {
40 autoSquash = true;
41 autoStash = true;
42 updateRefs = true;
43 };
44 rerere = {
45 enabled = true;
46 autoupdate = true;
47 };
48 merge.conflictstyle = "zdiff3";
49 commit.verbose = true;
50 column.ui = "auto";
51 branch.sort = "-committerdate";
52 tag.sort = "version:refname";
53 help.autocorrect = "prompt";
54 };
55 maintenance.enable = true;
56 };
57 home.file.".config/git/gitignore".source = ./gitignore;
58
59 programs.gh = {
60 enable = true;
61 extensions = with pkgs; [
62 gh-poi # `gh poi` to delete local branches that have been merged
63 ];
64 };
65
66 programs.jujutsu = {
67 enable = true;
68 settings = {
69 user.name = "Alex Bates";
70 user.email = lib.mkDefault "alex@bates64.com";
71 ui.default-command = ["log" "--summary"];
72 ui.movement.edit = true;
73 ui.editor = "zeditor --wait";
74 revsets.log = "present(@) | ancestors(@ ~ ::remote_bookmarks(), 2) | heads(::@ & bookmarks())";
75 fsmonitor.backend = "watchman";
76 fsmonitor.watchman.register-snapshot-trigger = true;
77 revset-aliases."immutable_heads()" = "builtin_immutable_heads() | (trunk().. & ~mine())"; # make others commits immutable
78 template-aliases."format_timestamp(timestamp)" = ''if(timestamp.before("1 year ago"), timestamp.format("%b %-d %Y"), timestamp.ago())'';
79 template-aliases."format_short_signature(signature)" = ''coalesce(signature.name(), name_placeholder)'';
80 template-aliases."builtin_log_compact(commit)" = ''
81 if(commit.root(),
82 format_root_commit(commit),
83 label(
84 separate(" ",
85 if(commit.current_working_copy(), "working_copy"),
86 if(commit.immutable(), "immutable", "mutable"),
87 if(commit.conflict(), "conflicted"),
88 ),
89 separate(" ",
90 format_short_change_id_with_change_offset(commit),
91 if(commit.description(),
92 commit.description().first_line(),
93 label(if(commit.empty(), "empty"), description_placeholder),
94 ),
95 if(commit.empty(), empty_commit_marker),
96 commit.bookmarks(),
97 commit.tags(),
98 commit.working_copies(),
99 format_commit_labels(commit),
100 if(!commit.mine(), format_short_signature(commit.author())),
101 format_timestamp(commit_timestamp(commit)),
102 ) ++ "\n",
103 )
104 )
105 '';
106 };
107 };
108
109 home.packages = [ pkgs.watchman ]; # for programs.jujutsu.settings.fsmonitor.backend
110}