nixpkgs/pkgs/development/interpreters/lua-5/interpreter.nix
Chuck d13360bfb7 lua5: Fix src URLs
The 672c3c1d2a refactor accidentally
dropped the last version component from the source URLs.  This change
puts its back.

$ for lua in lua5_{1,2,3};do nix-instantiate --json --eval . -A $lua.src.urls | jq -r '.[]' | xargs nix-prefetch-url; done

Before this change:

lua-5.1.tar.gz 1hbjhh211p82vhwqhx4mmhmvhv56060acnka80gbmfdk3q3bjnvz (wrong hash because this is lua 5.1.0.  We want 5.1.5 )
lua-5.2.tar.gz HTTP error 404
lua-5.3.tar.gz HTTP error 404

After this change:

lua-5.1.5.tar.gz 0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16
lua-5.2.4.tar.gz 0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr <-- Desired hash
lua-5.3.5.tar.gz 1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc

Converted to base16 with `nix-hash --type sha256 --to-base16`:

lua-5.1.5.tar.gz 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 <-- Desired hash
lua-5.2.4.tar.gz b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b
lua-5.3.5.tar.gz 0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac <-- Desired hash
2020-01-31 18:00:45 -08:00

115 lines
3.5 KiB
Nix

{ stdenv, fetchurl, readline
, compat ? false
, callPackage
, packageOverrides ? (self: super: {})
, sourceVersion
, hash
, patches ? []
, postConfigure ? null
, postBuild ? null
}:
let
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
self = stdenv.mkDerivation rec {
pname = "lua";
luaversion = with sourceVersion; "${major}.${minor}";
version = "${luaversion}.${sourceVersion.patch}";
src = fetchurl {
url = "https://www.lua.org/ftp/${pname}-${version}.tar.gz";
sha256 = hash;
};
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion;
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
buildInputs = [ readline ];
inherit patches;
# see configurePhase for additional flags (with space)
makeFlags = [
"INSTALL_TOP=${placeholder "out"}"
"INSTALL_MAN=${placeholder "out"}/share/man/man1"
"R=${version}"
"LDFLAGS=-fPIC"
"V=${luaversion}"
] ++ (if stdenv.isDarwin then [
"PLAT=macosx"
] else [
"PLAT=linux"
]) ++ (if stdenv.buildPlatform != stdenv.hostPlatform then [
"CC=${stdenv.hostPlatform.config}-gcc"
"RANLIB=${stdenv.hostPlatform.config}-ranlib"
] else [])
;
configurePhase = ''
runHook preConfigure
makeFlagsArray+=(CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" )
makeFlagsArray+=(${stdenv.lib.optionalString stdenv.isDarwin "CC=\"$CC\""}${stdenv.lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) " 'AR=${stdenv.hostPlatform.config}-ar rcu'"})
installFlagsArray=( TO_BIN="lua luac" INSTALL_DATA='cp -d' \
TO_LIB="${if stdenv.isDarwin then "liblua.${version}.dylib" else "liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}"}" )
runHook postConfigure
'';
inherit postConfigure;
inherit postBuild;
postInstall = ''
mkdir -p "$out/share/doc/lua" "$out/lib/pkgconfig"
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/lua.pc" <<EOF
prefix=$out
libdir=$out/lib
includedir=$out/include
INSTALL_BIN=$out/bin
INSTALL_INC=$out/include
INSTALL_LIB=$out/lib
INSTALL_MAN=$out/man/man1
Name: Lua
Description: An Extensible Extension Language
Version: ${version}
Requires:
Libs: -L$out/lib -llua -lm
Cflags: -I$out/include
EOF
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${luaversion}.pc"
'';
passthru = rec {
buildEnv = callPackage ./wrapper.nix {
lua = self;
inherit (luaPackages) requiredLuaModules;
};
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;};
pkgs = luaPackages;
interpreter = "${self}/bin/lua";
};
meta = {
homepage = http://www.lua.org;
description = "Powerful, fast, lightweight, embeddable scripting language";
longDescription = ''
Lua combines simple procedural syntax with powerful data
description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, runs by interpreting bytecode
for a register-based virtual machine, and has automatic memory
management with incremental garbage collection, making it ideal
for configuration, scripting, and rapid prototyping.
'';
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.unix;
};
};
in self