summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexei Robyn <shados@shados.net>2019-06-14 15:17:52 +1000
committerAlexei Robyn <shados@shados.net>2019-06-14 15:17:52 +1000
commit671e53af6736630cad70e8c404f263c8720ae3a1 (patch)
tree41b1e958e48976ec8857f4311d0ad1f4a1fa1aec
parent274715cbc355e9d50e07a2f60a65a183f7d9855d (diff)
downloadnixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar.gz
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar.bz2
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar.lz
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar.xz
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.tar.zst
nixpkgs-671e53af6736630cad70e8c404f263c8720ae3a1.zip
update-luarocks: Use containing nixpkgs, ensure Lua drvs exist
-rwxr-xr-xmaintainers/scripts/update-luarocks-packages17
-rw-r--r--maintainers/scripts/update-luarocks-shell.nix9
2 files changed, 20 insertions, 6 deletions
diff --git a/maintainers/scripts/update-luarocks-packages b/maintainers/scripts/update-luarocks-packages
index b553286affa..a8d67d208e3 100755
--- a/maintainers/scripts/update-luarocks-packages
+++ b/maintainers/scripts/update-luarocks-packages
@@ -1,5 +1,5 @@
 #!/usr/bin/env nix-shell
-#!nix-shell -p parallel nix-prefetch-scripts luarocks-nix -i bash
+#!nix-shell update-luarocks-shell.nix -i bash
 
 # You'll likely want to use
 # ``
@@ -13,6 +13,12 @@ set -eu -o pipefail
 
 CSV_FILE="maintainers/scripts/luarocks-packages.csv"
 TMP_FILE="$(mktemp)"
+# Set in the update-luarocks-shell.nix
+NIXPKGS_PATH="$LUAROCKS_NIXPKGS_PATH"
+
+# 10 is a pretty arbitrary number of simultaneous jobs, but it is generally
+# impolite to hit a webserver with *too* many simultaneous connections :)
+PARALLEL_JOBS=10
 
 exit_trap() {
     local lc="$BASH_COMMAND" rc=$?
@@ -96,7 +102,8 @@ function convert_pkg() {
         luarocks_args+=("--maintainers=$maintainers")
     fi
     if [[ -n $lua_version ]]; then
-        luarocks_args+=("--lua-dir=$(nix path-info "nixpkgs.$lua_version")/bin")
+        lua_drv_path=$(nix-build --no-out-link "$NIXPKGS_PATH" -A "$lua_version")
+        luarocks_args+=("--lua-dir=$lua_drv_path/bin")
     fi
     luarocks_args+=("$lua_pkg_name")
     if [[ -n $pkg_version ]]; then
@@ -104,7 +111,6 @@ function convert_pkg() {
     fi
     echo "Running 'luarocks ${luarocks_args[*]}'" >&2
     if drv="$nix_pkg_name = $(luarocks "${luarocks_args[@]}")"; then
-        # echo "$drv" | tee -a "$TMP_FILE"
         echo "$drv"
     else
         echo "Failed to convert $nix_pkg_name" >&2
@@ -115,12 +121,11 @@ function convert_pkg() {
 # params needed when called via callPackage
 echo "$HEADER" | tee "$TMP_FILE"
 
+# Ensure parallel can run our bash function
 export -f convert_pkg
 export SHELL=bash
 # Read each line in the csv file and run convert_pkg for each, in parallel
-# 10 is a pretty arbitrary number of simultaneous jobs, but it is generally
-# impolite to hit a webserver with *too* many simultaneous connections :)
-parallel --group --keep-order --halt now,fail=1 --jobs 10 --colsep ',' convert_pkg {} <"$CSV_FILE" | tee -a "$TMP_FILE"
+parallel --group --keep-order --halt now,fail=1 --jobs "$PARALLEL_JOBS" --colsep ',' convert_pkg {} <"$CSV_FILE" | tee -a "$TMP_FILE"
 
 # close the set
 echo "$FOOTER" | tee -a "$TMP_FILE"
diff --git a/maintainers/scripts/update-luarocks-shell.nix b/maintainers/scripts/update-luarocks-shell.nix
new file mode 100644
index 00000000000..23a940b3691
--- /dev/null
+++ b/maintainers/scripts/update-luarocks-shell.nix
@@ -0,0 +1,9 @@
+{ nixpkgs ? import ../.. { }
+}:
+with nixpkgs;
+mkShell {
+  buildInputs = [
+    bash luarocks-nix nix-prefetch-scripts parallel
+  ];
+  LUAROCKS_NIXPKGS_PATH = toString nixpkgs.path;
+}