ci/version-info: create temp files in a temp directory

Avoid polluting the repo with temporary `channels.{nix,json,toml}`
files. Write them to a temporary working directory instead.

(cherry picked from commit bc997a2409)
This commit is contained in:
Matt Sturgeon 2025-07-07 17:00:48 +01:00
parent f8b5a2fa7d
commit 76d059bac2

View file

@ -20,6 +20,10 @@ writeShellApplication {
}; };
text = '' text = ''
work=$(mktemp -d)
(
cd "$work"
# Download channel info from NixOS/infra # Download channel info from NixOS/infra
curl ${channelsURL} | nix eval --file - --json > channels.json curl ${channelsURL} | nix eval --file - --json > channels.json
@ -29,15 +33,18 @@ writeShellApplication {
--argstr system ${stdenv.hostPlatform.system} \ --argstr system ${stdenv.hostPlatform.system} \
--arg-from-file channelsJSON channels.json \ --arg-from-file channelsJSON channels.json \
--out-link channels.toml --out-link channels.toml
)
( {
echo "# DO NOT MODIFY!" echo "# DO NOT MODIFY!"
echo "# This file was generated by ${ echo "# This file was generated by ${
lib.strings.removePrefix (toString ../.. + "/") (toString ./default.nix) lib.strings.removePrefix (toString ../.. + "/") (toString ./default.nix)
}" }"
cat ${mainInfo} cat ${mainInfo}
echo echo
cat channels.toml cat "$work/channels.toml"
) > version-info.toml } > version-info.toml
rm -rf "$work"
''; '';
} }