NixOS modules and an installer for Bitcoin developer servers on Hetzner bare metal.
Status: alpha. The module options may change.
| Output | Description |
|---|---|
packages.<system>.init |
Interactive installer. Runs on the developer's laptop. |
nixosModules.default |
Workstation preset with home-manager and nixvim. |
nixosModules.workstation |
Workstation preset without home-manager. |
nixosModules.hetzner-bare-metal |
Bootloader and networking settings for Hetzner bare metal. |
homeModules.nixvim |
nixvim editor configuration. |
devShells.<system>.bitcoin-core |
Bitcoin Core development shell (x86_64-linux, aarch64-darwin). |
templates.default |
Server repository scaffold, used by init. |
templates.bitcoin-core |
Bitcoin Core dev-shell scaffold. |
The workstation preset provides:
- Tools: compilers, debuggers,
gh,claude-code,codexand similar developer tools. - Shell setup: git, tmux, starship, direnv and zoxide.
- Services: guix, mosh and rootless docker.
- Memory: zram with earlyoom.
- Housekeeping: automatic nix store cleanup.
- SSH: a hardened sshd with SSH and GPG agent forwarding.
| Who | Needs |
|---|---|
| Admin | Hetzner Robot access to the server. |
| Developer | macOS or Linux laptop. |
| Nix with flakes enabled. | |
An SSH key loaded in ssh-agent. |
|
| Optional: a GPG key and a graphical pinentry, for commit signing on the server. See Commit signing. |
Nothing is built on the laptop. The system is built on the server.
- In Robot, open the server.
- Rescue tab: choose Linux, 64 bit, select the developer's SSH key and activate.
- Add the key under Key Management first if it is not listed.
- If no key is selected, the rescue system only accepts a password and
initcannot log in.
- Reset tab: run an automatic hardware reset. Rescue only takes effect on the next boot.
- Send the developer the server's IP address.
nix --version
nix run nixpkgs#hello # fails if flakes are not enabled
ssh-add -l # lists the key given to the admin
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@<ip> true
If flakes are not enabled, add this line to ~/.config/nix/nix.conf:
experimental-features = nix-command flakes
Run it from a new, empty directory:
mkdir ~/dev-server && cd ~/dev-server
nix run github:2140-dev/nix-dev-server#init
The installer asks for the following:
| Prompt | Default |
|---|---|
| Server IP | — |
| Disk layout | Smallest disk for /, others mounted at /data, /data2, ... |
| Hostname | <laptop user>-dev |
| Username on the server | Laptop username |
| Git name and email | git config --global user.name / user.email |
| GPG signing key | Secret keys from gpg --list-secret-keys, or "don't sign" |
| Time zone | Laptop time zone |
| Locale | en_US.UTF-8 |
The installer takes the server's SSH keys from the rescue login. It keeps only the keys that are also on the laptop, and shows them before any changes are made.
The installer then:
- Writes
configuration.nixanddisko.nixand commits them to the current directory. - Asks for confirmation, then erases all listed disks and installs NixOS with
nixos-anywhere. This takes about 15 minutes. - Adds the server's host key to
~/.ssh/known_hosts. - Commits the generated
hardware-configuration.nix. - Imports and trusts the GPG public key on the server, if one was selected.
- Copies the repository to
~/dev-serveron the server. - Offers to add a
Hostentry to~/.ssh/config.
The installer creates nothing outside the laptop and the server.
init --dry-run stops after step 1, before anything is installed.
ssh <hostname>
If the installer did not add the Host entry (for example because ~/.ssh/config is read-only), add it by hand:
Host <hostname>
HostName <ip>
User <user>
HostKeyAlias <hostname>
ForwardAgent yes
RemoteForward /run/user/<uid>/gnupg/S.gpg-agent <agent-extra-socket>
ExitOnForwardFailure yes
| Placeholder | Value |
|---|---|
<uid> |
Output of id -u on the server (usually 1000). |
<agent-extra-socket> |
Output of gpgconf --list-dirs agent-extra-socket on the laptop. |
The RemoteForward line is only needed for commit signing.
The server's configuration is in ~/dev-server on the server.
| Task | Command (in ~/dev-server) |
|---|---|
| Apply a configuration change | sudo nixos-rebuild switch --flake .#workstation |
| Update nix-dev-server and nixpkgs | nix flake update, then apply |
| Roll back | sudo nixos-rebuild switch --rollback |
| Add an SSH key | Add it to services.workstation.user.sshKeys, then apply |
| Add packages | Add them to services.workstation.extraPackages, then apply |
Commit changes to the repository. Pushing it to a remote is optional.
Signing on the server uses the GPG agent on the laptop, forwarded over SSH. Private keys never leave the laptop.
Laptop setup:
- Install a graphical pinentry. A terminal pinentry cannot prompt for requests that arrive from the server.
- macOS:
brew install pinentry-mac - Linux:
pinentry-gnome3orpinentry-qt
- macOS:
- Point gpg-agent at it in
~/.gnupg/gpg-agent.conf:On Intel Macs the path ispinentry-program /opt/homebrew/bin/pinentry-mac default-cache-ttl 3600 max-cache-ttl 28800/usr/local/bin/pinentry-mac. - Set
GPG_TTYfor local signing in the shell config:- zsh or bash:
export GPG_TTY=$(tty) - fish:
set -gx GPG_TTY (tty)
- zsh or bash:
- Restart the agent:
gpgconf --kill gpg-agent
Check that signing works, on the server:
cd ~/dev-server
git commit --allow-empty -m test
git log --show-signature -1 # expect: Good signature ... [ultimate]
Do not run gpgconf --kill all on the server. The agent socket there belongs to the laptop's agent.
| Symptom | Cause | Fix |
|---|---|---|
could not log in to root@<ip> with your SSH key |
Rescue activated without the developer's key, the server not reset, or the key not offered by ssh. |
Re-activate rescue with the key and reset. Check ssh -v root@<ip> true 2>&1 | grep Offering. |
no ssh-agent is running |
No agent on the laptop. | eval "$(ssh-agent)", then ssh-add <key>. |
run in an empty directory |
Leftovers from an earlier run. | Use a new directory. If the current directory was deleted, cd ~ first. |
REMOTE HOST IDENTIFICATION HAS CHANGED on a manual ssh |
The server was reinstalled or is in rescue. | ssh-keygen -R <ip>. The installer itself ignores old entries. |
gpg: signing failed: Inappropriate ioctl for device |
gpg-agent cannot show a passphrase prompt. | Signing on the laptop: set GPG_TTY. Signing on the server: install a graphical pinentry on the laptop. See Commit signing. |
gpg: signing failed: No agent running on the server |
Connected without the RemoteForward line. |
Use the Host entry above and reconnect. |
Permission denied (publickey) after install |
The key on the server is not one the laptop holds. | Boot rescue and run init again. |
missing or unsuitable terminal |
The server lacks the terminal's terminfo (e.g. Ghostty). | TERM=xterm-256color ssh <hostname> |
init generates a repository like templates.default. To write one by hand:
nix flake init -t github:2140-dev/nix-dev-server
Then fill in the FIXMEs.
Minimal configuration:
{
imports = [
nix-dev-server.nixosModules.default
nix-dev-server.nixosModules.hetzner-bare-metal
];
nixpkgs.config.allowUnfree = true; # claude-code, codex
services.workstation = {
enable = true;
user.name = "alice";
user.sshKeys = [ "ssh-ed25519 AAAA... alice@laptop" ];
};
}Make nixpkgs and disko follow nix-dev-server, so the system uses the versions this library is tested against:
inputs = {
nix-dev-server.url = "github:2140-dev/nix-dev-server";
nixpkgs.follows = "nix-dev-server/nixpkgs";
disko.follows = "nix-dev-server/disko";
};| Option | Type | Default |
|---|---|---|
services.workstation.enable |
bool | false |
services.workstation.user.name |
string | — |
services.workstation.user.sshKeys |
list of strings | [ ] |
services.workstation.timeZone |
string | "UTC" |
services.workstation.locale |
string | "en_US.UTF-8" |
services.workstation.extraPackages |
list of packages | [ ] |
The developer's git identity is set with home-manager.users.<name>.programs.git. See templates/default/configuration.nix.
nixosModules.workstation is the same preset without home-manager or nixvim:
{
imports = [
home-manager.nixosModules.home-manager
nix-dev-server.nixosModules.workstation
];
services.workstation = {
enable = true;
user.name = "alice";
};
home-manager.users.alice = {
imports = [ nix-dev-server.homeModules.nixvim ];
home.stateVersion = "25.05";
};
}In a Bitcoin Core checkout:
echo "use flake github:2140-dev/nix-dev-server#bitcoin-core" > .envrc
direnv allow
Or scaffold a local flake, which pins its own flake.lock, plus a justfile:
nix flake init -t github:2140-dev/nix-dev-server#bitcoin-core
direnv allow
just --list
The shell includes:
- clang with mold, cmake and ninja
- gdb
- the Python dependencies for the functional tests
- on Linux, bcc, bpftrace and systemtap for the USDT tests
nix flake check
| Check | Description |
|---|---|
workstation-vm |
Boots nixosModules.default in a VM and checks the user, services, agent forwarding setup and home-manager. |
init |
Builds the installer. shellcheck runs as part of the build. |
CI also evaluates nixosConfigurations.template, the scaffold built against the current checkout.
MIT. See LICENSE.