Skip to main content

How to use Lux with a rockspec file

This guide shows you how to use an existing LuaRocks rockspec with Lux.

note

Use this guide if you have an existing rockspec and prefer not to migrate to TOML. For new projects, the TOML format is recommended.

Create a project​

lx new .

Add the rockspec​

Place your rockspec in the project root as extra.rockspec:

extra.rockspec
package = "say"
version = "0.1.0-1"

source = {
url = "git+https://github.com/my/project",
}

build = {
type = "builtin",
modules = {
say = "src/my-project/init.lua"
}
}

Behaviour​

Lux prioritizes rockspec data over TOML. If both files define the same field (e.g. version or source), the rockspec value is used and the TOML value is ignored.

Clean up​

Remove fields from extra.rockspec that your TOML already covers. You can omit fields that would normally be required. Lux falls back to the TOML for anything not in the rockspec.

Example of a rockspec that only overrides the build table:

extra.rockspec
build = {
type = "builtin",
modules = {
say = "src/my-project/init.lua"
}
}

See lx generate-rockspec --help and lx install-rockspec --help for CLI options.