1<section xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xml:id="sec-language-lua">
4 <title>Lua</title>
5
6 <para>
7 Lua packages are built by the <varname>buildLuaPackage</varname> function.
8 This function is implemented in
9 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/lua-modules/generic/default.nix">
10 <filename>pkgs/development/lua-modules/generic/default.nix</filename></link>
11 and works similarly to <varname>buildPerlPackage</varname>. (See
12 <xref linkend="sec-language-perl"/> for details.)
13 </para>
14
15 <para>
16 Lua packages are defined in
17 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/lua-packages.nix"><filename>pkgs/top-level/lua-packages.nix</filename></link>.
18 Most of them are simple. For example:
19<programlisting>
20fileSystem = buildLuaPackage {
21 name = "filesystem-1.6.2";
22 src = fetchurl {
23 url = "https://github.com/keplerproject/luafilesystem/archive/v1_6_2.tar.gz";
24 sha256 = "1n8qdwa20ypbrny99vhkmx8q04zd2jjycdb5196xdhgvqzk10abz";
25 };
26 meta = {
27 homepage = "https://github.com/keplerproject/luafilesystem";
28 hydraPlatforms = stdenv.lib.platforms.linux;
29 maintainers = with maintainers; [ flosse ];
30 };
31};
32 </programlisting>
33 </para>
34
35 <para>
36 Though, more complicated package should be placed in a seperate file in
37 <link
38 xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/lua-modules"><filename>pkgs/development/lua-modules</filename></link>.
39 </para>
40
41 <para>
42 Lua packages accept additional parameter <varname>disabled</varname>, which
43 defines the condition of disabling package from luaPackages. For example, if
44 package has <varname>disabled</varname> assigned to <literal>lua.luaversion
45 != "5.1"</literal>, it will not be included in any luaPackages except
46 lua51Packages, making it only be built for lua 5.1.
47 </para>
48</section>