From 2bb951215c249e193ba2f8f6ba1dde821b67acb0 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Sun, 5 Jan 2025 09:51:32 +0000 Subject: [PATCH] admin: runner-installation: update NixOS instructions (#998) Preview: https://forgejo.codeberg.page/@docs_pull_998/docs/next/admin/runner-installation/#nixos Fixes #903. As described in that issue, the Nix package has been renamed upstream, as well as that the mentioned service module does not exist in reality. I reworked that section to bring everything up-to-date. The mentioned labels pre-population does not apply to Forgejo, at least. I have also added a small example as reference. Further, I included a small change to `scripts/preview.sh`, to detect the actual URL open command - on Linux, `xdg-open` is normally the canonical one. Reviewed-on: https://codeberg.org/forgejo/docs/pulls/998 Reviewed-by: Earl Warren Co-authored-by: Christoph Heiss Co-committed-by: Christoph Heiss --- docs/admin/runner-installation.md | 25 +++++++++++++++++++++++-- scripts/preview.sh | 8 +++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/admin/runner-installation.md b/docs/admin/runner-installation.md index 26eb4b7e..33e8e78b 100644 --- a/docs/admin/runner-installation.md +++ b/docs/admin/runner-installation.md @@ -517,9 +517,30 @@ Now, `Forgejo runner` will create networks with IPv6 enabled, and workflow conta ### NixOS -The [`forgejo-actions-runner`](https://github.com/NixOS/nixpkgs/blob/ac6977498b1246f21af08f3cf25ea7b602d94b99/pkgs/development/tools/continuous-integration/forgejo-actions-runner/default.nix) recipe is released in NixOS. +A [`forgejo-runner`](https://search.nixos.org/packages?channel=unstable&show=forgejo-runner&type=packages&query=forgejo-runner) package is available for Nix. +As NixOS service module [`services.gitea-actions-runner.*`](https://search.nixos.org/options?channel=unstable&type=options&query=services.gitea-actions-runner) can be used. -Please note that the `services.forgejo-actions-runner.instances..labels` key may be set to `[]` (an empty list) to use the packaged Forgejo instance list. One of `virtualisation.docker.enable` or `virtualisation.podman.enable` will need to be set. The default Forgejo image list is populated with docker images. +If application containers are to be used (Docker or Podman), one of `virtualisation.docker.enable` or `virtualisation.podman.enable` must also be set to `true`. + +An example service definition might look like this: + +```nix +services.gitea-actions-runner = { + package = pkgs.forgejo-runner; + instances.my-forgejo-instance = { + enable = true; + name = "my-forgejo-runner-01"; + token = ""; + url = "https://code.forgejo.org/"; + labels = [ + "node-22:docker://node:22-bookworm" + "nixos-latest:docker://nixos/nix" + ]; + settings = { ... }; + }; +``` + +The runner configuration can be specified in `services.gitea-actions-runner.instances..settings` as per [Configuration](#configuration). IPv6 support is not enabled by default for docker. The following snippet enables this. diff --git a/scripts/preview.sh b/scripts/preview.sh index 0c1ba13e..0dbd6fd6 100755 --- a/scripts/preview.sh +++ b/scripts/preview.sh @@ -1,5 +1,11 @@ #!/usr/bin/env sh +if hash xdg-open 2>/dev/null; then + open_cmd=xdg-open +else + open_cmd=open +fi + current_branch=$(git branch --show-current) repo_path=$(pwd) @@ -32,7 +38,7 @@ mkdir -p $(dirname ./src/content/images/$current_branch) # in case of branch na ln -s $repo_path/images/ ./public/images/$current_branch # once the dev server is running, open the current docs branch in the browser -sleep 3 && open http://localhost:4321/docs/$current_branch/ & +sleep 3 && $open_cmd http://localhost:4321/docs/$current_branch/ & # start the dev server pnpm run dev