Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 1 | { |
| 2 | config, |
| 3 | lib, |
| 4 | pkgs, |
| 5 | ... |
| 6 | }: |
| 7 | { |
| 8 | options.chimera.git = { |
| 9 | gitReview.enable = lib.mkEnableOption "Enable git review"; |
| 10 | delta.enable = lib.mkEnableOption "Enable delta, an alternative pager for git diffs that highlights syntax"; |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 11 | stgit.enable = lib.mkEnableOption "Install StGit, a tool that makes working with stacked patches easier"; |
Skyler Grey | 3883b64 | 2024-06-30 23:01:42 +0000 | [diff] [blame^] | 12 | jj.enable = lib.mkEnableOption "Install jj, a git-compatible VCS, allowing powerful features, performance and stability improvements ontop of git"; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 13 | auth = { |
| 14 | clicksUsername = lib.mkOption { |
| 15 | type = lib.types.str; |
| 16 | description = "Username for Clicks Gerrit"; |
| 17 | }; |
| 18 | }; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 19 | gpg = { |
| 20 | enable = lib.mkEnableOption "Enable signing with gpg"; |
| 21 | commit = lib.mkOption { |
| 22 | type = lib.types.bool; |
| 23 | description = "Enable gpg signing for commits by default"; |
| 24 | default = true; |
| 25 | }; |
| 26 | push = lib.mkOption { |
| 27 | type = lib.types.bool; |
| 28 | description = "Enable gpg signing for pushes by when asked by the server"; |
| 29 | default = true; |
| 30 | }; |
| 31 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 32 | }; |
| 33 | |
Skyler Grey | a947818 | 2024-05-25 00:33:38 +0000 | [diff] [blame] | 34 | config = let |
| 35 | urlReplacements = { |
| 36 | aur = { |
| 37 | http = "https://aur.archlinux.org/"; |
| 38 | ssh = "ssh://aur@aur.archlinux.org/"; |
| 39 | }; |
| 40 | aux = { |
| 41 | http = "https://github.com/auxolotl/"; |
| 42 | ssh = "ssh://git@github.com/auxolotl/"; |
| 43 | }; |
| 44 | cb = { |
| 45 | http = "https://codeberg.org/"; |
| 46 | ssh = "ssh://git@codeberg.org/"; |
| 47 | }; |
| 48 | clicks = { |
| 49 | http = "https://git.clicks.codes/"; |
| 50 | ssh = "ssh://${config.chimera.git.auth.clicksUsername}@ssh.clicks.codes:29418/"; |
| 51 | }; |
| 52 | fdo = { |
| 53 | http = "https://gitlab.freedesktop.org/"; |
| 54 | ssh = "ssh://git@gitlab.freedesktop.org/"; |
| 55 | }; |
| 56 | gh = { |
| 57 | http = "https://github.com/"; |
| 58 | ssh = "ssh://git@github.com/"; |
| 59 | }; |
| 60 | gl = { |
| 61 | http = "https://gitlab.com/"; |
| 62 | ssh = "ssh://git@gitlab.com/"; |
| 63 | }; |
| 64 | kde = { |
| 65 | http = "https://invent.kde.org/"; |
| 66 | ssh = "ssh://git@invent.kde.org/"; |
| 67 | }; |
| 68 | lix = { |
| 69 | http = "https://git.lix.systems/"; |
| 70 | ssh = "ssh://git@git.lix.systems/"; |
| 71 | }; |
Skyler Grey | c5fb2ea | 2024-05-31 23:07:42 +0000 | [diff] [blame] | 72 | srht = { |
| 73 | http = "https://git.sr.ht/"; |
| 74 | ssh = "git@git.sr.ht:"; |
| 75 | }; |
Skyler Grey | a947818 | 2024-05-25 00:33:38 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | replacementToHTTPInsteadOf = name: urls: { |
| 79 | name = urls.http; |
| 80 | value.insteadOf = "${name}:"; |
| 81 | }; |
| 82 | replacementToSSHInsteadOf = name: urls: { |
| 83 | name = urls.ssh; |
| 84 | value = { |
| 85 | insteadOf = "p:${name}:"; |
| 86 | pushInsteadOf = [ urls.http "${name}:" ]; |
| 87 | }; |
| 88 | }; |
| 89 | |
| 90 | replacementURLList = |
| 91 | (lib.mapAttrsToList replacementToHTTPInsteadOf urlReplacements) |
| 92 | ++ (lib.mapAttrsToList replacementToSSHInsteadOf urlReplacements); |
| 93 | |
| 94 | replacementURLs = builtins.listToAttrs replacementURLList; |
| 95 | in { |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 96 | chimera.gpg.enable = lib.mkIf config.chimera.git.gpg.enable true; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 97 | |
Skyler Grey | d5457a2 | 2024-02-15 23:02:32 +0000 | [diff] [blame] | 98 | home.packages = |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 99 | (if config.chimera.git.gitReview.enable then [ pkgs.git-review ] else [ ]) |
Skyler Grey | 3883b64 | 2024-06-30 23:01:42 +0000 | [diff] [blame^] | 100 | ++ (if config.chimera.git.stgit.enable then [ pkgs.stgit ] else [ ]) |
| 101 | ++ (if config.chimera.git.jj.enable then [ pkgs.jujutsu ] else [ ]); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 102 | |
| 103 | programs.zsh.shellAliases = |
| 104 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 105 | |
| 106 | programs.bash.shellAliases = |
| 107 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 108 | |
| 109 | programs.git = { |
| 110 | enable = true; |
| 111 | |
Skyler Grey | bb7586a | 2024-02-15 19:15:04 +0000 | [diff] [blame] | 112 | delta = { |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 113 | enable = config.chimera.git.delta.enable; |
| 114 | options.light = lib.mkIf config.chimera.theme.catppuccin.enable ( |
| 115 | config.chimera.theme.catppuccin.style == "Latte" |
| 116 | ); |
| 117 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 118 | |
| 119 | extraConfig = { |
| 120 | init.defaultBranch = "main"; |
| 121 | advice.skippedcherrypicks = false; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 122 | commit.gpgsign = lib.mkIf config.chimera.git.gpg.enable config.chimera.git.gpg.commit; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 123 | credential.helper = "cache"; |
| 124 | core = { |
| 125 | repositoryformatversion = 0; |
| 126 | filemode = true; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 127 | # TODO: from git docs, should we provide an option for this?: NOTE: this is a possibly dangerous operation; do not use it unless you understand the implications (see git-rebase[1] for details). |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 128 | }; |
| 129 | push = { |
| 130 | autoSetupRemote = true; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 131 | gpgSign = lib.mkIf config.chimera.git.gpg.enable ( |
| 132 | if config.chimera.git.gpg.push then "if-asked" else false |
| 133 | ); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 134 | }; |
Skyler Grey | fde4a19 | 2024-05-24 23:24:22 +0000 | [diff] [blame] | 135 | pull.rebase = "merges"; |
| 136 | rebase.updateRefs = true; |
Skyler Grey | a947818 | 2024-05-25 00:33:38 +0000 | [diff] [blame] | 137 | url = replacementURLs; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 138 | merge.conflictstyle = "diff3"; |
| 139 | trailer.ifexists = "addIfDifferent"; |
| 140 | }; |
| 141 | }; |
| 142 | }; |
| 143 | } |