nyrapkg

Standalone package manager for Nyra — like cargo for Rust. Repository: github.com/nyra-lang/pkg.

Split: Dependency management moved out of the nyra compiler CLI into nyrapkg. The nyra pkg command remains for build helpers only (build, prune, c, bind) — not init / add / install / verify.

Install layout

nyrapkg shares the Nyra install root (default ~/.nyra):

~/.nyra/
├── bin/
│   ├── nyra       # compiler (nyra-lang/nyra)
│   └── nyrapkg    # package manager (nyra-lang/pkg)
├── config         # registry=http://127.0.0.1:9470
└── lib/           # optional LLVM / WASI toolchain
curl -fsSL https://raw.githubusercontent.com/nyra-lang/pkg/main/scripts/install.sh | sh # Or from source export NYRA_HOME=~/.nyra nyra build --release -o nyrapkg /path/to/pkg nyrapkg bootstrap export PATH="$HOME/.nyra/bin:$PATH" nyrapkg --version

nyrapkg commands (dependencies)

nyrapkg init [path]                 # scaffold nyra.mod + main.ny + lock files
nyrapkg add ny-sqlite ^0.1.0        # add require + fetch + update lock
nyrapkg install ny-serde@^0.1.0     # alias for add
nyrapkg install                     # sync lock from existing require lines
nyrapkg sync [path]                 # same as bare install (manual edit → fetch)
nyrapkg verify [path]               # nyra.mod ↔ nyra.lock ↔ nyra.sum

nyrapkg --version                   # nyrapkg + nyra versions
nyrapkg which                       # NYRA_HOME, bin paths
nyrapkg bootstrap                   # copy binary → ~/.nyra/bin/nyrapkg
nyrapkg self update [version]       # update nyrapkg from releases
nyrapkg toolchain update [version]  # update nyra compiler (~/.nyra)
nyrapkg update nyra|self [version]  # aliases

nyra pkg commands (toolchain)

Still part of the compiler — native linking, C bindings, and project build:

nyra pkg build [path]              # verify lock + compile
nyra pkg prune [--check]           # remove unused imports / prefix locals
nyra pkg c add raylib              # system C lib (one command)
nyra pkg c list | c remove NAME
nyra pkg bind c vendor/api.h --lib foo --update-mod

Project files after nyrapkg init

nyrapkg init (or nyra pkg init) scaffolds a full NyraPkg project. Each file has a clear job:

FileLike…Role
main.nysrc/main.rs / index.jsEntry point — fn main() Hello World sample. Edit this to build your app. Run with nyra run ..
nyra.modCargo.toml / package.jsonModule name, optional tls, require, link / link-source. You may edit this by hand. Full directive list: nyra.mod syntax.
nyra.lockCargo.lock / package-lock.jsonPinned dependency versions (JSON). Rewritten by nyrapkg sync, add/install, or automatically before nyra run/build.
nyra.sumchecksum / integrityPer-module checksums checked by nyrapkg verify and nyra pkg build.
.nyra/cache/vendor/ / cargo registry cacheFetched package sources. Created when dependencies are installed or auto-synced.
target/target/Build output (debug/main, IR, incremental cache). Created by nyra build / nyra run — not by init.

nyra.mod syntax reference

nyra.mod is a line-oriented manifest (not TOML/JSON). One directive per line. Unknown lines are ignored, so a full line like # note is fine as a comment; do not put # … after a directive on the same line.

Minimal project (what nyrapkg init creates):

module myapp.local

That single line is enough to run nyra run .. Everything below is optional.

DirectiveRequired?What it doesExample
module <name> Yes (practically) Project / package identity. Stored in nyra.lock. Use a simple name (myapp.local) or a path-style id (github.com/you/app). module example.local
version <semver> No Your package version when publishing / describing this module. version 1.0.0
tls <backend> No HTTPS client backend for get("https://…") and friends. Default if omitted: rustls (bundled). Allowed values: rustls (stable default), native (Secure Transport / SChannel / Linux OpenSSL — stable), openssl (optional system OpenSSL). Pinned in nyra.lock as features.tls. tls rustls
require <pkg> [constraint] No NyraPkg dependency. Name + optional semver (^0.1.0), or a Git URL. Auto-synced on nyra run . / nyra build .. require ny-sqlite ^0.1.0
link <lib> No Native linker library (-l). Also: link -L /path for search paths, or other link -… flags. link sqlite3
link-source <file.c> No Compile a C file into this project at nyra build. link-source rt/sqlite.c
link-crate <name> No Rust crate bridge used with bind/bindgen workflows. link-crate uuid
link-arg <flag> No Extra linker argument passed through as-is. link-arg -framework
pgo-run <args…> No Arguments for the instrumented binary during nyra build --pgo. pgo-run --bench

Full example:

module github.com/you/myapp
version 1.0.0
tls rustls

require ny-sqlite ^0.1.0
require https://github.com/example/ny-lib

link sqlite3
link-source vendor/shim.c

What you usually do day to day:

TLS backends status (what works today): see net/http → TLS backends.

Add a library by hand in nyra.mod

You do not have to use nyrapkg add. Edit nyra.mod directly — just like editing Cargo.toml — then let Nyra fetch the package:

# nyra.mod
module myapp.local
version 1.0.0

require ny-sqlite ^0.1.0
require https://github.com/example/ny-lib

link sqlite3

Then either:

# after editing nyra.mod (add or remove require lines):
nyra run .
# → Syncing dependencies …
# → compiles and runs

# or sync only:
nyrapkg sync
# / nyrapkg install

Remove a library

Delete the require … line from nyra.mod, then nyra run . (or nyrapkg sync). Nyra drops that package from nyra.lock / nyra.sum and deletes .nyra/cache/<name>/.

# was:
require ny-sqlite ^0.1.0

# remove that line, then:
nyra run .
# → removing unused package 'ny-sqlite'

Prefer nyrapkg add ny-sqlite ^0.1.0 when you want the CLI to append the require line for you.

Files

FileRole
nyra.modModule name, require list, optional tls rustls|native|openssl
nyra.lockPinned dependencies (JSON)
nyra.sumChecksums per module
.nyra/cache/Downloaded Git / local modules

CLI commands (historical reference)

The block below listed the old monolithic nyra pkg surface. Use the split above in new projects.

# Dependencies → nyrapkg
nyrapkg init
nyrapkg install ny-sqlite@^0.1.0
nyrapkg verify

# Toolchain → nyra pkg
nyra pkg c add raylib
nyra pkg build
nyra pkg prune --check
nyra run .

nyra pkg prune

Removes unused code from a project — similar to cargo fix for lint warnings. Applies safe, automatic edits based on W002 (unused import) and W003 (unused variable).

# Apply fixes
nyra pkg prune

# Dry run (report only, no edits; exits 1 if unused code found)
nyra pkg prune --check

# Specific project directory
nyra pkg prune --path ./myapp
LintAction
W002 unused importRemoves the whole-module import "…" line (selective unused names warn only)
W003 unused variablePrefixes the name with _ (e.g. let deadlet _dead)

Prefixing unused locals is safer than deleting let statements when the initializer might have side effects.

Example — before:

import "src/unused.ny"
fn main() {
    let dead = 99
    print("ok")
}

After nyra pkg prune:

fn main() {
    let _dead = 99
    print("ok")
}

Implementation: compiler/lint/src/prune.rs · Compiler::prune_project() in the driver · CLI: cli/src/commands/pkg.rs. Tests: cargo test -p lint, cargo test -p compiler --test pkg_prune, fixture tests/fixtures/prune_unused/.

System C libraries (nyra pkg c)

One command — no manual -I paths or Homebrew keg paths:

nyra pkg c add raylib      # brew install + full bind + nyra.mod
nyra pkg c add zlib
nyra pkg c list
nyra pkg c remove raylib

import "vendor/bindings/raylib.ny"

Manifest: vendor/bindings/c-libs.toml. See C Bindgen.

Bind a system C library (manual)

Generate extern fn from a system header without a NyraPkg wrapper. Step-by-step: C Bindgen → zlib.

brew install zlib llvm
SDK=$(xcrun --show-sdk-path)
nyra pkg bind c /opt/homebrew/opt/zlib/include/zlib.h --lib z \
  -I /opt/homebrew/opt/zlib/include -I "$SDK/usr/include" \
  --export zlibVersion -o vendor/bindings/zlib.ny

# nyra.mod
link z
link -L /opt/homebrew/opt/zlib/lib

import "vendor/bindings/zlib.ny"

Install a package (ny-sqlite)

nyrapkg init
nyrapkg install ny-sqlite@^0.1.0   # semver, cache, link sqlite3 + rt/sqlite.c

import "pkg/ny-sqlite"

Serialization

Document JSON ships in stdlib — no package or nyra bind required:

import "stdlib/json/mod.ny"
let obj = parse_json("{\"ok\":true}")
print(stringify_json(obj))

Schema traits: stdlib/serde/mod.ny. Legacy shim: examples/packages/ny-serde (re-exports stdlib). Full TOML still uses NyraPkg:

nyrapkg install ny-toml@^0.1.0
nyra bind rust toml --template
import "pkg/ny-toml/toml.ny"

Example: examples/serde_json_pkg.ny · bundled sources: examples/packages/ny-serde (shim), examples/packages/ny-toml.

Packages land in .nyra/cache/<name>/ inside your project. Sources: bundled examples (dev with NYRA_HOME), HTTP registry (default http://127.0.0.1:9470 in ~/.nyra/config), or Git URLs. Native link lines merge into your nyra.mod; link-source .c files compile at nyra build.

Design (v1)

Semver constraints (^, ~, >=), optional HTTP registry, and package link-source for automatic .c linking at build time. nyrapkg is implemented in Nyra; the compiler reads the resulting lock files at link time.

nyra.mod example

module github.com/you/myapp
version 1.0.0
tls rustls

require ny-sqlite ^0.1.0
require https://github.com/example/ny-lib

link sqlite3
link-source vendor/shim.c

tls selects the HTTPS client backend (default rustls, bundled as libnyra_rt_tls.a). The choice is pinned in nyra.lock under features.tls. Status of each backend today: net/http → TLS backends. Full directive list: nyra.mod syntax.

Git dependencies

URLs in require trigger git clone / git fetch into .nyra/cache/ on nyrapkg sync, add/install, or automatically before nyra run/build. nyra pkg build verifies nyra.sum against nyra.lock before compiling.

Import paths

ImportResolves to
import "pkg/ny-sqlite".nyra/cache/ny-sqlite/ after nyrapkg install/sync or auto-fetch on nyra run
import "pkg/ny-serde/serde.ny"Compatibility shim → stdlib parse_json / stringify_json (prefer stdlib/json/mod.ny)
import "pkg/ny-toml/toml.ny"TOML parse_toml / stringify_toml via rust::toml
import "stdlib/vec.ny"$NYRA_HOME/share/stdlib/ or repo stdlib/

Registry

Configure in ~/.nyra/config:

registry=http://127.0.0.1:9470

nyrapkg resolves packages over HTTP/JSONL or from Git URLs. A local registry server may ship with the pkg repository when needed for development.

Reference packages

Bundled under examples/packages/ in the Nyra repo for development — same pattern as production packages:

PackageNative libImport
ny-sqlitelibsqlite3import "pkg/ny-sqlite"
ny-serdestdlib shim (no native lib)import "pkg/ny-serde/serde.ny" — prefer stdlib/json/mod.ny
ny-tomlrust::tomlimport "pkg/ny-toml/toml.ny"
ny-redishiredisimport "pkg/ny-redis"
ny-postgreslibpqimport "pkg/ny-postgres"
ny-mysqllibmysqlclientimport "pkg/ny-mysql"

Each ships link-source rt/*.c shims — Nyra app code calls extern fn; heavy work stays in the C library. See C Bindgen and FFI & ABI.