From e5d1a0751adb4963c0a4982503806ae5f19f52da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 13 Jul 2025 18:39:23 +0200 Subject: [PATCH] fix(report): use nix eval to list the components This is less error prone than parsing the information from `nix flake show`. --- scripts/create-report.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/create-report.sh b/scripts/create-report.sh index cab2166..6e04b9f 100755 --- a/scripts/create-report.sh +++ b/scripts/create-report.sh @@ -7,24 +7,25 @@ util_path="${GITHUB_ACTION_PATH:-.}/scripts/utils.sh" # shellcheck source=scripts/utils.sh . "${util_path}" -group 'Retrieving Flake information' -flake_info=$(nix flake show --json --quiet --quiet) -endgroup - system=$(nix eval --impure --json --expr 'builtins.currentSystem') -group 'Show Packages' -packages=$(echo "$flake_info" | jq --raw-output --argjson system "$system" 'getpath(["packages", $system]) | select(. != null) | keys[]') +# Extract the names of a flake attrset +get_names() { + nix eval --json --apply builtins.attrNames "$1" 2>/dev/null | jq --raw-output '.[]' +} + +group "Show Packages for $system" +packages=$(get_names .#packages."$system") [ -z "$packages" ] || log "$packages" endgroup group 'Show Home Manager Configurations' -hmConfigs=$(echo "$flake_info" | jq --raw-output '.homeConfigurations | select(. != null) | keys[]') +hmConfigs=$(get_names .#homeConfigurations) [ -z "$hmConfigs" ] || log "$hmConfigs" endgroup group 'Show NixOS Configurations' -nixosConfigs=$(echo "$flake_info" | jq --raw-output '.nixosConfigurations | select(. != null) | keys[]') +nixosConfigs=$(get_names .#nixosConfigurations) [ -z "$nixosConfigs" ] || log "$nixosConfigs" endgroup -- 2.50.0