Last active
November 7, 2023 19:36
-
-
Save ConnorBaker/c7284a765789e3762cdc982d08df5a0b to your computer and use it in GitHub Desktop.
Helper to build cudaPackages package set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| json_cuda_packages_categorized=$(nix eval --impure --json .#cudaPackages --apply ' | |
| attrs: | |
| let | |
| drvKind = drvName: | |
| let | |
| drv = attrs.${drvName}; | |
| nonDrv = !(drv ? drvPath && drv ? meta); | |
| unsupportedPlatform = | |
| let | |
| platforms = drv.meta.platforms or []; | |
| platformIsPresent = builtins.elem builtins.currentSystem platforms; | |
| platformsAreSpecified = [] != platforms; | |
| platformIsSupported = platformsAreSpecified -> platformIsPresent; | |
| in | |
| !platformIsSupported; | |
| broken = drv.meta.broken or false; | |
| in | |
| if nonDrv then "nonDrv" | |
| else if unsupportedPlatform then "unsupportedPlatform" | |
| else if broken then "broken" | |
| else "supported"; | |
| categorized = builtins.groupBy drvKind (builtins.attrNames attrs); | |
| expanded = categorized // { | |
| broken = builtins.listToAttrs (builtins.map (drvName: { | |
| name = drvName; | |
| value = | |
| if attrs.${drvName}.brokenConditions != {} | |
| then attrs.${drvName}.brokenConditions | |
| else { brokenReason = "unknown"; }; | |
| }) (categorized.broken or [])); | |
| unsupportedPlatform = builtins.listToAttrs (builtins.map (drvName: { | |
| name = drvName; | |
| value = attrs.${drvName}.meta.platforms or []; | |
| }) (categorized.unsupportedPlatform or [])); | |
| }; | |
| in | |
| expanded | |
| ') | |
| echo "Categorized packages:" | |
| echo "$json_cuda_packages_categorized" | jq | |
| readarray -t drv_names < <(jq -cr '.supported | .[]' <<< "$json_cuda_packages_categorized") | |
| declare -a installables=("${drv_names[@]/#/.#cudaPackages.}") | |
| echo "Building ${#installables[@]} installables: ${installables[@]}" | |
| nom build --impure --no-link --keep-going "${installables[@]}" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output: