luaPackages: copy passthruFun from python

Artturin 39571bd6 bdb8ca17

+150 -95
+1 -4
pkgs/development/interpreters/lua-5/build-lua-package.nix
··· 1 # Generic builder for lua packages 2 { lib 3 , lua 4 - , buildPackages 5 , wrapLua 6 , luarocks 7 # Whether the derivation provides a lua module or not. ··· 14 , version 15 16 # by default prefix `name` e.g. "lua5.2-${name}" 17 - , namePrefix ? if lua.pkgs.isLuaJIT 18 - then lua.name + "-" 19 - else "lua" + lua.luaversion + "-" 20 21 # Dependencies for building the package 22 , buildInputs ? []
··· 1 # Generic builder for lua packages 2 { lib 3 , lua 4 , wrapLua 5 , luarocks 6 # Whether the derivation provides a lua module or not. ··· 13 , version 14 15 # by default prefix `name` e.g. "lua5.2-${name}" 16 + , namePrefix ? "${lua.pname}${lua.sourceVersion.major}.${lua.sourceVersion.minor}-" 17 18 # Dependencies for building the package 19 , buildInputs ? []
+86 -2
pkgs/development/interpreters/lua-5/default.nix
··· 1 # similar to interpreters/python/default.nix 2 { stdenv, lib, callPackage, fetchurl, fetchpatch, makeBinaryWrapper }: 3 4 rec { 5 lua5_4 = callPackage ./interpreter.nix { 6 sourceVersion = { major = "5"; minor = "4"; patch = "3"; }; 7 hash = "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq"; 8 makeWrapper = makeBinaryWrapper; 9 10 patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch 11 ++ [ ··· 28 }; 29 30 lua5_4_compat = lua5_4.override({ 31 compat = true; 32 }); 33 34 lua5_3 = callPackage ./interpreter.nix { 35 sourceVersion = { major = "5"; minor = "3"; patch = "6"; }; 36 hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw"; 37 makeWrapper = makeBinaryWrapper; 38 39 patches = 40 lib.optionals stdenv.isDarwin [ ./5.2.darwin.patch ]; 41 }; 42 43 lua5_3_compat = lua5_3.override({ 44 compat = true; 45 }); 46 47 48 lua5_2 = callPackage ./interpreter.nix { 49 sourceVersion = { major = "5"; minor = "2"; patch = "4"; }; 50 hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"; 51 makeWrapper = makeBinaryWrapper; 52 patches = [ 53 ./CVE-2022-28805.patch 54 ] ++ lib.optional stdenv.isDarwin ./5.2.darwin.patch; 55 }; 56 57 lua5_2_compat = lua5_2.override({ 58 compat = true; 59 }); 60 61 62 lua5_1 = callPackage ./interpreter.nix { 63 sourceVersion = { major = "5"; minor = "1"; patch = "5"; }; 64 hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"; 65 makeWrapper = makeBinaryWrapper; 66 patches = (lib.optional stdenv.isDarwin ./5.1.darwin.patch) 67 ++ [ ./CVE-2014-5461.patch ]; 68 }; 69 70 luajit_2_0 = import ../luajit/2.0.nix { 71 self = luajit_2_0; 72 - inherit callPackage lib; 73 }; 74 75 luajit_2_1 = import ../luajit/2.1.nix { 76 self = luajit_2_1; 77 - inherit callPackage; 78 }; 79 80 }
··· 1 # similar to interpreters/python/default.nix 2 { stdenv, lib, callPackage, fetchurl, fetchpatch, makeBinaryWrapper }: 3 4 + 5 + let 6 + 7 + # Common passthru for all lua interpreters. 8 + # copied from python 9 + passthruFun = 10 + { executable 11 + , sourceVersion 12 + , luaversion 13 + , packageOverrides 14 + , luaOnBuildForBuild 15 + , luaOnBuildForHost 16 + , luaOnBuildForTarget 17 + , luaOnHostForHost 18 + , luaOnTargetForTarget 19 + , luaAttr ? null 20 + , self # is luaOnHostForTarget 21 + }: let 22 + luaPackages = callPackage 23 + # Function that when called 24 + # - imports lua-packages.nix 25 + # - adds spliced package sets to the package set 26 + # - applies overrides from `packageOverrides` 27 + ({ lua, overrides, callPackage, splicePackages, newScope }: let 28 + luaPackagesFun = callPackage ../../../top-level/lua-packages.nix { 29 + lua = self; 30 + }; 31 + generatedPackages = if (builtins.pathExists ../../lua-modules/generated-packages.nix) then 32 + (final: prev: callPackage ../../lua-modules/generated-packages.nix { inherit (final) callPackage; } final prev) 33 + else (final: prev: {}); 34 + overridenPackages = callPackage ../../lua-modules/overrides.nix { }; 35 + 36 + otherSplices = { 37 + selfBuildBuild = luaOnBuildForBuild.pkgs; 38 + selfBuildHost = luaOnBuildForHost.pkgs; 39 + selfBuildTarget = luaOnBuildForTarget.pkgs; 40 + selfHostHost = luaOnHostForHost.pkgs; 41 + selfTargetTarget = luaOnTargetForTarget.pkgs or {}; 42 + }; 43 + keep = self: { }; 44 + extra = spliced0: {}; 45 + extensions = lib.composeManyExtensions [ 46 + generatedPackages 47 + overridenPackages 48 + overrides 49 + ]; 50 + in lib.makeScopeWithSplicing 51 + splicePackages 52 + newScope 53 + otherSplices 54 + keep 55 + extra 56 + (lib.extends extensions luaPackagesFun)) 57 + { 58 + overrides = packageOverrides; 59 + lua = self; 60 + }; 61 + in rec { 62 + buildEnv = callPackage ./wrapper.nix { 63 + lua = self; 64 + inherit (luaPackages) requiredLuaModules; 65 + }; 66 + withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;}; 67 + pkgs = luaPackages; 68 + interpreter = "${self}/bin/${executable}"; 69 + inherit executable luaversion sourceVersion; 70 + luaOnBuild = luaOnBuildForHost.override { inherit packageOverrides; self = luaOnBuild; }; 71 + 72 + inherit luaAttr; 73 + }; 74 + 75 + in 76 + 77 rec { 78 lua5_4 = callPackage ./interpreter.nix { 79 + self = lua5_4; 80 sourceVersion = { major = "5"; minor = "4"; patch = "3"; }; 81 hash = "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq"; 82 makeWrapper = makeBinaryWrapper; 83 + inherit passthruFun; 84 85 patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch 86 ++ [ ··· 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 sourceVersion = { major = "5"; minor = "3"; patch = "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 sourceVersion = { major = "5"; minor = "2"; patch = "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 sourceVersion = { major = "5"; minor = "1"; patch = "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 lib passthruFun; 157 }; 158 159 luajit_2_1 = import ../luajit/2.1.nix { 160 self = luajit_2_1; 161 + inherit callPackage passthruFun; 162 }; 163 164 }
+27 -20
pkgs/development/interpreters/lua-5/interpreter.nix
··· 2 , compat ? false 3 , callPackage 4 , makeWrapper 5 , packageOverrides ? (final: prev: {}) 6 , sourceVersion 7 , hash 8 , patches ? [] 9 , postConfigure ? null 10 , postBuild ? null 11 , staticOnly ? stdenv.hostPlatform.isStatic 12 - }: 13 let 14 - luaversion = with sourceVersion; "${major}.${minor}"; 15 16 - luaPackages = callPackage ../../lua-modules { 17 - lua = self; 18 - overrides = packageOverrides; 19 - packagesAttr = "lua${lib.replaceChars ["."] ["_"] luaversion}.pkgs"; 20 - }; 21 22 plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux" 23 else if (stdenv.isLinux && lib.versionAtLeast self.luaversion "5.4") then "linux-readline" ··· 28 else if stdenv.hostPlatform.isBSD then "bsd" 29 else if stdenv.hostPlatform.isUnix then "posix" 30 else "generic"; 31 32 - self = stdenv.mkDerivation rec { 33 pname = "lua"; 34 version = "${luaversion}.${sourceVersion.patch}"; 35 ··· 125 ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${lib.replaceStrings [ "." ] [ "" ] luaversion}.pc" 126 ''; 127 128 - passthru = rec { 129 - inherit luaversion; 130 - buildEnv = callPackage ./wrapper.nix { 131 - lua = self; 132 - inherit makeWrapper; 133 - inherit (luaPackages) requiredLuaModules; 134 - }; 135 - withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;}; 136 - pkgs = luaPackages; 137 - interpreter = "${self}/bin/lua"; 138 }; 139 140 meta = { ··· 151 license = lib.licenses.mit; 152 platforms = lib.platforms.unix; 153 }; 154 - }; 155 - in self
··· 2 , compat ? false 3 , callPackage 4 , makeWrapper 5 + , self 6 , packageOverrides ? (final: prev: {}) 7 + , pkgsBuildBuild 8 + , pkgsBuildHost 9 + , pkgsBuildTarget 10 + , pkgsHostHost 11 + , pkgsTargetTarget 12 , sourceVersion 13 , hash 14 + , passthruFun 15 , patches ? [] 16 , postConfigure ? null 17 , postBuild ? null 18 , staticOnly ? stdenv.hostPlatform.isStatic 19 + , luaAttr ? "lua${sourceVersion.major}_${sourceVersion.minor}" 20 + } @ inputs: 21 let 22 + luaPackages = self.pkgs; 23 24 + luaversion = with sourceVersion; "${major}.${minor}"; 25 26 plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux" 27 else if (stdenv.isLinux && lib.versionAtLeast self.luaversion "5.4") then "linux-readline" ··· 32 else if stdenv.hostPlatform.isBSD then "bsd" 33 else if stdenv.hostPlatform.isUnix then "posix" 34 else "generic"; 35 + in 36 37 + stdenv.mkDerivation rec { 38 pname = "lua"; 39 version = "${luaversion}.${sourceVersion.patch}"; 40 ··· 130 ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${lib.replaceStrings [ "." ] [ "" ] luaversion}.pc" 131 ''; 132 133 + # copied from python 134 + passthru = let 135 + # When we override the interpreter we also need to override the spliced versions of the interpreter 136 + inputs' = lib.filterAttrs (n: v: ! lib.isDerivation v && n != "passthruFun") inputs; 137 + override = attr: let lua = attr.override (inputs' // { self = lua; }); in lua; 138 + in passthruFun rec { 139 + inherit self luaversion packageOverrides luaAttr sourceVersion; 140 + executable = "lua"; 141 + luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr}; 142 + luaOnBuildForHost = override pkgsBuildHost.${luaAttr}; 143 + luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr}; 144 + luaOnHostForHost = override pkgsHostHost.${luaAttr}; 145 + luaOnTargetForTarget = if lib.hasAttr luaAttr pkgsTargetTarget then (override pkgsTargetTarget.${luaAttr}) else {}; 146 }; 147 148 meta = { ··· 159 license = lib.licenses.mit; 160 platforms = lib.platforms.unix; 161 }; 162 + }
+3 -3
pkgs/development/interpreters/luajit/2.0.nix
··· 1 - { self, callPackage, lib }: 2 callPackage ./default.nix { 3 - inherit self; 4 - packagesAttr = "luajit_2_0.pkgs"; 5 version = "2.0.5-2022-03-13"; 6 rev = "93a65d3cc263aef2d2feb3d7ff2206aca3bee17e"; 7 isStable = true;
··· 1 + { self, callPackage, lib, passthruFun }: 2 callPackage ./default.nix { 3 + sourceVersion = { major = "2"; minor = "0"; patch = "5"; }; 4 + inherit self passthruFun; 5 version = "2.0.5-2022-03-13"; 6 rev = "93a65d3cc263aef2d2feb3d7ff2206aca3bee17e"; 7 isStable = true;
+3 -3
pkgs/development/interpreters/luajit/2.1.nix
··· 1 - { self, callPackage }: 2 callPackage ./default.nix { 3 - inherit self; 4 - packagesAttr = "luajit_2_1.pkgs"; 5 version = "2.1.0-2022-04-05"; 6 rev = "5e3c45c43bb0e0f1f2917d432e9d2dba12c42a6e"; 7 isStable = false;
··· 1 + { self, callPackage, passthruFun }: 2 callPackage ./default.nix { 3 + sourceVersion = { major = "2"; minor = "1"; patch = "0"; }; 4 + inherit self passthruFun; 5 version = "2.1.0-2022-04-05"; 6 rev = "5e3c45c43bb0e0f1f2917d432e9d2dba12c42a6e"; 7 isStable = false;
+26 -17
pkgs/development/interpreters/luajit/default.nix
··· 2 , stdenv 3 , fetchFromGitHub 4 , buildPackages 5 - , name ? "luajit-${version}" 6 , isStable 7 , hash 8 , rev 9 , version 10 - , packagesAttr 11 , extraMeta ? { } 12 , callPackage 13 , self 14 , packageOverrides ? (final: prev: {}) 15 , enableFFI ? true 16 , enableJIT ? true 17 , enableJITDebugModule ? enableJIT ··· 23 , enableAPICheck ? false 24 , enableVMAssertions ? false 25 , useSystemMalloc ? false 26 - }: 27 assert enableJITDebugModule -> enableJIT; 28 assert enableGDBJITSupport -> enableJIT; 29 assert enableValgrindSupport -> valgrind != null; 30 let 31 - luaPackages = callPackage ../../lua-modules { 32 - lua = self; 33 - overrides = packageOverrides; 34 - inherit packagesAttr; 35 - }; 36 37 XCFLAGS = with lib; 38 optional (!enableFFI) "-DLUAJIT_DISABLE_FFI" ··· 47 ; 48 in 49 stdenv.mkDerivation rec { 50 - inherit name version; 51 src = fetchFromGitHub { 52 owner = "LuaJIT"; 53 repo = "LuaJIT"; ··· 103 104 setupHook = luaPackages.lua-setup-hook luaPackages.luaLib.luaPathList luaPackages.luaLib.luaCPathList; 105 106 - passthru = rec { 107 - buildEnv = callPackage ../lua-5/wrapper.nix { 108 - lua = self; 109 - inherit (luaPackages) requiredLuaModules; 110 - }; 111 - withPackages = import ../lua-5/with-packages.nix { inherit buildEnv luaPackages; }; 112 - pkgs = luaPackages; 113 - interpreter = "${self}/bin/lua"; 114 }; 115 116 meta = with lib; {
··· 2 , stdenv 3 , fetchFromGitHub 4 , buildPackages 5 , isStable 6 , hash 7 , rev 8 , version 9 , extraMeta ? { } 10 , callPackage 11 , self 12 , packageOverrides ? (final: prev: {}) 13 + , pkgsBuildBuild 14 + , pkgsBuildHost 15 + , pkgsBuildTarget 16 + , pkgsHostHost 17 + , pkgsTargetTarget 18 + , sourceVersion 19 + , passthruFun 20 , enableFFI ? true 21 , enableJIT ? true 22 , enableJITDebugModule ? enableJIT ··· 28 , enableAPICheck ? false 29 , enableVMAssertions ? false 30 , useSystemMalloc ? false 31 + , luaAttr ? "luajit_${sourceVersion.major}_${sourceVersion.minor}" 32 + } @ inputs: 33 assert enableJITDebugModule -> enableJIT; 34 assert enableGDBJITSupport -> enableJIT; 35 assert enableValgrindSupport -> valgrind != null; 36 let 37 + 38 + luaPackages = self.pkgs; 39 40 XCFLAGS = with lib; 41 optional (!enableFFI) "-DLUAJIT_DISABLE_FFI" ··· 50 ; 51 in 52 stdenv.mkDerivation rec { 53 + pname = "luajit"; 54 + inherit version; 55 src = fetchFromGitHub { 56 owner = "LuaJIT"; 57 repo = "LuaJIT"; ··· 107 108 setupHook = luaPackages.lua-setup-hook luaPackages.luaLib.luaPathList luaPackages.luaLib.luaCPathList; 109 110 + # copied from python 111 + passthru = let 112 + # When we override the interpreter we also need to override the spliced versions of the interpreter 113 + inputs' = lib.filterAttrs (n: v: ! lib.isDerivation v && n != "passthruFun") inputs; 114 + override = attr: let lua = attr.override (inputs' // { self = lua; }); in lua; 115 + in passthruFun rec { 116 + inherit self luaversion packageOverrides luaAttr sourceVersion; 117 + executable = "lua"; 118 + luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr}; 119 + luaOnBuildForHost = override pkgsBuildHost.${luaAttr}; 120 + luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr}; 121 + luaOnHostForHost = override pkgsHostHost.${luaAttr}; 122 + luaOnTargetForTarget = if lib.hasAttr luaAttr pkgsTargetTarget then (override pkgsTargetTarget.${luaAttr}) else {}; 123 }; 124 125 meta = with lib; {
-43
pkgs/development/lua-modules/default.nix
··· 1 - # inspired by pkgs/development/haskell-modules/default.nix 2 - { pkgs, lib 3 - , lua 4 - , packagesAttr 5 - , stdenv 6 - , callPackage 7 - , overrides ? (final: prev: {}) 8 - }: 9 - 10 - let 11 - 12 - inherit (lib) extends; 13 - 14 - initialPackages = import ../../top-level/lua-packages.nix { 15 - inherit lua pkgs lib stdenv; 16 - }; 17 - 18 - overridenPackages = callPackage ./overrides.nix { }; 19 - 20 - generatedPackages = if (builtins.pathExists ./generated-packages.nix) then 21 - (final: prev: callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {}); 22 - 23 - extensions = lib.composeManyExtensions [ 24 - generatedPackages 25 - overridenPackages 26 - overrides 27 - ]; 28 - 29 - otherSplices = let 30 - packagesAttrFun = set: lib.getAttrFromPath (lib.splitString "." packagesAttr) set; 31 - in { 32 - selfBuildBuild = packagesAttrFun pkgs.pkgsBuildBuild; 33 - selfBuildHost = packagesAttrFun pkgs.pkgsBuildHost; 34 - selfBuildTarget = packagesAttrFun pkgs.pkgsBuildTarget; 35 - selfHostHost = packagesAttrFun pkgs.pkgsHostHost; 36 - selfTargetTarget = if pkgs.pkgsTargetTarget.__raw or false then {} else packagesAttrFun pkgs.pkgsTargetTarget; # might be missing; 37 - }; 38 - keep = self: { }; 39 - extra = spliced0: { }; 40 - 41 - in 42 - lib.makeScopeWithSplicing pkgs.splicePackages pkgs.newScope otherSplices keep extra 43 - (lib.extends extensions initialPackages)
···
+4 -3
pkgs/top-level/lua-packages.nix
··· 5 for each package in a separate file: the call to the function would 6 be almost as must code as the function itself. */ 7 8 - { stdenv 9 , lua 10 - , pkgs 11 - , lib 12 }: 13 14 self: 15
··· 5 for each package in a separate file: the call to the function would 6 be almost as must code as the function itself. */ 7 8 + { pkgs 9 + , stdenv 10 + , lib 11 , lua 12 }: 13 + 14 15 self: 16