This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / .github / ci-shared.sh
1.7 kB 49 lines
1#!/usr/bin/env bash 2# For the eval job of ci.yml: dry-run every matrix row, in parallel, and list 3# the derivations that more than one row would build (not substitutable from 4# any configured substituter). Usage: ci-shared.sh MATRIX_JSON OUTDIR 5# Writes OUTDIR/<name>.drvs per row, OUTDIR/shared-all.drvs and the 6# substitutable subset OUTDIR/shared.drvs. 7set -euo pipefail 8matrix=$1 9out=$2 10mkdir -p "$out" 11 12plan() { 13 local name=$1 14 shift 15 nix build --dry-run "$@" 2>"$out/$name.plan" || { 16 cat "$out/$name.plan" 17 return 1 18 } 19 # the drv lines below the "will be built:" header, up to the next header 20 awk '/^[^ ]/ { b = /will be built:$/; next } b && $1 ~ /^\/nix\/store\// { print $1 }' \ 21 "$out/$name.plan" | sort -u >"$out/$name.drvs" 22} 23 24pids=() 25while IFS=$'\t' read -r name installables; do 26 read -ra inst <<<"$installables" 27 plan "$name" "${inst[@]}" & 28 pids+=("$!") 29done < <(jq -r '.include[] | [.name, .installables] | @tsv' "$matrix") 30for pid in "${pids[@]}"; do 31 wait "$pid" 32done 33 34jq -r '.include[].name' "$matrix" | while read -r name; do cat "$out/$name.drvs"; done | 35 sort | uniq -d >"$out/shared-all.drvs" 36 37# allowSubstitutes = false (trivial builders: etc files, units, wrappers) is 38# never substituted, every machine builds those again anyway 39if [ -s "$out/shared-all.drvs" ]; then 40 xargs nix derivation show <"$out/shared-all.drvs" | jq -r ' 41 (.derivations // .) | to_entries[] 42 | select(.value 43 | (.structuredAttrs // (.env.__json | values | fromjson) // .env).allowSubstitutes 44 | . != false and . != "") 45 | if (.key | startswith("/")) then .key else "/nix/store/" + .key end' | 46 sort >"$out/shared.drvs" 47else 48 : >"$out/shared.drvs" 49fi