Usually used for a beefy building machine or CI, Hetzner offers the best price/performance.
Since these machines are bare metal, setting them up comes up with a cost - no more!
This setup uses a single command to bootstrap a machine and was tested using AX51-NVMe, but any machine with two SSDs should work.
Please contact [email protected] if you're having a different machine configuration or need support.
It will set up a machine using raid1 and ext4 for the root filesystem.
- Login to Hetzner Robot
- Make sure to put your SSH key into https://robot.hetzner.com/key/index
- Select the server you'd like to deploy
- Click
Rescue
-> Make sure you havelinux
selected and your SSH key -> ClickActivate
- Click
Reset
-> SelectExecute an automatic hardware reset
-> ClickSend
- Open Cachix
- If you're part of a team, click
Select an account
and clickCreate an organization
. - Click
Caches
in the top of the menu and create a new binary cache. - Open Cachix Deploy
- Select the account/organization in the menu
- Create a new workspace by selecting the previously created binary cache.
- Click "Add an agent"
- Pick a description and generate a token
- Save the token as
CACHIX_AGENT_TOKEN=xxx
tocachix-agent.token
Clone this repo and make sure to set sshPubKey
in flake.nix
with your public SSH key.
From the email you received when the Hetzner machine was processed, take IP and replace it in yourip
:
$ nix develop -c bootstrap-hetzner yourip myagent ./cachix-agent.token
Once the script finishes, your machine should come up in a few minutes and show up in your Cachix Deploy workspace.
In case anything goes wrong, you can order a remote console via the Support
tab in Hetzner Robot.
Your machine is running a plain NixOS configuration.
To deploy any changes from main
branch you'll need to configure a few things in .github/workflows/deploy.yml
:
myagent
: if you picked a different agent/hostname, change it hereCACHE_NAME
: changemycustomcache
into the name of the cache you created.CACHIX_AUTH_TOKEN
: in Cachix, find your cache via settings and create a write auth token. Go to your git repository, clickSettings
, clickSecrets
, clickActions
and add it as a repository setting.CACHIX_ACTIVATE_TOKEN
in Cachix Deploy, click on your newly created workspace and click "Start a deployment" to generate an token. Go to your git repository, clickSettings
, clickSecrets
, clickActions
and add it as a repository setting.
Assuming your github organization is called myorg
, here's the NixOS configuration:
nix.trustedUsers = [ "root" "github-runner-myorg" ];
systemd.services.github-runner-myorg.serviceConfig.ReadWritePaths = [ "/nix/var/nix/profiles/per-user/" ];
services.github-runners.myorg = {
enable = true;
url = "https://github.com/myorg";
tokenFile = "/etc/secrets/github-runner/myorg.token";
extraPackages = [ pkgs.cachix ];
};
And then go to (make sure to replace myorg with the organization's name) https://github.com/organizations/myorg/settings/actions/runners and copy the token to /etc/secrets/github-runner/myorg.token
.