1# similar to interpreters/python/default.nix
2{ stdenv, config, lib, callPackage, fetchFromGitHub, fetchurl, fetchpatch, makeBinaryWrapper }:
3
4
5let
6
7 # Common passthru for all lua interpreters.
8 # copied from python
9 passthruFun =
10 { executable
11 , luaversion
12 , packageOverrides
13 , luaOnBuildForBuild
14 , luaOnBuildForHost
15 , luaOnBuildForTarget
16 , luaOnHostForHost
17 , luaOnTargetForTarget
18 , luaAttr ? null
19 , self # is luaOnHostForTarget
20 }: let
21 luaPackages = callPackage
22 # Function that when called
23 # - imports lua-packages.nix
24 # - adds spliced package sets to the package set
25 # - applies overrides from `packageOverrides`
26 ({ lua, overrides, callPackage, makeScopeWithSplicing' }: let
27 luaPackagesFun = callPackage ../../../top-level/lua-packages.nix {
28 lua = self;
29 };
30 generatedPackages = if (builtins.pathExists ../../lua-modules/generated-packages.nix) then
31 (final: prev: callPackage ../../lua-modules/generated-packages.nix { inherit (final) callPackage; } final prev)
32 else (final: prev: {});
33 overriddenPackages = callPackage ../../lua-modules/overrides.nix { };
34
35 otherSplices = {
36 selfBuildBuild = luaOnBuildForBuild.pkgs;
37 selfBuildHost = luaOnBuildForHost.pkgs;
38 selfBuildTarget = luaOnBuildForTarget.pkgs;
39 selfHostHost = luaOnHostForHost.pkgs;
40 selfTargetTarget = luaOnTargetForTarget.pkgs or {};
41 };
42
43 aliases = final: prev:
44 lib.optionalAttrs config.allowAliases
45 (import ../../lua-modules/aliases.nix lib final prev);
46
47 extensions = lib.composeManyExtensions [
48 aliases
49 generatedPackages
50 overriddenPackages
51 overrides
52 ];
53 in makeScopeWithSplicing' {
54 inherit otherSplices;
55 f = lib.extends extensions luaPackagesFun;
56 })
57 {
58 overrides = packageOverrides;
59 lua = self;
60 };
61 in rec {
62 buildEnv = callPackage ./wrapper.nix {
63 lua = self;
64 makeWrapper = makeBinaryWrapper;
65 inherit (luaPackages) requiredLuaModules;
66 };
67 withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;};
68 pkgs = luaPackages;
69 interpreter = "${self}/bin/${executable}";
70 inherit executable luaversion;
71 luaOnBuild = luaOnBuildForHost.override { inherit packageOverrides; self = luaOnBuild; };
72
73 tests = callPackage ./tests { inherit (luaPackages) wrapLua; };
74
75 inherit luaAttr;
76 };
77
78in
79
80rec {
81 lua5_4 = callPackage ./interpreter.nix {
82 self = lua5_4;
83 version = "5.4.6";
84 hash = "sha256-fV6huctqoLWco93hxq3LV++DobqOVDLA7NBr9DmzrYg=";
85 makeWrapper = makeBinaryWrapper;
86 inherit passthruFun;
87
88 patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch;
89 };
90
91 lua5_4_compat = lua5_4.override({
92 self = lua5_4_compat;
93 compat = true;
94 });
95
96 lua5_3 = callPackage ./interpreter.nix {
97 self = lua5_3;
98 version = "5.3.6";
99 hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
100 makeWrapper = makeBinaryWrapper;
101 inherit passthruFun;
102
103 patches =
104 lib.optionals stdenv.isDarwin [ ./5.2.darwin.patch ];
105 };
106
107 lua5_3_compat = lua5_3.override({
108 self = lua5_3_compat;
109 compat = true;
110 });
111
112
113 lua5_2 = callPackage ./interpreter.nix {
114 self = lua5_2;
115 version = "5.2.4";
116 hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
117 makeWrapper = makeBinaryWrapper;
118 inherit passthruFun;
119 patches = [
120 ./CVE-2022-28805.patch
121 ] ++ lib.optional stdenv.isDarwin ./5.2.darwin.patch;
122 };
123
124 lua5_2_compat = lua5_2.override({
125 self = lua5_2_compat;
126 compat = true;
127 });
128
129
130 lua5_1 = callPackage ./interpreter.nix {
131 self = lua5_1;
132 version = "5.1.5";
133 hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
134 makeWrapper = makeBinaryWrapper;
135 inherit passthruFun;
136 patches = (lib.optional stdenv.isDarwin ./5.1.darwin.patch)
137 ++ [ ./CVE-2014-5461.patch ];
138 };
139
140 luajit_2_0 = import ../luajit/2.0.nix {
141 self = luajit_2_0;
142 inherit callPackage fetchFromGitHub lib passthruFun;
143 };
144
145 luajit_2_1 = import ../luajit/2.1.nix {
146 self = luajit_2_1;
147 inherit callPackage fetchFromGitHub passthruFun;
148 };
149
150 luajit_openresty = import ../luajit/openresty.nix {
151 self = luajit_openresty;
152 inherit callPackage fetchFromGitHub passthruFun;
153 };
154}