diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f59bba..3d0c3f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.2.5 (unreleased) +- Fixed `nvd history` to ignore broken profile symlinks in case they were + forcably removed somehow (issue #20). + - Improve the error message when calling `nvd list`, and `/run/current-system` doesn't exist (issue #21). diff --git a/src/nvd b/src/nvd index c68390d..1cc429c 100755 --- a/src/nvd +++ b/src/nvd @@ -915,7 +915,13 @@ def is_link_to_profile(path: Path, profile_name: str) -> bool: def make_profile_generation_list(profile_link: Path, minimum_version: int) -> List[ProfileVersion]: profile_name = PROFILE_LINK_REGEX.match(str(profile_link)).group("profile") - all_profile_links = [l for l in profile_link.parent.iterdir() if is_link_to_profile(l, profile_name)] + # Use exists() to filter out broken symlinks, which has been reported to happen + # either with `home-manager expire-generations` or `nix profile wipe-history` + # (on Darwin with the DetSys installer in case that's relevant, see issue #20). + all_profile_links = [ + l for l in profile_link.parent.iterdir() + if is_link_to_profile(l, profile_name) and l.exists() + ] all_profile_versions = [ProfileVersion(l) for l in all_profile_links] all_profile_versions.sort() profile_versions = [pv for pv in all_profile_versions if pv.version() >= minimum_version]