mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
update-scripts/version-info: get channel status for supported versions
Fetch channel info from NixOS/infra, the canonical source of truth.
This commit is contained in:
parent
a95db128a6
commit
9328f4437d
3 changed files with 99 additions and 0 deletions
|
@ -2,19 +2,41 @@
|
|||
lib,
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
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 \
|
||||
--inputs-from ${toString ../..} \
|
||||
--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
|
||||
'';
|
||||
}
|
||||
|
|
62
update-scripts/version-info/supported-versions.nix
Normal file
62
update-scripts/version-info/supported-versions.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
system ? builtins.currentSystem,
|
||||
pkgs ? import <nixpkgs> { inherit system; },
|
||||
lib ? import <nixpkgs/lib>,
|
||||
channelsJSON ? throw "Neither `channels` or `channelsJSON` provided",
|
||||
channels ? builtins.fromJSON channelsJSON,
|
||||
}:
|
||||
let
|
||||
# Pick out supported stable channels
|
||||
supported = [
|
||||
"beta"
|
||||
"stable"
|
||||
"deprecated"
|
||||
];
|
||||
|
||||
stable_versions =
|
||||
channels.channels
|
||||
|> builtins.mapAttrs (channel: entry: entry // { inherit channel; })
|
||||
|> builtins.attrValues
|
||||
|> builtins.filter (entry: entry.variant or null == "primary")
|
||||
|> builtins.filter (entry: builtins.elem entry.status supported)
|
||||
|> builtins.map (entry: {
|
||||
name = entry.channel |> builtins.match "nixos-(.+)" |> builtins.head;
|
||||
value = {
|
||||
inherit (entry) channel status;
|
||||
# Currently, Nixvim stable branches match NixOS channel names
|
||||
branch = entry.channel;
|
||||
};
|
||||
})
|
||||
|> builtins.listToAttrs;
|
||||
|
||||
newest_stable =
|
||||
stable_versions |> builtins.attrNames |> builtins.sort (a: b: a > b) |> builtins.head;
|
||||
|
||||
bumpYear = y: toString (lib.toIntBase10 y + 1);
|
||||
bumpMonth =
|
||||
m:
|
||||
assert m == "05" || m == "11";
|
||||
if m == "05" then "11" else "05";
|
||||
|
||||
unstable =
|
||||
newest_stable
|
||||
|> builtins.match "(.+)[.](.+)"
|
||||
|> (v: {
|
||||
y = builtins.elemAt v 0;
|
||||
m = builtins.elemAt v 1;
|
||||
})
|
||||
|> (v: {
|
||||
y = if v.m == "11" then bumpYear v.y else v.y;
|
||||
m = bumpMonth v.m;
|
||||
})
|
||||
|> (v: "${v.y}.${v.m}");
|
||||
in
|
||||
pkgs.writers.writeTOML "channels.toml" {
|
||||
versions = stable_versions // {
|
||||
${unstable} = {
|
||||
branch = "main";
|
||||
channel = "nixpkgs-unstable";
|
||||
status = "rolling";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -3,3 +3,18 @@
|
|||
nixpkgs_rev = "3d1f29646e4b57ed468d60f9d286cde23a8d1707"
|
||||
release = "25.11"
|
||||
unstable = true
|
||||
|
||||
[versions."24.11"]
|
||||
branch = "nixos-24.11"
|
||||
channel = "nixos-24.11"
|
||||
status = "deprecated"
|
||||
|
||||
[versions."25.05"]
|
||||
branch = "nixos-25.05"
|
||||
channel = "nixos-25.05"
|
||||
status = "stable"
|
||||
|
||||
[versions."25.11"]
|
||||
branch = "main"
|
||||
channel = "nixpkgs-unstable"
|
||||
status = "rolling"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue