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