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