about summary refs log tree commit diff
path: root/pkgs/development/lua-modules
diff options
context:
space:
mode:
authorMatthieu Coudron <886074+teto@users.noreply.github.com>2023-12-17 18:56:10 +0100
committerMatthieu Coudron <886074+teto@users.noreply.github.com>2023-12-17 22:44:40 +0100
commit8e9d4495c78515277aa43d579610ef3750f59e2c (patch)
treec501734fed724befaec27803b3438f69f580ab39 /pkgs/development/lua-modules
parent8855560298be3c6ba18d40bedd3256f91b5de5f4 (diff)
luarocks-packages-updater: silence some warnings
The script used to output:

```
Warning: Lua 5.1 interpreter not found at /nix/store/w577gc82dg7r1p480pp1kjbq7i32lhh2-lua-5.2.4
```
not sure why luarocks outputs since since it works nevertheless

added .flake8 so that the editor can pick it up too.
Diffstat (limited to 'pkgs/development/lua-modules')
-rw-r--r--pkgs/development/lua-modules/updater/.flake86
-rw-r--r--pkgs/development/lua-modules/updater/default.nix23
-rwxr-xr-xpkgs/development/lua-modules/updater/updater.py8
3 files changed, 32 insertions, 5 deletions
diff --git a/pkgs/development/lua-modules/updater/.flake8 b/pkgs/development/lua-modules/updater/.flake8
new file mode 100644
index 0000000000000..16f76a43624cf
--- /dev/null
+++ b/pkgs/development/lua-modules/updater/.flake8
@@ -0,0 +1,6 @@
+[flake8]
+# E111 => 4 spaces tabs
+# don't let spaces else it is not recognized
+# E123 buggy
+ignore =
+	E501,E265,E402
diff --git a/pkgs/development/lua-modules/updater/default.nix b/pkgs/development/lua-modules/updater/default.nix
index 40c93b21e8318..e556d4d0dec92 100644
--- a/pkgs/development/lua-modules/updater/default.nix
+++ b/pkgs/development/lua-modules/updater/default.nix
@@ -6,10 +6,24 @@
 # , nix-prefetch-git
 , nix-prefetch-scripts
 , luarocks-nix
+, lua5_1
+, lua5_2
+, lua5_3
+, lua5_4
 }:
 let
 
-    path = lib.makeBinPath [ nix nix-prefetch-scripts luarocks-nix ];
+  path = lib.makeBinPath [
+    nix nix-prefetch-scripts luarocks-nix
+  ];
+
+  luaversions = [
+    lua5_1
+    lua5_2
+    lua5_3
+    lua5_4
+  ];
+
 in
 buildPythonApplication {
   pname = "luarocks-packages-updater";
@@ -34,7 +48,12 @@ buildPythonApplication {
     cp ${../../../../maintainers/scripts/pluginupdate.py} $out/lib/pluginupdate.py
 
     # wrap python scripts
-    makeWrapperArgs+=( --prefix PATH : "${path}" --prefix PYTHONPATH : "$out/lib" )
+    makeWrapperArgs+=( --prefix PATH : "${path}" --prefix PYTHONPATH : "$out/lib" \
+      --set LUA_51 ${lua5_1} \
+      --set LUA_52 ${lua5_2} \
+      --set LUA_53 ${lua5_3} \
+      --set LUA_54 ${lua5_4}
+    )
     wrapPythonProgramsIn "$out"
   '';
 
diff --git a/pkgs/development/lua-modules/updater/updater.py b/pkgs/development/lua-modules/updater/updater.py
index 89a9bd9823a72..3f1d27ab129f1 100755
--- a/pkgs/development/lua-modules/updater/updater.py
+++ b/pkgs/development/lua-modules/updater/updater.py
@@ -16,6 +16,8 @@ import csv
 import logging
 import textwrap
 from multiprocessing.dummy import Pool
+import pluginupdate
+from pluginupdate import update_plugins, FetchConfig
 
 from typing import List, Tuple, Optional
 from pathlib import Path
@@ -24,8 +26,6 @@ log = logging.getLogger()
 log.addHandler(logging.StreamHandler())
 
 ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))).parent.parent  # type: ignore
-import pluginupdate
-from pluginupdate import update_plugins, FetchConfig, CleanEnvironment
 
 PKG_LIST = "maintainers/scripts/luarocks-packages.csv"
 TMP_FILE = "$(mktemp)"
@@ -171,7 +171,6 @@ def generate_pkg_nix(plug: LuaPlugin):
     if plug.maintainers:
         cmd.append(f"--maintainers={plug.maintainers}")
 
-    # if plug.server == "src":
     if plug.src != "":
         if plug.src is None:
             msg = (
@@ -193,6 +192,9 @@ def generate_pkg_nix(plug: LuaPlugin):
 
     if plug.luaversion:
         cmd.append(f"--lua-version={plug.luaversion}")
+        luaver = plug.luaversion.replace('.', '')
+        if luaver := os.getenv(f"LUA_{luaver}"):
+            cmd.append(f"--lua-dir={luaver}")
 
     log.debug("running %s", " ".join(cmd))