From b1f80738f157c37fe8d150b7ee19bdd9abd5d5dc Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 22 Aug 2022 17:42:58 +0300 Subject: [PATCH 01/12] lua-packages.nix: run nixpkgs-fmt --- pkgs/top-level/lua-packages.nix | 268 +++++++++++++++++--------------- 1 file changed, 142 insertions(+), 126 deletions(-) diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 012a4d1e0c77..2598fd314fee 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -1,141 +1,157 @@ /* This file defines the composition for Lua packages. It has - been factored out of all-packages.nix because there are many of - them. Also, because most Nix expressions for Lua packages are - trivial, most are actually defined here. I.e. there's no function - for each package in a separate file: the call to the function would - be almost as must code as the function itself. */ + been factored out of all-packages.nix because there are many of + them. Also, because most Nix expressions for Lua packages are + trivial, most are actually defined here. I.e. there's no function + for each package in a separate file: the call to the function would + be almost as must code as the function itself. */ -{ fetchurl, stdenv, lua, unzip, pkg-config -, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat -, autoreconfHook, gnum4 -, postgresql, cyrus_sasl -, fetchFromGitHub, which, writeText +{ fetchurl +, stdenv +, lua +, unzip +, pkg-config +, pcre +, oniguruma +, gnulib +, tre +, glibc +, sqlite +, openssl +, expat +, autoreconfHook +, gnum4 +, postgresql +, cyrus_sasl +, fetchFromGitHub +, which +, writeText , pkgs , lib }@args: let - packages = ( self: + packages = (self: -let - callPackage = pkgs.newScope self; + let + callPackage = pkgs.newScope self; - buildLuaApplication = args: buildLuarocksPackage ({namePrefix="";} // args ); + buildLuaApplication = args: buildLuarocksPackage ({ namePrefix = ""; } // args); - buildLuarocksPackage = lib.makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix { - inherit lua; - inherit (pkgs) lib; - inherit (luaLib) toLuaModule; - }); + buildLuarocksPackage = lib.makeOverridable (callPackage ../development/interpreters/lua-5/build-lua-package.nix { + inherit lua; + inherit (pkgs) lib; + inherit (luaLib) toLuaModule; + }); - luaLib = import ../development/lua-modules/lib.nix { - inherit (pkgs) lib; - inherit pkgs lua; - }; + luaLib = import ../development/lua-modules/lib.nix { + inherit (pkgs) lib; + inherit pkgs lua; + }; - #define build lua package function - buildLuaPackage = callPackage ../development/lua-modules/generic { - inherit writeText; - }; + #define build lua package function + buildLuaPackage = callPackage ../development/lua-modules/generic { + inherit writeText; + }; - getPath = drv: pathListForVersion: - lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; + getPath = drv: pathListForVersion: + lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; + in + { + # helper functions for dealing with LUA_PATH and LUA_CPATH + lib = luaLib; + + getLuaPath = drv: getPath drv luaLib.luaPathList; + getLuaCPath = drv: getPath drv luaLib.luaCPathList; + + inherit (callPackage ../development/interpreters/lua-5/hooks { inherit (args) lib; }) + luarocksMoveDataFolder luarocksCheckHook lua-setup-hook; + + inherit lua callPackage; + inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; + inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT + requiredLuaModules toLuaModule hasLuaModule; + + # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH + wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { + inherit lua lib; + inherit (pkgs.buildPackages) makeSetupHook makeWrapper; + }; + + luarocks = callPackage ../development/tools/misc/luarocks/default.nix { + inherit lua lib; + }; + + # a fork of luarocks used to generate nix lua derivations from rockspecs + luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; + + luxio = buildLuaPackage { + pname = "luxio"; + version = "13"; + + src = fetchurl { + url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2"; + sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz"; + }; + + nativeBuildInputs = [ which pkg-config ]; + + postPatch = '' + patchShebangs . + ''; + + preBuild = '' + makeFlagsArray=( + INST_LIBDIR="$out/lib/lua/${lua.luaversion}" + INST_LUADIR="$out/share/lua/${lua.luaversion}" + LUA_BINDIR="$out/bin" + INSTALL=install + ); + ''; + + meta = with lib; { + broken = stdenv.isDarwin; + description = "Lightweight UNIX I/O and POSIX binding for Lua"; + homepage = "https://www.gitano.org.uk/luxio/"; + license = licenses.mit; + maintainers = with maintainers; [ richardipsum ]; + platforms = platforms.unix; + }; + }; + + nfd = callPackage ../development/lua-modules/nfd { + inherit (lib) maintainers; + inherit (pkgs.gnome) zenity; + }; + + vicious = luaLib.toLuaModule (stdenv.mkDerivation rec { + pname = "vicious"; + version = "2.5.1"; + + src = fetchFromGitHub { + owner = "vicious-widgets"; + repo = "vicious"; + rev = "v${version}"; + sha256 = "sha256-geu/g/dFAVxtY1BuJYpZoVtFS/oL66NFnqiLAnJELtI="; + }; + + buildInputs = [ lua ]; + + installPhase = '' + mkdir -p $out/lib/lua/${lua.luaversion}/ + cp -r . $out/lib/lua/${lua.luaversion}/vicious/ + printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua + ''; + + meta = with lib; { + description = "A modular widget library for the awesome window manager"; + homepage = "https://vicious.rtfd.io"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ makefu mic92 McSinyx ]; + platforms = platforms.linux; + }; + }); + + }); in -{ - # helper functions for dealing with LUA_PATH and LUA_CPATH - lib = luaLib; - - getLuaPath = drv: getPath drv luaLib.luaPathList; - getLuaCPath = drv: getPath drv luaLib.luaCPathList; - - inherit (callPackage ../development/interpreters/lua-5/hooks { inherit (args) lib;}) - luarocksMoveDataFolder luarocksCheckHook lua-setup-hook; - - inherit lua callPackage; - inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; - inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT - requiredLuaModules toLuaModule hasLuaModule; - - # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH - wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { - inherit lua lib; - inherit (pkgs.buildPackages) makeSetupHook makeWrapper; - }; - - luarocks = callPackage ../development/tools/misc/luarocks/default.nix { - inherit lua lib; - }; - - # a fork of luarocks used to generate nix lua derivations from rockspecs - luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; - - luxio = buildLuaPackage { - pname = "luxio"; - version = "13"; - - src = fetchurl { - url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2"; - sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz"; - }; - - nativeBuildInputs = [ which pkg-config ]; - - postPatch = '' - patchShebangs . - ''; - - preBuild = '' - makeFlagsArray=( - INST_LIBDIR="$out/lib/lua/${lua.luaversion}" - INST_LUADIR="$out/share/lua/${lua.luaversion}" - LUA_BINDIR="$out/bin" - INSTALL=install - ); - ''; - - meta = with lib; { - broken = stdenv.isDarwin; - description = "Lightweight UNIX I/O and POSIX binding for Lua"; - homepage = "https://www.gitano.org.uk/luxio/"; - license = licenses.mit; - maintainers = with maintainers; [ richardipsum ]; - platforms = platforms.unix; - }; - }; - - nfd = callPackage ../development/lua-modules/nfd { - inherit (lib) maintainers; - inherit (pkgs.gnome) zenity; - }; - - vicious = luaLib.toLuaModule( stdenv.mkDerivation rec { - pname = "vicious"; - version = "2.5.1"; - - src = fetchFromGitHub { - owner = "vicious-widgets"; - repo = "vicious"; - rev = "v${version}"; - sha256 = "sha256-geu/g/dFAVxtY1BuJYpZoVtFS/oL66NFnqiLAnJELtI="; - }; - - buildInputs = [ lua ]; - - installPhase = '' - mkdir -p $out/lib/lua/${lua.luaversion}/ - cp -r . $out/lib/lua/${lua.luaversion}/vicious/ - printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua - ''; - - meta = with lib; { - description = "A modular widget library for the awesome window manager"; - homepage = "https://vicious.rtfd.io"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ makefu mic92 McSinyx ]; - platforms = platforms.linux; - }; - }); - -}); -in packages +packages From f0ba59156ff76082ba5c9aebd8247a0b3eb6cee3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 22 Aug 2022 17:44:02 +0300 Subject: [PATCH 02/12] lua-packages.nix: remove unused args --- pkgs/top-level/lua-packages.nix | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 2598fd314fee..bea7c8142f1c 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -8,20 +8,7 @@ { fetchurl , stdenv , lua -, unzip , pkg-config -, pcre -, oniguruma -, gnulib -, tre -, glibc -, sqlite -, openssl -, expat -, autoreconfHook -, gnum4 -, postgresql -, cyrus_sasl , fetchFromGitHub , which , writeText From 613c4107502b9d9906584dec11487947bcc70c53 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 22 Aug 2022 23:09:29 +0300 Subject: [PATCH 03/12] lua-modules: use composeManyExtensions --- pkgs/development/lua-modules/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/development/lua-modules/default.nix b/pkgs/development/lua-modules/default.nix index 0c8bc1814b53..8f1ca7deea16 100644 --- a/pkgs/development/lua-modules/default.nix +++ b/pkgs/development/lua-modules/default.nix @@ -17,13 +17,13 @@ let generatedPackages = if (builtins.pathExists ./generated-packages.nix) then (final: prev: pkgs.callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {}); - extensible-self = lib.makeExtensible - (extends overrides - (extends overridenPackages - (extends generatedPackages - initialPackages - ) - ) - ); + extensions = lib.composeManyExtensions [ + generatedPackages + overridenPackages + overrides + ]; + + extensible-self = lib.makeExtensible (lib.extends extensions initialPackages); + in extensible-self From ec35f6341bc64bea3cfd4f384085c6c28f3590b8 Mon Sep 17 00:00:00 2001 From: Artturin Date: Tue, 23 Aug 2022 01:45:37 +0300 Subject: [PATCH 04/12] lua-packages: try splicing --- .../editors/neovim/build-neovim-plugin.nix | 2 +- pkgs/applications/editors/neovim/utils.nix | 4 +- .../interpreters/lua-5/build-lua-package.nix | 12 +- .../interpreters/lua-5/interpreter.nix | 9 +- pkgs/development/interpreters/luajit/2.0.nix | 1 + pkgs/development/interpreters/luajit/2.1.nix | 1 + .../interpreters/luajit/default.nix | 13 +- pkgs/development/lua-modules/default.nix | 23 +- pkgs/development/lua-modules/nfd/default.nix | 6 +- pkgs/development/lua-modules/overrides.nix | 60 ++--- .../tools/misc/luarocks/default.nix | 9 +- pkgs/misc/openrussian-cli/default.nix | 4 +- pkgs/servers/nfd/default.nix | 2 +- pkgs/top-level/lua-packages.nix | 233 ++++++++---------- 14 files changed, 194 insertions(+), 185 deletions(-) diff --git a/pkgs/applications/editors/neovim/build-neovim-plugin.nix b/pkgs/applications/editors/neovim/build-neovim-plugin.nix index cb69b5ecacdb..f89d36741e94 100644 --- a/pkgs/applications/editors/neovim/build-neovim-plugin.nix +++ b/pkgs/applications/editors/neovim/build-neovim-plugin.nix @@ -20,7 +20,7 @@ in }@attrs: let originalLuaDrv = lua51Packages.${luaAttr}; - luaDrv = lua51Packages.lib.overrideLuarocks originalLuaDrv (drv: { + luaDrv = lua51Packages.luaLib.overrideLuarocks originalLuaDrv (drv: { extraConfig = '' -- to create a flat hierarchy lua_modules_path = "lua" diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index cb0c005759b8..fe3ffc3830f6 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -115,8 +115,8 @@ let ] ++ lib.optionals (binPath != "") [ "--suffix" "PATH" ":" binPath ] ++ lib.optionals (luaEnv != null) [ - "--prefix" "LUA_PATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaPathAbsStr luaEnv) - "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaCPathAbsStr luaEnv) + "--prefix" "LUA_PATH" ";" (neovim-unwrapped.lua.pkgs.luaLib.genLuaPathAbsStr luaEnv) + "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv) ]; manifestRc = vimUtils.vimrcContent ({ customRC = ""; }) ; diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix index 0af7b470b0b3..918bca238639 100644 --- a/pkgs/development/interpreters/lua-5/build-lua-package.nix +++ b/pkgs/development/interpreters/lua-5/build-lua-package.nix @@ -1,10 +1,12 @@ # Generic builder for lua packages { lib , lua +, buildPackages , wrapLua +, luarocks # Whether the derivation provides a lua module or not. -, toLuaModule , luarocksCheckHook +, luaLib }: { @@ -82,7 +84,7 @@ let # configured trees) luarocks_config = "luarocks-config.lua"; luarocks_content = let - generatedConfig = lua.pkgs.lib.generateLuarocksConfig { + generatedConfig = luaLib.generateLuarocksConfig { externalDeps = externalDeps ++ externalDepsGenerated; inherit extraVariables; inherit rocksSubdir; @@ -107,14 +109,14 @@ let ); externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps; - luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation ( + luarocksDrv = luaLib.toLuaModule ( lua.stdenv.mkDerivation ( builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // { name = namePrefix + pname + "-" + version; nativeBuildInputs = [ wrapLua - lua.pkgs.luarocks + luarocks ] ++ buildInputs ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs) @@ -156,7 +158,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG" - LUAROCKS=${lua.pkgs.luarocks}/bin/luarocks + LUAROCKS=luarocks if (( ''${NIX_DEBUG:-0} >= 1 )); then LUAROCKS="$LUAROCKS --verbose" fi diff --git a/pkgs/development/interpreters/lua-5/interpreter.nix b/pkgs/development/interpreters/lua-5/interpreter.nix index 1fb56851ce52..c392a2c3bb52 100644 --- a/pkgs/development/interpreters/lua-5/interpreter.nix +++ b/pkgs/development/interpreters/lua-5/interpreter.nix @@ -11,9 +11,12 @@ , staticOnly ? stdenv.hostPlatform.isStatic }: let + luaversion = with sourceVersion; "${major}.${minor}"; + luaPackages = callPackage ../../lua-modules { lua = self; overrides = packageOverrides; + packagesAttr = "lua${lib.replaceChars ["."] ["_"] luaversion}.pkgs"; }; plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux" @@ -28,7 +31,6 @@ plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux self = stdenv.mkDerivation rec { pname = "lua"; - luaversion = with sourceVersion; "${major}.${minor}"; version = "${luaversion}.${sourceVersion.patch}"; src = fetchurl { @@ -36,8 +38,8 @@ self = stdenv.mkDerivation rec { sha256 = hash; }; - LuaPathSearchPaths = luaPackages.lib.luaPathList; - LuaCPathSearchPaths = luaPackages.lib.luaCPathList; + LuaPathSearchPaths = luaPackages.luaLib.luaPathList; + LuaCPathSearchPaths = luaPackages.luaLib.luaCPathList; setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; nativeBuildInputs = [ makeWrapper ]; @@ -124,6 +126,7 @@ self = stdenv.mkDerivation rec { ''; passthru = rec { + inherit luaversion; buildEnv = callPackage ./wrapper.nix { lua = self; inherit makeWrapper; diff --git a/pkgs/development/interpreters/luajit/2.0.nix b/pkgs/development/interpreters/luajit/2.0.nix index f2fc16963cad..0816ecb548fb 100644 --- a/pkgs/development/interpreters/luajit/2.0.nix +++ b/pkgs/development/interpreters/luajit/2.0.nix @@ -1,6 +1,7 @@ { self, callPackage, lib }: callPackage ./default.nix { inherit self; + packagesAttr = "luajit_2_0.pkgs"; version = "2.0.5-2022-03-13"; rev = "93a65d3cc263aef2d2feb3d7ff2206aca3bee17e"; isStable = true; diff --git a/pkgs/development/interpreters/luajit/2.1.nix b/pkgs/development/interpreters/luajit/2.1.nix index 507bc40fcf6a..25232a52c4b4 100644 --- a/pkgs/development/interpreters/luajit/2.1.nix +++ b/pkgs/development/interpreters/luajit/2.1.nix @@ -1,6 +1,7 @@ { self, callPackage }: callPackage ./default.nix { inherit self; + packagesAttr = "luajit_2_1.pkgs"; version = "2.1.0-2022-04-05"; rev = "5e3c45c43bb0e0f1f2917d432e9d2dba12c42a6e"; isStable = false; diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix index 480e34244134..9fe697d887a7 100644 --- a/pkgs/development/interpreters/luajit/default.nix +++ b/pkgs/development/interpreters/luajit/default.nix @@ -7,6 +7,7 @@ , hash , rev , version +, packagesAttr , extraMeta ? { } , callPackage , self @@ -27,7 +28,11 @@ assert enableJITDebugModule -> enableJIT; assert enableGDBJITSupport -> enableJIT; assert enableValgrindSupport -> valgrind != null; let - luaPackages = callPackage ../../lua-modules { lua = self; overrides = packageOverrides; }; + luaPackages = callPackage ../../lua-modules { + lua = self; + overrides = packageOverrides; + inherit packagesAttr; + }; XCFLAGS = with lib; optional (!enableFFI) "-DLUAJIT_DISABLE_FFI" @@ -93,10 +98,10 @@ stdenv.mkDerivation rec { ln -s "$out"/bin/luajit-* "$out"/bin/luajit ''; - LuaPathSearchPaths = luaPackages.lib.luaPathList; - LuaCPathSearchPaths = luaPackages.lib.luaCPathList; + LuaPathSearchPaths = luaPackages.luaLib.luaPathList; + LuaCPathSearchPaths = luaPackages.luaLib.luaCPathList; - setupHook = luaPackages.lua-setup-hook luaPackages.lib.luaPathList luaPackages.lib.luaCPathList; + setupHook = luaPackages.lua-setup-hook luaPackages.luaLib.luaPathList luaPackages.luaLib.luaCPathList; passthru = rec { buildEnv = callPackage ../lua-5/wrapper.nix { diff --git a/pkgs/development/lua-modules/default.nix b/pkgs/development/lua-modules/default.nix index 8f1ca7deea16..30492b79d9c1 100644 --- a/pkgs/development/lua-modules/default.nix +++ b/pkgs/development/lua-modules/default.nix @@ -1,6 +1,8 @@ # inspired by pkgs/development/haskell-modules/default.nix { pkgs, lib , lua +, packagesAttr +, stdenv , overrides ? (final: prev: {}) }: @@ -8,9 +10,9 @@ let inherit (lib) extends; - initialPackages = (pkgs.callPackage ../../top-level/lua-packages.nix { - inherit lua; - }); + initialPackages = import ../../top-level/lua-packages.nix { + inherit lua pkgs lib stdenv; + }; overridenPackages = import ./overrides.nix { inherit pkgs; }; @@ -23,7 +25,18 @@ let overrides ]; - extensible-self = lib.makeExtensible (lib.extends extensions initialPackages); + otherSplices = let + packagesAttrFun = set: lib.getAttrFromPath (lib.splitString "." packagesAttr) set; + in { + selfBuildBuild = packagesAttrFun pkgs.pkgsBuildBuild; + selfBuildHost = packagesAttrFun pkgs.pkgsBuildHost; + selfBuildTarget = packagesAttrFun pkgs.pkgsBuildTarget; + selfHostHost = packagesAttrFun pkgs.pkgsHostHost; + selfTargetTarget = if pkgs.pkgsTargetTarget.__raw or false then {} else packagesAttrFun pkgs.pkgsTargetTarget; # might be missing; + }; + keep = self: { }; + extra = spliced0: { }; in - extensible-self + lib.makeScopeWithSplicing pkgs.splicePackages pkgs.newScope otherSplices keep extra + (lib.extends extensions initialPackages) diff --git a/pkgs/development/lua-modules/nfd/default.nix b/pkgs/development/lua-modules/nfd/default.nix index 6605202f6bd1..ab6e1b83d79b 100644 --- a/pkgs/development/lua-modules/nfd/default.nix +++ b/pkgs/development/lua-modules/nfd/default.nix @@ -1,4 +1,4 @@ -{ fetchFromGitHub, buildLuarocksPackage, lua, maintainers, pkg-config +{ fetchFromGitHub, buildLuarocksPackage, lua, pkg-config, lib , substituteAll, zenity }: buildLuarocksPackage { @@ -35,7 +35,7 @@ buildLuarocksPackage { description = "A tiny, neat lua library that portably invokes native file open and save dialogs."; homepage = "https://github.com/Alloyed/nativefiledialog/tree/master/lua"; - license.fullName = "zlib"; - maintainers = [ maintainers.scoder12 ]; + license = lib.licenses.zlib; + maintainers = [ lib.maintainers.scoder12 ]; }; } diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index 418db1b7bd3b..cbd93554bdec 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -29,7 +29,7 @@ with prev; ''; }); - cqueues = (prev.lib.overrideLuarocks prev.cqueues (drv: { + cqueues = (prev.luaLib.overrideLuarocks prev.cqueues (drv: { externalDeps = [ { name = "CRYPTO"; dep = pkgs.openssl_1_1; } { name = "OPENSSL"; dep = pkgs.openssl_1_1; } @@ -63,7 +63,7 @@ with prev; ''; }); - cyrussasl = prev.lib.overrideLuarocks prev.cyrussasl (drv: { + cyrussasl = prev.luaLib.overrideLuarocks prev.cyrussasl (drv: { externalDeps = [ { name = "LIBSASL"; dep = pkgs.cyrus_sasl; } ]; @@ -83,7 +83,7 @@ with prev; */ }); - ldbus = prev.lib.overrideLuarocks prev.ldbus (drv: { + ldbus = prev.luaLib.overrideLuarocks prev.ldbus (drv: { extraVariables = { DBUS_DIR="${pkgs.dbus.lib}"; DBUS_ARCH_INCDIR="${pkgs.dbus.lib}/lib/dbus-1.0/include"; @@ -94,7 +94,7 @@ with prev; ]; }); - ljsyscall = prev.lib.overrideLuarocks prev.ljsyscall (drv: rec { + ljsyscall = prev.luaLib.overrideLuarocks prev.ljsyscall (drv: rec { version = "unstable-20180515"; # package hasn't seen any release for a long time src = pkgs.fetchFromGitHub { @@ -135,7 +135,7 @@ with prev; ''; }); - lmathx = prev.lib.overrideLuarocks prev.lmathx (drv: + lmathx = prev.luaLib.overrideLuarocks prev.lmathx (drv: if luaAtLeast "5.1" && luaOlder "5.2" then { version = "20120430.51-1"; knownRockspec = (pkgs.fetchurl { @@ -167,7 +167,7 @@ with prev; ''; }); - lmpfrlib = prev.lib.overrideLuarocks prev.lmpfrlib (drv: { + lmpfrlib = prev.luaLib.overrideLuarocks prev.lmpfrlib (drv: { externalDeps = [ { name = "GMP"; dep = pkgs.gmp; } { name = "MPFR"; dep = pkgs.mpfr; } @@ -177,25 +177,25 @@ with prev; ''; }); - lrexlib-gnu = prev.lib.overrideLuarocks prev.lrexlib-gnu (drv: { + lrexlib-gnu = prev.luaLib.overrideLuarocks prev.lrexlib-gnu (drv: { buildInputs = [ pkgs.gnulib ]; }); - lrexlib-pcre = prev.lib.overrideLuarocks prev.lrexlib-pcre (drv: { + lrexlib-pcre = prev.luaLib.overrideLuarocks prev.lrexlib-pcre (drv: { externalDeps = [ { name = "PCRE"; dep = pkgs.pcre; } ]; }); - lrexlib-posix = prev.lib.overrideLuarocks prev.lrexlib-posix (drv: { + lrexlib-posix = prev.luaLib.overrideLuarocks prev.lrexlib-posix (drv: { buildInputs = [ pkgs.glibc.dev ]; }); - lua-iconv = prev.lib.overrideLuarocks prev.lua-iconv (drv: { + lua-iconv = prev.luaLib.overrideLuarocks prev.lua-iconv (drv: { buildInputs = [ pkgs.libiconv ]; @@ -209,14 +209,14 @@ with prev; ''; }); - lua-zlib = prev.lib.overrideLuarocks prev.lua-zlib (drv: { + lua-zlib = prev.luaLib.overrideLuarocks prev.lua-zlib (drv: { buildInputs = [ pkgs.zlib.dev ]; disabled = luaOlder "5.1" || luaAtLeast "5.4"; }); - luadbi-mysql = prev.lib.overrideLuarocks prev.luadbi-mysql (drv: { + luadbi-mysql = prev.luaLib.overrideLuarocks prev.luadbi-mysql (drv: { extraVariables = { # Can't just be /include and /lib, unfortunately needs the trailing 'mysql' MYSQL_INCDIR="${pkgs.libmysqlclient.dev}/include/mysql"; @@ -228,19 +228,19 @@ with prev; ]; }); - luadbi-postgresql = prev.lib.overrideLuarocks prev.luadbi-postgresql (drv: { + luadbi-postgresql = prev.luaLib.overrideLuarocks prev.luadbi-postgresql (drv: { buildInputs = [ pkgs.postgresql ]; }); - luadbi-sqlite3 = prev.lib.overrideLuarocks prev.luadbi-sqlite3 (drv: { + luadbi-sqlite3 = prev.luaLib.overrideLuarocks prev.luadbi-sqlite3 (drv: { externalDeps = [ { name = "SQLITE"; dep = pkgs.sqlite; } ]; }); - luaevent = prev.lib.overrideLuarocks prev.luaevent (drv: { + luaevent = prev.luaLib.overrideLuarocks prev.luaevent (drv: { propagatedBuildInputs = [ luasocket ]; @@ -250,7 +250,7 @@ with prev; disabled = luaOlder "5.1" || luaAtLeast "5.4"; }); - luaexpat = prev.lib.overrideLuarocks prev.luaexpat (drv: { + luaexpat = prev.luaLib.overrideLuarocks prev.luaexpat (drv: { externalDeps = [ { name = "EXPAT"; dep = pkgs.expat; } ]; @@ -258,7 +258,7 @@ with prev; # TODO Somehow automatically amend buildInputs for things that need luaffi # but are in luajitPackages? - luaffi = prev.lib.overrideLuarocks prev.luaffi (drv: { + luaffi = prev.luaLib.overrideLuarocks prev.luaffi (drv: { # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3 src = pkgs.fetchFromGitHub { owner = "facebook"; repo = "luaffifb"; @@ -269,7 +269,7 @@ with prev; disabled = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT; }); - luaossl = prev.lib.overrideLuarocks prev.luaossl (drv: { + luaossl = prev.luaLib.overrideLuarocks prev.luaossl (drv: { externalDeps = [ # https://github.com/wahern/luaossl/pull/199 { name = "CRYPTO"; dep = pkgs.openssl_1_1; } @@ -277,41 +277,41 @@ with prev; ]; }); - luasec = prev.lib.overrideLuarocks prev.luasec (drv: { + luasec = prev.luaLib.overrideLuarocks prev.luasec (drv: { externalDeps = [ { name = "OPENSSL"; dep = pkgs.openssl_1_1; } ]; }); - luasql-sqlite3 = prev.lib.overrideLuarocks prev.luasql-sqlite3 (drv: { + luasql-sqlite3 = prev.luaLib.overrideLuarocks prev.luasql-sqlite3 (drv: { externalDeps = [ { name = "SQLITE"; dep = pkgs.sqlite; } ]; }); - luasystem = prev.lib.overrideLuarocks prev.luasystem (drv: pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { + luasystem = prev.luaLib.overrideLuarocks prev.luasystem (drv: pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { buildInputs = [ pkgs.glibc.out ]; }); - luazip = prev.lib.overrideLuarocks prev.luazip (drv: { + luazip = prev.luaLib.overrideLuarocks prev.luazip (drv: { buildInputs = [ pkgs.zziplib ]; }); - lua-yajl = prev.lib.overrideLuarocks prev.lua-yajl (drv: { + lua-yajl = prev.luaLib.overrideLuarocks prev.lua-yajl (drv: { buildInputs = [ pkgs.yajl ]; }); - luaunbound = prev.lib.overrideLuarocks prev.luaunbound(drv: { + luaunbound = prev.luaLib.overrideLuarocks prev.luaunbound(drv: { externalDeps = [ { name = "libunbound"; dep = pkgs.unbound; } ]; }); - luuid = (prev.lib.overrideLuarocks prev.luuid (drv: { + luuid = (prev.luaLib.overrideLuarocks prev.luuid (drv: { externalDeps = [ { name = "LIBUUID"; dep = pkgs.libuuid; } ]; @@ -361,7 +361,7 @@ with prev; ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.fixDarwinDylibNames ]; }; - luv = prev.lib.overrideLuarocks prev.luv (drv: { + luv = prev.luaLib.overrideLuarocks prev.luv (drv: { buildInputs = [ pkgs.pkg-config pkgs.libuv ]; @@ -381,13 +381,13 @@ with prev; }); - lyaml = prev.lib.overrideLuarocks prev.lyaml (oa: { + lyaml = prev.luaLib.overrideLuarocks prev.lyaml (oa: { buildInputs = [ pkgs.libyaml ]; }); - mpack = prev.lib.overrideLuarocks prev.mpack (drv: { + mpack = prev.luaLib.overrideLuarocks prev.mpack (drv: { buildInputs = [ pkgs.libmpack ]; # the rockspec doesn't use the makefile so you may need to export more flags USE_SYSTEM_LUA = "yes"; @@ -401,7 +401,7 @@ with prev; ''; }); - readline = (prev.lib.overrideLuarocks prev.readline (drv: { + readline = (prev.luaLib.overrideLuarocks prev.readline (drv: { unpackCmd = '' unzip "$curSrc" tar xf *.tar.gz @@ -418,7 +418,7 @@ with prev; ''; }); - sqlite = prev.lib.overrideLuarocks prev.sqlite (drv: { + sqlite = prev.luaLib.overrideLuarocks prev.sqlite (drv: { doCheck = true; checkInputs = [ final.plenary-nvim pkgs.neovim-unwrapped ]; diff --git a/pkgs/development/tools/misc/luarocks/default.nix b/pkgs/development/tools/misc/luarocks/default.nix index 70df08af2de0..3628467617d2 100644 --- a/pkgs/development/tools/misc/luarocks/default.nix +++ b/pkgs/development/tools/misc/luarocks/default.nix @@ -1,4 +1,4 @@ -{lib, stdenv, fetchFromGitHub +{lib, stdenv, fetchFromGitHub, buildPackages , curl, makeWrapper, which, unzip , lua # for 'luarocks pack' @@ -43,12 +43,13 @@ stdenv.mkDerivation rec { fi ''; - nativeBuildInputs = [ makeWrapper installShellFiles ]; + nativeBuildInputs = [ makeWrapper installShellFiles lua unzip ]; - buildInputs = [ lua curl which ]; + buildInputs = [ curl which ]; postInstall = '' sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* + for i in "$out"/bin/*; do test -L "$i" || { wrapProgram "$i" \ @@ -58,7 +59,7 @@ stdenv.mkDerivation rec { --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" } done - + '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd luarocks --bash <($out/bin/luarocks completion bash) installShellCompletion --cmd luarocks --zsh <($out/bin/luarocks completion zsh) ''; diff --git a/pkgs/misc/openrussian-cli/default.nix b/pkgs/misc/openrussian-cli/default.nix index e6e089e88612..038bdd5a73f1 100644 --- a/pkgs/misc/openrussian-cli/default.nix +++ b/pkgs/misc/openrussian-cli/default.nix @@ -37,8 +37,8 @@ stdenv.mkDerivation rec { cp openrussian $out/bin wrapProgram $out/bin/openrussian \ - --prefix LUA_PATH ';' '${lua.pkgs.lib.genLuaPathAbsStr luaEnv}' \ - --prefix LUA_CPATH ';' '${lua.pkgs.lib.genLuaCPathAbsStr luaEnv}' + --prefix LUA_PATH ';' '${lua.pkgs.luaLib.genLuaPathAbsStr luaEnv}' \ + --prefix LUA_CPATH ';' '${lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv}' runHook postInstall ''; diff --git a/pkgs/servers/nfd/default.nix b/pkgs/servers/nfd/default.nix index 2f0176de2b82..3eda5e2b25dd 100644 --- a/pkgs/servers/nfd/default.nix +++ b/pkgs/servers/nfd/default.nix @@ -50,6 +50,6 @@ stdenv.mkDerivation rec { description = "Named Data Neworking (NDN) Forwarding Daemon"; license = licenses.gpl3Plus; platforms = platforms.unix; - maintainers = [ maintainers.bertof ]; + maintainers = [ lib.maintainers.bertof ]; }; } diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index bea7c8142f1c..42d7a44cf82c 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -5,140 +5,123 @@ for each package in a separate file: the call to the function would be almost as must code as the function itself. */ -{ fetchurl -, stdenv +{ stdenv , lua -, pkg-config -, fetchFromGitHub -, which -, writeText , pkgs , lib -}@args: +}: + +self: let - packages = (self: + inherit (self) callPackage; - let - callPackage = pkgs.newScope self; + buildLuaApplication = args: buildLuarocksPackage ({ namePrefix = ""; } // args); - buildLuaApplication = args: buildLuarocksPackage ({ namePrefix = ""; } // args); + buildLuarocksPackage = lib.makeOverridable (callPackage ../development/interpreters/lua-5/build-lua-package.nix { }); - buildLuarocksPackage = lib.makeOverridable (callPackage ../development/interpreters/lua-5/build-lua-package.nix { - inherit lua; - inherit (pkgs) lib; - inherit (luaLib) toLuaModule; - }); + luaLib = callPackage ../development/lua-modules/lib.nix { }; - luaLib = import ../development/lua-modules/lib.nix { - inherit (pkgs) lib; - inherit pkgs lua; - }; + #define build lua package function + buildLuaPackage = callPackage ../development/lua-modules/generic { }; - #define build lua package function - buildLuaPackage = callPackage ../development/lua-modules/generic { - inherit writeText; - }; + getPath = drv: pathListForVersion: + lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; - getPath = drv: pathListForVersion: - lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; - - in - { - # helper functions for dealing with LUA_PATH and LUA_CPATH - lib = luaLib; - - getLuaPath = drv: getPath drv luaLib.luaPathList; - getLuaCPath = drv: getPath drv luaLib.luaCPathList; - - inherit (callPackage ../development/interpreters/lua-5/hooks { inherit (args) lib; }) - luarocksMoveDataFolder luarocksCheckHook lua-setup-hook; - - inherit lua callPackage; - inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; - inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT - requiredLuaModules toLuaModule hasLuaModule; - - # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH - wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { - inherit lua lib; - inherit (pkgs.buildPackages) makeSetupHook makeWrapper; - }; - - luarocks = callPackage ../development/tools/misc/luarocks/default.nix { - inherit lua lib; - }; - - # a fork of luarocks used to generate nix lua derivations from rockspecs - luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; - - luxio = buildLuaPackage { - pname = "luxio"; - version = "13"; - - src = fetchurl { - url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2"; - sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz"; - }; - - nativeBuildInputs = [ which pkg-config ]; - - postPatch = '' - patchShebangs . - ''; - - preBuild = '' - makeFlagsArray=( - INST_LIBDIR="$out/lib/lua/${lua.luaversion}" - INST_LUADIR="$out/share/lua/${lua.luaversion}" - LUA_BINDIR="$out/bin" - INSTALL=install - ); - ''; - - meta = with lib; { - broken = stdenv.isDarwin; - description = "Lightweight UNIX I/O and POSIX binding for Lua"; - homepage = "https://www.gitano.org.uk/luxio/"; - license = licenses.mit; - maintainers = with maintainers; [ richardipsum ]; - platforms = platforms.unix; - }; - }; - - nfd = callPackage ../development/lua-modules/nfd { - inherit (lib) maintainers; - inherit (pkgs.gnome) zenity; - }; - - vicious = luaLib.toLuaModule (stdenv.mkDerivation rec { - pname = "vicious"; - version = "2.5.1"; - - src = fetchFromGitHub { - owner = "vicious-widgets"; - repo = "vicious"; - rev = "v${version}"; - sha256 = "sha256-geu/g/dFAVxtY1BuJYpZoVtFS/oL66NFnqiLAnJELtI="; - }; - - buildInputs = [ lua ]; - - installPhase = '' - mkdir -p $out/lib/lua/${lua.luaversion}/ - cp -r . $out/lib/lua/${lua.luaversion}/vicious/ - printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua - ''; - - meta = with lib; { - description = "A modular widget library for the awesome window manager"; - homepage = "https://vicious.rtfd.io"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ makefu mic92 McSinyx ]; - platforms = platforms.linux; - }; - }); - - }); in -packages +{ + + # Dont take luaPackages from "global" pkgs scope to avoid mixing lua versions + luaPackages = self; + + # helper functions for dealing with LUA_PATH and LUA_CPATH + inherit luaLib; + + getLuaPath = drv: getPath drv luaLib.luaPathList; + getLuaCPath = drv: getPath drv luaLib.luaCPathList; + + inherit (callPackage ../development/interpreters/lua-5/hooks { }) + luarocksMoveDataFolder luarocksCheckHook lua-setup-hook; + + inherit lua; + inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; + inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT + requiredLuaModules toLuaModule hasLuaModule; + + # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH + wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { + inherit (pkgs.buildPackages) makeSetupHook makeWrapper; + }; + + luarocks = callPackage ../development/tools/misc/luarocks/default.nix { }; + + # a fork of luarocks used to generate nix lua derivations from rockspecs + luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; + + luxio = callPackage ({ fetchurl, which, pkg-config }: buildLuaPackage { + pname = "luxio"; + version = "13"; + + src = fetchurl { + url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2"; + sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz"; + }; + + nativeBuildInputs = [ which pkg-config ]; + + postPatch = '' + patchShebangs . + ''; + + preBuild = '' + makeFlagsArray=( + INST_LIBDIR="$out/lib/lua/${lua.luaversion}" + INST_LUADIR="$out/share/lua/${lua.luaversion}" + LUA_BINDIR="$out/bin" + INSTALL=install + ); + ''; + + meta = with lib; { + broken = stdenv.isDarwin; + description = "Lightweight UNIX I/O and POSIX binding for Lua"; + homepage = "https://www.gitano.org.uk/luxio/"; + license = licenses.mit; + maintainers = with maintainers; [ richardipsum ]; + platforms = platforms.unix; + }; + }); + + nfd = callPackage ../development/lua-modules/nfd { + inherit (pkgs.gnome) zenity; + }; + + vicious = (callPackage ({ fetchFromGitHub }: stdenv.mkDerivation rec { + pname = "vicious"; + version = "2.5.1"; + + src = fetchFromGitHub { + owner = "vicious-widgets"; + repo = "vicious"; + rev = "v${version}"; + sha256 = "sha256-geu/g/dFAVxtY1BuJYpZoVtFS/oL66NFnqiLAnJELtI="; + }; + + buildInputs = [ lua ]; + + installPhase = '' + mkdir -p $out/lib/lua/${lua.luaversion}/ + cp -r . $out/lib/lua/${lua.luaversion}/vicious/ + printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua + ''; + + meta = with lib; { + description = "A modular widget library for the awesome window manager"; + homepage = "https://vicious.rtfd.io"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ makefu mic92 McSinyx ]; + platforms = platforms.linux; + }; + }) {}); + +} From a2c61752fb424f0f4345113d18a1b4a14a10c381 Mon Sep 17 00:00:00 2001 From: Artturin Date: Tue, 23 Aug 2022 02:31:38 +0300 Subject: [PATCH 05/12] lua.pkgs.luarocks: fix usage in cross-compilation copy of comment https://github.com/luarocks/luarocks/pull/1433/commits/8d878e4981d71c08090f509c390dcb4c879971f6#r954257465 with this patch the build of luasystem fails LD=ld ``` ld -shared -o system/core.so src/core.o src/compat.o src/time.o -L/nix/store/...-glibc-2.35-163/lib -Wl,-rpath,/nix/store/...-glibc-2.35-163/lib -lrt /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: unrecognized option '-Wl,-rpath,/nix/store/...-glibc-2.35-163/lib' /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: use the --help option for usage information Error: Build error: Failed compiling module system/core.so ``` LD=gcc ``` gcc -shared -o system/core.so src/core.o src/compat.o src/time.o -L/nix/store/...-glibc-2.35-163/lib -Wl,-rpath,/nix/store/...-glibc-2.35-163/lib -lrt ``` `-Wl,rpath... -lrt` are added by https://github.com/luarocks/luarocks/blob/ecb63347bf7d44c68210befc9d03c013350c7831/src/luarocks/build/builtin.lua#L249-L250 --- pkgs/development/tools/misc/luarocks/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/misc/luarocks/default.nix b/pkgs/development/tools/misc/luarocks/default.nix index 3628467617d2..533648c217d6 100644 --- a/pkgs/development/tools/misc/luarocks/default.nix +++ b/pkgs/development/tools/misc/luarocks/default.nix @@ -1,4 +1,5 @@ {lib, stdenv, fetchFromGitHub, buildPackages +, fetchpatch , curl, makeWrapper, which, unzip , lua # for 'luarocks pack' @@ -20,7 +21,15 @@ stdenv.mkDerivation rec { sha256 = "sha256-i0NmF268aK5lr4zjYyhk4TPUO7Zyz0Cl0fSW43Pmd1Q="; }; - patches = [ ./darwin-3.7.0.patch ]; + patches = [ + ./darwin-3.7.0.patch + # follow standard environmental variables + # https://github.com/luarocks/luarocks/pull/1433 + (fetchpatch { + url = "https://github.com/luarocks/luarocks/commit/d719541577a89909185aa8de7a33cf73b7a63ac3.diff"; + sha256 = "sha256-rMnhZFqLEul0wnsxvw9nl6JXVanC5QgOZ+I/HJ0vRCM="; + }) + ]; postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' From a59a6bc4ea5ef1cd5d9148e8420b42495785592d Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 24 Aug 2022 19:06:16 +0300 Subject: [PATCH 06/12] lua-modules/overrides.nix: run nixpkgs-fmt --- pkgs/development/lua-modules/overrides.nix | 146 +++++++++++---------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index cbd93554bdec..36b04817987d 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -5,7 +5,7 @@ with prev; ##########################################3 #### manual fixes for generated packages ##########################################3 - bit32 = prev.bit32.overrideAttrs(oa: { + bit32 = prev.bit32.overrideAttrs (oa: { # Small patch in order to no longer redefine a Lua 5.2 function that Luajit # 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for # more @@ -14,7 +14,7 @@ with prev; ]; }); - busted = prev.busted.overrideAttrs(oa: { + busted = prev.busted.overrideAttrs (oa: { nativeBuildInputs = oa.nativeBuildInputs ++ [ pkgs.installShellFiles ]; @@ -35,14 +35,15 @@ with prev; { name = "OPENSSL"; dep = pkgs.openssl_1_1; } ]; disabled = luaOlder "5.1" || luaAtLeast "5.4"; - })).overrideAttrs(oa: rec { + })).overrideAttrs (oa: rec { # Parse out a version number without the Lua version inserted version = with pkgs.lib; let version' = prev.cqueues.version; rel = splitVersion version'; date = head rel; rev = last (splitString "-" (last rel)); - in "${date}-${rev}"; + in + "${date}-${rev}"; nativeBuildInputs = oa.nativeBuildInputs ++ [ pkgs.gnum4 @@ -50,17 +51,18 @@ with prev; # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua # version, which doesn't work well for us, so modify it - postConfigure = let inherit (prev.cqueues) pname; in '' - # 'all' target auto-detects correct Lua version, which is fine for us as - # we only have the right one available :) - sed -Ei ''${rockspecFilename} \ - -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.3|' \ - -e 's|build_target = "[^"]+"|build_target = "all"|' \ - -e 's|version = "[^"]+"|version = "${version}"|' - specDir=$(dirname ''${rockspecFilename}) - cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec" - rockspecFilename="$specDir/${pname}-${version}.rockspec" - ''; + postConfigure = let inherit (prev.cqueues) pname; in + '' + # 'all' target auto-detects correct Lua version, which is fine for us as + # we only have the right one available :) + sed -Ei ''${rockspecFilename} \ + -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.3|' \ + -e 's|build_target = "[^"]+"|build_target = "all"|' \ + -e 's|version = "[^"]+"|version = "${version}"|' + specDir=$(dirname ''${rockspecFilename}) + cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec" + rockspecFilename="$specDir/${pname}-${version}.rockspec" + ''; }); cyrussasl = prev.luaLib.overrideLuarocks prev.cyrussasl (drv: { @@ -69,7 +71,7 @@ with prev; ]; }); - http = prev.http.overrideAttrs(oa: { + http = prev.http.overrideAttrs (oa: { patches = [ (pkgs.fetchpatch { name = "invalid-state-progression.patch"; @@ -78,16 +80,16 @@ with prev; }) ]; /* TODO: separate docs derivation? (pandoc is heavy) - nativeBuildInputs = [ pandoc ]; - makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ]; + nativeBuildInputs = [ pandoc ]; + makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ]; */ }); ldbus = prev.luaLib.overrideLuarocks prev.ldbus (drv: { extraVariables = { - DBUS_DIR="${pkgs.dbus.lib}"; - DBUS_ARCH_INCDIR="${pkgs.dbus.lib}/lib/dbus-1.0/include"; - DBUS_INCDIR="${pkgs.dbus.dev}/include/dbus-1.0"; + DBUS_DIR = "${pkgs.dbus.lib}"; + DBUS_ARCH_INCDIR = "${pkgs.dbus.lib}/lib/dbus-1.0/include"; + DBUS_INCDIR = "${pkgs.dbus.dev}/include/dbus-1.0"; }; buildInputs = with pkgs; [ dbus @@ -139,33 +141,33 @@ with prev; if luaAtLeast "5.1" && luaOlder "5.2" then { version = "20120430.51-1"; knownRockspec = (pkgs.fetchurl { - url = "https://luarocks.org/lmathx-20120430.51-1.rockspec"; + url = "https://luarocks.org/lmathx-20120430.51-1.rockspec"; sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0"; }).outPath; src = pkgs.fetchurl { - url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz"; + url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz"; sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51"; }; } else - if luaAtLeast "5.2" && luaOlder "5.3" then { - version = "20120430.52-1"; - knownRockspec = (pkgs.fetchurl { - url = "https://luarocks.org/lmathx-20120430.52-1.rockspec"; - sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya"; - }).outPath; - src = pkgs.fetchurl { - url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz"; - sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5"; - }; - } else - { - disabled = luaOlder "5.1" || luaAtLeast "5.5"; - # works fine with 5.4 as well - postConfigure = '' - substituteInPlace ''${rockspecFilename} \ - --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5' - ''; - }); + if luaAtLeast "5.2" && luaOlder "5.3" then { + version = "20120430.52-1"; + knownRockspec = (pkgs.fetchurl { + url = "https://luarocks.org/lmathx-20120430.52-1.rockspec"; + sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya"; + }).outPath; + src = pkgs.fetchurl { + url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz"; + sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5"; + }; + } else + { + disabled = luaOlder "5.1" || luaAtLeast "5.5"; + # works fine with 5.4 as well + postConfigure = '' + substituteInPlace ''${rockspecFilename} \ + --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5' + ''; + }); lmpfrlib = prev.luaLib.overrideLuarocks prev.lmpfrlib (drv: { externalDeps = [ @@ -201,7 +203,7 @@ with prev; ]; }); - lua-lsp = prev.lua-lsp.overrideAttrs(oa: { + lua-lsp = prev.lua-lsp.overrideAttrs (oa: { # until Alloyed/lua-lsp#28 postConfigure = '' substituteInPlace ''${rockspecFilename} \ @@ -219,8 +221,8 @@ with prev; luadbi-mysql = prev.luaLib.overrideLuarocks prev.luadbi-mysql (drv: { extraVariables = { # Can't just be /include and /lib, unfortunately needs the trailing 'mysql' - MYSQL_INCDIR="${pkgs.libmysqlclient.dev}/include/mysql"; - MYSQL_LIBDIR="${pkgs.libmysqlclient}/lib/mysql"; + MYSQL_INCDIR = "${pkgs.libmysqlclient.dev}/include/mysql"; + MYSQL_LIBDIR = "${pkgs.libmysqlclient}/lib/mysql"; }; buildInputs = [ pkgs.mariadb.client @@ -261,7 +263,8 @@ with prev; luaffi = prev.luaLib.overrideLuarocks prev.luaffi (drv: { # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3 src = pkgs.fetchFromGitHub { - owner = "facebook"; repo = "luaffifb"; + owner = "facebook"; + repo = "luaffifb"; rev = "532c757e51c86f546a85730b71c9fef15ffa633d"; sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig"; }; @@ -305,7 +308,7 @@ with prev; ]; }); - luaunbound = prev.luaLib.overrideLuarocks prev.luaunbound(drv: { + luaunbound = prev.luaLib.overrideLuarocks prev.luaunbound (drv: { externalDeps = [ { name = "libunbound"; dep = pkgs.unbound; } ]; @@ -316,7 +319,7 @@ with prev; { name = "LIBUUID"; dep = pkgs.libuuid; } ]; disabled = luaOlder "5.1" || (luaAtLeast "5.4"); - })).overrideAttrs(oa: { + })).overrideAttrs (oa: { meta = oa.meta // { platforms = pkgs.lib.platforms.linux; }; @@ -329,9 +332,10 @@ with prev; patches = [ ./luuid.patch ]; - postConfigure = let inherit (prev.luuid) version pname; in '' - sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|' - ''; + postConfigure = let inherit (prev.luuid) version pname; in + '' + sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|' + ''; }); @@ -342,23 +346,23 @@ with prev; pname = "libluv"; inherit (prev.luv) version meta src; - cmakeFlags = [ - "-DBUILD_SHARED_LIBS=ON" - "-DBUILD_MODULE=OFF" - "-DWITH_SHARED_LIBUV=ON" - "-DLUA_BUILD_TYPE=System" - "-DWITH_LUA_ENGINE=${if isLuaJIT then "LuaJit" else "Lua"}" - ]; + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DBUILD_MODULE=OFF" + "-DWITH_SHARED_LIBUV=ON" + "-DLUA_BUILD_TYPE=System" + "-DWITH_LUA_ENGINE=${if isLuaJIT then "LuaJit" else "Lua"}" + ]; - # to make sure we dont use bundled deps - postUnpack = '' - rm -rf deps/lua deps/libuv - ''; + # to make sure we dont use bundled deps + postUnpack = '' + rm -rf deps/lua deps/libuv + ''; - buildInputs = [ pkgs.libuv final.lua ]; + buildInputs = [ pkgs.libuv final.lua ]; - nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake ] - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.fixDarwinDylibNames ]; + nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake ] + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.fixDarwinDylibNames ]; }; luv = prev.luaLib.overrideLuarocks prev.luv (drv: { @@ -394,7 +398,7 @@ with prev; USE_SYSTEM_MPACK = "yes"; }); - rapidjson = prev.rapidjson.overrideAttrs(oa: { + rapidjson = prev.rapidjson.overrideAttrs (oa: { preBuild = '' sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt @@ -418,7 +422,7 @@ with prev; ''; }); - sqlite = prev.luaLib.overrideLuarocks prev.sqlite (drv: { + sqlite = prev.luaLib.overrideLuarocks prev.sqlite (drv: { doCheck = true; checkInputs = [ final.plenary-nvim pkgs.neovim-unwrapped ]; @@ -435,14 +439,14 @@ with prev; }); - std-_debug = prev.std-_debug.overrideAttrs(oa: { + std-_debug = prev.std-_debug.overrideAttrs (oa: { # run make to generate lib/std/_debug/version.lua preConfigure = '' make all ''; }); - std-normalize = prev.std-normalize.overrideAttrs(oa: { + std-normalize = prev.std-normalize.overrideAttrs (oa: { # run make to generate lib/std/_debug/version.lua preConfigure = '' make all @@ -451,8 +455,8 @@ with prev; # TODO just while testing, remove afterwards # toVimPlugin should do it instead - gitsigns-nvim = prev.gitsigns-nvim.overrideAttrs(oa: { - nativeBuildInputs = oa.nativeBuildInputs or [] ++ [ pkgs.vimUtils.vimGenDocHook ]; + gitsigns-nvim = prev.gitsigns-nvim.overrideAttrs (oa: { + nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [ pkgs.vimUtils.vimGenDocHook ]; }); # aliases From 0345bab9a67b41b0d1b7fbe6f126e80174a20169 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 24 Aug 2022 19:34:46 +0300 Subject: [PATCH 07/12] lua-modules/overrides.nix: using pkgs. messes up splicing, dont use it commands used and then added -*'s manually because the word match doesn't match those ``` rg -o '\w*pkgs\.\w*' ./pkgs/development/lua-modules/overrides.nix | sort | uniq sd 'pkgs.' '' --string-mode ./pkgs/development/lua-modules/overrides.nix ``` --- pkgs/development/lua-modules/default.nix | 5 +- pkgs/development/lua-modules/overrides.nix | 167 +++++++++++++-------- 2 files changed, 107 insertions(+), 65 deletions(-) diff --git a/pkgs/development/lua-modules/default.nix b/pkgs/development/lua-modules/default.nix index 30492b79d9c1..e7ce417d2f17 100644 --- a/pkgs/development/lua-modules/default.nix +++ b/pkgs/development/lua-modules/default.nix @@ -3,6 +3,7 @@ , lua , packagesAttr , stdenv +, callPackage , overrides ? (final: prev: {}) }: @@ -14,10 +15,10 @@ let inherit lua pkgs lib stdenv; }; - overridenPackages = import ./overrides.nix { inherit pkgs; }; + overridenPackages = callPackage ./overrides.nix { }; generatedPackages = if (builtins.pathExists ./generated-packages.nix) then - (final: prev: pkgs.callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {}); + (final: prev: callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {}); extensions = lib.composeManyExtensions [ generatedPackages diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index 36b04817987d..475bfbe4598c 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -1,4 +1,45 @@ -{ pkgs }: +# do not add pkgs, it messes up splicing +{ stdenv +, cmake +, cyrus_sasl +, dbus +, expat +, fetchFromGitHub +, fetchpatch +, fetchurl +, fixDarwinDylibNames +, glib +, glibc +, gmp +, gnulib +, gnum4 +, gobject-introspection +, installShellFiles +, lib +, libevent +, libiconv +, libmpack +, libmysqlclient +, libuuid +, libuv +, libyaml +, mariadb +, mpfr +, neovim-unwrapped +, openssl_1_1 +, pcre +, pkg-config +, postgresql +, readline +, sqlite +, unbound +, vimPlugins +, vimUtils +, yajl +, zlib +, zziplib +}: + final: prev: with prev; { @@ -16,7 +57,7 @@ with prev; busted = prev.busted.overrideAttrs (oa: { nativeBuildInputs = oa.nativeBuildInputs ++ [ - pkgs.installShellFiles + installShellFiles ]; postConfigure = '' substituteInPlace ''${rockspecFilename} \ @@ -31,13 +72,13 @@ with prev; cqueues = (prev.luaLib.overrideLuarocks prev.cqueues (drv: { externalDeps = [ - { name = "CRYPTO"; dep = pkgs.openssl_1_1; } - { name = "OPENSSL"; dep = pkgs.openssl_1_1; } + { name = "CRYPTO"; dep = openssl_1_1; } + { name = "OPENSSL"; dep = openssl_1_1; } ]; disabled = luaOlder "5.1" || luaAtLeast "5.4"; })).overrideAttrs (oa: rec { # Parse out a version number without the Lua version inserted - version = with pkgs.lib; let + version = with lib; let version' = prev.cqueues.version; rel = splitVersion version'; date = head rel; @@ -46,7 +87,7 @@ with prev; "${date}-${rev}"; nativeBuildInputs = oa.nativeBuildInputs ++ [ - pkgs.gnum4 + gnum4 ]; # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua @@ -67,13 +108,13 @@ with prev; cyrussasl = prev.luaLib.overrideLuarocks prev.cyrussasl (drv: { externalDeps = [ - { name = "LIBSASL"; dep = pkgs.cyrus_sasl; } + { name = "LIBSASL"; dep = cyrus_sasl; } ]; }); http = prev.http.overrideAttrs (oa: { patches = [ - (pkgs.fetchpatch { + (fetchpatch { name = "invalid-state-progression.patch"; url = "https://github.com/daurnimator/lua-http/commit/cb7b59474a.diff"; sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7"; @@ -87,11 +128,11 @@ with prev; ldbus = prev.luaLib.overrideLuarocks prev.ldbus (drv: { extraVariables = { - DBUS_DIR = "${pkgs.dbus.lib}"; - DBUS_ARCH_INCDIR = "${pkgs.dbus.lib}/lib/dbus-1.0/include"; - DBUS_INCDIR = "${pkgs.dbus.dev}/include/dbus-1.0"; + DBUS_DIR = "${dbus.lib}"; + DBUS_ARCH_INCDIR = "${dbus.lib}/lib/dbus-1.0/include"; + DBUS_INCDIR = "${dbus.dev}/include/dbus-1.0"; }; - buildInputs = with pkgs; [ + buildInputs = [ dbus ]; }); @@ -99,7 +140,7 @@ with prev; ljsyscall = prev.luaLib.overrideLuarocks prev.ljsyscall (drv: rec { version = "unstable-20180515"; # package hasn't seen any release for a long time - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "justincormack"; repo = "ljsyscall"; rev = "e587f8c55aad3955dddab3a4fa6c1968037b5c6e"; @@ -112,19 +153,19 @@ with prev; ''; disabled = luaOlder "5.1" || luaAtLeast "5.3"; - propagatedBuildInputs = with pkgs.lib; optional (!isLuaJIT) luaffi; + propagatedBuildInputs = with lib; optional (!isLuaJIT) luaffi; }); lgi = prev.lgi.overrideAttrs (oa: { nativeBuildInputs = oa.nativeBuildInputs ++ [ - pkgs.pkg-config + pkg-config ]; buildInputs = [ - pkgs.glib - pkgs.gobject-introspection + glib + gobject-introspection ]; patches = [ - (pkgs.fetchpatch { + (fetchpatch { name = "lgi-find-cairo-through-typelib.patch"; url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch"; sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c"; @@ -140,22 +181,22 @@ with prev; lmathx = prev.luaLib.overrideLuarocks prev.lmathx (drv: if luaAtLeast "5.1" && luaOlder "5.2" then { version = "20120430.51-1"; - knownRockspec = (pkgs.fetchurl { + knownRockspec = (fetchurl { url = "https://luarocks.org/lmathx-20120430.51-1.rockspec"; sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0"; }).outPath; - src = pkgs.fetchurl { + src = fetchurl { url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz"; sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51"; }; } else if luaAtLeast "5.2" && luaOlder "5.3" then { version = "20120430.52-1"; - knownRockspec = (pkgs.fetchurl { + knownRockspec = (fetchurl { url = "https://luarocks.org/lmathx-20120430.52-1.rockspec"; sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya"; }).outPath; - src = pkgs.fetchurl { + src = fetchurl { url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz"; sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5"; }; @@ -171,8 +212,8 @@ with prev; lmpfrlib = prev.luaLib.overrideLuarocks prev.lmpfrlib (drv: { externalDeps = [ - { name = "GMP"; dep = pkgs.gmp; } - { name = "MPFR"; dep = pkgs.mpfr; } + { name = "GMP"; dep = gmp; } + { name = "MPFR"; dep = mpfr; } ]; unpackPhase = '' cp $src $(stripHash $src) @@ -181,25 +222,25 @@ with prev; lrexlib-gnu = prev.luaLib.overrideLuarocks prev.lrexlib-gnu (drv: { buildInputs = [ - pkgs.gnulib + gnulib ]; }); lrexlib-pcre = prev.luaLib.overrideLuarocks prev.lrexlib-pcre (drv: { externalDeps = [ - { name = "PCRE"; dep = pkgs.pcre; } + { name = "PCRE"; dep = pcre; } ]; }); lrexlib-posix = prev.luaLib.overrideLuarocks prev.lrexlib-posix (drv: { buildInputs = [ - pkgs.glibc.dev + glibc.dev ]; }); lua-iconv = prev.luaLib.overrideLuarocks prev.lua-iconv (drv: { buildInputs = [ - pkgs.libiconv + libiconv ]; }); @@ -213,7 +254,7 @@ with prev; lua-zlib = prev.luaLib.overrideLuarocks prev.lua-zlib (drv: { buildInputs = [ - pkgs.zlib.dev + zlib.dev ]; disabled = luaOlder "5.1" || luaAtLeast "5.4"; }); @@ -221,24 +262,24 @@ with prev; luadbi-mysql = prev.luaLib.overrideLuarocks prev.luadbi-mysql (drv: { extraVariables = { # Can't just be /include and /lib, unfortunately needs the trailing 'mysql' - MYSQL_INCDIR = "${pkgs.libmysqlclient.dev}/include/mysql"; - MYSQL_LIBDIR = "${pkgs.libmysqlclient}/lib/mysql"; + MYSQL_INCDIR = "${libmysqlclient.dev}/include/mysql"; + MYSQL_LIBDIR = "${libmysqlclient}/lib/mysql"; }; buildInputs = [ - pkgs.mariadb.client - pkgs.libmysqlclient + mariadb.client + libmysqlclient ]; }); luadbi-postgresql = prev.luaLib.overrideLuarocks prev.luadbi-postgresql (drv: { buildInputs = [ - pkgs.postgresql + postgresql ]; }); luadbi-sqlite3 = prev.luaLib.overrideLuarocks prev.luadbi-sqlite3 (drv: { externalDeps = [ - { name = "SQLITE"; dep = pkgs.sqlite; } + { name = "SQLITE"; dep = sqlite; } ]; }); @@ -247,14 +288,14 @@ with prev; luasocket ]; externalDeps = [ - { name = "EVENT"; dep = pkgs.libevent; } + { name = "EVENT"; dep = libevent; } ]; disabled = luaOlder "5.1" || luaAtLeast "5.4"; }); luaexpat = prev.luaLib.overrideLuarocks prev.luaexpat (drv: { externalDeps = [ - { name = "EXPAT"; dep = pkgs.expat; } + { name = "EXPAT"; dep = expat; } ]; }); @@ -262,7 +303,7 @@ with prev; # but are in luajitPackages? luaffi = prev.luaLib.overrideLuarocks prev.luaffi (drv: { # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3 - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "facebook"; repo = "luaffifb"; rev = "532c757e51c86f546a85730b71c9fef15ffa633d"; @@ -275,53 +316,53 @@ with prev; luaossl = prev.luaLib.overrideLuarocks prev.luaossl (drv: { externalDeps = [ # https://github.com/wahern/luaossl/pull/199 - { name = "CRYPTO"; dep = pkgs.openssl_1_1; } - { name = "OPENSSL"; dep = pkgs.openssl_1_1; } + { name = "CRYPTO"; dep = openssl_1_1; } + { name = "OPENSSL"; dep = openssl_1_1; } ]; }); luasec = prev.luaLib.overrideLuarocks prev.luasec (drv: { externalDeps = [ - { name = "OPENSSL"; dep = pkgs.openssl_1_1; } + { name = "OPENSSL"; dep = openssl_1_1; } ]; }); luasql-sqlite3 = prev.luaLib.overrideLuarocks prev.luasql-sqlite3 (drv: { externalDeps = [ - { name = "SQLITE"; dep = pkgs.sqlite; } + { name = "SQLITE"; dep = sqlite; } ]; }); - luasystem = prev.luaLib.overrideLuarocks prev.luasystem (drv: pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { - buildInputs = [ pkgs.glibc.out ]; + luasystem = prev.luaLib.overrideLuarocks prev.luasystem (drv: lib.optionalAttrs stdenv.isLinux { + buildInputs = [ glibc.out ]; }); luazip = prev.luaLib.overrideLuarocks prev.luazip (drv: { buildInputs = [ - pkgs.zziplib + zziplib ]; }); lua-yajl = prev.luaLib.overrideLuarocks prev.lua-yajl (drv: { buildInputs = [ - pkgs.yajl + yajl ]; }); luaunbound = prev.luaLib.overrideLuarocks prev.luaunbound (drv: { externalDeps = [ - { name = "libunbound"; dep = pkgs.unbound; } + { name = "libunbound"; dep = unbound; } ]; }); luuid = (prev.luaLib.overrideLuarocks prev.luuid (drv: { externalDeps = [ - { name = "LIBUUID"; dep = pkgs.libuuid; } + { name = "LIBUUID"; dep = libuuid; } ]; disabled = luaOlder "5.1" || (luaAtLeast "5.4"); })).overrideAttrs (oa: { meta = oa.meta // { - platforms = pkgs.lib.platforms.linux; + platforms = lib.platforms.linux; }; # Trivial patch to make it work in both 5.1 and 5.2. Basically just the # tiny diff between the two upstream versions placed behind an #if. @@ -341,7 +382,7 @@ with prev; # as advised in https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570 # we shouldn't use luarocks machinery to build complex cmake components - libluv = pkgs.stdenv.mkDerivation { + libluv = stdenv.mkDerivation { pname = "libluv"; inherit (prev.luv) version meta src; @@ -359,15 +400,15 @@ with prev; rm -rf deps/lua deps/libuv ''; - buildInputs = [ pkgs.libuv final.lua ]; + buildInputs = [ libuv final.lua ]; - nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake ] - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.fixDarwinDylibNames ]; + nativeBuildInputs = [ pkg-config cmake ] + ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ]; }; luv = prev.luaLib.overrideLuarocks prev.luv (drv: { - buildInputs = [ pkgs.pkg-config pkgs.libuv ]; + buildInputs = [ pkg-config libuv ]; # Use system libuv instead of building local and statically linking extraVariables = { @@ -387,12 +428,12 @@ with prev; lyaml = prev.luaLib.overrideLuarocks prev.lyaml (oa: { buildInputs = [ - pkgs.libyaml + libyaml ]; }); mpack = prev.luaLib.overrideLuarocks prev.mpack (drv: { - buildInputs = [ pkgs.libmpack ]; + buildInputs = [ libmpack ]; # the rockspec doesn't use the makefile so you may need to export more flags USE_SYSTEM_LUA = "yes"; USE_SYSTEM_MPACK = "yes"; @@ -410,30 +451,30 @@ with prev; unzip "$curSrc" tar xf *.tar.gz ''; - propagatedBuildInputs = prev.readline.propagatedBuildInputs ++ [ pkgs.readline.out ]; + propagatedBuildInputs = prev.readline.propagatedBuildInputs ++ [ readline.out ]; extraVariables = rec { - READLINE_INCDIR = "${pkgs.readline.dev}/include"; + READLINE_INCDIR = "${readline.dev}/include"; HISTORY_INCDIR = READLINE_INCDIR; }; })).overrideAttrs (old: { # Without this, source root is wrongly set to ./readline-2.6/doc setSourceRoot = '' - sourceRoot=./readline-${pkgs.lib.versions.majorMinor old.version} + sourceRoot=./readline-${lib.versions.majorMinor old.version} ''; }); sqlite = prev.luaLib.overrideLuarocks prev.sqlite (drv: { doCheck = true; - checkInputs = [ final.plenary-nvim pkgs.neovim-unwrapped ]; + checkInputs = [ final.plenary-nvim neovim-unwrapped ]; # we override 'luarocks test' because otherwise neovim doesn't find/load the plenary plugin checkPhase = '' - export LIBSQLITE="${pkgs.sqlite.out}/lib/libsqlite3.so" + export LIBSQLITE="${sqlite.out}/lib/libsqlite3.so" export HOME="$TMPDIR"; nvim --headless -i NONE \ - -u test/minimal_init.vim --cmd "set rtp+=${pkgs.vimPlugins.plenary-nvim}" \ + -u test/minimal_init.vim --cmd "set rtp+=${vimPlugins.plenary-nvim}" \ -c "PlenaryBustedDirectory test/auto/ { minimal_init = './test/minimal_init.vim' }" ''; @@ -456,7 +497,7 @@ with prev; # TODO just while testing, remove afterwards # toVimPlugin should do it instead gitsigns-nvim = prev.gitsigns-nvim.overrideAttrs (oa: { - nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [ pkgs.vimUtils.vimGenDocHook ]; + nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [ vimUtils.vimGenDocHook ]; }); # aliases From a13d38708998938c8f95e35292ef2ace24108a54 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 24 Aug 2022 23:44:04 +0300 Subject: [PATCH 08/12] build-lua-package: remove unnecessary adding of buildInputs to nativeBuildInputs and move externalDeps' back to buildInputs both accidentally caused in https://github.com/NixOS/nixpkgs/pull/178158/files --- .../interpreters/lua-5/build-lua-package.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix index 918bca238639..b69c7443e7ec 100644 --- a/pkgs/development/interpreters/lua-5/build-lua-package.nix +++ b/pkgs/development/interpreters/lua-5/build-lua-package.nix @@ -117,11 +117,11 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab nativeBuildInputs = [ wrapLua luarocks - ] - ++ buildInputs - ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs) - ++ (map (d: d.dep) externalDeps') - ; + ] ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs); + + buildInputs = buildInputs + ++ (map (d: d.dep) externalDeps'); + # propagate lua to active setup-hook in nix-shell propagatedBuildInputs = propagatedBuildInputs ++ [ lua ]; From 50a629cc3ade2e77c807702c14460239258a8016 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 25 Aug 2022 00:17:57 +0300 Subject: [PATCH 09/12] libmpack: fix cross libmpack-aarch64-unknown-linux-gnu> libtool: link: gcc -shared -fPIC -DPIC build/debug/src/.libs/core.o build/debug/src/.libs/conv.o build/debug/src/.libs/object.o build/debug/src/.libs/rpc.o -Wl,-soname -Wl,libmpack.so.0 -o build/debug/.libs/libmpack.so.0.0.0 libmpack-aarch64-unknown-linux-gnu> /nix/store/6rdvl63vp5p0gyknf0c3svlwfjd5nbjg-libtool-2.4.7/bin/libtool: line 10840: gcc: command not found libmpack-aarch64-unknown-linux-gnu> make: *** [Makefile:151: build/debug/libmpack.la] Error 127 --- pkgs/development/libraries/libmpack/default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libmpack/default.nix b/pkgs/development/libraries/libmpack/default.nix index b62da40499cd..a3e902c0f59f 100644 --- a/pkgs/development/libraries/libmpack/default.nix +++ b/pkgs/development/libraries/libmpack/default.nix @@ -10,9 +10,7 @@ stdenv.mkDerivation rec { sha256 = "0rai5djdkjz7bsn025k5489in7r1amagw1pib0z4qns6b52kiar2"; }; - nativeBuildInputs = [ libtool ]; - - makeFlags = [ "LIBTOOL=libtool" "PREFIX=$(out)" ]; + makeFlags = [ "LIBTOOL=${libtool}/bin/libtool" "PREFIX=$(out)" ]; meta = with lib; { description = "Simple implementation of msgpack in C"; From bdb8ca175ab6c65d2b7db2c085f0c4e4ef4743f5 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 25 Aug 2022 00:38:06 +0300 Subject: [PATCH 10/12] luaPackages.lgi: fix cross --- pkgs/development/lua-modules/overrides.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index 475bfbe4598c..1f76b4e5a6c9 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -172,6 +172,12 @@ with prev; }) ]; + # https://github.com/lgi-devs/lgi/pull/300 + postPatch = '' + substituteInPlace lgi/Makefile tests/Makefile \ + --replace 'PKG_CONFIG =' 'PKG_CONFIG ?=' + ''; + # there is only a rockspec.in in the repo, the actual rockspec must be generated preConfigure = '' make rock From 39571bd6fa6d558c45d67e91333a3cfda645b738 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 26 Aug 2022 06:17:06 +0300 Subject: [PATCH 11/12] luaPackages: copy passthruFun from python --- .../interpreters/lua-5/build-lua-package.nix | 5 +- .../interpreters/lua-5/default.nix | 88 ++++++++++++++++++- .../interpreters/lua-5/interpreter.nix | 47 +++++----- pkgs/development/interpreters/luajit/2.0.nix | 6 +- pkgs/development/interpreters/luajit/2.1.nix | 6 +- .../interpreters/luajit/default.nix | 43 +++++---- pkgs/development/lua-modules/default.nix | 43 --------- pkgs/top-level/lua-packages.nix | 7 +- 8 files changed, 150 insertions(+), 95 deletions(-) delete mode 100644 pkgs/development/lua-modules/default.nix diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix index b69c7443e7ec..b2f82ddb4694 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 97e444ded903..39de72785437 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 c392a2c3bb52..d4af272e7cf6 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 +} diff --git a/pkgs/development/interpreters/luajit/2.0.nix b/pkgs/development/interpreters/luajit/2.0.nix index 0816ecb548fb..fe7843caeb0f 100644 --- a/pkgs/development/interpreters/luajit/2.0.nix +++ b/pkgs/development/interpreters/luajit/2.0.nix @@ -1,7 +1,7 @@ -{ self, callPackage, lib }: +{ self, callPackage, lib, passthruFun }: callPackage ./default.nix { - inherit self; - packagesAttr = "luajit_2_0.pkgs"; + sourceVersion = { major = "2"; minor = "0"; patch = "5"; }; + inherit self passthruFun; version = "2.0.5-2022-03-13"; rev = "93a65d3cc263aef2d2feb3d7ff2206aca3bee17e"; isStable = true; diff --git a/pkgs/development/interpreters/luajit/2.1.nix b/pkgs/development/interpreters/luajit/2.1.nix index 25232a52c4b4..d5c539331e00 100644 --- a/pkgs/development/interpreters/luajit/2.1.nix +++ b/pkgs/development/interpreters/luajit/2.1.nix @@ -1,7 +1,7 @@ -{ self, callPackage }: +{ self, callPackage, passthruFun }: callPackage ./default.nix { - inherit self; - packagesAttr = "luajit_2_1.pkgs"; + sourceVersion = { major = "2"; minor = "1"; patch = "0"; }; + inherit self passthruFun; version = "2.1.0-2022-04-05"; rev = "5e3c45c43bb0e0f1f2917d432e9d2dba12c42a6e"; isStable = false; diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix index 9fe697d887a7..2d47b0395c36 100644 --- a/pkgs/development/interpreters/luajit/default.nix +++ b/pkgs/development/interpreters/luajit/default.nix @@ -2,16 +2,21 @@ , stdenv , fetchFromGitHub , buildPackages -, name ? "luajit-${version}" , isStable , hash , rev , version -, packagesAttr , extraMeta ? { } , callPackage , self , packageOverrides ? (final: prev: {}) +, pkgsBuildBuild +, pkgsBuildHost +, pkgsBuildTarget +, pkgsHostHost +, pkgsTargetTarget +, sourceVersion +, passthruFun , enableFFI ? true , enableJIT ? true , enableJITDebugModule ? enableJIT @@ -23,16 +28,14 @@ , enableAPICheck ? false , enableVMAssertions ? false , useSystemMalloc ? false -}: +, luaAttr ? "luajit_${sourceVersion.major}_${sourceVersion.minor}" +} @ inputs: assert enableJITDebugModule -> enableJIT; assert enableGDBJITSupport -> enableJIT; assert enableValgrindSupport -> valgrind != null; let - luaPackages = callPackage ../../lua-modules { - lua = self; - overrides = packageOverrides; - inherit packagesAttr; - }; + + luaPackages = self.pkgs; XCFLAGS = with lib; optional (!enableFFI) "-DLUAJIT_DISABLE_FFI" @@ -47,7 +50,8 @@ let ; in stdenv.mkDerivation rec { - inherit name version; + pname = "luajit"; + inherit version; src = fetchFromGitHub { owner = "LuaJIT"; repo = "LuaJIT"; @@ -103,14 +107,19 @@ stdenv.mkDerivation rec { setupHook = luaPackages.lua-setup-hook luaPackages.luaLib.luaPathList luaPackages.luaLib.luaCPathList; - passthru = rec { - buildEnv = callPackage ../lua-5/wrapper.nix { - lua = self; - inherit (luaPackages) requiredLuaModules; - }; - withPackages = import ../lua-5/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 = with lib; { diff --git a/pkgs/development/lua-modules/default.nix b/pkgs/development/lua-modules/default.nix deleted file mode 100644 index e7ce417d2f17..000000000000 --- a/pkgs/development/lua-modules/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -# inspired by pkgs/development/haskell-modules/default.nix -{ pkgs, lib -, lua -, packagesAttr -, stdenv -, callPackage -, overrides ? (final: prev: {}) -}: - -let - - inherit (lib) extends; - - initialPackages = import ../../top-level/lua-packages.nix { - inherit lua pkgs lib stdenv; - }; - - overridenPackages = callPackage ./overrides.nix { }; - - generatedPackages = if (builtins.pathExists ./generated-packages.nix) then - (final: prev: callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {}); - - extensions = lib.composeManyExtensions [ - generatedPackages - overridenPackages - overrides - ]; - - otherSplices = let - packagesAttrFun = set: lib.getAttrFromPath (lib.splitString "." packagesAttr) set; - in { - selfBuildBuild = packagesAttrFun pkgs.pkgsBuildBuild; - selfBuildHost = packagesAttrFun pkgs.pkgsBuildHost; - selfBuildTarget = packagesAttrFun pkgs.pkgsBuildTarget; - selfHostHost = packagesAttrFun pkgs.pkgsHostHost; - selfTargetTarget = if pkgs.pkgsTargetTarget.__raw or false then {} else packagesAttrFun pkgs.pkgsTargetTarget; # might be missing; - }; - keep = self: { }; - extra = spliced0: { }; - -in - lib.makeScopeWithSplicing pkgs.splicePackages pkgs.newScope otherSplices keep extra - (lib.extends extensions initialPackages) diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 42d7a44cf82c..3617e7632333 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -5,12 +5,13 @@ for each package in a separate file: the call to the function would be almost as must code as the function itself. */ -{ stdenv -, lua -, pkgs +{ pkgs +, stdenv , lib +, lua }: + self: let From 7b24b57c14b954ff15a0b49b8a0404a222e3f258 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 26 Aug 2022 20:00:31 +0300 Subject: [PATCH 12/12] luaPackages.luarocks: don't refer to luaOnBuild --- pkgs/development/tools/misc/luarocks/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/tools/misc/luarocks/default.nix b/pkgs/development/tools/misc/luarocks/default.nix index 533648c217d6..18285481514b 100644 --- a/pkgs/development/tools/misc/luarocks/default.nix +++ b/pkgs/development/tools/misc/luarocks/default.nix @@ -58,6 +58,8 @@ stdenv.mkDerivation rec { postInstall = '' sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* + substituteInPlace $out/etc/luarocks/* \ + --replace '${lua.luaOnBuild}' '${lua}' for i in "$out"/bin/*; do test -L "$i" || { @@ -86,6 +88,10 @@ stdenv.mkDerivation rec { export LUA_PATH="src/?.lua;''${LUA_PATH:-}" ''; + disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + lua.luaOnBuild + ]; + passthru = { updateScript = nix-update-script { attrPath = pname;