fix(report): use nix eval to list the components
All checks were successful
All checks were successful
This is less error prone than parsing the information from `nix flake show`.
This commit is contained in:
parent
6b0b78e496
commit
f6ba3c1516
1 changed files with 9 additions and 8 deletions
|
@ -7,24 +7,25 @@ util_path="${GITHUB_ACTION_PATH:-.}/scripts/utils.sh"
|
||||||
# shellcheck source=scripts/utils.sh
|
# shellcheck source=scripts/utils.sh
|
||||||
. "${util_path}"
|
. "${util_path}"
|
||||||
|
|
||||||
group 'Retrieving Flake information'
|
|
||||||
flake_info=$(nix flake show --json --quiet --quiet)
|
|
||||||
endgroup
|
|
||||||
|
|
||||||
system=$(nix eval --impure --json --expr 'builtins.currentSystem')
|
system=$(nix eval --impure --json --expr 'builtins.currentSystem')
|
||||||
|
|
||||||
group 'Show Packages'
|
# Extract the names of a flake attrset
|
||||||
packages=$(echo "$flake_info" | jq --raw-output --argjson system "$system" 'getpath(["packages", $system]) | select(. != null) | keys[]')
|
get_names() {
|
||||||
|
nix eval --json --apply builtins.attrNames "$1" 2>/dev/null || echo '[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
group "Show Packages for $system"
|
||||||
|
packages=$(get_names .#packages."$system")
|
||||||
[ -z "$packages" ] || log "$packages"
|
[ -z "$packages" ] || log "$packages"
|
||||||
endgroup
|
endgroup
|
||||||
|
|
||||||
group 'Show Home Manager Configurations'
|
group 'Show Home Manager Configurations'
|
||||||
hmConfigs=$(echo "$flake_info" | jq --raw-output '.homeConfigurations | select(. != null) | keys[]')
|
hmConfigs=$(get_names .#homeConfigurations)
|
||||||
[ -z "$hmConfigs" ] || log "$hmConfigs"
|
[ -z "$hmConfigs" ] || log "$hmConfigs"
|
||||||
endgroup
|
endgroup
|
||||||
|
|
||||||
group 'Show NixOS Configurations'
|
group 'Show NixOS Configurations'
|
||||||
nixosConfigs=$(echo "$flake_info" | jq --raw-output '.nixosConfigurations | select(. != null) | keys[]')
|
nixosConfigs=$(get_names .#nixosConfigurations)
|
||||||
[ -z "$nixosConfigs" ] || log "$nixosConfigs"
|
[ -z "$nixosConfigs" ] || log "$nixosConfigs"
|
||||||
endgroup
|
endgroup
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue