diff options
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix')
-rw-r--r-- | nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix | 82 |
1 files changed, 21 insertions, 61 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix b/nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix index 64e872ad5f63..ff93e842eeae 100644 --- a/nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix +++ b/nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix @@ -25,7 +25,6 @@ pname # propagate build dependencies so in case we have A -> B -> C, # C can import package A propagated by B , propagatedBuildInputs ? [] -, propagatedNativeBuildInputs ? [] # used to disable derivation, useful for specific lua versions # TODO move from this setting meta.broken to a 'disabled' attribute on the @@ -50,7 +49,7 @@ pname # The latter is used to work-around luarocks having a problem with # multiple-output derivations as external deps: # https://github.com/luarocks/luarocks/issues/766<Paste> -, externalDeps ? lib.unique (lib.filter (drv: !drv ? luaModule) (propagatedBuildInputs ++ buildInputs)) +, externalDeps ? [] # Appended to the generated luarocks config , extraConfig ? "" @@ -74,7 +73,6 @@ pname let generatedRockspecFilename = "${rockspecDir}/${pname}-${version}.rockspec"; - # TODO fix warnings "Couldn't load rockspec for ..." during manifest # construction -- from initial investigation, appears it will require # upstream luarocks changes to fix cleanly (during manifest construction, @@ -82,70 +80,30 @@ let # configured trees) luarocks_config = "luarocks-config.lua"; luarocks_content = let - extraVariablesStr = lib.concatStringsSep "\n " - (lib.mapAttrsToList (k: v: "${k}='${v}';") extraVariables); - in '' - local_cache = "" - -- To prevent collisions when creating environments, we install the rock - -- files into per-package subdirectories - rocks_subdir = '${rocksSubdir}' - -- Then we need to tell luarocks where to find the rock files per - -- dependency - rocks_trees = { - ${lib.concatStringsSep "\n, " rocksTrees} - } - '' + lib.optionalString lua.pkgs.isLuaJIT '' - -- Luajit provides some additional functionality built-in; this exposes - -- that to luarock's dependency system - rocks_provided = { - jit='${lua.luaversion}-1'; - ffi='${lua.luaversion}-1'; - luaffi='${lua.luaversion}-1'; - bit='${lua.luaversion}-1'; - } - '' + '' - -- For single-output external dependencies - external_deps_dirs = { - ${lib.concatStringsSep "\n, " externalDepsDirs} - } - variables = { - -- Some needed machinery to handle multiple-output external dependencies, - -- as per https://github.com/luarocks/luarocks/issues/766 - ${lib.optionalString (lib.length depVariables > 0) '' - ${lib.concatStringsSep "\n " depVariables}''} - ${extraVariablesStr} - } - ${extraConfig} - ''; + generatedConfig = lua.pkgs.lib.generateLuarocksConfig { + externalDeps = externalDeps ++ externalDepsGenerated; + inherit extraVariables; + inherit rocksSubdir; + inherit requiredLuaRocks; + }; + in + '' + ${generatedConfig} + ${extraConfig} + ''; rocksSubdir = "${attrs.pname}-${version}-rocks"; - externalDepsDirs = map - (x: "'${builtins.toString x}'") - (lib.filter (lib.isDerivation) externalDeps); - - rocksTrees = lib.imap0 - (i: dep: "{ name = [[dep-${toString i}]], root = '${dep}', rocks_dir = '${dep}/${dep.rocksSubdir}' }") - requiredLuaRocks; - # Filter out the lua derivation itself from the Lua module dependency # closure, as it doesn't have a rock tree :) requiredLuaRocks = lib.filter (d: d ? luaModule) - (lua.pkgs.requiredLuaModules propagatedBuildInputs); - - # Explicitly point luarocks to the relevant locations for multiple-output - # derivations that are external dependencies, to work around an issue it has - # (https://github.com/luarocks/luarocks/issues/766) - depVariables = lib.concatMap ({name, dep}: [ - "${name}_INCDIR='${lib.getDev dep}/include';" - "${name}_LIBDIR='${lib.getLib dep}/lib';" - "${name}_BINDIR='${lib.getBin dep}/bin';" - ]) externalDeps'; + (lua.pkgs.requiredLuaModules luarocksDrv.propagatedBuildInputs); # example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ] + externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs)); externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps; -in -toLuaModule ( lua.stdenv.mkDerivation ( + + luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation ( builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // { name = namePrefix + pname + "-" + version; @@ -187,13 +145,12 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab runHook postConfigure ''; - # TODO could be moved to configurePhase buildPhase = '' runHook preBuild nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG" - LUAROCKS=luarocks + LUAROCKS=${lua.pkgs.luarocks}/bin/luarocks if (( ''${NIX_DEBUG:-0} >= 1 )); then LUAROCKS="$LUAROCKS --verbose" fi @@ -236,6 +193,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab passthru = { inherit lua; # The lua interpreter inherit externalDeps; + inherit luarocks_content; } // passthru; meta = { @@ -244,4 +202,6 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab maintainers = (meta.maintainers or []) ++ [ ]; broken = disabled; } // meta; -})) +})); +in + luarocksDrv |