summaryrefslogtreecommitdiff
path: root/pkgs/development/interpreters/lua-5/default.nix
blob: 1147893e5e43281b3e917cff9d41b462a7fba2fd (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
# similar to interpreters/python/default.nix
{
  stdenv,
  lib,
  callPackage,
  fetchFromGitHub,
  makeBinaryWrapper,
}:

let

  # Common passthru for all lua interpreters.
  # copied from python
  passthruFun =
    {
      executable,
      luaversion,
      packageOverrides,
      luaOnBuildForBuild,
      luaOnBuildForHost,
      luaOnBuildForTarget,
      luaOnHostForHost,
      luaOnTargetForTarget,
      luaAttr ? null,
      self, # is luaOnHostForTarget
    }:
    let
      luaPackages =
        callPackage
          # Function that when called
          # - imports lua-packages.nix
          # - adds spliced package sets to the package set
          # - applies overrides from `packageOverrides`
          (
            {
              lua,
              overrides,
              callPackage,
              makeScopeWithSplicing',
            }:
            let
              luaPackagesFun = callPackage ../../../top-level/lua-packages.nix {
                lua = self;
              };
              generatedPackages =
                if (builtins.pathExists ../../lua-modules/generated-packages.nix) then
                  (
                    final: prev:
                    callPackage ../../lua-modules/generated-packages.nix { inherit (final) callPackage; } final prev
                  )
                else
                  (final: prev: { });
              overriddenPackages = callPackage ../../lua-modules/overrides.nix { };

              otherSplices = {
                selfBuildBuild = luaOnBuildForBuild.pkgs;
                selfBuildHost = luaOnBuildForHost.pkgs;
                selfBuildTarget = luaOnBuildForTarget.pkgs;
                selfHostHost = luaOnHostForHost.pkgs;
                selfTargetTarget = luaOnTargetForTarget.pkgs or { };
              };

              extensions = lib.composeManyExtensions [
                generatedPackages
                overriddenPackages
                overrides
              ];
            in
            makeScopeWithSplicing' {
              inherit otherSplices;
              f = lib.extends extensions luaPackagesFun;
            }
          )
          {
            overrides = packageOverrides;
            lua = self;
          };
    in
    rec {
      buildEnv = callPackage ./wrapper.nix {
        lua = self;
        makeWrapper = makeBinaryWrapper;
        inherit (luaPackages) requiredLuaModules;
      };
      withPackages = import ./with-packages.nix { inherit buildEnv luaPackages; };
      pkgs = luaPackages;
      interpreter = "${self}/bin/${executable}";
      inherit executable luaversion;
      luaOnBuild = luaOnBuildForHost.override {
        inherit packageOverrides;
        self = luaOnBuild;
      };

      tests = callPackage ./tests {
        lua = self;
        inherit (luaPackages) wrapLua;
      };

      inherit luaAttr;
    };

in

rec {
  lua5_5 = callPackage ./interpreter.nix {
    self = lua5_5;
    version = "5.5.0";
    hash = "sha256-V8zDK7vQBcq3W8xSREBSU1r2kXiduiuQFtXFBkDWiz0=";
    makeWrapper = makeBinaryWrapper;
    inherit passthruFun;

    patches = lib.optional stdenv.hostPlatform.isDarwin ./5.5.darwin.patch;
  };

  lua5_5_compat = lua5_5.override {
    self = lua5_5_compat;
    compat = true;
  };

  lua5_4 = callPackage ./interpreter.nix {
    self = lua5_4;
    version = "5.4.7";
    hash = "sha256-n79eKO+GxphY9tPTTszDLpEcGii0Eg/z6EqqcM+/HjA=";
    makeWrapper = makeBinaryWrapper;
    inherit passthruFun;

    patches = lib.optional stdenv.hostPlatform.isDarwin ./5.4.darwin.patch;
  };

  lua5_4_compat = lua5_4.override {
    self = lua5_4_compat;
    compat = true;
  };

  lua5_3 = callPackage ./interpreter.nix {
    self = lua5_3;
    version = "5.3.6";
    hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
    makeWrapper = makeBinaryWrapper;
    inherit passthruFun;

    patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./5.2.darwin.patch ];
  };

  lua5_3_compat = lua5_3.override {
    self = lua5_3_compat;
    compat = true;
  };

  lua5_2 = callPackage ./interpreter.nix {
    self = lua5_2;
    version = "5.2.4";
    hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
    makeWrapper = makeBinaryWrapper;
    inherit passthruFun;
    patches = [
      ./CVE-2022-28805.patch
    ]
    ++ lib.optional stdenv.hostPlatform.isDarwin ./5.2.darwin.patch;
  };

  lua5_2_compat = lua5_2.override {
    self = lua5_2_compat;
    compat = true;
  };

  lua5_1 = callPackage ./interpreter.nix {
    self = lua5_1;
    version = "5.1.5";
    hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
    makeWrapper = makeBinaryWrapper;
    inherit passthruFun;
    patches = (lib.optional stdenv.hostPlatform.isDarwin ./5.1.darwin.patch) ++ [
      ./CVE-2014-5461.patch
    ];
  };

  luajit_2_0 = import ../luajit/2.0.nix {
    self = luajit_2_0;
    inherit
      callPackage
      fetchFromGitHub
      lib
      passthruFun
      ;
  };

  luajit_2_1 = import ../luajit/2.1.nix {
    self = luajit_2_1;
    inherit callPackage fetchFromGitHub passthruFun;
  };

  luajit_openresty = import ../luajit/openresty.nix {
    self = luajit_openresty;
    inherit callPackage fetchFromGitHub passthruFun;
  };
}