Add instructions for self-hosted NixOS runners #42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I attempted the following:
But this action failed: https://github.com/lovesegfault/nix-config/actions/runs/6496771196/job/17644474420
I could just guard the action with an
if
, and expose the host's Nix to the runner, but I wanted to keep things identical to the GitHub-hosted runners, if at all possible.Error
Metadata
I understand you want to keep your actions the same, and presumably you don't actually want our installer to install Nix. Despite that, can you check to see if
sudo
is installed and in your runner's PATH?Next... what behavior would you like and expect out of this action when Nix is already installed / you're already on NixOS?
I think what I'm asking for might be either impossible or unwise without placing the runner inside a container.
I tried just adding
nix
to the runner PATH, but the action still fails: https://github.com/lovesegfault/nix-config/actions/runs/6496992160/job/17645257639What about making the action check whether Nix is already installed/available, and do nothing in that case?
Ah, so it is trying to run
sudo
. Specifically the one from security wrappers which is setuid. I'll check with the team and see what is reasonable!Sounds good, please redeem this beer ticket next time we meet: 🎟️
So we've done some work already to detect an existing Nix install, but it is really only looking for a Nix installed by the Determinate Nix Installer:
I think we could add a second check there, like look to see if you're on NixOS or if the
nix
binary is in your PATH. If we do this we should also check to see if flakes are enabled or not, and emit a warning about it if they aren't.That sounds good, I guess checking whether things are enabled is just
nix show-config
and then looking at theexperimental-features
key.I believe there are two issues at play here. I'm going to try to tease them apart.
Issue 1: Installer requires
sudo
I'm trying to read between the lines of this issue and it appears you are unwilling or unable to give the
runner
usersudo
access.Github Actions, according to it's documentation, conventionally has passwordless
sudo
access. Actions are generally allowed to have this expectation:Since your runner does not appear to conform to this, it is likely you'll experience issues with some other actions as well. I do not think this represents a bug in the
nix-installer
or this action. All our supported Nix install methods requireroot
and check for it quite early.My suggestion here is to do something like:
Alternatively you could set some environment in the
runner
user and check that (egNIXOS=true
).Even if you did add
sudo
thenix-installer
would fail on NixOS. (See issue 2)Issue 2: Installer will exit with failure on NixOS
Normally the installer (on the
ostree
andlinux
plans) will validate that it is not running on NixOS and error if it is:c79dcb91ae/src/planner/linux.rs (L174-L180)
We could consider creating a
nixos
planner however it would be difficult to define what exactly that did. Many modern flakes-only systems do not actually contain aconfiguration.nix
or similar, and editing NixOS definitions that may be part of some flake is of considerable complexity.As Graham mentioned, in this case it may be easier for the action to detect it's running on NixOS and essentially do a noop.