nixos-rebuild-ng: print out diffed closures

This commit is contained in:
Elec3137
2026-02-11 09:35:15 -08:00
parent 388d8d23cd
commit 6ac558781e
2 changed files with 8 additions and 2 deletions
@@ -1,3 +1,4 @@
import sys
import json
import logging
import os
@@ -538,6 +539,11 @@ def list_generations(profile: Profile) -> list[GenerationJson]:
)
def diff_closures(current_config: Path, new_config: Path, target_host: Remote | None = None):
print(
f"<<< {current_config}"
f">>> {new_config}",
file=sys.stderr
)
run_wrapper(
[
"nix",
@@ -321,12 +321,12 @@ def build_and_activate_system(
grouped_nix_args=grouped_nix_args,
)
current_config = Path("/run/current-system")
current_config = Path("/run/current-system").readlink()
if args.diff:
if current_config.exists():
nix.diff_closures(current_config=current_config, new_config=path_to_config, target_host=target_host)
else:
logger.warn(f"missing '{str(current_config)}', skipping configuration diff...")
logger.warning(f"missing '{str(current_config)}', skipping configuration diff...")
_activate_system(
path_to_config=path_to_config,