From 76d059bac23d8ee5bb5cc624cd5a9206092ae8ab Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Mon, 7 Jul 2025 17:00:48 +0100 Subject: [PATCH] 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 bc997a240953bda9fa526e8a3d6f798a6072308a) --- update-scripts/version-info/default.nix | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/update-scripts/version-info/default.nix b/update-scripts/version-info/default.nix index e11c0e4c..c746b1eb 100644 --- a/update-scripts/version-info/default.nix +++ b/update-scripts/version-info/default.nix @@ -20,24 +20,31 @@ writeShellApplication { }; text = '' - # 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 - + work=$(mktemp -d) ( + 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 "# This file was generated by ${ lib.strings.removePrefix (toString ../.. + "/") (toString ./default.nix) }" cat ${mainInfo} echo - cat channels.toml - ) > version-info.toml + cat "$work/channels.toml" + } > version-info.toml + + rm -rf "$work" ''; }