aboutsummaryrefslogtreecommitdiff
path: root/docs/config_file_format.md
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/config_file_format.md226
1 files changed, 226 insertions, 0 deletions
diff --git a/docs/config_file_format.md b/docs/config_file_format.md
new file mode 100644
index 00000000..3cbe5deb
--- /dev/null
+++ b/docs/config_file_format.md
@@ -0,0 +1,226 @@
1# Config file format
2
3The LuaRocks configuration file is a Lua file containing assignments. Default
4values are assumed for variables that are not assigned explicitly.
5
6The location of the configuration file can be configured through flags during
7installation. If no `--force-config` or `/FORCECONFIG` flags were used on
8installation, the `LUAROCKS_CONFIG` environment variable can be used as well
9(or for a particular Lua version, `LUAROCKS_CONFIG_5_2`, similar to the
10`LUA_PATH_5_2` feature introduced in Lua 5.2).
11
12The default value is platform-dependent; exact paths depend on flags given
13during installation, but on Unix systems it would be something like
14`/etc/luarocks/config.lua` or `/etc/luarocks/config-5.1.lua` for older
15versions of lua; on Windows systems, `c:\luarocks\config.lua`.
16
17Specifically on Unix systems, the following directories are searched (in this
18order) for a user config file:
19
20* `$XDG_CONFIG_HOME/luarocks/`.
21* `$HOME/.config/luarocks/`.
22* `$HOME/.luarocks/`.
23
24# Locations
25
26* `rocks_trees` (array of strings or tables) - The path to the local rocks
27 trees, where rocks are installed. When installing rocks, LuaRocks tries to
28 pick a location to store the rock starting from the bottom of the list; when
29 loading rocks in runtime, LuaRocks scans from the top of the list. This way,
30 if one has the local dir first and the system-wide dir last (this is what
31 the default installation does, for instance), rocks installed by the user
32 take precedence over rocks installed system-wide, and rocks installed by the
33 admin user go to the system-wide dir while user installations go to their
34 home directory. An entry in this table can be:
35 * a string, denoting the prefix of a tree. For example: `home.."/.luarocks"`
36 * a table, where deployment subdirectories of a tree can be further
37 customized. The 'root' field is mandatory; 'bin_dir', 'lib_dir' and
38 'lua_dir' are optional. Example: `{ root = home.."/local", bin_dir =
39 home.."/local/arch/bin", lib_dir = home.."/local/arch/lib/lua/5.1",
40 lua_dir = home.."/local/share/lua/5.1" }`
41
42* `rocks_servers` (array of strings) - Remote URLs or local pathnames of rocks
43 servers: directories containing .rock or .rockspec files, and a "manifest"
44 file, generated by the luarocks-admin make_manifest command. Default is {
45 "http://luarocks.org/repositories/rocks" }.
46
47* `external_deps_dirs` (array of strings) - Where to look for external
48 dependencies, when a prefix is not set for a specific dependency in the
49 _variables_ table (see below) or through the command-line. Default is {
50 "/usr/local", "/usr" } on Unix; { "c:\\external" } on Windows.
51
52* `external_deps_subdirs` (table with string keys and string values) -
53 Subdirectories to be used in conjunction with external_deps_dirs. Specifies
54 where to look for specific types external dependencies. This can be
55 overriden, for example, on Linux distributions which feature multiarch
56 libraries and libraries are no longer in the "lib" subdir. Default is { bin
57 = "bin", lib = "lib", include = "include" }.
58
59* `runtime_external_deps_subdirs` (table with string keys and string values) -
60 Same as the above, to be used with _luarocks install_.
61
62* `lib_modules_path` (string) - The path where modules with native C
63 extensions will be installed. If you are using a x86_64 *nix OS, you will
64 probably need this line in `config.lua`:
65 `lib_modules_path="/lib64/lua/"..lua_version`. See [issue
66 416](https://github.com/keplerproject/luarocks/issues/416).
67
68# File upload
69
70* `upload_server` (string) - An FTP URL for a rock server (optionally
71 including username and password), or an alias specified in the
72 upload_servers table. Example:
73 `"ftp://_user_:_password_@ftp.luarocks.org/repositories/rocks"`
74
75* `upload_user` (string) - Default login name rock servers.
76
77* `upload_password` (string) - Default password rock servers.
78
79* `upload_servers` (table with string keys and table values) - A list of
80 aliases for URLs, to be used for accessing repositories through various
81 protocols. Each entry has a string alias as a key and a table as a value.
82 This table value contains protocol names as keys and pathnames as values.
83 Protocols "http", "ftp" and "sftp" are supported. Example: `{ rocks = { http
84 = "www.example.com/rocks", sftp = "example.com/var/rocks" } }`
85
86# Platform-specific settings
87
88* `lua_extension` (string) - Filename extension of Lua files (without the
89 dot/separator). Default is "lua".
90
91* `lib_extension` (string) - Filename extension of dynamic library files
92 (without the dot/separator). Default is "so" on Unix; "dll" on Windows.
93
94* `arch` (string) - A two-part string identifying operating system and
95 hardware architecture, for filtering binary rocks. This value is
96 autodetected by LuaRocks. Example values are "macosx-powerpc" and
97 "win32-x86".
98
99* `platforms` (array of string) - A list of string identifiers indicating
100 which platform constraints can be satisfied by the running system. This is
101 used for filtering commands on the LuaRocks build rules. This allows a more
102 general platform definition such as "unix" when the same build commands are
103 valid for all Unix variants, instead of enumerating all known valid arch
104 entries, and at the same time using a more specific definition such as
105 "macosx" when a platform-specific flag is used. This value is automatically
106 filled according to the value of _arch_.
107
108* `external_deps_patterns` (table) - Name patterns to be used when matching
109 dependencies in a [portable
110 way](platform_agnostic_external_dependencies.md).
111
112* `runtime_external_deps_patterns` (table) - Name patterns to be used by
113 _luarocks install_ when matching dependencies in a [portable
114 way](platform_agnostic_external_dependencies.md).
115
116* `link_lua_explicitly` (boolean) - Link the Lua library to the built modules
117 when using the builtin mode (this is set to true for Cygwin).
118
119# Variables
120
121* `variables` (table) - A table containing string-to-string key-value pairs
122 containing variables to be substituted by build rules in rockspecs. LuaRocks
123 provides a general facility for build back-ends in which they can substitute
124 the entries of this table in strings containing references written
125 $(LIKE_THIS). Some standard variables are expected by the included
126 back-ends. For example, the "make" back-end expects the LIBFLAG to contain
127 the flag to be passed to the C compiler to instruct it to build a shared
128 library. So, in Linux systems, `variables["LIBFLAG"] = "-shared"`.
129
130After reading the user entries, LuaRocks dynamically adds entries to this
131table that refer to the rock being compiled, to make values available to the
132build back-end. These are:
133
134* `PREFIX` - The installation prefix of the rock (absolute path inside the
135 rocks tree). Example: `"/home/hisham/.luarocks/5.1/foo/1.0-1/"`
136
137 * `LUADIR` - Directory for storing Lua modules written in Lua (absolute path
138 inside the rock entry of the rocks tree). Example:
139 `"/home/hisham/.luarocks/5.1/foo/1.0-1/lua/"`
140
141 * `LIBDIR` - Directory for storing Lua modules written in C (absolute path
142 inside the rock entry of the rocks tree). Example:
143 `"/home/hisham/.luarocks/5.1/foo/1.0-1/lib/"`
144
145 * `BINDIR` - Directory for storing command-line scripts (absolute path
146 inside the rock entry of the rocks tree). Example:
147 `"/home/hisham/.luarocks/5.1/foo/1.0-1/bin/"`
148
149 * `CONFDIR` - Directory for storing configuration files for a module
150 (absolute path inside the rock entry of the rocks tree). Example:
151 `"/home/hisham/.luarocks/5.1/foo/1.0-1/conf/"`
152
153Such entries should not be added by the user in the configuration file, as
154they are dynamically constructed for each different rock. If you need to
155customize the various locations where files are deployed in a tree, use the
156table syntax for `rocks_trees` entries (see above).
157
158<font color="green">(since 2.0.5)</font> You can also override external
159commands called by LuaRocks by using entries in the _variables_ table, in case
160you need to customize the way they are called. Note that by installing
161appropriate Lua modules, most of these external command invocations can be
162avoided. Currently recognized entries in the _variables_ table are:
163
164* `MAKE` for build.type="make";
165
166* `CC, LD` (and `RC` on Windows) for build.type="builtin";
167
168* `CVS, GIT, SSCM, SVN` for their respective download protocols;
169
170* `RSYNC, SCP` for luarocks-admin operations;
171
172* `WGET` or `CURL` when LuaSocket is not installed;
173
174* `PWD, MKDIR, RMDIR, CP, LS, RM, FIND, TEST, CHMOD, STAT` when LuaFileSystem
175 is not installed;
176
177* `ZIP` when Lua-Zlib is not installed;
178
179* `UNZIP` when LuaZip is not installed;
180
181* `GUNZIP, BUNZIP2, TAR` on Unix or `SEVENZ` on Windows for source extraction
182 during "luarocks build";
183
184* `MD5SUM, OPENSSL` or `MD5` according to the operating system, when the Lua
185 md5 module is not installed.
186
187# External input
188
189As the config file itself is a Lua code file, there is some possibility to
190execute Lua code. Because it is run in a sandbox this is very limited, but
191might still be useful.
192
193What LuaRocks makes available:
194
195* parameters/values: several values are made available to the config file
196 (pre-loaded in the sandbox) and include things like processor and OS
197 platform, rocks trees which are in use, etc. (see `dump_env()` below)
198
199* function: `os_getenv(varname)`; this is the regular Lua function
200 `os.getenv()` and allows one to fetch environment variable values from the
201 OS.
202
203* function: `dump_env()`; this will dump a list of all variables provided by
204 LuaRocks as a debug aid.
205
206To test this, add a line `dump_env()` to your config file and execute
207`luarocks` on the commandline to see the results.
208
209# Other
210
211* `cmake_generator` (string) - If specified it overrides the default cmake
212 generator. Currently only Makefile-based generators are supported.
213
214* `wrap_bin_scripts` (boolean) - The default value is true: scripts installed
215 at bin/ are launched by a wrapper script that sets path environment
216 variables to ensure Lua modules are found. If set to false, scripts
217 installed at bin/ are copied directly, and no wrappers are generated.
218
219* `use_extensions` (boolean) - If specified, rockspec format verison 1.1 is
220 enabled, adding the deploy.wrap_bin_scripts option to the rockspec format,
221 which acts like the wrap_bin_scripts option above, in a rock by rock basis.
222
223* `local_by_default` (boolean) - If `true`, the tree in the user's home
224 directory is used as if the command line option `--local` had been given
225
226