diff options
| author | Franck Cuny <franck@fcuny.net> | 2024-03-04 15:02:31 -0800 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2024-03-04 15:02:31 -0800 |
| commit | e2f467882f9fd67805b69e5dff6c1652d4c47629 (patch) | |
| tree | 500206b90fe6d81b44a8a9cbe78d2fe5becafd1b /nix/profiles/home-manager/git.nix | |
| parent | create profiles for home-manager (diff) | |
| download | infra-e2f467882f9fd67805b69e5dff6c1652d4c47629.tar.gz | |
move all home-manager settings under the profiles
Diffstat (limited to 'nix/profiles/home-manager/git.nix')
| -rw-r--r-- | nix/profiles/home-manager/git.nix | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/nix/profiles/home-manager/git.nix b/nix/profiles/home-manager/git.nix new file mode 100644 index 0000000..ce9c0a9 --- /dev/null +++ b/nix/profiles/home-manager/git.nix @@ -0,0 +1,80 @@ +{ lib, pkgs, config, ... }: +let + sshPub = builtins.fromTOML ( + builtins.readFile ../../../configs/ssh-pubkeys.toml + ); +in +{ + home.file.".ssh/allowed_signers".text = lib.concatMapStrings (x: "franck@fcuny.net ${x}\n") (with sshPub; [ aptos work git ykey-laptop op ]); + + programs.git = { + enable = true; + userName = "Franck Cuny"; + userEmail = "franck@fcuny.net"; + + signing = { + key = "key::${sshPub.op}"; + signByDefault = true; + }; + + aliases = { + amend = "commit --amend"; + ll = "log --pretty=\"format:%h %G? %aN %s\""; + }; + + extraConfig = { + core.whitespace = "trailing-space,space-before-tab"; + color.ui = "true"; + + gpg.format = "ssh"; + gpg.ssh.allowedSignersFile = "~/.ssh/allowed_signers"; + gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; + + # abort if the remote branch does not match the local one + push.default = "simple"; + + # https://adamj.eu/tech/2024/01/18/git-improve-diff-histogram/ + diff.algorithm = "histogram"; + + init.defaultBranch = "main"; + + pull.rebase = true; + rebase = { + # Automatically create a temporary stash entry before the + # operation begins, and apply it after the operation ends. + autoStash = true; + # Print a warning if some commits are removed + missingCommitsCheck = "warn"; + }; + + branch.autosetuprebase = "remote"; + branch.sort = "authordate"; + + commit.template = "${config.xdg.dataHome}/git/commit.template"; + }; + + ignores = [ + "*~" + ".direnv" + "__pycache__" + ]; + }; + + xdg.dataFile."git/commit.template".source = pkgs.writeText "commit.template" '' + + # (If applied, this commit will...) <subject> + + # Explain why this change is being made + + # --- COMMIT END --- + # Remember to + # Use the imperative mood, present tense: `change' not `changed' nor `changes' + # Do not end the subject line with a period + # Use the body to explain what and why vs. how + # Can use multiple lines with "-" for bullet points in body +''; + + home.packages = with pkgs; [ + gitAndTools.pre-commit + ]; +} |
