From 49a8f719ecc32f6709aedbddd7cd3ff81291cb1f Mon Sep 17 00:00:00 2001 From: Kate Adkins Date: Sun, 24 Nov 2024 13:57:42 -0700 Subject: [PATCH] git: set up difftastic properly --- nixos/configs/ccache.nix | 38 +++++++++++++++++++++++++++++++ nixos/configs/dotfiles/git.hm.nix | 18 ++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 nixos/configs/ccache.nix diff --git a/nixos/configs/ccache.nix b/nixos/configs/ccache.nix new file mode 100644 index 0000000..364864c --- /dev/null +++ b/nixos/configs/ccache.nix @@ -0,0 +1,38 @@ +# +# Support for using Ccache. +# +{ config, ... }: +{ + programs.ccache.enable = true; + nix.settings.extra-sandbox-paths = [ config.programs.ccache.cacheDir ]; + + nixpkgs.overlays = [ + (self: super: { + ccacheWrapper = super.ccacheWrapper.override { + extraConfig = '' + export CCACHE_COMPRESS=1 + export CCACHE_DIR="${config.programs.ccache.cacheDir}" + export CCACHE_UMASK=007 + if [ ! -d "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' does not exist" + echo "Please create it with:" + echo " sudo mkdir -m0770 '$CCACHE_DIR'" + echo " sudo chown root:nixbld '$CCACHE_DIR'" + echo "=====" + exit 1 + fi + if [ ! -w "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)" + echo "Please verify its access permissions" + echo "=====" + exit 1 + fi + ''; + }; + }) + + # Use this for kernel packages. +]; +} diff --git a/nixos/configs/dotfiles/git.hm.nix b/nixos/configs/dotfiles/git.hm.nix index 1c696fa..abc9dcb 100644 --- a/nixos/configs/dotfiles/git.hm.nix +++ b/nixos/configs/dotfiles/git.hm.nix @@ -1,4 +1,7 @@ { deprekages, pkgs, ... }: +let + difft = "${pkgs.difftastic}/bin/difft"; +in { # @@ -11,13 +14,22 @@ # Note: we no longer set a name, here, forcing us to choose our e-mail and username # on a per-project basis. - # Proide the difftastic command. - difftastic.enable = true; - extraConfig = { # Use main as our branch names. init.defaultBranch = "main"; + # + # Use difftastic. + # + alias = { + dlog = "-c diff.external=${difft} log --ext-diff"; + dshow = "-c diff.external=${difft} show --ext-diff"; + ddiff = "-c diff.external=${difft} diff"; + dl = "-c diff.external=${difft} log -p --ext-diff"; + ds = "-c diff.external=${difft} show --ext-diff"; + dd = "-c diff.external=${difft} diff"; + }; + # # Use mergiraf. #