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