Skip to content

Commit

Permalink
adding missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Jan 21, 2019
1 parent 93f2f69 commit 15d6cef
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 28 deletions.
4 changes: 2 additions & 2 deletions doc/languages-frameworks/lua.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ Luarocks2nix is a tool capable of generating nix derivations from a rockspec fil
upload the file on luarocks.org.
2. nix won't work with all packages. If the package lists `external_dependencies` in its rockspec file then it won't work.

You can run `nix-shell -p luarocks-nix` and then `luarocks convert2nix
PKG_NAME`. Once you have checked the package works without modifications, you can add it to `maintainers/scripts/update-luarocks-packages.sh`
You can run `nix-shell -p luarocks-nix` and then `luarocks nix PKG_NAME`.
Once you have checked the package works without modifications, you can add it to `maintainers/scripts/luarocks.sh`
Nix rely on luarocks to install lua packages, basically it runs:
`luarocks make --deps-mode=none --tree $out`

Expand Down
44 changes: 44 additions & 0 deletions maintainers/scripts/lua-packages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ansicolors,
argparse,
basexx,
cqueues
dkjson
fifo
lgi
lpeg_patterns
lpty,
lrexlib-gnu,
lrexlib-posix,
ltermbox,
lua-cjson,
lua-cmsgpack,
lua_cliargs,
lua-iconv,
lua-term,
lua-zlib,
luacheck,
luadbi,
luaexpat,
luaffi,http://luarocks.org/dev,
luaevent,
luabitop,
luasocket,
luafilesystem,
luaposix,
luasec,
luazip,
luuid,
http,
penlight,
say,
std.normalize,
std._debug,
luv,
luasystem,
mediator_lua,http://luarocks.org/manifests/teto
mpack,http://luarocks.org/manifests/teto
nvim-client,http://luarocks.org/manifests/teto
busted,http://luarocks.org/manifests/teto
luassert,http://luarocks.org/manifests/teto
coxpcall,https://luarocks.org/manifests/hisham
lpeg,https://luarocks.org/manifests/gvvaughan
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p lua5_2.withPackages(ps:[ps.luarocks-nix]) nix-prefetch-scripts
#!nix-shell -p nix-prefetch-scripts luarocks-nix -i bash

# You'll likely want to use
# ``
# nixpkgs $ maintainers/scripts/update-luarocks-packages.sh > pkgs/top-level/lua-generated-packages.nix
# nixpkgs $ maintainers/scripts/update-luarocks-packages.sh > pkgs/development/lua-modules/generated-packages.nix
# ``
# to update all libraries in that folder.
# to debug, redirect stderr to stdout with 2>&1


# stop the script upon C-C
set -eu -o pipefail

if [ $# -lt 1 ]; then
echo "Usage: $0 GENERATED_FILENAME"
echo "(most likely pkgs/top-level/lua-generated-packages.nix)"
echo "(most likely pkgs/development/lua-modules/generated-packages.nix)"
exit 1
fi

Expand Down Expand Up @@ -51,21 +52,20 @@ read -d '' -r HEADER <<EOM
/* ${GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT!
Regenerate it with:
nixpkgs$ ${0} ${GENERATED_NIXFILE}

These packages are manually refined in lua-overrides.nix
*/
{
self
, lua
, buildLuaPackage
, stdenv
, fetchurl
, luaAtLeast
, luaOlder
, isLua51
, isLua52
, pkgs
, ...
} @ args:
self: super:
with self;
rec {
{
EOM

read -d '' -r FOOTER <<'EOM'
Expand All @@ -83,29 +83,38 @@ function convert_pkg () {
server=" --server=$2"
fi

echo "looking at $pkg from server $server" >&2
drv=$(luarocks convert2nix $server "$pkg")
if [ $? -gt 0 ]; then
version="${3:-}"

set -x
echo "looking at $pkg (version $version) from server $server" >&2
cmd="luarocks nix $server $pkg $version"
drv="$($cmd)"
if [ $? -ne 0 ]; then
echo "Failed to convert $pkg" >&2
echo "$drv" >&2
else
echo "$drv" | tee -a "$TMP_FILE"
fi
}

# list of packages
source maintainers/scripts/lua_packages.sh
# source maintainers/scripts/lua_packages.sh

# params needed when called via callPackage
echo "$HEADER" | tee $TMP_FILE
echo "$HEADER" | tee "$TMP_FILE"

if [ ! -z $PACKAGE ]; then
convert_pkg "$PACKAGE" "${pkg_list[$PACKAGE]}"
if [ ! -z "$PACKAGE" ]; then
convert_pkg "$PACKAGE"
else
for pkg_name in "${!pkg_list[@]}";
# list of packages with format
# name,server,version
while IFS=, read -r pkg_name server version
do
convert_pkg $pkg_name "${pkg_list[$pkg_name]}"
done
if [ -z "$pkg_name" ]; then
echo "Skipping empty package name" >&2
fi
echo "PKG $pkg_name version $version from server $server" >&2
convert_pkg "$pkg_name" "$server" "$version"
done < maintainers/scripts/lua-packages.csv
fi
# close the set
echo "$FOOTER" | tee -a "$TMP_FILE"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/lua-modules/generated-packages.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* pkgs/development/lua-modules/generated-packages.nix is an auto-generated file -- DO NOT EDIT!
Regenerate it with:
nixpkgs$ maintainers/scripts/update-luarocks-packages.sh pkgs/development/lua-modules/generated-packages.nix
nixpkgs$ maintainers/scripts/update-luarocks-packages pkgs/development/lua-modules/generated-packages.nix
*/
{
# , lua
Expand Down
13 changes: 9 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7881,10 +7881,15 @@ in

luarocks = luaPackages.luarocks;

# fork that adds the 'convert2nix' command to luarocks
# hopefully it can be installed as an addon once luarocks
# completes addon support
luarocks-nix = luaPackages.luarocks-nix;
# fork that adds the 'nix' command to luarocks
luarocks-nix = luarocks.overrideAttrs(old: {
src = fetchFromGitHub {
owner = "teto";
repo = "luarocks";
rev = "d669e8e118e6ca8bff05f32dbc9e5589e6ac45d2";
sha256 = "1lay3905a5sx2a4y68lbys0913qs210hcj9kn2lbqinw86c1vyc3";
};
});


toluapp = callPackage ../development/tools/toluapp {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/lua-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let
isLuaJIT = (builtins.parseDrvName lua.name).name == "luajit";

# Check whether a derivation provides a lua module.
hasLuaModule = drv: drv? luaModule ;
hasLuaModule = drv: drv ? luaModule ;

callPackage = pkgs.newScope self;

Expand Down

0 comments on commit 15d6cef

Please sign in to comment.