about summary refs log tree commit diff
path: root/modules/git
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/default.nix81
1 files changed, 42 insertions, 39 deletions
diff --git a/modules/git/default.nix b/modules/git/default.nix
index f370ae6..447d90a 100644
--- a/modules/git/default.nix
+++ b/modules/git/default.nix
@@ -1,6 +1,5 @@
 {
   config,
-  inputs,
   lib,
   libNginx,
   libPlausible,
@@ -35,35 +34,20 @@ in
   config = lib.mkMerge [
     (lib.mkIf cfg.client.enable {
       secrets = {
-        glab-cli-config = {
-          file = "${inputs.self}/secrets/glab-cli-config";
-          path = "${config.dirs.config}/glab-cli/config.yml";
-          owner = lib.my.username;
-        };
-        # NOTE SSO requires relogin every day, so keeping persistent auth tokens
-        # doesn't work.
+        # TODO Use this.
         # gh-hosts = {
         #   file = "${inputs.self}/secrets/gh-hosts";
         #   path = "${config.dirs.config}/gh/hosts.yml";
         #   owner = my.username;
         # };
-        hut = {
-          file = "${inputs.self}/secrets/hut";
-          path = "${config.dirs.config}/hut/config";
-          owner = lib.my.username;
-        };
       };
 
-      nixfiles.modules.common.shell.aliases = {
-        gl = "glab";
-        ht = "hut";
-      };
+      nixfiles.modules.common.shell.aliases.gl = "glab";
 
       hm = {
         home.packages = with pkgs; [
           git-extras
           glab
-          hut
         ];
 
         programs = {
@@ -74,29 +58,47 @@ in
 
             userName = lib.my.username;
             userEmail = lib.my.email;
-            signing = {
-              inherit (lib.my.pgp) key;
-              signByDefault = true;
-            };
 
             extraConfig =
               {
                 color.ui = true;
-                core.whitespace = "trailing-space";
+                core = {
+                  fsmonitor = true;
+                  untrackedCache = true;
+                  whitespace = "trailing-space";
+                };
+                log.showSignature = true;
                 init.defaultBranch = "master";
                 status.submoduleSummary = true;
                 commit.verbose = true;
-                push.autoSetupRemote = true;
+                push = {
+                  autoSetupRemote = true;
+                  default = "simple";
+                  followTags = true;
+                };
+                fetch = {
+                  prune = true;
+                  pruneTags = true;
+                  all = true;
+                };
                 pull.rebase = true;
+                merge.conflictstyle = "zdiff3";
                 rebase = {
-                  autoStash = true;
                   autoSquash = true;
+                  autoStash = true;
+                  updateRefs = true;
+                };
+                rerere = {
+                  enabled = true;
+                  autoupdate = true;
                 };
-                rerere.enabled = true;
                 branch.sort = "-committerdate";
+                tag.sort = "version:refname";
                 diff = {
+                  algorithm = "histogram";
+                  colorMoved = "plain";
                   mnemonicPrefix = true;
-                  renames = "copies";
+                  renames = true;
                   submodule = "log";
                 };
                 submodule.recurse = true;
@@ -109,18 +111,15 @@ in
                   confirm = "always";
                 };
                 column.ui = "auto";
-                github.user = lib.my.username;
-                gitlab.user = lib.my.username;
               }
               // lib.mapAttrs' (n: v: lib.nameValuePair ''url "git@${v}:"'' { insteadOf = "${n}:"; }) {
-                "bitbucket" = "bitbucket.com";
                 "codeberg" = "codeberg.org";
                 "github" = "github.com";
                 "gitlab" = "gitlab.com";
-                "sourcehut" = "git.sr.ht";
               }
               // lib.mapAttrs' (n: v: lib.nameValuePair ''url "https://${v}/"'' { insteadOf = "${n}:"; }) {
                 "alpine" = "gitlab.alpinelinux.org";
+                "bitbucket" = "bitbucket.com";
                 "clan" = "git.clan.lol";
                 "debian" = "salsa.debian.org";
                 "freedesktop" = "gitlab.freedesktop.org";
@@ -132,6 +131,7 @@ in
                 "nixca" = "gitlab.nixca.dev";
                 "notabug" = "notabug.org";
                 "opencode" = "opencode.net";
+                "sourcehut" = "git.sr.ht";
                 "syndicate" = "git.syndicate-lang.org";
                 "torproject" = "gitlab.torproject.org";
                 "videolan" = "code.videolan.org";
@@ -145,7 +145,7 @@ in
               {
                 amend = "commit --amend";
                 cat = "cat-file -p";
-                fast = "clone --depth=1";
+                fast = "clone --depth=1 --single-branch";
                 fixup = "commit --fixup";
                 fuck = "!${git} reset --hard && ${git} clean --force -dx";
                 get = "pull --all --recurse-submodules --autostash";
@@ -157,8 +157,8 @@ in
                 wtc = "!${curl} -sq whatthecommit.com/index.txt | ${git} commit -F -";
               };
 
-            # All helper tools/editor generated files should go here. This must be
-            # kept void of any project-specific or residual files.
+            # All helper tools/editor generated files should go here. This must
+            # be kept void of any project-specific files.
             ignores = [
               "*~"
               ".DS_Store"
@@ -208,7 +208,7 @@ in
 
           settings = {
             root-title = "git.azahi.cc";
-            root-desc = "British scientists have discovered that using GitHub frequently is harmful to one's mental health, especially GitHub Actions...";
+            root-desc = "Personal projects and other stuff.";
 
             footer = "${pkgs.writeText "cgit-footer" ''
               <p style="text-align: center;">Consider giving <a href="https://nixos.org">Nix/NixOS</a> a try! <3</p>
@@ -236,6 +236,7 @@ in
 
             readme = [
               ":README"
+              ":README.md"
               ":readme.md"
               ":readme.org"
             ];
@@ -270,7 +271,6 @@ in
           enable = true;
           user = "git";
           group = "git";
-          adminPubkey = lib.my.ssh.key;
           extraGitoliteRc = ''
             # This allows cgit to scan repositories while running under a
             # different user.
@@ -294,14 +294,17 @@ in
           in
           {
             "/" = {
-              extraConfig = lib.mkBefore extraHead;
+              extraConfig = lib.mkBefore (libNginx.config.noAICrawlers + extraHead);
               fastcgiParams.HTTP_ACCEPT_ENCODING = "";
             };
             "~ /.+/(info/refs|git-upload-pack)" = {
-              extraConfig = lib.mkBefore extraHead;
+              extraConfig = lib.mkBefore (libNginx.config.noAICrawlers + extraHead);
               fastcgiParams.HTTP_ACCEPT_ENCODING = "";
             };
-            "= /logo.gif".alias = "${./logo.gif}";
+            "= /logo.gif" = {
+              alias = "${./logo.gif}";
+              extraConfig = lib.mkForce "";
+            };
             "= /favicon.ico" = {
               alias = "${./favicon.ico}";
               extraConfig = lib.mkForce "";

Consider giving Nix/NixOS a try! <3