nix-community.nixvim/update-scripts/version-info/default.nix
Matt Sturgeon 76d059bac2 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)
2025-07-07 16:27:47 +00:00

50 lines
1.1 KiB
Nix

{
lib,
path,
callPackage,
writeShellApplication,
stdenv,
}:
let
mainInfo = callPackage ./main.nix { };
channelsURL = "https://raw.githubusercontent.com/NixOS/infra/refs/heads/main/channels.nix";
in
writeShellApplication {
name = "version-info";
runtimeEnv = {
NIX_CONFIG = ''
experimental-features = nix-command flakes pipe-operators
'';
NIX_PATH = "nixpkgs=${toString path}";
};
text = ''
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 "$work/channels.toml"
} > version-info.toml
rm -rf "$work"
'';
}