summary refs log tree commit diff
path: root/pkgs/development/interpreters/lua-5/default.nix
blob: c11a9d10d7b3931569209e9cd464c7d65b1c89bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{stdenv, fetchurl, ncurses, readline}:

stdenv.mkDerivation {
  name = "lua-5.1.4";

  src = fetchurl {
    url = "http://www.lua.org/ftp/lua-5.1.4.tar.gz";
    sha256 = "0fmgk100ficm1jbm4ga9xy484v4cm89wsdfckdybb9gjx8jy4f5h";
  };

  NIX_CFLAGS_COMPILE = "-fPIC";
  buildFlags = if stdenv.isLinux then "linux" else
	       if stdenv.isDarwin then "macosx" else
	       if stdenv.isFreeBSD then "freebsd" else
	       if stdenv.isBSD then "bsd" else
	       "posix";
  installFlags = "install INSTALL_TOP=\${out}";
  postInstall = ''
    sed -i -e "s@/usr/local@$out@" etc/lua.pc
    sed -i -e "s@-llua -lm@-llua -lm -ldl@" etc/lua.pc
    mkdir -p "$out/lib/pkgconfig"
    install -m 644 etc/lua.pc $out/lib/pkgconfig/lua.pc
  '';
  buildInputs = [ ncurses readline ];

  crossAttrs = {
    preBuild = ''
      sed -i -e "s/ gcc/$crossConfig-gcc/" \
        -e "s/ ar/$crossConfig-ar/" \
        -e "s/ ranlib/$crossConfig-ranlib/" \
        src/Makefile
    '';
    dontStrip = true;
  };

  meta = {
    homepage = "http://www.lua.org";
    description = "Lua is a 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 = "MIT";
    platforms = stdenv.lib.platforms.unix;
    maintainers = [];
  };
}