Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 168 lines 5.1 kB view raw
1# similar to interpreters/python/default.nix 2{ stdenv, 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 keep = self: { }; 43 extra = spliced0: {}; 44 extensions = lib.composeManyExtensions [ 45 generatedPackages 46 overriddenPackages 47 overrides 48 ]; 49 in makeScopeWithSplicing 50 otherSplices 51 keep 52 extra 53 (lib.extends extensions luaPackagesFun)) 54 { 55 overrides = packageOverrides; 56 lua = self; 57 }; 58 in rec { 59 buildEnv = callPackage ./wrapper.nix { 60 lua = self; 61 makeWrapper = makeBinaryWrapper; 62 inherit (luaPackages) requiredLuaModules; 63 }; 64 withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;}; 65 pkgs = luaPackages; 66 interpreter = "${self}/bin/${executable}"; 67 inherit executable luaversion; 68 luaOnBuild = luaOnBuildForHost.override { inherit packageOverrides; self = luaOnBuild; }; 69 70 tests = callPackage ./tests { inherit (luaPackages) wrapLua; }; 71 72 inherit luaAttr; 73 }; 74 75in 76 77rec { 78 lua5_4 = callPackage ./interpreter.nix { 79 self = lua5_4; 80 version = "5.4.4"; 81 hash = "sha256-Fkx4SWU7gK5nvsS3RzuIS/XMjS3KBWU0dewu0nuev2E="; 82 makeWrapper = makeBinaryWrapper; 83 inherit passthruFun; 84 85 patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch 86 ++ [ 87 (fetchpatch { 88 name = "CVE-2022-28805.patch"; 89 url = "https://github.com/lua/lua/commit/1f3c6f4534c6411313361697d98d1145a1f030fa.patch"; 90 sha256 = "sha256-YTwoolSnRNJIHFPVijSO6ZDw35BG5oWYralZ8qOb9y8="; 91 stripLen = 1; 92 extraPrefix = "src/"; 93 excludes = [ "src/testes/*" ]; 94 }) 95 (fetchpatch { 96 name = "CVE-2022-33099.patch"; 97 url = "https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf.patch"; 98 sha256 = "sha256-qj1Dq1ojVoknALSa67jhgH3G3Kk4GtJP6ROFElVF+D0="; 99 stripLen = 1; 100 extraPrefix = "src/"; 101 }) 102 ]; 103 }; 104 105 lua5_4_compat = lua5_4.override({ 106 self = lua5_4_compat; 107 compat = true; 108 }); 109 110 lua5_3 = callPackage ./interpreter.nix { 111 self = lua5_3; 112 version = "5.3.6"; 113 hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw"; 114 makeWrapper = makeBinaryWrapper; 115 inherit passthruFun; 116 117 patches = 118 lib.optionals stdenv.isDarwin [ ./5.2.darwin.patch ]; 119 }; 120 121 lua5_3_compat = lua5_3.override({ 122 self = lua5_3_compat; 123 compat = true; 124 }); 125 126 127 lua5_2 = callPackage ./interpreter.nix { 128 self = lua5_2; 129 version = "5.2.4"; 130 hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"; 131 makeWrapper = makeBinaryWrapper; 132 inherit passthruFun; 133 patches = [ 134 ./CVE-2022-28805.patch 135 ] ++ lib.optional stdenv.isDarwin ./5.2.darwin.patch; 136 }; 137 138 lua5_2_compat = lua5_2.override({ 139 self = lua5_2_compat; 140 compat = true; 141 }); 142 143 144 lua5_1 = callPackage ./interpreter.nix { 145 self = lua5_1; 146 version = "5.1.5"; 147 hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"; 148 makeWrapper = makeBinaryWrapper; 149 inherit passthruFun; 150 patches = (lib.optional stdenv.isDarwin ./5.1.darwin.patch) 151 ++ [ ./CVE-2014-5461.patch ]; 152 }; 153 154 luajit_2_0 = import ../luajit/2.0.nix { 155 self = luajit_2_0; 156 inherit callPackage fetchFromGitHub lib passthruFun; 157 }; 158 159 luajit_2_1 = import ../luajit/2.1.nix { 160 self = luajit_2_1; 161 inherit callPackage fetchFromGitHub passthruFun; 162 }; 163 164 luajit_openresty = import ../luajit/openresty.nix { 165 self = luajit_openresty; 166 inherit callPackage fetchFromGitHub passthruFun; 167 }; 168}