Search code examples
nixnixos

how to see what package has been removed after rollback on nixos


introduction

I wanted to test if

nix-env --rollback

could change what I changed in /etc/nixos/configuration.nix The answer is no but now a package has been delete and I what to know which package has been deleted.

Is there a way to know that?

I know that I could have done

nix-env -q

before and after the roolback and compare. But if I forget to do that before, I need a solution.

update

  nix-env -iA nixos.nix-diff

  nix-diff /nix/var/nix/profiles/system /nix/var/nix/profiles/system-$22-link
  • /nix/var/nix/profiles/system:{out}
  • /nix/var/nix/profiles/system-2-link:{out} nix-diff: unknown-deriver: openBinaryFile: does not exist (No such file or directory)"

Solution

  • You can use nix profile history to inspect the package changes.

    Suppose you are in version 30, and by install nix-diff package you profile becomes version 31, then nix profile history will give

    Version 31 (2022-12-10) <- 30:
      nix-diff: ∅ -> 1.0.18
    

    This history preserves even if you rollback from version 31 to 30.

    You may also interested in nix profile diff-closure, which show diff of the whole closure between profile versions.