nix home-manager diff result with current $HOME

by tennox
GNU/Linux ◆ alacritty ◆ fish 77 views

WIP demo

nix build .#nixosConfigurations.$NIXOS_INTERNAL_HOSTNAME.config.home-manager.users.$USER.home-files
#!/usr/bin/env bash

if [[ ! -L ./result ]]; then
  echo "./result is not a link" >&2
  exit 1
fi

DIFF_TARGET="$1"
different=$(
  diff -rq --brief --from-file=result $1 |
    #| rg -v '^Only in /home'
    rg '^Files result/(.+) and' -or '$1' 
    # xargs -n1 -I{} echo `realpath --relative-to=~ {}`
)

echo "$different" | fzf --preview 'delta $(realpath "'"$DIFF_TARGET"'/"{}) $(realpath "result/"{})' --preview-window=bottom,80%