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,24 +20,31 @@ writeShellApplication {
}; };
text = '' text = ''
# Download channel info from NixOS/infra work=$(mktemp -d)
curl ${channelsURL} | nix eval --file - --json > channels.json
# Use channels.nix to build channels.toml
nix build --impure \
--file ${./supported-versions.nix} \
--argstr system ${stdenv.hostPlatform.system} \
--arg-from-file channelsJSON channels.json \
--out-link channels.toml
( (
cd "$work"
# Download channel info from NixOS/infra
curl ${channelsURL} | nix eval --file - --json > channels.json
# Use channels.nix to build channels.toml
nix build --impure \
--file ${./supported-versions.nix} \
--argstr system ${stdenv.hostPlatform.system} \
--arg-from-file channelsJSON channels.json \
--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"
''; '';
} }