New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/github-runner: init at v2.277.1 #116775
Conversation
pkgs/development/tools/continuous-integration/github-runner/default.nix
Outdated
Show resolved
Hide resolved
pkgs/development/tools/continuous-integration/github-runner/default.nix
Outdated
Show resolved
Hide resolved
pkgs/development/tools/continuous-integration/github-runner/default.nix
Outdated
Show resolved
Hide resolved
Result of 1 package built successfully:1 suggestion:
|
Also note that not only a change to the option value will trigger a reconfiguration but also modifications to the file's content.
Adds a parent directory "github-runner/" to all of the systemd lifecycle directories StateDirectory=, RuntimeDirectory= and LogDirectory=. Doing this has two motivations: 1. Something like this would required if we want to support multiple runners configurations. Please note that this is already possible using NixOS containers. 2. Having an additional parent directory makes it easier to remap any of the directories. Without a parent, systemd is going to complain if, for example, the given StateDirectory= is a symlink.
Changing this option triggers a new runner registration. | ||
''; | ||
example = "nixos"; | ||
default = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have testet your PR, work fine so far :-) But get following error if I do not set option name
.
error: cannot coerce null to a string
at /nix/store/rfxj941pv6yf3p2rikhx8wsw3y1q7m34-source/nixos/modules/services/continuous-integration/github-runner.nix:6:18:
5| svcName = "github-runner";
6| systemdUser = "${svcName}-${cfg.name}";
| ^
7| systemdDir = "${svcName}/${cfg.name}";
Looks like hostname is not set as default as described. But maybe I have done something wrong? But after setting name it works fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Hopefully this is fixed in 9dcd2ec.
Until now, the runner registration did not set the `--name` argument if the configuration option was `null`, the default for the option. According to GitHub's documentation, this instructs the registration script to use the machine's hostname. This commit causes the registration to always pass the `--name` argument to the runner configuration script. The option now defaults to `networking.hostName` which should be always set on NixOS. This change becomes necessary as the systemd service name includes the name of the runner since fcfa809 and, hence, expects it to be set. Thus, an unset `name` option leads to an error.
Forcing a `name` option to comply with a pattern which could also be used as a hostname is probably not required by GitHub.
User and group naming restrictions are a complex topic [1] that I don't even want to touch. Let systemd figure out the username and group and reference it in our scripts through the USER environment variable. [1] https://systemd.io/USER_NAMES/
The escaping applied to the subdirectory paths given to StateDirectory=, RuntimeDirectory= and LogsDirectory= apparently doesn't use the same strategy that is used to escape unit names (cf. systemd-escape(1)). This makes it unreasonably hard to construct reliable paths which work for StateDirectory=/RuntimeDirectory=/LogsDirectory= and ExecStartPre=. Against this background, I decided to (re-)apply restrictions to the name a user might give for the GitHub runner. The pattern for `networking.hostName` seems like a reasonable choice, also as its value is the default if the `name` option isn't set. This reverts commit 193ac67.
@veehaitch is this ready? |
I'd say: yes! I've been using the runner without any issues since opening this PR. Obviously, there's room for improvement. Mainly support for multiple runner definitions (currently, we can achieve this with containers) and runner registration using a personal access token. I'd suggest, however, to implement those improvements in follow-ups. This PR is pretty big already. |
sweet! |
@zimbatm This causes an eval error, because the kerberos attribute isn't passed.
https://gist.github.com/GrahamcOfBorg/2f92163fa71808194f67a2b60974f5a3 |
How come CI didn't catch that? |
dcb501f99325 wasn't included yet in this branch's base |
The ofborg results are a week old I think. |
Thanks, this is fantastic! |
Motivation for this change
#101426
Adds GitHub Actions Runner to nixpkgs. Only
x86_64-linux
is supported right now. The .NET tests are run in the check phase and pass (apart from some online tests).Required quite a few source patches to make it work with Nix:
rev
fromfetchFromGitHub
to the propertyGitInfoCommitHash
directly.RUNNER_ROOT
which allows changing the root directory.The output derivation tries to resemble the structure of the upstream releases where it makes sense. Also, the scripts
config.sh
andrun.sh
are fully usable.Also adds a NixOS module:
name
,url
,runnerGroup
,extraLabels
,tokenFile
or its content changes, a registration is triggered.Thanks @Trundle for helping out 馃檹馃徎
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)