[GH-ISSUE #6304] Native mods on dedicated servers: who builds the server engine (design proposal) #2047

Open
opened 2026-11-02 15:51:37 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @levzzz5154 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6304

Originally assigned to: @wxundup on GitHub.

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

Part of #4953 ("Native mod builds for dedicated servers").

A product proposal: who builds a dedicated server's game when it has native mods. It needs a maintainer's decision before any code, so nothing is claimed.

The problem

A native mod is compiled into the game. The launcher does that for a player's instance. A dedicated server has no launcher. horizon-server runs a release's horizon-engine (the game built --no-default-features, without sound or controllers) or horizon-client --dedicated, and has no idea native mods exist. docs/native-mods.md says: "Dedicated servers: native mods are not built yet." Every server-side hook (machines, pipes, recipes, commands) is therefore single player and LAN only. That is most of what #4953 builds.

How it works today

  • The launcher's build (launcher/src/native_mods.rs, docs/native-mods.md "What the launcher does"):
    • Source: the release's commit as a GitHub tarball (about 63 MB).
    • Toolchain: its own pinned Rust 1.99.1, SHA-256 checked, with its own CARGO_HOME (rust_toolchain.rs). Linux and macOS need a system cc; Linux also needs pkg-config and the ALSA and udev headers.
    • Patching: horizon-mixins, built once at a pinned revision.
    • Build: cargo build --locked --profile fast -p horizon-client, with the default features (sound and controllers).
    • Install: a new version native-<commit>-<key> beside the base, with native-mods.json.
    • Cost: first build 4.5 min on a fast Linux desktop, 7–12 min on Windows or a loaded machine; then about 50 s, or 11 s for a mod crate change; 1.5–2 GB of target/, plus 0.5–1.7 GB of Rust.
    • Trust: native code is unsandboxed. There is a red warning before every build, --trust-native-code in the CLI, and the registry lists a native mod only after a maintainer reads its source.
  • horizon-server (crates/horizon-server, docs/hosting.md):
    • Engine: [engine] path, else the current release, else beside itself, else the PATH; horizon-engine before horizon-client.
    • Updates: signed SHA256SUMS (horizon-release-sign), unpacked into releases/<tag>, current switched, rolled back with the world on a failed start.
    • Config: server.toml has no mods section and rejects unknown keys.
  • Joining: content mods are checked by a hash in the configuration phase (horizon:block_registry). Native mods aren't checked at all; docs say "only client-side hooks do anything" when joining a server.
  • #5446 and #6216 (open): the game becomes a library with a thin executable, and trait mods link into it. An edit to a trait mod rebuilds in about 7 s. Building still needs the source and a toolchain. Rust has no stable ABI, so a prebuilt game library can't be shipped for mods to link against, except for the exact pinned compiler.
  • Works by hand today: pointing [engine] path at a launcher-built horizon-client of the same OS and architecture. #6216's dedicated-server proofs ran that way. It links ALSA and udev, gets no updates, and is the player's build.

Options

A. horizon-server builds the engine itself (recommended). The launcher's build pipeline moves into a crate both use (horizon-native-build: toolchain, source, mixins, cargo, install key). The server builds with --no-default-features into releases/native-<key>/horizon-engine and switches current to it.

  • Config: server.toml gets [native]: the mods folder (horizon-native-mods/), trust_native_code (must be set, the CLI's flag), and the profile.
  • Commands: horizon-server native build and horizon-server native status.
  • Updates: horizon-server update downloads the release, rebuilds at its commit, and switches only when the build succeeds. The existing rollback covers a bad start.
  • For:
    • One pipeline for players and servers.
    • Builds on the machine that runs it, so it is right for its OS and CPU, Linux arm64 included.
    • Updates and rollback stay automatic.
    • The registry's review and the hash pins apply unchanged.
  • Against:
    • A toolchain and a C compiler on the server, plus about 3 GB of disk.
    • Minutes of CPU on a small VPS at first build and after each update. Build memory on a 2 GB VPS isn't measured yet.

B. The launcher builds a server engine for an instance and exports it. "Export server": a --no-default-features build plus the mods list, as an archive to upload.

  • For: no toolchain on the server; the launcher's UI and warnings.
  • Against:
    • Only for the player's own OS and architecture. Most servers are Linux; many players are on Windows, and cross-linking from Windows to Linux needs a linker the launcher doesn't ship.
    • The admin uploads it again after every update.
    • Hosts that only take a server folder (panels, containers) can't run the launcher.

C. cargo horizon-mod server build for people with Rust.

  • For: small; good for mod authors testing a server.
  • Against: admins without Rust are left out. It's a tool for developers, not hosting.

D. Prebuilt engines from mod authors or CI.

  • Against:
    • One build per combination of mods, versions and Horizon releases.
    • A binary nobody reviewed, where today the registry reviews source and the player's machine builds it.
  • Not recommended.

Recommendation

A, built from the launcher's own pipeline moved into a shared crate, so the two never drift apart. C then comes almost free as a thin command over the same crate. The join check (step 5) is needed whatever is chosen.

Steps (for A)

  1. Move the build core (native_mods.rs's source, patch, compile and install key, and rust_toolchain.rs) into crates/horizon-native-build, used by the launcher. A move: the launcher behaves the same.
  2. Features as a parameter: a server build (--no-default-features, horizon-engine).
  3. horizon-server: [native] in server.toml, native build and native status, install into releases/native-<key>/, refuse to start an engine built for another mod set. Docs in hosting.md.
  4. Updates: horizon-server update rebuilds before it switches, and keeps the old engine when the build fails.
  5. Joining: the server announces its native mods (ids and versions) to Horizon clients in the configuration phase. A client missing one that has a client half is told which, beside the content hash check.
  6. packaging/server/Dockerfile: an image variant with the toolchain.
  7. cargo horizon-mod server build over the same crate (option C).

Decisions needed (maintainers: Ludovic)

  • A, B or C as the supported route.
  • Whether a server may build native mods that aren't in the registry (a local folder, as --dev-mod), and behind which flag.
  • Whether the join check refuses clients missing a native mod's client half, or only warns them.
Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6304 Originally assigned to: @wxundup on GitHub. > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. Part of #4953 ("Native mod builds for dedicated servers"). A product proposal: who builds a dedicated server's game when it has native mods. It needs a maintainer's decision before any code, so nothing is claimed. ## The problem A native mod is compiled into the game. The launcher does that for a player's instance. A dedicated server has no launcher. `horizon-server` runs a release's `horizon-engine` (the game built `--no-default-features`, without sound or controllers) or `horizon-client --dedicated`, and has no idea native mods exist. docs/native-mods.md says: "Dedicated servers: native mods are not built yet." Every server-side hook (machines, pipes, recipes, commands) is therefore single player and LAN only. That is most of what #4953 builds. ## How it works today - **The launcher's build** (`launcher/src/native_mods.rs`, docs/native-mods.md "What the launcher does"): - Source: the release's commit as a GitHub tarball (about 63 MB). - Toolchain: its own pinned Rust 1.99.1, SHA-256 checked, with its own `CARGO_HOME` (`rust_toolchain.rs`). Linux and macOS need a system `cc`; Linux also needs `pkg-config` and the ALSA and udev headers. - Patching: horizon-mixins, built once at a pinned revision. - Build: `cargo build --locked --profile fast -p horizon-client`, with the default features (sound and controllers). - Install: a new version `native-<commit>-<key>` beside the base, with `native-mods.json`. - Cost: first build 4.5 min on a fast Linux desktop, 7–12 min on Windows or a loaded machine; then about 50 s, or 11 s for a mod crate change; 1.5–2 GB of `target/`, plus 0.5–1.7 GB of Rust. - Trust: native code is unsandboxed. There is a red warning before every build, `--trust-native-code` in the CLI, and the registry lists a native mod only after a maintainer reads its source. - **horizon-server** (`crates/horizon-server`, docs/hosting.md): - Engine: `[engine] path`, else the `current` release, else beside itself, else the PATH; `horizon-engine` before `horizon-client`. - Updates: signed `SHA256SUMS` (`horizon-release-sign`), unpacked into `releases/<tag>`, `current` switched, rolled back with the world on a failed start. - Config: `server.toml` has no mods section and rejects unknown keys. - **Joining:** content mods are checked by a hash in the configuration phase (`horizon:block_registry`). Native mods aren't checked at all; docs say "only client-side hooks do anything" when joining a server. - **#5446 and #6216 (open):** the game becomes a library with a thin executable, and trait mods link into it. An edit to a trait mod rebuilds in about 7 s. Building still needs the source and a toolchain. Rust has no stable ABI, so a prebuilt game library can't be shipped for mods to link against, except for the exact pinned compiler. - **Works by hand today:** pointing `[engine] path` at a launcher-built `horizon-client` of the same OS and architecture. #6216's dedicated-server proofs ran that way. It links ALSA and udev, gets no updates, and is the player's build. ## Options **A. `horizon-server` builds the engine itself (recommended).** The launcher's build pipeline moves into a crate both use (`horizon-native-build`: toolchain, source, mixins, cargo, install key). The server builds with `--no-default-features` into `releases/native-<key>/horizon-engine` and switches `current` to it. - Config: `server.toml` gets `[native]`: the mods folder (`horizon-native-mods/`), `trust_native_code` (must be set, the CLI's flag), and the profile. - Commands: `horizon-server native build` and `horizon-server native status`. - Updates: `horizon-server update` downloads the release, rebuilds at its commit, and switches only when the build succeeds. The existing rollback covers a bad start. - For: - One pipeline for players and servers. - Builds on the machine that runs it, so it is right for its OS and CPU, Linux arm64 included. - Updates and rollback stay automatic. - The registry's review and the hash pins apply unchanged. - Against: - A toolchain and a C compiler on the server, plus about 3 GB of disk. - Minutes of CPU on a small VPS at first build and after each update. Build memory on a 2 GB VPS isn't measured yet. **B. The launcher builds a server engine for an instance and exports it.** "Export server": a `--no-default-features` build plus the mods list, as an archive to upload. - For: no toolchain on the server; the launcher's UI and warnings. - Against: - Only for the player's own OS and architecture. Most servers are Linux; many players are on Windows, and cross-linking from Windows to Linux needs a linker the launcher doesn't ship. - The admin uploads it again after every update. - Hosts that only take a server folder (panels, containers) can't run the launcher. **C. `cargo horizon-mod server build` for people with Rust.** - For: small; good for mod authors testing a server. - Against: admins without Rust are left out. It's a tool for developers, not hosting. **D. Prebuilt engines from mod authors or CI.** - Against: - One build per combination of mods, versions and Horizon releases. - A binary nobody reviewed, where today the registry reviews source and the player's machine builds it. - Not recommended. ## Recommendation A, built from the launcher's own pipeline moved into a shared crate, so the two never drift apart. C then comes almost free as a thin command over the same crate. The join check (step 5) is needed whatever is chosen. ## Steps (for A) 1. Move the build core (`native_mods.rs`'s source, patch, compile and install key, and `rust_toolchain.rs`) into `crates/horizon-native-build`, used by the launcher. A move: the launcher behaves the same. 2. Features as a parameter: a server build (`--no-default-features`, `horizon-engine`). 3. `horizon-server`: `[native]` in `server.toml`, `native build` and `native status`, install into `releases/native-<key>/`, refuse to start an engine built for another mod set. Docs in hosting.md. 4. Updates: `horizon-server update` rebuilds before it switches, and keeps the old engine when the build fails. 5. Joining: the server announces its native mods (ids and versions) to Horizon clients in the configuration phase. A client missing one that has a client half is told which, beside the content hash check. 6. `packaging/server/Dockerfile`: an image variant with the toolchain. 7. `cargo horizon-mod server build` over the same crate (option C). ## Decisions needed (maintainers: Ludovic) - A, B or C as the supported route. - Whether a server may build native mods that aren't in the registry (a local folder, as `--dev-mod`), and behind which flag. - Whether the join check refuses clients missing a native mod's client half, or only warns them.
Author
Owner

@wxundup commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

Implementing the same-platform dedicated native-engine build/export path through the existing launcher pipeline, following team approval relayed by wxundup. Scope: headless compile, separate build identity, independently retained export, tests and operator/developer documentation. Shared server-side build orchestration and automatic update rebuilding remain follow-up work.

<!-- gh-comment-id:6563950451 --> @wxundup commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim Implementing the same-platform dedicated native-engine build/export path through the existing launcher pipeline, following team approval relayed by wxundup. Scope: headless compile, separate build identity, independently retained export, tests and operator/developer documentation. Shared server-side build orchestration and automatic update rebuilding remain follow-up work.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2047
No description provided.