diff options
author | Artturin <Artturin@artturin.com> | 2022-08-26 06:17:06 +0300 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2022-08-26 20:55:30 +0300 |
commit | 39571bd6fa6d558c45d67e91333a3cfda645b738 (patch) | |
tree | 6c50a5f66864f348ff17d18d36cca41139e0ebc3 /pkgs/development/interpreters/lua-5 | |
parent | bdb8ca175ab6c65d2b7db2c085f0c4e4ef4743f5 (diff) |
luaPackages: copy passthruFun from python
Diffstat (limited to 'pkgs/development/interpreters/lua-5')
-rw-r--r-- | pkgs/development/interpreters/lua-5/build-lua-package.nix | 5 | ||||
-rw-r--r-- | pkgs/development/interpreters/lua-5/default.nix | 88 | ||||
-rw-r--r-- | pkgs/development/interpreters/lua-5/interpreter.nix | 47 |
3 files changed, 114 insertions, 26 deletions
diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix index b69c7443e7ecc..b2f82ddb4694f 100644 --- a/pkgs/development/interpreters/lua-5/build-lua-package.nix +++ b/pkgs/development/interpreters/lua-5/build-lua-package.nix @@ -1,7 +1,6 @@ # Generic builder for lua packages { lib , lua -, buildPackages , wrapLua , luarocks # Whether the derivation provides a lua module or not. @@ -14,9 +13,7 @@ pname , version # by default prefix `name` e.g. "lua5.2-${name}" -, namePrefix ? if lua.pkgs.isLuaJIT - then lua.name + "-" - else "lua" + lua.luaversion + "-" +, namePrefix ? "${lua.pname}${lua.sourceVersion.major}.${lua.sourceVersion.minor}-" # Dependencies for building the package , buildInputs ? [] diff --git a/pkgs/development/interpreters/lua-5/default.nix b/pkgs/development/interpreters/lua-5/default.nix index 97e444ded903c..39de727854374 100644 --- a/pkgs/development/interpreters/lua-5/default.nix +++ b/pkgs/development/interpreters/lua-5/default.nix @@ -1,11 +1,86 @@ # similar to interpreters/python/default.nix { stdenv, lib, callPackage, fetchurl, fetchpatch, makeBinaryWrapper }: + +let + + # Common passthru for all lua interpreters. + # copied from python + passthruFun = + { executable + , sourceVersion + , 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, splicePackages, newScope }: 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: {}); + overridenPackages = callPackage ../../lua-modules/overrides.nix { }; + + otherSplices = { + selfBuildBuild = luaOnBuildForBuild.pkgs; + selfBuildHost = luaOnBuildForHost.pkgs; + selfBuildTarget = luaOnBuildForTarget.pkgs; + selfHostHost = luaOnHostForHost.pkgs; + selfTargetTarget = luaOnTargetForTarget.pkgs or {}; + }; + keep = self: { }; + extra = spliced0: {}; + extensions = lib.composeManyExtensions [ + generatedPackages + overridenPackages + overrides + ]; + in lib.makeScopeWithSplicing + splicePackages + newScope + otherSplices + keep + extra + (lib.extends extensions luaPackagesFun)) + { + overrides = packageOverrides; + lua = self; + }; + in rec { + buildEnv = callPackage ./wrapper.nix { + lua = self; + inherit (luaPackages) requiredLuaModules; + }; + withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;}; + pkgs = luaPackages; + interpreter = "${self}/bin/${executable}"; + inherit executable luaversion sourceVersion; + luaOnBuild = luaOnBuildForHost.override { inherit packageOverrides; self = luaOnBuild; }; + + inherit luaAttr; + }; + +in + rec { lua5_4 = callPackage ./interpreter.nix { + self = lua5_4; sourceVersion = { major = "5"; minor = "4"; patch = "3"; }; hash = "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq"; makeWrapper = makeBinaryWrapper; + inherit passthruFun; patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch ++ [ @@ -28,53 +103,62 @@ rec { }; lua5_4_compat = lua5_4.override({ + self = lua5_4_compat; compat = true; }); lua5_3 = callPackage ./interpreter.nix { + self = lua5_3; sourceVersion = { major = "5"; minor = "3"; patch = "6"; }; hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw"; makeWrapper = makeBinaryWrapper; + inherit passthruFun; patches = lib.optionals stdenv.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; sourceVersion = { major = "5"; minor = "2"; patch = "4"; }; hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"; makeWrapper = makeBinaryWrapper; + inherit passthruFun; patches = [ ./CVE-2022-28805.patch ] ++ lib.optional stdenv.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; sourceVersion = { major = "5"; minor = "1"; patch = "5"; }; hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"; makeWrapper = makeBinaryWrapper; + inherit passthruFun; patches = (lib.optional stdenv.isDarwin ./5.1.darwin.patch) ++ [ ./CVE-2014-5461.patch ]; }; luajit_2_0 = import ../luajit/2.0.nix { self = luajit_2_0; - inherit callPackage lib; + inherit callPackage lib passthruFun; }; luajit_2_1 = import ../luajit/2.1.nix { self = luajit_2_1; - inherit callPackage; + inherit callPackage passthruFun; }; } diff --git a/pkgs/development/interpreters/lua-5/interpreter.nix b/pkgs/development/interpreters/lua-5/interpreter.nix index c392a2c3bb524..d4af272e7cf61 100644 --- a/pkgs/development/interpreters/lua-5/interpreter.nix +++ b/pkgs/development/interpreters/lua-5/interpreter.nix @@ -2,22 +2,26 @@ , compat ? false , callPackage , makeWrapper +, self , packageOverrides ? (final: prev: {}) +, pkgsBuildBuild +, pkgsBuildHost +, pkgsBuildTarget +, pkgsHostHost +, pkgsTargetTarget , sourceVersion , hash +, passthruFun , patches ? [] , postConfigure ? null , postBuild ? null , staticOnly ? stdenv.hostPlatform.isStatic -}: +, luaAttr ? "lua${sourceVersion.major}_${sourceVersion.minor}" +} @ inputs: let - luaversion = with sourceVersion; "${major}.${minor}"; + luaPackages = self.pkgs; - luaPackages = callPackage ../../lua-modules { - lua = self; - overrides = packageOverrides; - packagesAttr = "lua${lib.replaceChars ["."] ["_"] luaversion}.pkgs"; - }; + luaversion = with sourceVersion; "${major}.${minor}"; plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux" else if (stdenv.isLinux && lib.versionAtLeast self.luaversion "5.4") then "linux-readline" @@ -28,8 +32,9 @@ plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux else if stdenv.hostPlatform.isBSD then "bsd" else if stdenv.hostPlatform.isUnix then "posix" else "generic"; +in -self = stdenv.mkDerivation rec { +stdenv.mkDerivation rec { pname = "lua"; version = "${luaversion}.${sourceVersion.patch}"; @@ -125,16 +130,19 @@ self = stdenv.mkDerivation rec { ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${lib.replaceStrings [ "." ] [ "" ] luaversion}.pc" ''; - passthru = rec { - inherit luaversion; - buildEnv = callPackage ./wrapper.nix { - lua = self; - inherit makeWrapper; - inherit (luaPackages) requiredLuaModules; - }; - withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;}; - pkgs = luaPackages; - interpreter = "${self}/bin/lua"; + # copied from python + passthru = let + # When we override the interpreter we also need to override the spliced versions of the interpreter + inputs' = lib.filterAttrs (n: v: ! lib.isDerivation v && n != "passthruFun") inputs; + override = attr: let lua = attr.override (inputs' // { self = lua; }); in lua; + in passthruFun rec { + inherit self luaversion packageOverrides luaAttr sourceVersion; + executable = "lua"; + luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr}; + luaOnBuildForHost = override pkgsBuildHost.${luaAttr}; + luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr}; + luaOnHostForHost = override pkgsHostHost.${luaAttr}; + luaOnTargetForTarget = if lib.hasAttr luaAttr pkgsTargetTarget then (override pkgsTargetTarget.${luaAttr}) else {}; }; meta = { @@ -151,5 +159,4 @@ self = stdenv.mkDerivation rec { license = lib.licenses.mit; platforms = lib.platforms.unix; }; -}; -in self +} |