Skip to main content
Documentation
Preview
You're viewing the Next docs — a rolling preview of in-development changes. The current release docs may differ.

Build an Image with Rugix Bakery

Add Nexigon Agent to a Rugix Bakery image, connect a device to Nexigon Hub, and open a remote connection to it. The nexigon-rugix repository provides the recipes. For a new project, the Nexigon template for Rugix Bakery already includes them, together with release scripts and CI configuration.

Before You Start

You need:

  • A Rugix Bakery project, for example from the Rugix quickstart.
  • A device or VM to run its image.
  • A Nexigon account with permission to add devices to a project.

Create a Deployment Token

In Nexigon, open Devices, choose the project, and select Add Device → Deployment Token. Optionally give the token a name, choose Create, and copy the token. Nexigon Hub does not show it again.

The token lets every device built from the image join the project. Getting Started explains how the token, the device’s certificate, and its fingerprint work together. For production, Provision Devices pairs each device individually instead of building a token into the image.

Add the Nexigon Recipes

Add the Nexigon recipe repository:

rugix-bakery.toml
[repositories]
nexigon = { git = "https://github.com/nexigon/nexigon-rugix.git", branch = "v0.4" }

Add nexigon/nexigon-agent to install Nexigon Agent and nexigon/nexigon-agent-config to configure it. For a project based on the Rugix quickstart, the customized layer can look like this:

layers/customized.toml
#:schema https://raw.githubusercontent.com/silitics/rugix/refs/tags/v0.8.0/schemas/rugix-bakery-layer.schema.json

parent = "core/debian-bookworm"

recipes = [
    "core/set-hostname",
    "core/persist-root-home",
    "core/ssh",
    "rugix-extra/debian-setup-network",
    "rugix-extra/debian-setup-timesyncd",
    "rugix-extra/avahi",
    "nexigon/nexigon-agent",
    "nexigon/nexigon-agent-config",
    "hello-world",
]

[parameters."nexigon/nexigon-agent-config"]
extra_config = """
[terminal]
enabled = true
user = "root"

[forwarding]
enabled = true
allowed-tcp-ports = [22]

[[exports]]
name = "Web UI"
protocol = "http"
port = 80
"""

extra_config adds settings to the agent’s configuration. This example enables the browser terminal, exports the web server on port 80, and permits SSH forwarding to port 22. Remote Access explains these settings.

Set the Credentials and Build

The nexigon-agent-config recipe reads the Nexigon Hub URL and deployment token from the project’s .env file:

.env
NEXIGON_HUB_URL="https://eu.nexigon.cloud"
NEXIGON_TOKEN="deployment_..."

Replace the values with your instance URL and token, and add .env to .gitignore to keep the token out of version control.

Build and boot the image with your project’s usual workflow. Nexigon Agent starts on boot. Refresh Devices in Nexigon and open the newly connected device.

A connected device

If the device does not appear, inspect journalctl -u nexigon-agent on the device. Check the URL, token, and network connection, and accept the device’s pending certificate if the token does not enable Auto Accept.

Open a Remote Connection

On the device page, choose Generate URL and open a URL for the web server on port 80, or open the browser terminal for a shell on the device.

For SSH, install and configure Nexigon CLI on your workstation and copy the device ID, beginning with d_, from the device page. Forward a local port to the device’s SSH port, and connect to it from a second terminal:

nexigon-cli forward <device-id> 2222:22
ssh -p 2222 root@localhost

With a user token, add --organization <org-id> to the first command, as Organization Selection describes.

Access Devices Remotely explains these methods in detail.

Next Steps

Set Up System Updates adds remote updates of the image, and Set Up Rugix Apps adds applications that update independently of it.