NixOS で configuration.nix を書き換えた場合や nix flake update で上流のハッシュを更新した場合、通常 nixos-rebuild switch コマンドを使ってその変更を適用します。この方法は至極一般的なのですが、自分が今から当てる変更によってどのソフトウェアがどのように更新されるかということはよく分かりません:
# ある日の手元のマシンの更新風景。nix flake update を打ったあとに
# nixos-rebuild switch を実行。 この更新作業によって何が変わった
# かは良くわからない。 (service の再起動などは一応表示されるが……)
$ sudo nixos-rebuild switch --flake path:.#anise
building the system configuration...
cleaning /boot/efi/limine/xen
removing unused boot files...
stopping the following units: accounts-daemon.service, systemd-tmpfiles-resetup.service, waydroid-container.service, xrdp.service
NOT restarting the following changed units: display-manager.service, xrdp-sesman.service
activating the configuration...
setting up /etc...
reloading user units for anqou...
restarting sysinit-reactivation.target
reloading the following units: dbus-broker.service
restarting the following units: polkit.service, systemd-udevd.service
starting the following units: accounts-daemon.service, systemd-tmpfiles-resetup.service, waydroid-container.service, xrdp.service
the following new units were started: NetworkManager-dispatcher.service
Done. The new configuration is /nix/store/6c8854cg5mx79hxg6gmhiyk0gy7hdcsy-nixos-system-anise-25.11.20260417.c7f4703
nh を使うとこの問題を解決することができます。 nh(yet-another-nix-helper の略らしい)は NixOS Options にサポートがあり、以下のようにインストールできます:
programs.nh.enable = true;
nh には様々な機能があるのですが、その中の nh os switch コマンドを使うと nixos-rebuild switch と同等の処理を実行しつつ、どのソフトウェアがどのように更新されたかを表示させることができます:
$ nh os switch --ask . -H anise --diff always
. で configuration.nix があるディレクトリを指定し -H anise でホスト名を指定します。また --ask オプションをつけることで適用前に y/n の確認を求められるようになります。さらに --diff always をつけておかないと差分表示が出ないときがあります。詳細は nh の README などを参照してください。