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 | }; |
| 71 | }; |
| 72 | |
| 73 | replacementToHTTPInsteadOf = name: urls: { |
| 74 | name = urls.http; |
| 75 | value.insteadOf = "${name}:"; |
| 76 | }; |
| 77 | replacementToSSHInsteadOf = name: urls: { |
| 78 | name = urls.ssh; |
| 79 | value = { |
| 80 | insteadOf = "p:${name}:"; |
| 81 | pushInsteadOf = [ urls.http "${name}:" ]; |
| 82 | }; |
| 83 | }; |
| 84 | |
| 85 | replacementURLList = |
| 86 | (lib.mapAttrsToList replacementToHTTPInsteadOf urlReplacements) |
| 87 | ++ (lib.mapAttrsToList replacementToSSHInsteadOf urlReplacements); |
| 88 | |
| 89 | replacementURLs = builtins.listToAttrs replacementURLList; |
| 90 | in { |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 91 | chimera.gpg.enable = lib.mkIf config.chimera.git.gpg.enable true; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 92 | |
Skyler Grey | d5457a2 | 2024-02-15 23:02:32 +0000 | [diff] [blame] | 93 | home.packages = |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 94 | (if config.chimera.git.gitReview.enable then [ pkgs.git-review ] else [ ]) |
Samuel Shuert | 849a93e | 2024-02-21 22:38:53 +0000 | [diff] [blame] | 95 | ++ (if config.chimera.git.stgit.enable then [ pkgs.stgit ] else [ ]); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 96 | |
| 97 | programs.zsh.shellAliases = |
| 98 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 99 | |
| 100 | programs.bash.shellAliases = |
| 101 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 102 | |
| 103 | programs.git = { |
| 104 | enable = true; |
| 105 | |
Skyler Grey | bb7586a | 2024-02-15 19:15:04 +0000 | [diff] [blame] | 106 | delta = { |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 107 | enable = config.chimera.git.delta.enable; |
| 108 | options.light = lib.mkIf config.chimera.theme.catppuccin.enable ( |
| 109 | config.chimera.theme.catppuccin.style == "Latte" |
| 110 | ); |
| 111 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 112 | |
| 113 | extraConfig = { |
| 114 | init.defaultBranch = "main"; |
| 115 | advice.skippedcherrypicks = false; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 116 | 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] | 117 | credential.helper = "cache"; |
| 118 | core = { |
| 119 | repositoryformatversion = 0; |
| 120 | filemode = true; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 121 | # 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] | 122 | }; |
| 123 | push = { |
| 124 | autoSetupRemote = true; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 125 | gpgSign = lib.mkIf config.chimera.git.gpg.enable ( |
| 126 | if config.chimera.git.gpg.push then "if-asked" else false |
| 127 | ); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 128 | }; |
Skyler Grey | fde4a19 | 2024-05-24 23:24:22 +0000 | [diff] [blame] | 129 | pull.rebase = "merges"; |
| 130 | rebase.updateRefs = true; |
Skyler Grey | a947818 | 2024-05-25 00:33:38 +0000 | [diff] [blame] | 131 | url = replacementURLs; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 132 | merge.conflictstyle = "diff3"; |
| 133 | trailer.ifexists = "addIfDifferent"; |
| 134 | }; |
| 135 | }; |
| 136 | }; |
| 137 | } |