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.9 kB 54 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 per row OUTDIR/<name>.drvs and OUTDIR/<name>.fetch, the paths it 6# would substitute (for .github/lazy-store.sh), OUTDIR/shared-all.drvs and 7# the substitutable subset OUTDIR/shared.drvs. 8set -euo pipefail 9matrix=$1 10out=$2 11mkdir -p "$out" 12 13plan() { 14 local name=$1 15 shift 16 nix build --dry-run "$@" 2>"$out/$name.plan" || { 17 cat "$out/$name.plan" 18 return 1 19 } 20 section 'will be built:$' <"$out/$name.plan" >"$out/$name.drvs" 21 section 'will be fetched' <"$out/$name.plan" >"$out/$name.fetch" 22} 23 24# the path lines below the header matching $1, up to the next header 25section() { 26 awk -v h="$1" '/^[^ ]/ { f = $0 ~ h; next } f && $1 ~ /^\/nix\/store\// { print $1 }' | sort -u 27} 28 29pids=() 30while IFS=$'\t' read -r name installables; do 31 read -ra inst <<<"$installables" 32 plan "$name" "${inst[@]}" & 33 pids+=("$!") 34done < <(jq -r '.include[] | [.name, .installables] | @tsv' "$matrix") 35for pid in "${pids[@]}"; do 36 wait "$pid" 37done 38 39jq -r '.include[].name' "$matrix" | while read -r name; do cat "$out/$name.drvs"; done | 40 sort | uniq -d >"$out/shared-all.drvs" 41 42# allowSubstitutes = false (trivial builders: etc files, units, wrappers) is 43# never substituted, every machine builds those again anyway 44if [ -s "$out/shared-all.drvs" ]; then 45 xargs nix derivation show <"$out/shared-all.drvs" | jq -r ' 46 (.derivations // .) | to_entries[] 47 | select(.value 48 | (.structuredAttrs // (.env.__json | values | fromjson) // .env).allowSubstitutes 49 | . != false and . != "") 50 | if (.key | startswith("/")) then .key else "/nix/store/" + .key end' | 51 sort >"$out/shared.drvs" 52else 53 : >"$out/shared.drvs" 54fi