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