| 1 | { lib, pkgs, ... }: |
| 2 | { |
| 3 | programs.jujutsu = { |
| 4 | enable = true; |
| 5 | package = pkgs.symlinkJoin { |
| 6 | name = "jujutsu-linear"; |
| 7 | paths = [ pkgs.jujutsu ]; |
| 8 | inherit (pkgs.jujutsu) meta version; |
| 9 | postBuild = '' |
| 10 | rm "$out/bin/jj" |
| 11 | cp ${pkgs.writeShellScript "jj" '' |
| 12 | ${lib.optionalString pkgs.stdenv.isDarwin '' |
| 13 | if [[ -t 0 && -t 1 && -z "''${SSH_CONNECTION-}''${SSH_CLIENT-}''${SSH_TTY-}" ]]; then |
| 14 | set -- '--config=--scope=[{ "--when".commands = ["diff"], ui.diff-formatter = "knife", ui.paginate = "never" }]' "$@" |
| 15 | fi |
| 16 | ''} |
| 17 | for arg in "$@"; do |
| 18 | case "$arg" in |
| 19 | desc|describe) |
| 20 | exec ${pkgs.nodejs}/bin/node ${./packages/agent-linear/agent-linear.js} jj ${pkgs.jujutsu}/bin/jj "$@" |
| 21 | ;; |
| 22 | esac |
| 23 | done |
| 24 | exec ${pkgs.jujutsu}/bin/jj "$@" |
| 25 | ''} "$out/bin/jj" |
| 26 | ''; |
| 27 | }; |
| 28 | # my workflow is based on creating changes and editing them. while they |
| 29 | # are in progress the description starts with "WIP: " |
| 30 | settings = rec { |
| 31 | colors = { |
| 32 | bookmark = "green"; |
| 33 | bookmarks = colors.bookmark; |
| 34 | local_bookmarks = colors.bookmarks; |
| 35 | remote_bookmarks = colors.bookmark; |
| 36 | "working_copy bookmark" = "bright green"; |
| 37 | "working_copy bookmarks" = colors."working_copy bookmark"; |
| 38 | "working_copy local_bookmarks" = colors."working_copy bookmark"; |
| 39 | "working_copy remote_bookmarks" = colors."working_copy bookmark"; |
| 40 | |
| 41 | "author" = { |
| 42 | fg = "bright black"; |
| 43 | bold = false; |
| 44 | italic = true; |
| 45 | }; |
| 46 | "working_copy author" = colors.author; |
| 47 | committer = { |
| 48 | fg = "bright black"; |
| 49 | bold = false; |
| 50 | }; |
| 51 | |
| 52 | desc = { |
| 53 | bold = true; |
| 54 | fg = "default"; |
| 55 | }; |
| 56 | description = colors.desc; |
| 57 | cc_wip = { |
| 58 | fg = "bright yellow"; |
| 59 | bold = true; |
| 60 | reverse = true; |
| 61 | }; |
| 62 | cc_header = { |
| 63 | bold = true; |
| 64 | fg = "default"; |
| 65 | }; |
| 66 | cc_feat = "green"; |
| 67 | cc_fix = "red"; |
| 68 | cc_hotfix = "red"; |
| 69 | cc_chore = "yellow"; |
| 70 | cc_test = "blue"; |
| 71 | cc_other = "blue"; |
| 72 | cc_scope = { |
| 73 | fg = "cyan"; |
| 74 | bold = false; |
| 75 | italic = true; |
| 76 | }; |
| 77 | |
| 78 | active_marker = { |
| 79 | fg = "bright magenta"; |
| 80 | bold = true; |
| 81 | reverse = true; |
| 82 | }; |
| 83 | "change_id shortest rest" = { |
| 84 | fg = "bright black"; |
| 85 | bold = true; |
| 86 | }; |
| 87 | conflict_marker = { |
| 88 | fg = "bright red"; |
| 89 | bold = true; |
| 90 | reverse = true; |
| 91 | }; |
| 92 | |
| 93 | timestamp = "bright black"; |
| 94 | "committer timestamp" = colors.committer; |
| 95 | commit_id = { |
| 96 | fg = "bright black"; |
| 97 | bold = false; |
| 98 | }; |
| 99 | muted = "bright black"; |
| 100 | }; |
| 101 | ui.default-command = lib.mkForce "show"; |
| 102 | merge-tools.knife = lib.mkIf pkgs.stdenv.isDarwin { |
| 103 | program = "/Applications/Knife Diff.app/Contents/MacOS/knife-code"; |
| 104 | diff-args = [ "$left" "$right" ]; |
| 105 | edit-args = [ "--edit" "$left" "$right" ]; |
| 106 | }; |
| 107 | # ui.graph.style = "square"; |
| 108 | revsets = { |
| 109 | short-prefixes = "(trunk()..@)::"; |
| 110 | }; |
| 111 | "template-aliases" = { |
| 112 | "format_log_author(commit)" = '' |
| 113 | if(commit.mine(), "You", commit.author().name().match("[^ ]+")) |
| 114 | ''; |
| 115 | "format_log_timestamp(timestamp)" = '' |
| 116 | if(timestamp.after("1 day ago"), timestamp.ago(), timestamp.local().format("%Y-%m-%d")) |
| 117 | ''; |
| 118 | "format_short_commit_header(commit)" = '' |
| 119 | separate(" ", |
| 120 | format_short_change_id_with_change_offset(commit), |
| 121 | label("author", format_log_author(commit)), |
| 122 | label("timestamp", format_log_timestamp(commit_timestamp(commit))), |
| 123 | commit.bookmarks(), |
| 124 | commit.tags(), |
| 125 | commit.working_copies(), |
| 126 | format_commit_labels(commit), |
| 127 | if(config("ui.show-cryptographic-signatures").as_boolean(), |
| 128 | format_short_cryptographic_signature(commit.signature()) |
| 129 | ), |
| 130 | ) |
| 131 | ''; |
| 132 | }; |
| 133 | aliases = { |
| 134 | "ab" = [ "abandon" ]; |
| 135 | "desc" = [ |
| 136 | "describe" |
| 137 | "--ignore-working-copy" |
| 138 | ]; |
| 139 | }; |
| 140 | }; |
| 141 | }; |
| 142 | } |