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