It's an exciting day at Cloudsmith HQ, today we're launching beta support for hosted private LuaRocks module repositories.

Created in Brazil in the early 90s, Lua is a lightweight language, designed primarily for embedding into other applications. Lua has a focus on speed, portability and extensibility, making it the perfect choice in many situations. Lua works equally well on all major platforms, whether you prefer Linux, Mac or Windows.

LuaRocks is the package manager for Lua. LuaRocks is responsible for downloading, building and installing dependencies, known as Rocks. The primary source of open-source LuaRocks is the official LuaRocks module repository. LuaRocks.org is a community-run hosting service for Lua modules and provides a valuable resource which is central to the Lua ecosystem. Anyone can upload Rocks for distribution, either in the main repository or in a per-user repository which is provided by the service.

Whilst LuaRocks.org is the main repository for rocks, LuaRocks provides all the necessary tooling and configuration flags to easily allow pointing at another repository if needed. Cloudsmith, as of today, can provide an alternative repository for hosting your rocks as needed.

There are a number of great reasons you may wish to run your own private repository:

  • To develop Lua modules internally and share them privately to other teams.
  • To distribute and deploy your own Lua modules in a pipeline at your org.
  • To distribute Lua modules as vendored software (i.e. maybe commercially).
  • To make modifications to public Lua modules, without republishing publicly.
  • To mirror public Lua modules, to isolate from uncontrolled upstream issues.
  • To capture the exact state of your dependencies at a particular version/release.
  • To control (whitelist/blacklist) the exact Lua modules allowed for your org.
  • To keep track of the exact versions/releases of Lua modules you have/use.

If you're interested in the possibilities that hosting your own rocks brings, then Cloudsmith is here for you. Sign up today to begin hosting and distributing your Lua modules at the world's first hosted private Lua modules repository service.

See also:

Getting started

Getting started with Cloudsmith and LuaRocks couldn't be simpler. First, you'll need a Cloudsmith account and a repository to which you can upload your modules.

If you need to install Lua and LuaRocks you can find instructions on the Lua website and the LuaRocks wiki.

Cloudsmith should work with all supported versions of LuaRocks, but we reccomend using at least version 3.0 or later for the best experience. You can check your local version like so:

$ luarocks --version
/usr/local/bin/luarocks 3.1.3
LuaRocks main command-line interface

Uploading your module

Next, you'll need a rock for uploading to Cloudsmith. LuaRocks has several methods for doing so, you can create source, binary or metadata-only rocks. For full documentation on creating your own rocks, see the tutorial on the LuaRocks wiki.

For demonstration purposes we'll use a rock from LuaRocks.org named cloudsmith-example.

Next, you can push the module to Cloudsmith using the Cloudsmith CLI. We don't yet support uploading modules with luarocks upload, but we'll be adding support in a future release (if you want it, please let us know). For now, use the CLI.

First, ensure you've installed the Cloudsmith CLI and configured authentication:

$ pip install cloudsmith-cli
$ export CLOUDSMITH_API_KEY=xxxxx

Then, use the CLI to upload the module, which operates like luarocks upload but is specific to Cloudsmith:

$ cloudsmith push luarocks my-org/my-repo cloudsmith-example-1.0-2.src.rock

Checking luarocks package upload parameters ... OK
Checking cloudsmith-example-1.0-2.src.rock file upload parameters ... OK
Requesting file upload for cloudsmith-example-1.0-2.src.rock ... OK
Uploading cloudsmith-example-1.0-2.src.rock:  [####################################]  100%
Creating a new luarocks package ... OK
Created: my-org/my-repo/cloudsmith-example-10-2srcrock (tvFNIpDZ3uhy)

Synchronising cloudsmith-example-10-2srcrock:  [####################################]  100%  Sync Completed / Fully Synchronised
Package synchronised successfully!

Your repository should now contain the uploaded modules. An example of which is our official Cloudsmith examples repository (this is where we upload our examples to), as shown below:

Install your Lua modules from Cloudsmith

Installing packages from a custom LuaRocks server couldn't be simpler, we only need to pass a single command-line argument to specify the location of the custom repository:

$ luarocks install cloudsmith-example \
  --server https://dl.cloudsmith.io/TOKEN/my-org/my-repo/luarocks
Installing https://dl.cloudsmith.io/TOKEN/my-org/my-repo/luarocks/cloudsmith-example-4.1-1.rockspec

cloudsmith-example 4.1-1 is now installed in /usr/local (license: MIT <http://opensource.org/licenses/MIT>)

If required, you can configure the repository centrally in your LuaRocks config file too.

It really is that simple, and now you've sourced a module privately from your very own private Lua module repository on Cloudsmith. Well done!

One small step for man...

Cloudsmith provides fully featured Lua module repositories on all plans, flexible enough for use whether you’re hosting public modules for a public or open source project, or private modules for your company’s internal needs. We're extremely proud to be able to support the Lua ecosystem with this tooling.

You can find further, context-specific information, including detailed setup and integration instructions inside each Cloudsmith repository. You can see an example of this documentation in our public examples repository.

Why wait? Get your public and private Lua module repository hosting at Cloudsmith now.