@@ -58,25 +58,27 @@ echo "=== Fetching LTS and Cabal versions (parallel) ==="
5858
5959 search_result=$( retry gh api " search/commits" \
6060 -X GET \
61- -f q=" repo:NixOS/nixpkgs haskellPackages stackage LTS committer-date:<=$nixpkgs_date_iso " \
61+ -f q=" repo:NixOS/nixpkgs \" haskellPackages: stackage LTS\" committer-date:<=$nixpkgs_date_iso " \
6262 -f sort=" committer-date" \
6363 -f order=" desc" \
6464 -f per_page=1 \
65- --jq ' .items[0].commit.message' )
65+ --jq ' .items[0].commit.message | split("\n")[0] ' )
6666
6767 if [[ -z " $search_result " || " $search_result " == " null" ]]; then
6868 echo " Error: Could not find LTS commit" >&2
6969 exit 1
7070 fi
7171
72- lts_version=$( echo " $search_result " | grep -oP ' LTS \K[0-9]+\.[0-9]+' | tail -1)
72+ # `|| true` prevents set -e from silently killing the subshell when
73+ # grep finds no match — we want the explicit empty-check below to fire.
74+ lts_version=$( echo " $search_result " | grep -oP ' LTS \K[0-9]+\.[0-9]+' | tail -1 || true)
7375 if [[ -z " $lts_version " ]]; then
7476 echo " Error: Could not parse LTS version" >&2
7577 exit 1
7678 fi
7779
78- echo " $lts_version "
79- ) > " $lts_result " &
80+ echo " $lts_version " > " $lts_result "
81+ ) &
8082lts_pid=$!
8183
8284# Background job: Get latest Cabal versions from Hackage
@@ -85,8 +87,8 @@ lts_pid=$!
8587 " https://hackage.haskell.org/package/Cabal/preferred" | jq -r ' .["normal-version"][0]' )
8688 cabal_syntax_ver=$( retry curl -sH " Accept: application/json" \
8789 " https://hackage.haskell.org/package/Cabal-syntax/preferred" | jq -r ' .["normal-version"][0]' )
88- echo " $cabal_ver $cabal_syntax_ver "
89- ) > " $cabal_result " &
90+ echo " $cabal_ver $cabal_syntax_ver " > " $cabal_result "
91+ ) &
9092cabal_pid=$!
9193
9294# Wait for both
@@ -145,9 +147,13 @@ cd nix/packages
145147gen_pkg () {
146148 local name=" $1 "
147149 shift
150+ (
151+ set -Eeou pipefail
152+ trap ' rm -f "${name}.nix.tmp"' EXIT # Error cleanup
148153 echo " # Generated by update-deps" > " ${name} .nix.tmp"
149154 retry cabal2nix " $@ " >> " ${name} .nix.tmp"
150155 mv " ${name} .nix.tmp" " ${name} .nix"
156+ )
151157 echo " ${name} : done"
152158}
153159
0 commit comments