aboutsummaryrefslogtreecommitdiffstats
path: root/nix-conf/pkgs/scripts/home-diff-closures.nix
blob: ff2d74c558aeb2c280eee1720fe08e9b90dcf9ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
{ lib, pkgs, ... }:

pkgs.writeShellScriptBin "home-diff-closures" ''
  home_profiles="$HOME/.local/state/nix/profiles/home-manager-*-link"

  # Skip the diff if there are fewer than 2 home profiles.
  if [ $(ls -d1v $home_profiles 2>/dev/null | wc -l) -lt 2 ]; then
    echo "Skipping closure diff..."
  else
    ${lib.getExe pkgs.nix} store diff-closures $(ls -d1v $home_profiles | tail -2)
  fi
''