nix-user-diff 590 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh --
  2. set -ue
  3. : "${NIX_PROFILES_DIR:=/nix/var/nix/profiles/per-user/${USER:?}}"
  4. generation_files() (
  5. cd "${NIX_PROFILES_DIR}/profile-${1:?}-link" || kill "${$}"
  6. fd . | sort
  7. )
  8. generation="${1:-$(
  9. nix-env --list-generations | sed -n '/current/s/\s\+\([0-9]\+\).*/\1/p'
  10. )}"
  11. previous_generation="${2:-$((generation - 1))}"
  12. : "$((generation + previous_generation))"
  13. exec 9<<EOF
  14. $(
  15. {
  16. generation_files "${previous_generation}" 4<&- | {
  17. generation_files "${generation}" 3<&- | {
  18. diff -Naur /dev/fd/3 -
  19. }
  20. } 3<&0 <&4 4<&-
  21. } 4<&0
  22. )
  23. EOF
  24. exec sed -n '/^[+-][^+-]/p' <&9