From d6656137cbe0b2f578ba20cc6ee998fc97e52121 Mon Sep 17 00:00:00 2001 From: Emmet Date: Sat, 8 Nov 2025 17:35:04 -0600 Subject: [PATCH] git change-commits helper script --- modules/user/git/git.nix | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/user/git/git.nix b/modules/user/git/git.nix index 780a928..7f07703 100644 --- a/modules/user/git/git.nix +++ b/modules/user/git/git.nix @@ -1,8 +1,16 @@ -{ config, lib, pkgs, pkgs-stable, osConfig, ... }: +{ + config, + lib, + pkgs, + pkgs-stable, + osConfig, + ... +}: let cfg = config.userSettings.git; -in { +in +{ options = { userSettings.git = { enable = lib.mkEnableOption "Enable git"; @@ -10,15 +18,25 @@ in { }; config = lib.mkIf cfg.enable { - home.packages = [ pkgs.git pkgs-stable.openssh ]; + home.packages = [ + pkgs.git + pkgs.git-extras + pkgs.git-filter-repo + pkgs-stable.openssh + ]; programs.git.enable = true; programs.git.userName = config.userSettings.name; programs.git.userEmail = config.userSettings.email; + programs.git.aliases = { + change-commits = ''!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --env-filter "if [[ \"$`echo $VAR`\" = '$OLD' ]]; then export $VAR='$NEW'; fi" $@; }; f''; + }; programs.git.extraConfig = { init.defaultBranch = "main"; - safe.directory = [ osConfig.systemSettings.dotfilesDir - osConfig.systemSettings.secretsFlakeDir - (config.home.homeDirectory + "/.cache/nix/tarball-cache") ]; + safe.directory = [ + osConfig.systemSettings.dotfilesDir + osConfig.systemSettings.secretsFlakeDir + (config.home.homeDirectory + "/.cache/nix/tarball-cache") + ]; }; programs.git.lfs.enable = true; services.ssh-agent.enable = true;