nixos-rebuild-ng: print out diffed closures
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user