From cc0b526646600a94d09e48c4a2f5b3da092b831e Mon Sep 17 00:00:00 2001
From: Carl Smedstad <carl.smedstad@protonmail.com>
Date: Mon, 5 Apr 2021 01:45:41 +0200
Subject: Respect the environment variable XDG_CACHE_HOME

This is needed in order to follow the XDG Base Directory specification.
More info here:

  https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
---
 src/luarocks/core/cfg.lua | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
index 3c672693..7ea86542 100644
--- a/src/luarocks/core/cfg.lua
+++ b/src/luarocks/core/cfg.lua
@@ -385,7 +385,8 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
       }
       defaults.export_path_separator = ":"
       defaults.wrapper_suffix = ""
-      defaults.local_cache = home.."/.cache/luarocks"
+      local xdg_cache_home = os.getenv("XDG_CACHE_HOME") or home.."/.cache"
+      defaults.local_cache = xdg_cache_home.."/luarocks"
       if not defaults.variables.CFLAGS:match("-fPIC") then
          defaults.variables.CFLAGS = defaults.variables.CFLAGS.." -fPIC"
       end
-- 
cgit v1.2.3-55-g6feb