A rebar3 template for building Erlang NIF (Native Implemented Function) projects with Rust using Rustler.
Scaffold Erlang/Rust hybrid projects with a single rebar3 command.
Add the following to your global rebar3 configuration at ~/.config/rebar3/rebar.config:
{plugins, [
{erlrustnif, {git, "https://github.com/JayKickliter/erlrustnif.git", {branch, "main"}}}
]}.Copy the template directory to your rebar3 templates location:
cp -r priv/templates/erlrustnif ~/.config/rebar3/templates/rebar3 new erlrustnif myproject
cd myproject
rebar3 compile
rebar3 eunitEach generated project includes:
- Erlang module with NIF loader and public API
- Rust NIF implementation using Rustler framework
- EUnit tests
- GitHub Actions workflows for macOS and Linux
- Automatic Rust compilation via
rebar3 - Code quality tools: dialyzer, erlfmt, clippy, rustfmt
Rust crates are named {{name}}-native to avoid naming collisions in
workspaces.
Automatically detects the platform (Linux, macOS, Windows) and generates appropriate library extensions.
Pre-compile hooks automatically build Rust code with cargo build --release, copy the compiled library to priv/ with .so extension,
and load the NIF on module initialization.
The Erlang module automatically discovers the compiled native library from multiple locations, working both in development and when installed as a package.
Includes testing, code quality checks, CI/CD pipelines, and documentation generation.
Generated projects require:
- Erlang/OTP: 27 or later
- Rust: Stable toolchain
rebar3: 3.24.0 or later
Dual licensed under Apache License 2.0 or MIT license at your option.