name: user-app-development description: Guide for developing, building, and running Nanvix user-space applications across supported runtimes and languages. Use this when asked about guest app implementation or execution.
User Application Development
Use this skill when the user asks about developing, building, or running user-space applications on Nanvix. User applications are programs that run inside the Nanvix guest environment.
Supported Languages and Examples
| Application | Path | Lang | Runtime |
|---|---|---|---|
hello-rust-nostd |
src/user/hello-rust-nostd/ |
Rust | Bare-metal |
Running Applications
Interactive Mode (recommended for development)
# Run a native application with console output.
./bin/nanvixd.elf \
-console-file /dev/stdout \
-- ./bin/hello-rust-nostd.elf
# Pass arguments to the application.
./bin/nanvixd.elf \
-console-file /dev/stdout \
-- ./bin/echo-rust-nostd.elf arg1 arg2
# Pass arguments and environment variables.
./bin/nanvixd.elf \
-console-file /dev/stdout \
-- ./bin/echo-rust-nostd.elf \
"arg1 arg2;VAR1=foo VAR2=bar"
# Pass arguments, environment variables, and kernel arguments.
# Format: "<app args>;<env vars>;<kernel args>"
./bin/nanvixd.elf \
-console-file /dev/stdout \
-- ./bin/echo-rust-nostd.elf \
"arg1 arg2;VAR1=foo;feature1 feature2"
HTTP Mode (for multi-application scenarios)
# Start nanvixd in HTTP mode.
NANVIX_HTTP_ADDR=127.0.0.1:8080
./bin/nanvixd.elf -http-addr $NANVIX_HTTP_ADDR
# Spawn an application via HTTP (in another terminal).
curl --silent \
--header "Content-Type: application/json" \
--header "X-NVX-Message-Type: NEW" \
--request POST \
--data '{"tenant_id":"foo",
"app_name":"bar",
"program":"./bin/hello-rust-nostd.elf",
"program_args":""}' \
http://${NANVIX_HTTP_ADDR}
Standalone UserVM Mode (expert/debugging)
./bin/uservm.elf \
-kernel ./bin/kernel.elf \
-initrd ./bin/hello-rust-nostd.elf \
-standalone
Running on Windows
On Windows, nanvixd supports standalone interactive mode (no HTTP mode). Both nanvixd and the
UserVM are built natively with the WHP backend:
# Run via nanvixd (recommended).
.\bin\nanvixd.exe -- .\bin\hello-rust-nostd.elf
You can also launch a run via z.ps1:
# Run with default options.
.\z.ps1 run
# Run with a custom guest binary.
.\z.ps1 run -- -program bin\hello-rust-nostd.elf
For low-level debugging, the standalone UserVM is still available:
.\bin\uservm.exe -kernel .\bin\kernel.elf -initrd .\bin\hello-rust-nostd.elf -standalone
Note: HTTP mode is Linux-only. On Windows, only standalone interactive mode via
nanvixdis supported.
Creating a New Rust Application (no_std)
Create directory at
src/user/<name>/.Add
Cargo.toml:[package] name = "<name>" version.workspace = true license-file.workspace = true authors.workspace = true edition.workspace = true [[bin]] name = "<name>" path = "src/main.rs" [dependencies] nvx = { workspace = true } sys = { workspace = true } syslog = { workspace = true }Create
src/main.rs:// Copyright(c) The Maintainers of Nanvix. // Licensed under the MIT License. #![no_std] #![no_main] extern crate alloc; // Application entry point.Add to workspace
membersin rootCargo.toml.Add to
ALL_GUEST_APPLICATIONSin theMakefile.
Creating a New C Application
- Create directory at
src/user/<name>/. - Create a
Makefilefollowing the pattern in existing C applications. - Write source files using the Nanvix POSIX layer (
#include <nanvix/...>). - The application links against
libposix.a,libc.a, and the custom linker script atbuild/user/linker/x86/user.ld.
Logging
- Use
RUST_LOGenvironment variable fornanvixddaemon-level logging. - Guest-side logging uses the
syslogcrate (error!,warn!,info!,debug!,trace!). - Console output defaults to
logs/directory; use-console-file /dev/stdoutto redirect to terminal.