git: set up difftastic properly

This commit is contained in:
Kate 2024-11-24 13:57:42 -07:00
parent 357c8d36d0
commit 49a8f719ec
2 changed files with 53 additions and 3 deletions

38
nixos/configs/ccache.nix Normal file
View file

@ -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.
];
}

View file

@ -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.
#