xorg.xorgserver: Restore XQuartz.app's usage of environment variables.

XQuartz.app needs to be able to find the `startx' from the `xinit'
package, but it defaults to assuming it is in the same directory as
the Xquartz binary, which it will never be. This restores a patch that
uses environment variables to locate `startx', which is what the
`xquartz' package is expecting to use.

+85
+84
pkgs/servers/x11/xorg/darwin/bundle_main.patch
··· 1 + This patch makes it possible (and necessary) to specify the default 2 + shell, xterm client, and startx script from environment variables. These 3 + defaults are used when launching the XQuartz.app, which in turn needs to know 4 + how to start the X server. `startx' comes from the `xinit' package, 5 + which also has a dependency on `xorg-server', so we can't hardcode 6 + sane defaults. If the environment variables are specified, they 7 + override any value in the preferences settings. 8 + 9 + When developing an installable package for XQuartz/XQuartz.app, we'll 10 + need to set an `LSEnvironment' entry in the plist for the XQuartz.app. 11 + (See stub.patch for more details.). 12 + 13 + diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c 14 + index de82e2280..da58a5d44 100644 15 + --- a/hw/xquartz/mach-startup/bundle-main.c 16 + +++ b/hw/xquartz/mach-startup/bundle-main.c 17 + @@ -76,8 +76,6 @@ extern int noPanoramiXExtension; 18 + extern Bool noCompositeExtension; 19 + #endif 20 + 21 + -#define DEFAULT_CLIENT X11BINDIR "/xterm" 22 + -#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz" 23 + #define DEFAULT_SHELL "/bin/sh" 24 + 25 + #define _STRINGIZE(s) #s 26 + @@ -108,7 +106,7 @@ server_main(int argc, char **argv, char **envp); 27 + static int 28 + execute(const char *command); 29 + static char * 30 + -command_from_prefs(const char *key, const char *default_value); 31 + +command_from_prefs(const char *key, const char *env_name, const char *default_value); 32 + 33 + static char *pref_app_to_run; 34 + static char *pref_login_shell; 35 + @@ -669,14 +667,19 @@ main(int argc, char **argv, char **envp) 36 + pid_t child1, child2; 37 + int status; 38 + 39 + - pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT); 40 + + pref_app_to_run = command_from_prefs("app_to_run", 41 + + "XQUARTZ_DEFAULT_CLIENT", 42 + + NULL); 43 + assert(pref_app_to_run); 44 + 45 + - pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL); 46 + + pref_login_shell = command_from_prefs("login_shell", 47 + + "XQUARTZ_DEFAULT_SHELL", 48 + + DEFAULT_SHELL); 49 + assert(pref_login_shell); 50 + 51 + pref_startx_script = command_from_prefs("startx_script", 52 + - DEFAULT_STARTX); 53 + + "XQUARTZ_DEFAULT_STARTX", 54 + + NULL); 55 + assert(pref_startx_script); 56 + 57 + /* Do the fork-twice trick to avoid having to reap zombies */ 58 + @@ -753,7 +756,7 @@ execute(const char *command) 59 + } 60 + 61 + static char * 62 + -command_from_prefs(const char *key, const char *default_value) 63 + +command_from_prefs(const char *key, const char *env_name, const char *default_value) 64 + { 65 + char *command = NULL; 66 + 67 + @@ -763,6 +766,17 @@ command_from_prefs(const char *key, const char *default_value) 68 + if (!key) 69 + return NULL; 70 + 71 + + if (env_name != NULL) { 72 + + command = getenv(env_name); 73 + + if (command != NULL) { 74 + + return strdup(command); 75 + + } 76 + + } 77 + + 78 + + if (!default_value) { 79 + + return NULL; 80 + + } 81 + + 82 + cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII); 83 + 84 + if (!cfKey)
+1
pkgs/servers/x11/xorg/overrides.nix
··· 763 763 sha256 = "0zm9g0g1jvy79sgkvy0rjm6ywrdba2xjd1nsnjbxjccckbr6i396"; 764 764 name = "revert-fb-changes-2.patch"; 765 765 }) 766 + ./darwin/bundle_main.patch 766 767 ./darwin/stub.patch 767 768 ]; 768 769