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
94 tests = callPackage ./tests {
95 lua = self;
96 inherit (luaPackages) wrapLua;
97 };
98
99 inherit luaAttr;
100 };
101
102in
103
104rec {
105 lua5_5 = callPackage ./interpreter.nix {
106 self = lua5_5;
107 version = "5.5.0";
108 hash = "sha256-V8zDK7vQBcq3W8xSREBSU1r2kXiduiuQFtXFBkDWiz0=";
109 makeWrapper = makeBinaryWrapper;
110 inherit passthruFun;
111
112 patches = lib.optional stdenv.hostPlatform.isDarwin ./5.5.darwin.patch;
113 };
114
115 lua5_5_compat = lua5_5.override {
116 self = lua5_5_compat;
117 compat = true;
118 };
119
120 lua5_4 = callPackage ./interpreter.nix {
121 self = lua5_4;
122 version = "5.4.7";
123 hash = "sha256-n79eKO+GxphY9tPTTszDLpEcGii0Eg/z6EqqcM+/HjA=";
124 makeWrapper = makeBinaryWrapper;
125 inherit passthruFun;
126
127 patches = lib.optional stdenv.hostPlatform.isDarwin ./5.4.darwin.patch;
128 };
129
130 lua5_4_compat = lua5_4.override {
131 self = lua5_4_compat;
132 compat = true;
133 };
134
135 lua5_3 = callPackage ./interpreter.nix {
136 self = lua5_3;
137 version = "5.3.6";
138 hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
139 makeWrapper = makeBinaryWrapper;
140 inherit passthruFun;
141
142 patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./5.2.darwin.patch ];
143 };
144
145 lua5_3_compat = lua5_3.override {
146 self = lua5_3_compat;
147 compat = true;
148 };
149
150 lua5_2 = callPackage ./interpreter.nix {
151 self = lua5_2;
152 version = "5.2.4";
153 hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
154 makeWrapper = makeBinaryWrapper;
155 inherit passthruFun;
156 patches = [
157 ./CVE-2022-28805.patch
158 ]
159 ++ lib.optional stdenv.hostPlatform.isDarwin ./5.2.darwin.patch;
160 };
161
162 lua5_2_compat = lua5_2.override {
163 self = lua5_2_compat;
164 compat = true;
165 };
166
167 lua5_1 = callPackage ./interpreter.nix {
168 self = lua5_1;
169 version = "5.1.5";
170 hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
171 makeWrapper = makeBinaryWrapper;
172 inherit passthruFun;
173 patches = (lib.optional stdenv.hostPlatform.isDarwin ./5.1.darwin.patch) ++ [
174 ./CVE-2014-5461.patch
175 ];
176 };
177
178 luajit_2_0 = import ../luajit/2.0.nix {
179 self = luajit_2_0;
180 inherit
181 callPackage
182 fetchFromGitHub
183 lib
184 passthruFun
185 ;
186 };
187
188 luajit_2_1 = import ../luajit/2.1.nix {
189 self = luajit_2_1;
190 inherit callPackage fetchFromGitHub passthruFun;
191 };
192
193 luajit_openresty = import ../luajit/openresty.nix {
194 self = luajit_openresty;
195 inherit callPackage fetchFromGitHub passthruFun;
196 };
197}