NixOS system configurations + dotfiles via home-manager
at main 112 lines 3.7 kB view raw
1{ lib, ... }: 2let 3 settings = { 4 user = { 5 name = "Peter Rice"; 6 email = lib.mkDefault "peterrice@fastmail.com"; 7 }; 8 ui.default-command = "log"; 9 ui.diff-formatter = ":git"; 10 ui.diff-editor = ":builtin"; 11 templates.draft_commit_description = "builtin_draft_commit_description_with_diff"; 12 revsets.bookmark-advance-to = "heads(::@ ~ empty())"; 13 template-aliases.shell_prompt = '' 14 separate(" ", 15 concat("(", 16 self.parents().map(|parent| parent.change_id().shortest()).join("/"), 17 " -> ", 18 format_short_change_id_with_change_offset(self), 19 ")", 20 ), 21 bookmarks, 22 tags, 23 if(conflict, label("conflict", "×")), 24 if(empty, label("empty", "(empty)")), 25 if(description, 26 concat("(", description.first_line(), ")"), 27 if(!empty, description_placeholder), 28 ), 29 ) 30 ''; 31 template-aliases."in_branch(commit)" = "commit.contained_in(\"immutable_heads()..bookmarks()\")"; 32 templates.log_node = '' 33 if(self && !current_working_copy && !immutable && !conflict && in_branch(self), 34 "", 35 builtin_log_node 36 ) 37 ''; 38 }; 39 path = "jj/config.toml"; 40in 41{ 42 flake.modules.hjem.core = 43 { pkgs, ... }: 44 { 45 packages = [ pkgs.jujutsu ]; 46 xdg.config.files.${path} = { 47 generator = (pkgs.formats.toml { }).generate path; 48 value = settings; 49 }; 50 51 fish.interactiveShellInit = # fish 52 '' 53 abbr -a j 'jj' 54 abbr -a js 'jj show' 55 abbr -a jn 'jj new' 56 abbr -a jd 'jj desc' 57 abbr -a jsq 'jj squash' 58 abbr -a jr 'jj rebase' 59 abbr -a ju 'jj undo' 60 abbr -a jrs 'jj restore -i --changes-in' 61 abbr -a jb 'jj bookmark' 62 abbr -a jg 'jj git' 63 abbr -a jgp 'jj git push' 64 ''; 65 fish.functions.fish_vcs_prompt = # fish 66 '' 67 fish_jj_prompt $argv; or fish_git_prompt $argv; or fish_hg_prompt $argv 68 ''; 69 fish.functions.fish_jj_prompt = # fish 70 '' 71 if not command -sq jj 72 return 1 73 end 74 set -l info "$(jj log \ 75 --ignore-working-copy \ 76 --revisions @ \ 77 --no-graph \ 78 --color=always \ 79 --template shell_prompt \ 80 2>/dev/null)" 81 or return 1 82 if test -n "$info" 83 printf ' %s' $info 84 end 85 ''; 86 fish.wrappers."jj show".summarize = # fish 87 '' 88 set recent (jj log --no-graph \ 89 -r 'ancestors(immutable_heads(), 12) & ~description("flake.lock")' \ 90 -T 'separate("\n", 91 format_short_commit_id(self.commit_id()), 92 self.description())' \ 93 | string collect) 94 jj show --no-pager --context 12 $argv[1] >&2 95 jj show --no-pager --context 12 $argv[1] |\ 96 llm -s "Write a one-line commit message for these changes. It \ 97 should be under 50 characters. If 50 characters is not enough to \ 98 express the main point of the changes you may continue to write \ 99 one or more paragraphs describing the changes, which should be \ 100 wrapped at 80 characters. 101 102 It should match the style of these recent commit messages in the \ 103 same repository, which are each prefixed by a hexadecimal commit \ 104 id and a newline: 105 $recent 106 107 Write the commit message with no commentary, as if the output \ 108 were going straight into the commit 109 " | tee /dev/tty | jj desc --stdin --editor $argv[1] 110 ''; 111 }; 112}