all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 8478a7bf721071732bb2586b7a33171c1ad40167 4072 bytes (raw)
name: gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
From 6eb753c5bf67764890856cf23a67c0bf65973c16 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Thu, 29 Jul 2021 22:24:50 +0200
Subject: [PATCH] Add environment variable MINETEST_MOD_PATH

This adds an environment variable MINETEST_MOD_PATH.
When it exists, Minetest will look there for mods
in addition to ~/.minetest/mods/.

This patch as-is is not yet ready for upstream, because:

  * the GUI will only display mods in MINETEST_MOD_PATH
    or mods in ~/.minetest/mods, it won't combine the two

  * the GUI for installing mods from ContentDB is disabled
    when MINETEST_MOD_PATH is set, because otherwise Minetest
    would try to install mods in the store.

  * MINETEST_MOD_PATH can only have a single component
---
 builtin/mainmenu/dlg_contentstore.lua |  7 +++++++
 src/content/subgames.cpp              |  3 +++
 src/script/lua_api/l_mainmenu.cpp     | 14 +++++++++++++-
 src/script/lua_api/l_mainmenu.h       |  2 ++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua
index 7096c9187..c4a2cbd18 100644
--- a/builtin/mainmenu/dlg_contentstore.lua
+++ b/builtin/mainmenu/dlg_contentstore.lua
@@ -22,6 +22,13 @@ if not core.get_http_api then
 	end
 	return
 end
+if core.mod_path_set() then
+	function create_store_dlg()
+		return messagebox("store",
+				fgettext("Mods from ContentDB cannot be installed when mods from Guix are also installed"))
+	end
+	return
+end
 
 -- Unordered preserves the original order of the ContentDB API,
 -- before the package list is ordered based on installed state.
diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp
index e9dc609b0..1809f189e 100644
--- a/src/content/subgames.cpp
+++ b/src/content/subgames.cpp
@@ -110,6 +110,9 @@ SubgameSpec findSubgame(const std::string &id)
 	std::set<std::string> mods_paths;
 	if (!user_game)
 		mods_paths.insert(share + DIR_DELIM + "mods");
+	const char *env_mod_path = getenv("MINETEST_MOD_PATH");
+	if (env_mod_path)
+		mods_paths.insert(std::string(env_mod_path));
 	if (user != share || user_game)
 		mods_paths.insert(user + DIR_DELIM + "mods");
 
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index ad00de1c4..737550c42 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -495,9 +495,19 @@ int ModApiMainMenu::l_get_user_path(lua_State *L)
 /******************************************************************************/
 int ModApiMainMenu::l_get_modpath(lua_State *L)
 {
+	const char *c_modpath = getenv("MINETEST_MOD_PATH");
 	std::string modpath = fs::RemoveRelativePathComponents(
 		porting::path_user + DIR_DELIM + "mods" + DIR_DELIM);
-	lua_pushstring(L, modpath.c_str());
+	if (c_modpath == NULL)
+		c_modpath = modpath.c_str();
+	lua_pushstring(L, c_modpath);
+	return 1;
+}
+
+/******************************************************************************/
+int ModApiMainMenu::l_mod_path_set(lua_State *L)
+{
+	lua_pushboolean(L, NULL != getenv("MINETEST_MOD_PATH"));
 	return 1;
 }
 
@@ -855,6 +865,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
 	API_FCT(get_mapgen_names);
 	API_FCT(get_user_path);
 	API_FCT(get_modpath);
+	API_FCT(mod_path_set);
 	API_FCT(get_clientmodpath);
 	API_FCT(get_gamepath);
 	API_FCT(get_texturepath);
@@ -888,6 +899,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
 	API_FCT(get_mapgen_names);
 	API_FCT(get_user_path);
 	API_FCT(get_modpath);
+	API_FCT(mod_path_set);
 	API_FCT(get_clientmodpath);
 	API_FCT(get_gamepath);
 	API_FCT(get_texturepath);
diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
index ec2d20da2..719c26077 100644
--- a/src/script/lua_api/l_mainmenu.h
+++ b/src/script/lua_api/l_mainmenu.h
@@ -112,6 +112,8 @@ class ModApiMainMenu: public ModApiBase
 
 	static int l_get_modpath(lua_State *L);
 
+	static int l_mod_path_set(lua_State *L);
+
 	static int l_get_clientmodpath(lua_State *L);
 
 	static int l_get_gamepath(lua_State *L);
-- 
2.32.0


debug log:

solving 8478a7bf72 ...
found 8478a7bf72 in https://yhetil.org/guix/20210802155019.6122-2-maximedevos@telenet.be/

applying [1/1] https://yhetil.org/guix/20210802155019.6122-2-maximedevos@telenet.be/
diff --git a/gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch b/gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch
new file mode 100644
index 0000000000..8478a7bf72

1:38: space before tab in indent.
 	end
1:39: space before tab in indent.
 	return
1:48: trailing whitespace.
 
1:56: space before tab in indent.
 	std::set<std::string> mods_paths;
1:57: space before tab in indent.
 	if (!user_game)
Checking patch gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch...
Applied patch gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch cleanly.
warning: squelched 28 whitespace errors
warning: 33 lines add whitespace errors.

index at:
100644 8478a7bf721071732bb2586b7a33171c1ad40167	gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.