2010/3/30 Ludovic Courtès <[email protected]>: > Hi, > > François Perrad <[email protected]> writes: > >> + phases = "unpackPhase checkPhase installPhase fixupPhase"; >> + doCheck = true; >> + installFlags = "install DESTDIR=\${out}"; >> + postInstall = '' >> + export LUA_PATH="$out/share/lua/5.1/?.lua;$LUA_PATH" >> + ''; > > Exporting variables in ‘postInstall’ is probably useless since nothing > important happens after ‘installPhase’. > > I think what you want is a ‘setup hook’. See, e.g., guile/setup-hook.sh.
Thanks a lot. That works with this new patch. François > > Hope this helps, > Ludo’. > > _______________________________________________ > nix-dev mailing list > [email protected] > https://mail.cs.uu.nl/mailman/listinfo/nix-dev > >
From dccca85df6aa936049f73f465a8507ddf728356f Mon Sep 17 00:00:00 2001 From: fperrad <[email protected]> Date: Wed, 31 Mar 2010 15:52:12 +0200 Subject: [PATCH] first Lua modules --- pkgs/development/interpreters/lua-5/default.nix | 24 +++- pkgs/development/interpreters/lua-5/setup-hook.sh | 22 +++ pkgs/development/lua-modules/generic/default.nix | 56 +++++++ pkgs/top-level/all-packages.nix | 12 ++ pkgs/top-level/lua-packages.nix | 170 +++++++++++++++++++++ 5 files changed, 280 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/interpreters/lua-5/setup-hook.sh create mode 100644 pkgs/development/lua-modules/generic/default.nix create mode 100644 pkgs/top-level/lua-packages.nix diff --git a/pkgs/development/interpreters/lua-5/default.nix b/pkgs/development/interpreters/lua-5/default.nix index 2b0d79f..852cc08 100644 --- a/pkgs/development/interpreters/lua-5/default.nix +++ b/pkgs/development/interpreters/lua-5/default.nix @@ -1,12 +1,28 @@ {stdenv, fetchurl, ncurses, readline}: -stdenv.mkDerivation { - name = "lua-5.1.4"; +stdenv.mkDerivation rec { + majorVersion = "5.1"; + version = "${majorVersion}.4"; + name = "lua-${version}"; src = fetchurl { - url = http://www.lua.org/ftp/lua-5.1.4.tar.gz; - sha256 = "0fmgk100ficm1jbm4ga9xy484v4cm89wsdfckdybb9gjx8jy4f5h"; + url = "http://www.lua.org/ftp/${name}.tar.gz"; + sha1 = "2b11c8e60306efb7f0734b747588f57995493db7"; }; buildFlags = "linux"; # TODO: support for non-linux systems installFlags = "install INSTALL_TOP=\${out}"; buildInputs = [ ncurses readline ]; + setupHook = ./setup-hook.sh; + + meta = { + 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. + ''; + homepage = http://www.lua.org/; + license = "MIT"; + }; } diff --git a/pkgs/development/interpreters/lua-5/setup-hook.sh b/pkgs/development/interpreters/lua-5/setup-hook.sh new file mode 100644 index 0000000..c627294 --- /dev/null +++ b/pkgs/development/interpreters/lua-5/setup-hook.sh @@ -0,0 +1,22 @@ +addLuaLibPath () { + if [ -z $LUA_PATH ]; then + export LUA_PATH=";;" + fi + if [ -z $LUA_CPATH ]; then + export LUA_CPATH=";;" + fi + if [ -d "$1/share/lua/5.1" ]; then + export LUA_PATH="$LUA_PATH;$1/share/lua/5.1/?.lua;$1/share/lua/5.1/?/init.lua" + fi + if [ -d "$1/share/lua/5.2" ]; then + export LUA_PATH="$LUA_PATH;$1/share/lua/5.2/?.lua;$1/share/lua/5.2/?/init.lua" + fi + if [ -d "$1/lib/lua/5.1" ]; then + export LUA_CPATH="$LUA_CPATH;$1/lib/lua/5.1/?.so;$1/lib/lua/5.1/?/core.so" + fi + if [ -d "$1/lib/lua/5.2" ]; then + export LUA_CPATH="$LUA_CPATH;$1/lib/lua/5.2/?.so;$1/lib/lua/5.2/?/core.so" + fi +} + +envHooks=(${envhoo...@]} addLuaLibPath) diff --git a/pkgs/development/lua-modules/generic/default.nix b/pkgs/development/lua-modules/generic/default.nix new file mode 100644 index 0000000..5503b98 --- /dev/null +++ b/pkgs/development/lua-modules/generic/default.nix @@ -0,0 +1,56 @@ +{ lua5, lib }: + +{ name, namePrefix ? "lua-", src, meta, patches ? [] +, ... } @ attrs: + +let + # Return the list of recursively propagated build inputs of PKG. + recursiveBuildInputs = + pkg: + [ pkg ] ++ + (if pkg ? propagatedBuildNativeInputs + then lib.concatLists (map recursiveBuildInputs + pkg.propagatedBuildNativeInputs) + else []); + +in + +lua5.stdenv.mkDerivation ( + # Keep extra attributes from ATTR, e.g., `patchPhase', etc. + attrs + + // + + (rec { + inherit src meta patches; + + name = namePrefix + attrs.name; + + buildInputs = [ lua5 ] ++ + (if attrs ? buildInputs then attrs.buildInputs else []); + + propagatedBuildInputs = (if attrs ? propagatedBuildInputs then attrs.propagatedBuildInputs else []); + + postFixup = '' + # Wrap scripts that are under `{s,}bin/' so that they get the right + # package.path & package.cpath. + for i in "$out/bin/"* "$out/sbin/"* + do + if head -n1 "$i" | grep -q "${lua5}" + then + echo "wrapping \`$i'..." + echo "TODO: package.path & package.cpath" + fi + done + + # If a user installs a Lua package, she probably also wants its + # dependencies in the user environment (since Lua modules don't + # have something like an RPATH, so the only way to find the + # dependencies is to have them in the LUA_PATH & LUA_CPATH variables). + if test -e $out/nix-support/propagated-build-inputs; then + ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages + fi + ''; + +})) + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c459fc1..69d38ae 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5296,6 +5296,18 @@ let }; + ### DEVELOPMENT / LUA MODULES + + buildLuaPackage = + import ../development/lua-modules/generic { + inherit lua5 lib; + }; + + luaPackages = recurseIntoAttrs (import ./lua-packages.nix { + inherit pkgs; + }); + + ### DEVELOPMENT / PERL MODULES buildPerlPackage = import ../development/perl-modules/generic perl; diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix new file mode 100644 index 0000000..27d1460 --- /dev/null +++ b/pkgs/top-level/lua-packages.nix @@ -0,0 +1,170 @@ +{ pkgs }: + +rec { + inherit (pkgs) fetchurl stdenv lua5 buildLuaPackage; + + Coat = buildLuaPackage rec { + name = "Coat-0.8.2"; + src = fetchurl { + url = http://github.com/downloads/fperrad/lua-Coat/lua-coat-0.8.2.tar.gz; + md5 = "e5ee0e9aa985daafe6ca9ade9bd27dc4"; + }; + buildInputs = [ pkgs.perl ]; + propagatedBuildInputs = [ TestMore ]; + + buildPhase = "echo DUMMY BUILD"; + doCheck = true; + installFlags = "install DESTDIR=\${out}"; + + meta = { + description = "Yet Another Lua Object-Oriented Model"; + homepage = http://luacoat.luaforge.net/; + license = "MIT"; + }; + }; + + lfs = buildLuaPackage rec { + name = "lfs-1.5.0"; + src = fetchurl { + url = http://cloud.github.com/downloads/keplerproject/luafilesystem/luafilesystem-1.5.0.tar.gz; + sha256 = "00f6e1dc1e1da7f0fa77e375f0a04908ec4241a4c5e8d98031614f4a4a50c7cb"; + }; + + installFlags = "install LUA_LIBDIR=\${out}/lib/lua/${lua5.majorVersion}"; + + meta = { + description = "File System Library for the Lua Programming Language"; + longDescription = '' + LuaFileSystem is a Lua library developed to complement the set of + functions related to file systems offered by the standard Lua + distribution. LuaFileSystem offers a portable way to access the + underlying directory structure and file attributes. + ''; + homepage = http://www.keplerproject.org/; + license = "MIT"; + }; + }; + + lpeg = buildLuaPackage rec { + name = "lpeg-0.9"; + src = fetchurl { + url = http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-0.9.tar.gz; + md5 = "84a4f5fb4b87b90bb1b7284ec6bb69bc"; + }; + + doCheck = true; + checkPhase = "lua test.lua"; + installPhase = '' + ensureDir $out/share/lua/${lua5.majorVersion} + ensureDir $out/lib/lua/${lua5.majorVersion} + cp re.lua $out/share/lua/${lua5.majorVersion} + cp lpeg.so $out/lib/lua/${lua5.majorVersion} + ''; + + meta = { + description = "Parsing Expression Grammars For Lua"; + longDescription = '' + LPeg is a new pattern-matching library for Lua, based on Parsing + Expression Grammars (PEGs). The nice thing about PEGs is that it + has a formal basis (instead of being an ad-hoc set of features), + allows an efficient and simple implementation, and does most things + we expect from a pattern-matching library (and more, as we can + define entire grammars). + ''; + homepage = http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html; + license = "MIT"; + }; + }; + + + random = buildLuaPackage rec { + name = "random"; + src = fetchurl { + url = http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lrandom.tar.gz; + md5 = "954385b197a37890613e32748dce351f"; + }; + + buildPhase = '' + gcc -O2 -c -o lrandom.o lrandom.c + gcc -shared -o random.so lrandom.o + ''; + doCheck = true; + checkPhase = "lua test.lua"; + installPhase = '' + ensureDir $out/lib/lua/${lua5.majorVersion} + cp random.so $out/lib/lua/${lua5.majorVersion} + ''; + + meta = { + description = "A library for generating random numbers"; + longDescription = '' + A library for generating random numbers based on the Mersenne Twister, + a pseudorandom number generating algorithm developped by Makoto Matsumoto + and Takuji Nishimura (alphabetical order) in 1996/1997. + ''; + homepage = http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/; + license = "Public Domain"; + }; + }; + + socket = buildLuaPackage rec { + name = "socket-2.0.2"; + src = fetchurl { + url = http://luaforge.net/frs/download.php/2664/luasocket-2.0.2.tar.gz; + md5 = "41445b138deb7bcfe97bff957503da8e"; + }; + + installFlags = "install INSTALL_TOP_LIB=\${out}/lib/lua/${lua5.majorVersion} INSTALL_TOP_SHARE=\${out}/share/lua/${lua5.majorVersion}"; + + meta = { + description = "Network support for the Lua language"; + longDescription = '' + LuaSocket is a Lua extension library that is composed by two parts: a C core + that provides support for the TCP and UDP transport layers, and a set of Lua + modules that add support for functionality commonly needed by applications + that deal with the Internet. + ''; + homepage = http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/; + license = "MIT"; + }; + }; + + TestLongString = buildLuaPackage rec { + name = "TestLongString-0.1.2"; + src = fetchurl { + url = http://github.com/downloads/fperrad/lua-TestLongString/lua-testlongstring-0.1.2.tar.gz; + md5 = "0b1078aa86609df91b6ba085ee147992"; + }; + buildInputs = [ pkgs.perl ]; + propagatedBuildInputs = [ TestMore ]; + + buildPhase = "echo DUMMY BUILD"; + doCheck = true; + installFlags = "install DESTDIR=\${out}"; + + meta = { + description = "a lua-TestMore extension"; + homepage = http://testlongstring.luaforge.net/; + license = "MIT"; + }; + }; + + TestMore = buildLuaPackage rec { + name = "TestMore-0.2.1"; + src = fetchurl { + url = http://github.com/downloads/fperrad/lua-TestMore/lua-testmore-0.2.1.tar.gz; + md5 = "7ffdeb47dcfe3a247ac2294b16526d4a"; + }; + buildInputs = [ pkgs.perl ]; + + buildPhase = "echo DUMMY BUILD"; + doCheck = true; + installFlags = "install DESTDIR=\${out}"; + + meta = { + description = "an Unit Testing Framework"; + homepage = http://testmore.luaforge.net/; + license = "MIT"; + }; + }; +} -- 1.6.3.3
_______________________________________________ nix-dev mailing list [email protected] https://mail.cs.uu.nl/mailman/listinfo/nix-dev
