LnL7 / nix-darwin

nix modules for darwin
MIT License
2.43k stars 407 forks source link

Diff old and new generation in postActivation script #981

Closed ofalvai closed 1 week ago

ofalvai commented 1 week ago

With home-manager and nvd, I can do something like this:

home.activation.reportChanges = config.lib.dag.entryAnywhere ''
  if [[ -v oldGenPath ]]; then
    PATH=$PATH:${lib.makeBinPath [pkgs.nvd]}
    run nvd diff $oldGenPath $newGenPath
  fi
'';

Is it possible to do something similar using system.activationScripts.postActivation? More specifically, is there a way to access oldGenPath and newGenPath?

Samasaur1 commented 1 week ago

Seems like something like this works:

system.activationScripts.postActivation.text = ''
  if [ -e '/run/current-system' ]
  then
    ${pkgs.nvd}/bin/nvd diff "/run/current-system" "$(readlink -f "$systemConfig")"
  fi
'';
ofalvai commented 1 week ago

Nice, this seems to be working. Thank you!