mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-04 18:15:08 +02:00
ci: rename update-scripts
→ ci
This changes how we think about this directory; it does not need to be exclusively for scripts related to updates, but should be a place for any scripts intended to be run by CI workflows. This mindset should make it easier to develop and test the business logic of workflows, without always needing to test "in production" on the nixvim repo or a fork.
This commit is contained in:
parent
7388c85c54
commit
2b2b1e6d8f
18 changed files with 13 additions and 12 deletions
42
ci/version-info/default.nix
Normal file
42
ci/version-info/default.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
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
|
||||
'';
|
||||
}
|
27
ci/version-info/main.nix
Normal file
27
ci/version-info/main.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
lib,
|
||||
writers,
|
||||
}:
|
||||
let
|
||||
inherit (builtins)
|
||||
all
|
||||
match
|
||||
attrNames
|
||||
;
|
||||
inherit (lib)
|
||||
importJSON
|
||||
;
|
||||
|
||||
lockFile = importJSON ../../flake.lock;
|
||||
nixpkgsLock =
|
||||
# Assert there is only one nixpkgs node
|
||||
assert all (node: match "nixpkgs_[0-9]+" node == null) (attrNames lockFile.nodes);
|
||||
lockFile.nodes.nixpkgs.original;
|
||||
|
||||
info = {
|
||||
inherit (lib.trivial) release;
|
||||
nixpkgs_rev = lib.trivial.revisionWithDefault (throw "nixpkgs revision not available");
|
||||
unstable = lib.strings.hasSuffix "-unstable" nixpkgsLock.ref;
|
||||
};
|
||||
in
|
||||
writers.writeTOML "version-info.toml" info
|
62
ci/version-info/supported-versions.nix
Normal file
62
ci/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";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue