Commit 82e9b3f3 authored by Mykola Orliuk's avatar Mykola Orliuk
Browse files

lua.lib: lift toLua to top in generateLuarocksConfig

With asBindings option of toLua we can generate whole block of global
variables assignments.
parent 7287c0e0
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -109,31 +109,31 @@ rec {
      externalDepsDirs = map
        (x: builtins.toString x)
        (lib.filter (lib.isDerivation) externalDeps);
  in ''
    local_cache = ""
    -- To prevent collisions when creating environments, we install the rock
    -- files into per-package subdirectories
    rocks_subdir = ${toLua {} rocksSubdir}
    -- first tree is the default target where new rocks are installed,
    -- any other trees in the list are treated as additional sources of installed rocks for matching dependencies.
    rocks_trees = ${toLua {} (
  in toLua { asBindings = true; } ({
    local_cache = "";
    # To prevent collisions when creating environments, we install the rock
    # files into per-package subdirectories
    rocks_subdir = rocksSubdir;
    # first tree is the default target where new rocks are installed,
    # any other trees in the list are treated as additional sources of installed rocks for matching dependencies.
    rocks_trees = (
      [{name = "current"; root = "${placeholder "out"}"; rocks_dir = "current"; }] ++
      rocksTrees
    )}
  '' + lib.optionalString lua.pkgs.isLuaJIT ''
    -- Luajit provides some additional functionality built-in; this exposes
    -- that to luarock's dependency system
    rocks_provided = ${toLua {} {
    );
  } // lib.optionalAttrs lua.pkgs.isLuaJIT {
    # Luajit provides some additional functionality built-in; this exposes
    # that to luarock's dependency system
    rocks_provided = {
      jit = "${lua.luaversion}-1";
      ffi = "${lua.luaversion}-1";
      luaffi = "${lua.luaversion}-1";
      bit = "${lua.luaversion}-1";
    }}
  '' + ''
    -- For single-output external dependencies
    external_deps_dirs = ${toLua {} externalDepsDirs}
    -- Some needed machinery to handle multiple-output external dependencies,
    -- as per https://github.com/luarocks/luarocks/issues/766
    variables = ${toLua {} (depVariables // extraVariables)}
  '';
    };
  } // {
    # For single-output external dependencies
    external_deps_dirs = externalDepsDirs;
    # Some needed machinery to handle multiple-output external dependencies,
    # as per https://github.com/luarocks/luarocks/issues/766
    variables = (depVariables // extraVariables);
  });
}