diff options
Diffstat (limited to '')
-rw-r--r-- | docs/embedding_luarocks_in_an_application.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/embedding_luarocks_in_an_application.md b/docs/embedding_luarocks_in_an_application.md new file mode 100644 index 00000000..008be1d4 --- /dev/null +++ b/docs/embedding_luarocks_in_an_application.md | |||
@@ -0,0 +1,36 @@ | |||
1 | # Embedding LuaRocks in an application | ||
2 | |||
3 | You can use LuaRocks bundled inside your application, for example, to install | ||
4 | application-specific extension modules. Packaging those extensions or plugins | ||
5 | as rocks reduces maintenance overhead and allows the user to perform updates. | ||
6 | |||
7 | In this scenario, it is not desirable to have the application-specific | ||
8 | LuaRocks and any other copy of LuaRocks installed by the user (or other | ||
9 | applications!) to interfere with each other. For this reason, the `configure` | ||
10 | script allows hardcoding the location of a configuration file. For example, | ||
11 | the compilation process of a package bundling LuaRocks could do something like | ||
12 | this: | ||
13 | |||
14 | ```bash | ||
15 | export PREFIX=$HOME/my-app/ | ||
16 | ./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config | ||
17 | ``` | ||
18 | |||
19 | The copy of LuaRocks installed in `$HOME/my-app/` will ignore customization | ||
20 | schemes such as the `$LUAROCKS_CONFIG` environment variable and will only use | ||
21 | `$HOME/my-app/luarocks/config-5.x.lua`. | ||
22 | |||
23 | An interesting option in those cases is for the application to provide in its | ||
24 | configuration file an URL for their own rocks repository, so they can have | ||
25 | control over updates to be performed. Continuing the previous example, the | ||
26 | config-5.x.lua file could contain something like this: | ||
27 | |||
28 | ```lua | ||
29 | rocks_servers = { | ||
30 | "http://www.example.com/my-app-plugins/rocks/" | ||
31 | } | ||
32 | ``` | ||
33 | |||
34 | This way the bundled copy of LuaRocks will download rocks from your app's | ||
35 | plugins and not the https://luarocks.org server (note that the user would | ||
36 | still be able to override it explicitly using the `--server` flag). | ||