2019-02-04 11:30:58 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -p nix-prefetch-scripts luarocks-nix -i bash
|
|
|
|
|
|
|
|
# You'll likely want to use
|
|
|
|
# ``
|
|
|
|
# nixpkgs $ maintainers/scripts/update-luarocks-packages 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
|
|
|
|
|
|
|
|
CSV_FILE="maintainers/scripts/luarocks-packages.csv"
|
|
|
|
TMP_FILE="$(mktemp)"
|
|
|
|
|
|
|
|
exit_trap()
|
|
|
|
{
|
|
|
|
local lc="$BASH_COMMAND" rc=$?
|
|
|
|
test $rc -eq 0 || echo -e "*** error $rc: $lc.\nGenerated temporary file in $TMP_FILE" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
print_help() {
|
|
|
|
echo "Usage: $0 <GENERATED_FILE>"
|
|
|
|
echo "(most likely pkgs/development/lua-modules/generated-packages.nix)"
|
2019-06-04 10:06:08 +01:00
|
|
|
echo ""
|
|
|
|
echo " -c <CSV_FILE> to set the list of luarocks package to generate"
|
|
|
|
exit 1
|
2019-02-04 11:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-06-04 10:06:08 +01:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
trap exit_trap EXIT
|
2019-02-04 11:30:58 +00:00
|
|
|
|
|
|
|
while getopts ":hc:" opt; do
|
|
|
|
case $opt in
|
|
|
|
h)
|
|
|
|
print_help
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
echo "Loading package list from $OPTARG !" >&2
|
|
|
|
CSV_FILE="$OPTARG"
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
done
|
|
|
|
|
|
|
|
GENERATED_NIXFILE="$1"
|
|
|
|
|
|
|
|
HEADER="
|
|
|
|
/* ${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
|
|
|
|
*/
|
2019-02-26 05:51:42 +00:00
|
|
|
{ self, stdenv, fetchurl, fetchgit, pkgs, ... } @ args:
|
2019-02-04 11:30:58 +00:00
|
|
|
self: super:
|
|
|
|
with self;
|
|
|
|
{
|
|
|
|
"
|
|
|
|
|
|
|
|
FOOTER="
|
|
|
|
}
|
|
|
|
/* GENERATED */
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
function convert_pkg () {
|
2019-03-07 07:58:54 +00:00
|
|
|
nix_pkg_name="$1"
|
|
|
|
lua_pkg_name="$2"
|
2019-06-04 10:43:28 +01:00
|
|
|
server="${3:+--only-server=$3}"
|
2019-06-04 10:48:44 +01:00
|
|
|
pkg_version="${4:-}"
|
|
|
|
lua_version="${5:+--lua-dir=$(nix path-info nixpkgs.$5)/bin}"
|
2019-02-04 11:30:58 +00:00
|
|
|
|
2019-06-04 10:48:44 +01:00
|
|
|
echo "looking at $lua_pkg_name (version $pkg_version) from server [$server]" >&2
|
|
|
|
cmd="luarocks nix $server $lua_version $lua_pkg_name $pkg_version"
|
|
|
|
echo "Running $cmd" >&2
|
2019-03-07 07:58:54 +00:00
|
|
|
drv="$nix_pkg_name = $($cmd)"
|
2019-02-04 11:30:58 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to convert $pkg" >&2
|
|
|
|
else
|
|
|
|
echo "$drv" | tee -a "$TMP_FILE"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# params needed when called via callPackage
|
|
|
|
echo "$HEADER" | tee "$TMP_FILE"
|
|
|
|
|
|
|
|
# list of packages with format
|
2019-06-04 10:48:44 +01:00
|
|
|
while IFS=, read -r nix_pkg_name lua_pkg_name server pkg_version luaversion
|
2019-02-04 11:30:58 +00:00
|
|
|
do
|
2019-03-25 08:04:33 +00:00
|
|
|
if [ "${nix_pkg_name:0:1}" == "#" ]; then
|
|
|
|
echo "Skipping comment ${nix_pkg_name}" >&2
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [ -z "$lua_pkg_name" ]; then
|
|
|
|
echo "Using nix_name as lua_pkg_name" >&2
|
|
|
|
lua_pkg_name="$nix_pkg_name"
|
|
|
|
fi
|
2019-06-04 10:48:44 +01:00
|
|
|
convert_pkg "$nix_pkg_name" "$lua_pkg_name" "$server" "$pkg_version" "$luaversion"
|
2019-02-04 11:30:58 +00:00
|
|
|
done < "$CSV_FILE"
|
|
|
|
|
|
|
|
# close the set
|
|
|
|
echo "$FOOTER" | tee -a "$TMP_FILE"
|
|
|
|
|
|
|
|
cp "$TMP_FILE" "$GENERATED_NIXFILE"
|