1/* 2 This file defines the composition for Lua packages. It has 3 been factored out of all-packages.nix because there are many of 4 them. Also, because most Nix expressions for Lua packages are 5 trivial, most are actually defined here. I.e. there's no function 6 for each package in a separate file: the call to the function would 7 be almost as must code as the function itself. 8*/ 9 10{ 11 pkgs, 12 stdenv, 13 lib, 14 lua, 15}: 16 17self: 18 19let 20 inherit (self) callPackage; 21 22 buildLuaApplication = args: buildLuarocksPackage ({ namePrefix = ""; } // args); 23 24 buildLuarocksPackage = lib.makeOverridable ( 25 callPackage ../development/interpreters/lua-5/build-luarocks-package.nix { } 26 ); 27 28 luaLib = callPackage ../development/lua-modules/lib.nix { }; 29 30 #define build lua package function 31 buildLuaPackage = callPackage ../development/lua-modules/generic { }; 32 33 getPath = 34 drv: pathListForVersion: lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; 35 36in 37rec { 38 39 # Dont take luaPackages from "global" pkgs scope to avoid mixing lua versions 40 luaPackages = self; 41 42 # helper functions for dealing with LUA_PATH and LUA_CPATH 43 inherit luaLib; 44 45 getLuaPath = drv: getPath drv luaLib.luaPathList; 46 getLuaCPath = drv: getPath drv luaLib.luaCPathList; 47 48 inherit (callPackage ../development/interpreters/lua-5/hooks { }) 49 luarocksMoveDataFolder 50 luarocksCheckHook 51 ; 52 53 inherit lua; 54 inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; 55 inherit (luaLib) 56 luaOlder 57 luaAtLeast 58 isLua51 59 isLua52 60 isLua53 61 isLuaJIT 62 requiredLuaModules 63 toLuaModule 64 hasLuaModule 65 ; 66 67 # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH 68 wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { 69 inherit (pkgs.buildPackages) makeSetupHook makeWrapper; 70 }; 71 72 luarocks_bootstrap = toLuaModule (callPackage ../development/tools/misc/luarocks/default.nix { }); 73 74 # a fork of luarocks used to generate nix lua derivations from rockspecs 75 luarocks-nix = toLuaModule (callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }); 76 77 awesome-wm-widgets = callPackage ( 78 { 79 stdenv, 80 fetchFromGitHub, 81 lua, 82 lib, 83 }: 84 85 stdenv.mkDerivation { 86 pname = "awesome-wm-widgets"; 87 version = "0-unstable-2024-02-15"; 88 89 src = fetchFromGitHub { 90 owner = "streetturtle"; 91 repo = "awesome-wm-widgets"; 92 rev = "2a27e625056c50b40b1519eed623da253d36cc27"; 93 hash = "sha256-qz/kUIpuhWwTLbwbaES32wGKe4D2hfz90dnq+mrHrj0="; 94 }; 95 96 installPhase = '' 97 runHook preInstall 98 99 target=$out/lib/lua/${lua.luaversion}/awesome-wm-widgets 100 mkdir -p $target 101 cp -r $src/* $target 102 103 runHook postInstall 104 ''; 105 106 meta = { 107 description = "Widgets for Awesome window manager"; 108 homepage = "https://github.com/streetturtle/awesome-wm-widgets"; 109 license = lib.licenses.mit; 110 maintainers = with lib.maintainers; [ averdow ]; 111 }; 112 } 113 ) { }; 114 115 lua-pam = callPackage ( 116 { 117 fetchFromGitHub, 118 linux-pam, 119 openpam, 120 }: 121 buildLuaPackage rec { 122 pname = "lua-pam"; 123 version = "unstable-2015-07-03"; 124 125 src = fetchFromGitHub { 126 owner = "devurandom"; 127 repo = "lua-pam"; 128 rev = "3818ee6346a976669d74a5cbc2a83ad2585c5953"; 129 hash = "sha256-YlMZ5mM9Ij/9yRmgA0X1ahYVZMUx8Igj5OBvAMskqTg="; 130 fetchSubmodules = true; 131 }; 132 133 # The makefile tries to link to `-llua<luaversion>` 134 LUA_LIBS = "-llua"; 135 136 buildInputs = 137 lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ] 138 ++ lib.optionals stdenv.hostPlatform.isDarwin [ openpam ]; 139 140 installPhase = '' 141 runHook preInstall 142 143 install -Dm755 pam.so $out/lib/lua/${lua.luaversion}/pam.so 144 145 runHook postInstall 146 ''; 147 148 meta = with lib; { 149 # The package does not build with lua 5.4 or luaJIT 150 broken = luaAtLeast "5.4" || isLuaJIT; 151 description = "Lua module for PAM authentication"; 152 homepage = "https://github.com/devurandom/lua-pam"; 153 license = licenses.mit; 154 maintainers = with maintainers; [ traxys ]; 155 }; 156 } 157 ) { }; 158 159 lua-resty-core = callPackage ( 160 { fetchFromGitHub }: 161 buildLuaPackage rec { 162 pname = "lua-resty-core"; 163 version = "0.1.28"; 164 165 src = fetchFromGitHub { 166 owner = "openresty"; 167 repo = "lua-resty-core"; 168 rev = "v${version}"; 169 sha256 = "sha256-RJ2wcHTu447wM0h1fa2qCBl4/p9XL6ZqX9pktRW64RI="; 170 }; 171 172 propagatedBuildInputs = [ lua-resty-lrucache ]; 173 174 meta = with lib; { 175 description = "New FFI-based API for lua-nginx-module"; 176 homepage = "https://github.com/openresty/lua-resty-core"; 177 license = licenses.bsd3; 178 maintainers = [ ]; 179 }; 180 } 181 ) { }; 182 183 lua-resty-lrucache = callPackage ( 184 { fetchFromGitHub }: 185 buildLuaPackage rec { 186 pname = "lua-resty-lrucache"; 187 version = "0.13"; 188 189 src = fetchFromGitHub { 190 owner = "openresty"; 191 repo = "lua-resty-lrucache"; 192 rev = "v${version}"; 193 sha256 = "sha256-J8RNAMourxqUF8wPKd8XBhNwGC/x1KKvrVnZtYDEu4Q="; 194 }; 195 196 meta = with lib; { 197 description = "Lua-land LRU Cache based on LuaJIT FFI"; 198 homepage = "https://github.com/openresty/lua-resty-lrucache"; 199 license = licenses.bsd3; 200 maintainers = [ ]; 201 }; 202 } 203 ) { }; 204 205 luv = callPackage ../development/lua-modules/luv { }; 206 libluv = callPackage ../development/lua-modules/luv/lib.nix { }; 207 208 luxio = callPackage ( 209 { 210 fetchurl, 211 which, 212 pkg-config, 213 }: 214 buildLuaPackage rec { 215 pname = "luxio"; 216 version = "13"; 217 218 src = fetchurl { 219 url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-${version}.tar.bz2"; 220 sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz"; 221 }; 222 223 nativeBuildInputs = [ 224 which 225 pkg-config 226 ]; 227 228 postPatch = '' 229 patchShebangs const-proc.lua 230 ''; 231 232 preBuild = '' 233 makeFlagsArray=( 234 INST_LIBDIR="$out/lib/lua/${lua.luaversion}" 235 INST_LUADIR="$out/share/lua/${lua.luaversion}" 236 LUA_BINDIR="$out/bin" 237 INSTALL=install 238 ); 239 ''; 240 241 meta = with lib; { 242 broken = stdenv.hostPlatform.isDarwin; 243 description = "Lightweight UNIX I/O and POSIX binding for Lua"; 244 homepage = "https://www.gitano.org.uk/luxio/"; 245 license = licenses.mit; 246 maintainers = with maintainers; [ richardipsum ]; 247 platforms = platforms.unix; 248 }; 249 } 250 ) { }; 251 252 nfd = callPackage ../development/lua-modules/nfd { 253 inherit (pkgs) zenity; 254 }; 255 256 vicious = callPackage ( 257 { fetchFromGitHub }: 258 stdenv.mkDerivation rec { 259 pname = "vicious"; 260 version = "2.6.0"; 261 262 src = fetchFromGitHub { 263 owner = "vicious-widgets"; 264 repo = "vicious"; 265 rev = "v${version}"; 266 sha256 = "sha256-VlJ2hNou2+t7eSyHmFkC2xJ92OH/uJ/ewYHkFLQjUPQ="; 267 }; 268 269 buildInputs = [ lua ]; 270 271 installPhase = '' 272 mkdir -p $out/lib/lua/${lua.luaversion}/ 273 cp -r . $out/lib/lua/${lua.luaversion}/vicious/ 274 printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua 275 ''; 276 277 meta = with lib; { 278 description = "Modular widget library for the awesome window manager"; 279 homepage = "https://vicious.rtfd.io"; 280 changelog = "https://vicious.rtfd.io/en/v${version}/changelog.html"; 281 license = licenses.gpl2Plus; 282 maintainers = with maintainers; [ 283 makefu 284 mic92 285 McSinyx 286 ]; 287 platforms = platforms.linux; 288 }; 289 } 290 ) { }; 291}