about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix')
-rw-r--r--nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix40
1 files changed, 27 insertions, 13 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix b/nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix
index ea46fd107980..97ac535c9303 100644
--- a/nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix
+++ b/nixpkgs/pkgs/development/interpreters/lua-5/build-luarocks-package.nix
@@ -51,9 +51,10 @@
 
 # Appended to the generated luarocks config
 , extraConfig ? ""
-# Inserted into the generated luarocks config in the "variables" table
-, extraVariables ? {}
-# The two above arguments have access to builder variables -- e.g. to $out
+
+# transparent mapping nix <-> lua used as LUAROCKS_CONFIG
+# Refer to https://github.com/luarocks/luarocks/wiki/Config-file-format for specs
+, luarocksConfig ? {}
 
 # relative to srcRoot, path to the rockspec to use when using rocks
 , rockspecFilename ? null
@@ -92,7 +93,7 @@ let
     luarocks
   ];
 
-  inherit doCheck extraVariables rockspecFilename knownRockspec externalDeps nativeCheckInputs;
+  inherit doCheck extraConfig rockspecFilename knownRockspec externalDeps nativeCheckInputs;
 
   buildInputs = let
     # example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
@@ -116,9 +117,18 @@ let
     text = self.luarocks_content;
   };
 
-  luarocks_content = let
-      externalDepsGenerated = lib.filter (drv: !drv ? luaModule)
-        (self.nativeBuildInputs ++ self.propagatedBuildInputs ++ self.buildInputs);
+  luarocks_content =
+      (lib.generators.toLua { asBindings = true; } self.luarocksConfig) +
+      ''
+
+      ${self.extraConfig}
+      '';
+
+  # TODO make it the default variable
+  luarocksConfig = let
+    externalDepsGenerated = lib.filter (drv: !drv ? luaModule)
+      (self.nativeBuildInputs ++ self.propagatedBuildInputs ++ self.buildInputs);
+
     generatedConfig = luaLib.generateLuarocksConfig {
       externalDeps = lib.unique (self.externalDeps ++ externalDepsGenerated);
       # Filter out the lua derivation itself from the Lua module dependency
@@ -126,13 +136,17 @@ let
       # luaLib.hasLuaModule
       requiredLuaRocks = lib.filter luaLib.hasLuaModule
         (lua.pkgs.requiredLuaModules (self.nativeBuildInputs ++ self.propagatedBuildInputs));
-      inherit (self) extraVariables rocksSubdir;
+      inherit (self) rocksSubdir;
     };
-    in
-      ''
-      ${generatedConfig}
-      ${extraConfig}
-      '';
+
+    luarocksConfig' = lib.recursiveUpdate luarocksConfig
+      (lib.optionalAttrs (attrs ? extraVariables) (lib.warn "extraVariables in buildLuarocksPackage is deprecated, use luarocksConfig instead"
+      {
+        variables = attrs.extraVariables;
+      }))
+    ;
+  in lib.recursiveUpdate generatedConfig luarocksConfig';
+
 
   configurePhase = ''
     runHook preConfigure