diff options
author | Matthieu Coudron <886074+teto@users.noreply.github.com> | 2024-02-11 19:36:56 +0100 |
---|---|---|
committer | Matthieu Coudron <886074+teto@users.noreply.github.com> | 2024-02-17 15:58:13 +0100 |
commit | 50e877ed8982f52de379ed76c3ab20850e1edff0 (patch) | |
tree | 1d8ea10e3a3e6b82600a8466b61b5f910f2beebb /pkgs/development/interpreters/lua-5 | |
parent | bc9b32647ab47be299d8a835a2ef8095503ed952 (diff) |
buildLuarocksPackage: accept structured luarocks config
There is an arbitrary mapping being done right now between nixpkgs lua infrastructre and luarocks config schema. This is confusing if you use lua so let's make it possible to use the lua names in the nixpkgs, thanks to the lib.generators.toLua convertor. The only nixpkgs thing to remember should be to put the config into `luarocksConfig` `buildLuarocksPackage.extraVariables` should become `buildLuarocksPackage.luarocksConfig.variables`
Diffstat (limited to 'pkgs/development/interpreters/lua-5')
-rw-r--r-- | pkgs/development/interpreters/lua-5/build-luarocks-package.nix | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/pkgs/development/interpreters/lua-5/build-luarocks-package.nix b/pkgs/development/interpreters/lua-5/build-luarocks-package.nix index 882cd583717ba..97ac535c93036 100644 --- a/pkgs/development/interpreters/lua-5/build-luarocks-package.nix +++ b/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 extraConfig 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} - ${self.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 |