update flake lock, add flake diff, add evaluation json

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
2025-03-07 22:26:18 -05:00
parent a755a0c792
commit e2c127a012
8 changed files with 150 additions and 55 deletions

30
flupdt/flake_diff.py Normal file
View File

@ -0,0 +1,30 @@
"""Utility to diff nix derivations."""
import logging
import shutil
from flupdt.common import bash_wrapper
def compare_derivations(
path_to_flake: str, path_to_pre_drv: str, path_to_post_drv: str
) -> list[str]:
"""Gets all derivations present in a flake.
:param path_to_flake: path to flake to be checked
:returns a list of all valid derivations in the flake
:raises RuntimeError: fails if nix is not present in the PATH
"""
nvd_path = shutil.which("nvd")
if nvd_path is None:
status_msg = "nvd is not available in the PATH, please verify that it is installed"
raise RuntimeError(status_msg)
diff_output = bash_wrapper(
f"{nvd_path} diff {path_to_pre_drv} {path_to_post_drv}", path=path_to_flake
)
logging.debug(diff_output[0])
logging.debug(diff_output[1])
logging.debug(diff_output[2])
return diff_output