Files
nixos-config/home/terminal/software/git.nix
T
jory 62c70dab19
CI / Flake check (aarch64-linux) (push) Failing after 17m27s
CI / Flake check (x86_64-linux) (push) Failing after 53m5s
CI / Pre-commit checks (x86_64-linux) (push) Successful in 11s
chore: improve code formatting and configuration across multiple files
The diff shows comprehensive code cleanup and formatting improvements across 18 files, including cleaner argument structures, additional package configurations, and improved formatting in the `home/terminal/software/git.nix` hook script.
2026-07-20 06:52:25 +02:00

164 lines
4.7 KiB
Nix

{
config,
pkgs,
...
}: let
configFile = "git/config";
ignoreFile = "git/ignore";
hooksDir = "git/hooks";
toINI = (pkgs.formats.ini {}).generate;
# Hook that auto-generates a Conventional Commit message from staged diff
prepareCommitMsg = pkgs.writeShellScript "prepare-commit-msg" ''
# Only run if there are staged changes
if git diff --cached --quiet 2>/dev/null; then
exit 0
fi
echo "Generating commit message from staged changes..." >&2
# Generate Conventional Commit message using opencode run
git diff --cached | timeout 30 ${pkgs.opencode}/bin/opencode run \
-m opencode/north-mini-code-free \
"You are an expert software engineer writing professional Git commit messages.
Create a clean Conventional Commit for the provided diff.
Rules:
- Format: type(optional scope): imperative description
- Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- First line: maximum 72 characters, starts with capital letter, imperative present tense
- If relevant, add a blank line followed by a short body explaining the motivation and key changes
- Be concise and professional. No emojis, no markdown.
Output ONLY the commit message. Do not add any extra text, quotes, or explanations." \
2>/dev/null > "$1"
# Fallback if generation failed or timed out
if [ ! -s "$1" ]; then
echo "chore: auto-generated commit message" > "$1"
fi
'';
in {
users.users.someone.packages = with pkgs; [
git
delta
gnupg
git-lfs
peco
];
xdg.configFile."${configFile}".source = toINI "config" {
alias = {
af = "!git add $(git ls-files -m -o --exclude-standard | fzf -m)";
br = "branch";
ca = "commit -am";
co = "checkout";
d = "diff";
df = "!git hist | peco | awk '{print $2}' | xargs -I {} git diff {}^ {}";
"edit-unmerged" = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; hx `f`";
fuck = "commit --amend -m";
hist = "log --pretty=format:\"%Cgreen%h %Creset%cd %Cblue[%cn] %Creset%s%C(yellow)%d%C(reset)\" --graph --date=relative --decorate --all";
llog = "log --graph --name-status --pretty=format:\"%C(red)%h %C(reset)(%cd) %C(green)%an %Creset%s %C(yellow)%d%Creset\" --date=relative";
pl = "!git pull origin $(git rev-parse --abbrev-ref HEAD)";
ps = "!git push origin $(git rev-parse --abbrev-ref HEAD)";
st = "status";
};
commit = {
gpgSign = "true";
};
core = {
editor = "nvim";
hooksPath = "${config.xdg.configHome}/git/hooks";
pager = "${pkgs.delta}/bin/delta";
whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
excludesFile = "${config.xdg.configHome}/${ignoreFile}";
};
delta = {
features = "unobtrusive-line-numbers decorations";
navigate = "true";
"side-by-side" = "true";
"true-color" = "never";
};
"delta-decorations" = {
"commit-decoration-style" = "bold grey box ul";
"file-decoration-style" = "ul";
"file-style" = "bold blue";
"hunk-header-decoration-style" = "box";
};
"delta-unobtrusive-line-numbers" = {
"line-numbers" = "true";
"line-numbers-left-format" = "{nm:>4}│";
"line-numbers-left-style" = "grey";
"line-numbers-right-format" = "{np:>4}│";
"line-numbers-right-style" = "grey";
};
diff = {
colorMoved = "default";
};
"filter-lfs" = {
clean = "git-lfs clean -- %f";
process = "git-lfs filter-process";
required = "true";
smudge = "git-lfs smudge -- %f";
};
gpg = {
format = "openpgp";
};
"gpg-openpgp" = {
program = "${pkgs.gnupg}/bin/gpg";
};
init = {
defaultBranch = "main";
};
interactive = {
diffFilter = "${pkgs.delta}/bin/delta --color-only";
};
merge = {
conflictstyle = "diff3";
stat = "true";
};
pull = {
ff = "only";
};
push = {
autoSetupRemote = "true";
default = "current";
};
rebase = {
autoSquash = "true";
autoStash = "true";
};
repack = {
usedeltabaseoffset = "true";
};
rerere = {
autoupdate = "true";
enabled = "true";
};
tag = {
gpgSign = "true";
};
user = {
email = "jory@severijnse.eu";
name = "Jory Severijnse";
signingKey = "0F8835ED078FDBF2";
};
};
xdg.configFile."${ignoreFile}".text = ''
*~
*.swp
*result*
.direnv
node_modules
.opencode/
.gemini/
GEMINI.md
AGENTS.md
.sisyphus
'';
xdg.configFile."${hooksDir}/prepare-commit-msg".source = prepareCommitMsg;
}