summaryrefslogtreecommitdiffstats
path: root/pkgs/top-level/lua-packages.nix
blob: 44464049bb85b1fd2095f9aac8d5758f3c915e3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
  This file defines the composition for Lua packages.  It has
  been factored out of all-packages.nix because there are many of
  them.  Also, because most Nix expressions for Lua packages are
  trivial, most are actually defined here.  I.e. there's no function
  for each package in a separate file: the call to the function would
  be almost as must code as the function itself.
*/

{
  pkgs,
  stdenv,
  lib,
  lua,
}:

self:

let
  inherit (self) callPackage;

  buildLuaApplication = args: buildLuarocksPackage ({ namePrefix = ""; } // args);

  buildLuarocksPackage = lib.makeOverridable (
    callPackage ../development/interpreters/lua-5/build-luarocks-package.nix { }
  );

  luaLib = callPackage ../development/lua-modules/lib.nix { };

  #define build lua package function
  buildLuaPackage = callPackage ../development/lua-modules/generic { };

  getPath =
    drv: pathListForVersion: lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion;

in
rec {

  # Dont take luaPackages from "global" pkgs scope to avoid mixing lua versions
  luaPackages = self;

  # helper functions for dealing with LUA_PATH and LUA_CPATH
  inherit luaLib;

  getLuaPath = drv: getPath drv luaLib.luaPathList;
  getLuaCPath = drv: getPath drv luaLib.luaCPathList;

  inherit (callPackage ../development/interpreters/lua-5/hooks { })
    luarocksMoveDataFolder
    luarocksCheckHook
    bustedCheckHook
    ;

  inherit lua;
  inherit buildLuaPackage buildLuarocksPackage buildLuaApplication;
  inherit (luaLib)
    luaOlder
    luaAtLeast
    isLua51
    isLua52
    isLua53
    isLuaJIT
    requiredLuaModules
    toLuaModule
    hasLuaModule
    ;

  # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH
  wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { };

  luarocks_bootstrap = toLuaModule (callPackage ../development/tools/misc/luarocks/default.nix { });

  # a fork of luarocks used to generate nix lua derivations from rockspecs
  luarocks-nix = toLuaModule (callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { });

  awesome-wm-widgets = callPackage (
    {
      stdenv,
      fetchFromGitHub,
      lua,
      lib,
    }:

    stdenv.mkDerivation {
      pname = "awesome-wm-widgets";
      version = "0-unstable-2024-02-15";

      src = fetchFromGitHub {
        owner = "streetturtle";
        repo = "awesome-wm-widgets";
        rev = "2a27e625056c50b40b1519eed623da253d36cc27";
        hash = "sha256-qz/kUIpuhWwTLbwbaES32wGKe4D2hfz90dnq+mrHrj0=";
      };

      installPhase = ''
        runHook preInstall

        target=$out/lib/lua/${lua.luaversion}/awesome-wm-widgets
        mkdir -p $target
        cp -r $src/* $target

        runHook postInstall
      '';

      meta = {
        description = "Widgets for Awesome window manager";
        homepage = "https://github.com/streetturtle/awesome-wm-widgets";
        license = lib.licenses.mit;
        maintainers = with lib.maintainers; [ averdow ];
      };
    }
  ) { };

  image-nvim = callPackage ../development/lua-modules/image-nvim { };

  json = callPackage ../development/lua-modules/json { };

  lua-https = callPackage ../development/lua-modules/lua-https { };

  lua-pam = callPackage (
    {
      fetchFromGitHub,
      linux-pam,
      openpam,
    }:
    buildLuaPackage {
      pname = "lua-pam";
      version = "unstable-2015-07-03";

      src = fetchFromGitHub {
        owner = "devurandom";
        repo = "lua-pam";
        rev = "3818ee6346a976669d74a5cbc2a83ad2585c5953";
        hash = "sha256-YlMZ5mM9Ij/9yRmgA0X1ahYVZMUx8Igj5OBvAMskqTg=";
        fetchSubmodules = true;
      };

      # The makefile tries to link to `-llua<luaversion>`
      env.LUA_LIBS = "-llua";

      buildInputs =
        lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ]
        ++ lib.optionals stdenv.hostPlatform.isDarwin [ openpam ];

      installPhase = ''
        runHook preInstall

        install -Dm755 pam.so $out/lib/lua/${lua.luaversion}/pam.so

        runHook postInstall
      '';

      meta = {
        # The package does not build with lua 5.4 or luaJIT
        broken = luaAtLeast "5.4" || isLuaJIT;
        description = "Lua module for PAM authentication";
        homepage = "https://github.com/devurandom/lua-pam";
        license = lib.licenses.mit;
        maintainers = with lib.maintainers; [ traxys ];
      };
    }
  ) { };

  lua-resty-core = callPackage (
    { fetchFromGitHub }:
    buildLuaPackage rec {
      pname = "lua-resty-core";
      # The version needs to fit to nginxModules.lua
      version = "0.1.34rc3";

      src = fetchFromGitHub {
        owner = "openresty";
        repo = "lua-resty-core";
        rev = "v${version}";
        sha256 = "sha256-+rtbaHEqKSvaba+zZwRUnUsdu3Jndi8OVGUtFC55Fts=";
      };

      propagatedBuildInputs = [ lua-resty-lrucache ];

      meta = {
        description = "New FFI-based API for lua-nginx-module";
        homepage = "https://github.com/openresty/lua-resty-core";
        license = lib.licenses.bsd3;
        maintainers = [ ];
      };
    }
  ) { };

  lua-resty-lrucache = callPackage (
    { fetchFromGitHub }:
    buildLuaPackage rec {
      pname = "lua-resty-lrucache";
      version = "0.15";

      src = fetchFromGitHub {
        owner = "openresty";
        repo = "lua-resty-lrucache";
        rev = "v${version}";
        sha256 = "sha256-G2l4Zo9Xm/m4zRfxrgzEvRE5LMO+UuX3kd7FwlCnxDA=";
      };

      meta = {
        description = "Lua-land LRU Cache based on LuaJIT FFI";
        homepage = "https://github.com/openresty/lua-resty-lrucache";
        license = lib.licenses.bsd3;
        maintainers = [ ];
      };
    }
  ) { };

  luv = callPackage ../development/lua-modules/luv { };
  libluv = callPackage ../development/lua-modules/luv/lib.nix { };

  luxio = callPackage (
    {
      fetchurl,
      which,
      pkg-config,
    }:
    buildLuaPackage rec {
      pname = "luxio";
      version = "13";

      src = fetchurl {
        url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-${version}.tar.bz2";
        sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz";
      };

      nativeBuildInputs = [
        which
        pkg-config
      ];

      postPatch = ''
        patchShebangs const-proc.lua
      '';

      preBuild = ''
        makeFlagsArray=(
          INST_LIBDIR="$out/lib/lua/${lua.luaversion}"
          INST_LUADIR="$out/share/lua/${lua.luaversion}"
          LUA_BINDIR="$out/bin"
          INSTALL=install
        );
      '';

      meta = {
        broken = stdenv.hostPlatform.isDarwin;
        description = "Lightweight UNIX I/O and POSIX binding for Lua";
        homepage = "https://www.gitano.org.uk/luxio/";
        license = lib.licenses.mit;
        maintainers = with lib.maintainers; [ richardipsum ];
        platforms = lib.platforms.unix;
      };
    }
  ) { };

  nfd = callPackage ../development/lua-modules/nfd {
    inherit (pkgs) zenity;
  };

  readline = callPackage ../development/lua-modules/readline { inherit (pkgs) readline; };
}