diff --git a/nixpkgs_review/report.py b/nixpkgs_review/report.py index 0e6684a9..c702cfaa 100644 --- a/nixpkgs_review/report.py +++ b/nixpkgs_review/report.py @@ -6,7 +6,7 @@ from typing import Literal from .nix import Attr -from .utils import System, info, link, skipped, warn +from .utils import System, info, link, skipped, system_order_key, warn def print_number( @@ -141,7 +141,7 @@ def order_reports(reports: dict[System, SystemReport]) -> dict[System, SystemRep return dict( sorted( reports.items(), - key=lambda item: "".join(reversed(item[0].split("-"))), + key=lambda item: system_order_key(system=item[0]), reverse=True, ) ) diff --git a/nixpkgs_review/review.py b/nixpkgs_review/review.py index c389c728..34bdc2a2 100644 --- a/nixpkgs_review/review.py +++ b/nixpkgs_review/review.py @@ -16,7 +16,7 @@ from .github import GithubClient from .nix import Attr, nix_build, nix_eval, nix_shell from .report import Report -from .utils import System, current_system, info, sh, warn +from .utils import System, current_system, info, sh, system_order_key, warn # keep up to date with `supportedPlatforms` # https://github.com/NixOS/ofborg/blob/cf2c6712bd7342406e799110e7cd465aa250cdca/ofborg/src/outpaths.nix#L12 @@ -212,8 +212,14 @@ def build_commit( for system in self.systems } - changed_attrs = {} - for system in self.systems: + # Systems ordered correctly (x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin) + sorted_systems: list[System] = sorted( + list(self.systems), + key=system_order_key, + reverse=True, + ) + changed_attrs: dict[System, set[str]] = {} + for system in sorted_systems: changed_pkgs, removed_pkgs = differences( base_packages[system], merged_packages[system] ) diff --git a/nixpkgs_review/utils.py b/nixpkgs_review/utils.py index 105fa1bd..90978a6e 100644 --- a/nixpkgs_review/utils.py +++ b/nixpkgs_review/utils.py @@ -76,3 +76,20 @@ def nix_nom_tool() -> str: return "nom" return "nix" + + +def system_order_key(system: System) -> str: + """ + For a consistent UI, we keep the platforms sorted as such: + - x86_64-linux + - aarch64-linux + - x86_64-darwin + - aarch64-darwin + + This helper turns a system name to an alias which can then be sorted in the anti-alphabetical order. + (i.e. should be used in `sort` with `reverse=True`) + + Example: + `aarch64-linux` -> `linuxaarch64` + """ + return "".join(reversed(system.split("-")))