From 665f38a501f4ece8927390774e574223e18f68eb Mon Sep 17 00:00:00 2001 From: oqyude Date: Tue, 20 Oct 2026 15:11:23 +0300 Subject: [PATCH] feat(ci): add the `ci` devshell with the Gitea runner tool set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раннер на sapphira отдаёт job'у PATH, равный своему hostPackages, и он фиксируется в systemd-юните при активации -- чтобы добавить туда инструмент, нужен nixos-rebuild switch на хосте. Для workflow'ов в oqyude/winos это тупик: jq (scripts/update-manifest.sh) и pwsh (scripts/update-kvrt.ps1) в наборе раннера отсутствуют, а nix-shell -p не запасной путь -- реестр nix на sapphira пустой, каналов нет, -p не находит nixpkgs. Что сделано: - lib/ci-tools.nix -- один список инструментов CI. - devshells/default.nix: devshell `ci` (nix develop .#ci) с этим списком. Workflow может взять PATH devshell'а и получить jq/pwsh без пересборки: nix develop /etc/nixos#ci --command bash -c 'echo $PATH' - modules/server/gitea-runner.nix: hostPackages берёт тот же список, чтобы набор раннера и devshell не расходились; в списке теперь ещё и powershell. Проверка: devshell собирается на sapphira (nix develop /etc/nixos#ci) и отдаёт jq и pwsh. --- devshells/default.nix | 23 +++++++++++++++++++++++ lib/ci-tools.nix | 32 ++++++++++++++++++++++++++++++++ modules/server/gitea-runner.nix | 16 +++++----------- 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 lib/ci-tools.nix diff --git a/devshells/default.nix b/devshells/default.nix index e499ef3..1d6fec4 100644 --- a/devshells/default.nix +++ b/devshells/default.nix @@ -18,6 +18,29 @@ let in { devShells.${system} = { + # `nix develop .#ci` -> the tool set a Gitea Actions job on sapphira + # needs. Same list as the runner's hostPackages (lib/ci-tools.nix), so a + # workflow can get the tools it needs without a nixos-rebuild: + # + # nix develop /etc/nixos#ci --command bash -c 'echo $PATH' + # + # The runner's own PATH is fixed in the systemd unit at activation time, + # and changing it needs `nixos-rebuild switch` on the host. The workflows + # in oqyude/winos therefore take the PATH from this devshell instead -- + # jq (scripts/update-manifest.sh) and pwsh (scripts/update-kvrt.ps1) are + # not in the runner's default set, and `nix-shell -p` is not a fallback + # on sapphira (empty nix registry, no channels). + ci = pkgs.mkShell { + name = "gitea-ci-devshell"; + + buildInputs = import ../lib/ci-tools.nix { inherit pkgs; }; + + shellHook = '' + echo "[ci-devshell] jq: $(command -v jq || echo MISSING)" + echo "[ci-devshell] pwsh: $(command -v pwsh || echo MISSING)" + ''; + }; + # `nix develop .#vtimeline` -> shell for testing the VeeamTimelineView # project (Playwright + ESLint + Prettier over a vanilla-JS frontend). vtimeline = pkgs.mkShell { diff --git a/lib/ci-tools.nix b/lib/ci-tools.nix new file mode 100644 index 0000000..8133a10 --- /dev/null +++ b/lib/ci-tools.nix @@ -0,0 +1,32 @@ +# The tool set a Gitea Actions job on sapphira needs. +# +# Two consumers, one list, so they cannot drift apart: +# +# * modules/server/gitea-runner.nix -- the runner's `hostPackages`. The +# upstream NixOS module turns that list into the PATH of every host-mode +# job (`path = coreutils ++ optionals wantsHost instance.hostPackages`), +# so a tool that is not listed here does not exist for the job at all. +# +# * devshells/default.nix -- the `ci` devshell. A job (or a developer) can +# enter it and get the same tools without waiting for a nixos-rebuild, +# which is what the workflows in oqyude/winos do: +# nix develop /etc/nixos#ci --command bash -c 'echo $PATH' +# +# Keep the list sorted by purpose: the first group is the default set the +# runner has always had, the rest are tools a specific workflow needs. +{ pkgs }: +with pkgs; [ + bash coreutils curl gawk gitMinimal gnused nodejs wget + nix + python3 + cacert + + # scripts/update-manifest.sh in oqyude/winos hard-requires jq + # ("for dep in curl jq") and calls it a dozen times. + jq + + # scripts/update-kvrt.ps1 in oqyude/winos runs under pwsh; the runner has + # no PowerShell otherwise, and `nix-shell -p powershell` is not a fallback + # here: the nix registry on sapphira is empty, so -p cannot resolve nixpkgs. + powershell +] diff --git a/modules/server/gitea-runner.nix b/modules/server/gitea-runner.nix index 6990124..40b3d4e 100644 --- a/modules/server/gitea-runner.nix +++ b/modules/server/gitea-runner.nix @@ -91,17 +91,11 @@ in container.options = ""; }; - # Default set (bash, coreutils, curl, gawk, gitMinimal, gnused, - # nodejs, wget) plus what ZeroQ workflows are most likely to need. - hostPackages = with pkgs; [ - bash coreutils curl gawk gitMinimal gnused nodejs wget - nix - python3 - cacert - # scripts/update-manifest.sh in oqyude/winos hard-requires jq - # ("for dep in curl jq") and the runner's PATH is exactly this list. - jq - ]; + # The PATH of every host-mode job. One shared list (lib/ci-tools.nix) with + # the `ci` devshell in devshells/default.nix, so the runner and the + # devshell cannot drift apart: a workflow can get the same tools through + # `nix develop /etc/nixos#ci` without waiting for a rebuild. + hostPackages = import ../../lib/ci-tools.nix { inherit pkgs; }; }; # ----- Workspace directory on tmpfs ---------------------------------------