mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
Merge pull request #228272 from quentinmit/xquartz
xquartz, xorg.xorgserver: Fix broken xquartz package
This commit is contained in:
commit
660a9c0af2
84
pkgs/servers/x11/xorg/darwin/bundle_main.patch
Normal file
84
pkgs/servers/x11/xorg/darwin/bundle_main.patch
Normal file
@ -0,0 +1,84 @@
|
||||
This patch makes it possible (and necessary) to specify the default
|
||||
shell, xterm client, and startx script from environment variables. These
|
||||
defaults are used when launching the XQuartz.app, which in turn needs to know
|
||||
how to start the X server. `startx' comes from the `xinit' package,
|
||||
which also has a dependency on `xorg-server', so we can't hardcode
|
||||
sane defaults. If the environment variables are specified, they
|
||||
override any value in the preferences settings.
|
||||
|
||||
When developing an installable package for XQuartz/XQuartz.app, we'll
|
||||
need to set an `LSEnvironment' entry in the plist for the XQuartz.app.
|
||||
(See stub.patch for more details.).
|
||||
|
||||
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
|
||||
index de82e2280..da58a5d44 100644
|
||||
--- a/hw/xquartz/mach-startup/bundle-main.c
|
||||
+++ b/hw/xquartz/mach-startup/bundle-main.c
|
||||
@@ -76,8 +76,6 @@ extern int noPanoramiXExtension;
|
||||
extern Bool noCompositeExtension;
|
||||
#endif
|
||||
|
||||
-#define DEFAULT_CLIENT X11BINDIR "/xterm"
|
||||
-#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz"
|
||||
#define DEFAULT_SHELL "/bin/sh"
|
||||
|
||||
#define _STRINGIZE(s) #s
|
||||
@@ -108,7 +106,7 @@ server_main(int argc, char **argv, char **envp);
|
||||
static int
|
||||
execute(const char *command);
|
||||
static char *
|
||||
-command_from_prefs(const char *key, const char *default_value);
|
||||
+command_from_prefs(const char *key, const char *env_name, const char *default_value);
|
||||
|
||||
static char *pref_app_to_run;
|
||||
static char *pref_login_shell;
|
||||
@@ -669,14 +667,19 @@ main(int argc, char **argv, char **envp)
|
||||
pid_t child1, child2;
|
||||
int status;
|
||||
|
||||
- pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
|
||||
+ pref_app_to_run = command_from_prefs("app_to_run",
|
||||
+ "XQUARTZ_DEFAULT_CLIENT",
|
||||
+ NULL);
|
||||
assert(pref_app_to_run);
|
||||
|
||||
- pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
|
||||
+ pref_login_shell = command_from_prefs("login_shell",
|
||||
+ "XQUARTZ_DEFAULT_SHELL",
|
||||
+ DEFAULT_SHELL);
|
||||
assert(pref_login_shell);
|
||||
|
||||
pref_startx_script = command_from_prefs("startx_script",
|
||||
- DEFAULT_STARTX);
|
||||
+ "XQUARTZ_DEFAULT_STARTX",
|
||||
+ NULL);
|
||||
assert(pref_startx_script);
|
||||
|
||||
/* Do the fork-twice trick to avoid having to reap zombies */
|
||||
@@ -753,7 +756,7 @@ execute(const char *command)
|
||||
}
|
||||
|
||||
static char *
|
||||
-command_from_prefs(const char *key, const char *default_value)
|
||||
+command_from_prefs(const char *key, const char *env_name, const char *default_value)
|
||||
{
|
||||
char *command = NULL;
|
||||
|
||||
@@ -763,6 +766,17 @@ command_from_prefs(const char *key, const char *default_value)
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
+ if (env_name != NULL) {
|
||||
+ command = getenv(env_name);
|
||||
+ if (command != NULL) {
|
||||
+ return strdup(command);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!default_value) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
|
||||
|
||||
if (!cfKey)
|
61
pkgs/servers/x11/xorg/darwin/stub.patch
Normal file
61
pkgs/servers/x11/xorg/darwin/stub.patch
Normal file
@ -0,0 +1,61 @@
|
||||
When the X / Xquartz server initializes, it starts the XQuartz.app and
|
||||
hands-off the display FD. To start the XQuartz.app, Xquartz normally uses some
|
||||
system calls to get the path of the application by app bundle id, and then
|
||||
executes the Contents/MacOS/X11 script contained inside, which in turn executes
|
||||
Contents/MacOS/X11.bin (the actual app).
|
||||
|
||||
This patch replaces that discovery technique with a simple call to
|
||||
`getenv' and a hardcoded default. In order to make Xquartz work if the
|
||||
app is moved, we'll need another wrapper that sets the `XQUARTZ_X11'
|
||||
environment variable to point to the `X11' script.
|
||||
|
||||
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
|
||||
index 83252e805..f1974215b 100644
|
||||
--- a/hw/xquartz/mach-startup/stub.c
|
||||
+++ b/hw/xquartz/mach-startup/stub.c
|
||||
@@ -52,7 +52,6 @@
|
||||
|
||||
#include "launchd_fd.h"
|
||||
|
||||
-static CFURLRef x11appURL;
|
||||
static FSRef x11_appRef;
|
||||
static pid_t x11app_pid = 0;
|
||||
aslclient aslc;
|
||||
@@ -60,29 +59,21 @@ aslclient aslc;
|
||||
static void
|
||||
set_x11_path(void)
|
||||
{
|
||||
- OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId),
|
||||
- nil, &x11_appRef, &x11appURL);
|
||||
+ unsigned char *xquartzApp = getenv("XQUARTZ_APP");
|
||||
+ if (!xquartzApp) {
|
||||
+ xquartzApp = "@XQUARTZ_APP@";
|
||||
+ }
|
||||
+
|
||||
+ OSStatus osstatus = FSPathMakeRef(xquartzApp, &x11_appRef, NULL);
|
||||
|
||||
switch (osstatus) {
|
||||
case noErr:
|
||||
- if (x11appURL == NULL) {
|
||||
- asl_log(aslc, NULL, ASL_LEVEL_ERR,
|
||||
- "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
|
||||
- kX11AppBundleId);
|
||||
- exit(1);
|
||||
- }
|
||||
break;
|
||||
|
||||
- case kLSApplicationNotFoundErr:
|
||||
- asl_log(aslc, NULL, ASL_LEVEL_ERR,
|
||||
- "Xquartz: Unable to find application for %s",
|
||||
- kX11AppBundleId);
|
||||
- exit(10);
|
||||
-
|
||||
default:
|
||||
asl_log(aslc, NULL, ASL_LEVEL_ERR,
|
||||
- "Xquartz: Unable to find application for %s, error code = %d",
|
||||
- kX11AppBundleId, (int)osstatus);
|
||||
+ "Xquartz: Unable to find FSRef for %s, error code = %d",
|
||||
+ xquartzApp, (int)osstatus);
|
||||
exit(11);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{ abiCompat ? null,
|
||||
callPackage,
|
||||
lib, stdenv, makeWrapper, fetchurl, fetchpatch, fetchFromGitLab, buildPackages,
|
||||
lib, stdenv, makeWrapper, fetchurl, fetchpatch, fetchFromGitLab, buildPackages, substitute,
|
||||
automake, autoconf, libiconv, libtool, intltool,
|
||||
freetype, tradcpp, fontconfig, meson, ninja, ed, fontforge,
|
||||
libGL, spice-protocol, zlib, libGLU, dbus, libunwind, libdrm, netbsd,
|
||||
@ -763,6 +763,11 @@ self: super:
|
||||
sha256 = "0zm9g0g1jvy79sgkvy0rjm6ywrdba2xjd1nsnjbxjccckbr6i396";
|
||||
name = "revert-fb-changes-2.patch";
|
||||
})
|
||||
./darwin/bundle_main.patch
|
||||
(substitute {
|
||||
src = ./darwin/stub.patch;
|
||||
replacements = ["--subst-var-by" "XQUARTZ_APP" "${placeholder "out"}/Applications/XQuartz.app"];
|
||||
})
|
||||
];
|
||||
|
||||
configureFlags = [
|
||||
@ -774,6 +779,9 @@ self: super:
|
||||
"--with-apple-applications-dir=\${out}/Applications"
|
||||
"--with-bundle-id-prefix=org.nixos.xquartz"
|
||||
"--with-sha1=CommonCrypto"
|
||||
"--with-xkb-bin-directory=${xorg.xkbcomp}/bin"
|
||||
"--with-xkb-path=${xorg.xkeyboardconfig}/share/X11/xkb"
|
||||
"--with-xkb-output=$out/share/X11/xkb/compiled"
|
||||
"--without-dtrace" # requires Command Line Tools for Xcode
|
||||
];
|
||||
preConfigure = ''
|
||||
|
7
pkgs/servers/x11/xquartz/10-fontdir.sh
Executable file
7
pkgs/servers/x11/xquartz/10-fontdir.sh
Executable file
@ -0,0 +1,7 @@
|
||||
fontpath="@SYSTEM_FONTS@"
|
||||
[ -e "$HOME"/.fonts/fonts.dir ] && fontpath="$fontpath,$HOME/.fonts"
|
||||
[ -e "$HOME"/Library/Fonts/fonts.dir ] && fontpath="$fontpath,$HOME/Library/Fonts"
|
||||
[ -e /Library/Fonts/fonts.dir ] && fontpath="$fontpath,/Library/Fonts"
|
||||
[ -e /System/Library/Fonts/fonts.dir ] && fontpath="$fontpath,/System/Library/Fonts"
|
||||
@XSET@ fp= "$fontpath"
|
||||
unset fontpath
|
6
pkgs/servers/x11/xquartz/98-user.sh
Executable file
6
pkgs/servers/x11/xquartz/98-user.sh
Executable file
@ -0,0 +1,6 @@
|
||||
if [ -d "${HOME}/.xinitrc.d" ] ; then
|
||||
for f in "${HOME}"/.xinitrc.d/*.sh ; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
fi
|
@ -1,20 +0,0 @@
|
||||
#!@shell@
|
||||
|
||||
set "$(dirname "$0")"/X11.bin "${@}"
|
||||
|
||||
export XQUARTZ_DEFAULT_CLIENT="@DEFAULT_CLIENT@"
|
||||
export XQUARTZ_DEFAULT_SHELL="@DEFAULT_SHELL@"
|
||||
export XQUARTZ_DEFAULT_STARTX="@DEFAULT_STARTX@"
|
||||
export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
|
||||
|
||||
if [ -x ~/.x11run ]; then
|
||||
exec ~/.x11run "${@}"
|
||||
fi
|
||||
|
||||
case $(basename "${SHELL}") in
|
||||
bash) exec -l "${SHELL}" --login -c 'exec "${@}"' - "${@}" ;;
|
||||
ksh|sh|zsh) exec -l "${SHELL}" -c 'exec "${@}"' - "${@}" ;;
|
||||
csh|tcsh) exec -l "${SHELL}" -c 'exec $argv:q' "${@}" ;;
|
||||
es|rc) exec -l "${SHELL}" -l -c 'exec $*' "${@}" ;;
|
||||
*) exec "${@}" ;;
|
||||
esac
|
@ -1,7 +1,9 @@
|
||||
{ lib, stdenv, buildEnv, makeFontsConf, gnused, writeScript, xorg, bashInteractive, xterm, makeWrapper, ruby
|
||||
{ lib, stdenv, buildEnv, makeFontsConf, gnused, writeScript, xorg, bashInteractive, xterm, xcbuild, makeWrapper
|
||||
, quartz-wm, fontconfig, xlsfonts, xfontsel
|
||||
, ttf_bitstream_vera, freefont_ttf, liberation_ttf
|
||||
, shell ? "${bashInteractive}/bin/bash"
|
||||
, unfreeFonts ? false
|
||||
, extraFontDirs ? []
|
||||
}:
|
||||
|
||||
# ------------
|
||||
@ -46,13 +48,13 @@ let
|
||||
sed=${gnused}/bin/sed
|
||||
|
||||
cp ${./org.nixos.xquartz.startx.plist} $tmpdir/$agentName
|
||||
$sed -i "s|@LAUNCHD_STARTX@|$NIX_LINK/etc/X11/xinit/launchd_startx|" $tmpdir/$agentName
|
||||
$sed -i "s|@LAUNCHD_STARTX@|$NIX_LINK/libexec/launchd_startx|" $tmpdir/$agentName
|
||||
$sed -i "s|@STARTX@|$NIX_LINK/bin/startx|" $tmpdir/$agentName
|
||||
$sed -i "s|@XQUARTZ@|$NIX_LINK/bin/Xquartz|" $tmpdir/$agentName
|
||||
|
||||
cp ${./org.nixos.xquartz.privileged_startx.plist} $tmpdir/$daemonName
|
||||
$sed -i "s|@PRIVILEGED_STARTX@|$NIX_LINK/lib/X11/xinit/privileged_startx|" $tmpdir/$daemonName
|
||||
$sed -i "s|@PRIVILEGED_STARTX_D@|$NIX_LINK/lib/X11/xinit/privileged_startx.d|" $tmpdir/$daemonName
|
||||
$sed -i "s|@PRIVILEGED_STARTX@|$NIX_LINK/libexec/privileged_startx|" $tmpdir/$daemonName
|
||||
$sed -i "s|@PRIVILEGED_STARTX_D@|$NIX_LINK/etc/X11/xinit/privileged_startx.d|" $tmpdir/$daemonName
|
||||
|
||||
sudo cp $tmpdir/$agentName /Library/LaunchAgents/$agentName
|
||||
sudo cp $tmpdir/$daemonName /Library/LaunchDaemons/$daemonName
|
||||
@ -60,15 +62,16 @@ let
|
||||
sudo launchctl load -w /Library/LaunchDaemons/$daemonName
|
||||
'';
|
||||
fontDirs = [
|
||||
xorg.fontbhlucidatypewriter100dpi
|
||||
xorg.fontbhlucidatypewriter75dpi
|
||||
ttf_bitstream_vera
|
||||
freefont_ttf
|
||||
liberation_ttf
|
||||
xorg.fontbh100dpi
|
||||
xorg.fontmiscmisc
|
||||
xorg.fontcursormisc
|
||||
];
|
||||
] ++ lib.optionals unfreeFonts [
|
||||
xorg.fontbhlucidatypewriter100dpi
|
||||
xorg.fontbhlucidatypewriter75dpi
|
||||
xorg.fontbh100dpi
|
||||
] ++ extraFontDirs;
|
||||
fontsConf = makeFontsConf {
|
||||
fontDirectories = fontDirs ++ [
|
||||
"/Library/Fonts"
|
||||
@ -79,26 +82,22 @@ let
|
||||
inherit stdenv xorg fontDirs;
|
||||
};
|
||||
# any X related programs expected to be available via $PATH
|
||||
env = buildEnv {
|
||||
name = "xquartz-env";
|
||||
pathsToLink = [ "/bin" ];
|
||||
paths = with xorg; [
|
||||
# non-xorg
|
||||
quartz-wm xterm fontconfig
|
||||
# xorg
|
||||
xlsfonts xfontsel
|
||||
bdftopcf fontutil iceauth libXpm lndir luit makedepend mkfontdir
|
||||
mkfontscale sessreg setxkbmap smproxy twm x11perf xauth xbacklight xclock
|
||||
xcmsdb xcursorgen xdm xdpyinfo xdriinfo xev xeyes xfs xgamma xhost
|
||||
xinput xkbcomp xkbevd xkbutils xkill xlsatoms xlsclients xmessage xmodmap
|
||||
xpr xprop xrandr xrdb xrefresh xset xsetroot xvinfo xwd xwininfo xwud
|
||||
];
|
||||
};
|
||||
pkgs = with xorg; [
|
||||
# non-xorg
|
||||
quartz-wm xterm fontconfig
|
||||
# xorg
|
||||
xlsfonts xfontsel
|
||||
bdftopcf fontutil iceauth libXpm lndir luit makedepend mkfontdir
|
||||
mkfontscale sessreg setxkbmap smproxy twm x11perf xauth xbacklight xclock
|
||||
xcmsdb xcursorgen xdm xdpyinfo xdriinfo xev xeyes xfs xgamma xhost
|
||||
xinput xkbcomp xkbevd xkbutils xkill xlsatoms xlsclients xmessage xmodmap
|
||||
xpr xprop xrandr xrdb xrefresh xset xsetroot xvinfo xwd xwininfo xwud
|
||||
];
|
||||
in stdenv.mkDerivation {
|
||||
pname = "xquartz";
|
||||
version = lib.getVersion xorg.xorgserver;
|
||||
|
||||
nativeBuildInputs = [ ruby makeWrapper ];
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
unpackPhase = "sourceRoot=.";
|
||||
|
||||
@ -117,74 +116,65 @@ in stdenv.mkDerivation {
|
||||
fontsConfPath=$out/etc/X11/fonts.conf
|
||||
cp ${fontsConf} $fontsConfPath
|
||||
|
||||
cp ${./startx} $out/bin/startx
|
||||
substituteInPlace $out/bin/startx \
|
||||
--replace "@shell@" "${stdenv.shell}" \
|
||||
--replace "@PATH@" "$out/bin:${env}" \
|
||||
--replace "@XAUTH@" "${xorg.xauth}/bin/xauth" \
|
||||
--replace "@FONT_CACHE@" "$out/bin/font_cache" \
|
||||
--replace "@PRIVILEGED_STARTX@" "$out/lib/X11/xinit/privileged_startx" \
|
||||
--replace "@DEFAULT_SERVER@" "$out/bin/Xquartz" \
|
||||
--replace "@DEFAULT_CLIENT@" "${xterm}/bin/xterm" \
|
||||
--replace "@XINIT@" "$out/bin/xinit" \
|
||||
--replace "@XINITRC@" "$out/etc/X11/xinit/xinitrc" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath"
|
||||
--replace "bindir=${xorg.xinit}/bin" "bindir=$out/bin" \
|
||||
--replace 'defaultserver=${xorg.xorgserver}/bin/X' "defaultserver=$out/bin/Xquartz" \
|
||||
--replace "${xorg.xinit}" "$out" \
|
||||
--replace "${xorg.xorgserver}" "$out" \
|
||||
--replace "eval xinit" "eval $out/bin/xinit" \
|
||||
--replace "sysclientrc=/etc/X11/xinit/xinitrc" "sysclientrc=$out/etc/X11/xinit/xinitrc"
|
||||
|
||||
wrapProgram $out/bin/Xquartz \
|
||||
--set XQUARTZ_X11 $out/Applications/XQuartz.app/Contents/MacOS/X11
|
||||
--set XQUARTZ_APP $out/Applications/XQuartz.app
|
||||
|
||||
defaultStartX="$out/bin/startx -- $out/bin/Xquartz"
|
||||
|
||||
ruby ${./patch_plist.rb} \
|
||||
${lib.escapeShellArg (builtins.toXML {
|
||||
XQUARTZ_DEFAULT_CLIENT = "${xterm}/bin/xterm";
|
||||
XQUARTZ_DEFAULT_SHELL = shell;
|
||||
XQUARTZ_DEFAULT_STARTX = "@STARTX@";
|
||||
FONTCONFIG_FILE = "@FONTCONFIG_FILE@";
|
||||
})} \
|
||||
$out/Applications/XQuartz.app/Contents/Info.plist
|
||||
substituteInPlace $out/Applications/XQuartz.app/Contents/Info.plist \
|
||||
--replace "@STARTX@" "$defaultStartX" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath"
|
||||
${xcbuild}/bin/PlistBuddy $out/Applications/XQuartz.app/Contents/Info.plist <<EOF
|
||||
Add :LSEnvironment dictionary
|
||||
Add :LSEnvironment:XQUARTZ_DEFAULT_CLIENT string "${xterm}/bin/xterm"
|
||||
Add :LSEnvironment:XQUARTZ_DEFAULT_SHELL string "${shell}"
|
||||
Add :LSEnvironment:XQUARTZ_DEFAULT_STARTX string "$defaultStartX"
|
||||
Add :LSEnvironment:FONTCONFIG_FILE string "$fontsConfPath"
|
||||
Save
|
||||
EOF
|
||||
|
||||
mkdir -p $out/lib/X11/xinit/privileged_startx.d
|
||||
cp ${./privileged} $out/lib/X11/xinit/privileged_startx.d/privileged
|
||||
substituteInPlace $out/lib/X11/xinit/privileged_startx.d/privileged \
|
||||
--replace "@shell@" "${stdenv.shell}" \
|
||||
--replace "@PATH@" "$out/bin:${env}" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath" \
|
||||
--replace "@FONT_CACHE@" "$out/bin/font_cache"
|
||||
substituteInPlace $out/etc/X11/xinit/xinitrc \
|
||||
--replace ${xorg.xinit} $out \
|
||||
--replace xmodmap ${xorg.xmodmap}/bin/xmodmap \
|
||||
--replace xrdb ${xorg.xrdb}/bin/xrdb
|
||||
|
||||
mkdir -p $out/etc/X11/xinit/xinitrc.d
|
||||
|
||||
cp ${./10-fontdir.sh} $out/etc/X11/xinit/xinitrc.d/10-fontdir.sh
|
||||
substituteInPlace $out/etc/X11/xinit/xinitrc.d/10-fontdir.sh \
|
||||
--subst-var-by "SYSTEM_FONTS" "${fonts}/share/X11-fonts/" \
|
||||
--subst-var-by "XSET" "${xorg.xset}/bin/xset"
|
||||
|
||||
cp ${./98-user.sh} $out/etc/X11/xinit/xinitrc.d/98-user.sh
|
||||
|
||||
cat > $out/etc/X11/xinit/xinitrc.d/99-quartz-wm.sh <<EOF
|
||||
exec ${quartz-wm}/bin/quartz-wm
|
||||
EOF
|
||||
chmod +x $out/etc/X11/xinit/xinitrc.d/99-quartz-wm.sh
|
||||
|
||||
substituteInPlace $out/etc/X11/xinit/privileged_startx.d/20-font_cache \
|
||||
--replace ${xorg.xinit} $out
|
||||
|
||||
cp ${./font_cache} $out/bin/font_cache
|
||||
substituteInPlace $out/bin/font_cache \
|
||||
--replace "@shell@" "${stdenv.shell}" \
|
||||
--replace "@PATH@" "$out/bin:${env}" \
|
||||
--replace "@ENCODINGSDIR@" "${xorg.encodings}/share/fonts/X11/encodings" \
|
||||
--replace "@MKFONTDIR@" "${xorg.mkfontdir}/bin/mkfontdir" \
|
||||
--replace "@MKFONTSCALE@" "${xorg.mkfontscale}/bin/mkfontscale" \
|
||||
--replace "@FC_CACHE@" "${fontconfig.bin}/bin/fc-cache" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath"
|
||||
|
||||
cp ${./xinitrc} $out/etc/X11/xinit/xinitrc
|
||||
substituteInPlace $out/etc/X11/xinit/xinitrc \
|
||||
--replace "@shell@" "${stdenv.shell}" \
|
||||
--replace "@PATH@" "$out/bin:${env}" \
|
||||
--replace "@XSET@" "${xorg.xset}/bin/xset" \
|
||||
--replace "@XMODMAP@" "${xorg.xmodmap}/bin/xmodmap" \
|
||||
--replace "@XRDB@" "${xorg.xrdb}/bin/xrdb" \
|
||||
--replace "@SYSTEM_FONTS@" "${fonts}/share/X11-fonts/" \
|
||||
--replace "@QUARTZ_WM@" "${quartz-wm}/bin/quartz-wm" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath"
|
||||
|
||||
cp ${./X11} $out/Applications/XQuartz.app/Contents/MacOS/X11
|
||||
substituteInPlace $out/Applications/XQuartz.app/Contents/MacOS/X11 \
|
||||
--replace "@shell@" "${stdenv.shell}" \
|
||||
--replace "@DEFAULT_SHELL@" "${shell}" \
|
||||
--replace "@DEFAULT_STARTX@" "$defaultStartX" \
|
||||
--replace "@DEFAULT_CLIENT@" "${xterm}/bin/xterm" \
|
||||
--replace "@FONTCONFIG_FILE@" "$fontsConfPath"
|
||||
--subst-var-by "shell" "${stdenv.shell}" \
|
||||
--subst-var-by "PATH" "$out/bin" \
|
||||
--subst-var-by "ENCODINGSDIR" "${xorg.encodings}/share/fonts/X11/encodings" \
|
||||
--subst-var-by "MKFONTDIR" "${xorg.mkfontdir}/bin/mkfontdir" \
|
||||
--subst-var-by "MKFONTSCALE" "${xorg.mkfontscale}/bin/mkfontscale" \
|
||||
--subst-var-by "FC_CACHE" "${fontconfig.bin}/bin/fc-cache" \
|
||||
--subst-var-by "FONTCONFIG_FILE" "$fontsConfPath"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
platforms = platforms.darwin;
|
||||
maintainers = with maintainers; [ cstrahan ];
|
||||
|
@ -1,47 +0,0 @@
|
||||
require 'rexml/document'
|
||||
|
||||
# This script is for setting environment variables in OSX applications.
|
||||
#
|
||||
# This script takes two arguments:
|
||||
# 1) A Nix attrset serialized via `builtins.toXML'
|
||||
# 2) The path to an OSX app's Info.plist file.
|
||||
|
||||
def main(serialized_attrs, plist_path)
|
||||
env = attrs_to_hash(serialized_attrs)
|
||||
doc = REXML::Document.new(File.open(plist_path, &:read))
|
||||
topmost_dict = doc.root.elements.detect { |e| e.name == "dict" }
|
||||
topmost_dict.add_element("key").tap do |key|
|
||||
key.text = "LSEnvironment"
|
||||
end
|
||||
topmost_dict.add_element(env_to_dict(env))
|
||||
|
||||
formatter = REXML::Formatters::Pretty.new(2)
|
||||
formatter.compact = true
|
||||
formatter.write(doc, File.open(plist_path, "w"))
|
||||
end
|
||||
|
||||
# Convert a `builtins.toXML' serialized attrs to a hash.
|
||||
# This assumes the values are strings.
|
||||
def attrs_to_hash(serialized_attrs)
|
||||
hash = {}
|
||||
env_vars = REXML::Document.new(serialized_attrs)
|
||||
env_vars.root.elements[1].elements.each do |attr|
|
||||
name = attr.attribute("name")
|
||||
value = attr.elements.first.attribute("value")
|
||||
hash[name] = value
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
def env_to_dict(env)
|
||||
dict = REXML::Element.new("dict")
|
||||
env.each do |k, v|
|
||||
key = dict.add_element("key")
|
||||
key.text = k
|
||||
string = dict.add_element("string")
|
||||
string.text = v
|
||||
end
|
||||
dict
|
||||
end
|
||||
|
||||
main(ARGV[0], ARGV[1])
|
@ -1,43 +0,0 @@
|
||||
#!@shell@
|
||||
|
||||
export PATH=@PATH@:$PATH
|
||||
export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
|
||||
|
||||
# Our usage of mktemp fails with GNU, so prefer /usr/bin to hopefully
|
||||
# get BSD mktemp
|
||||
if [ -x /usr/bin/mktemp ] ; then
|
||||
MKTEMP=/usr/bin/mktemp
|
||||
else
|
||||
MKTEMP=mktemp
|
||||
fi
|
||||
|
||||
STAT=/usr/bin/stat
|
||||
|
||||
for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do
|
||||
success=0
|
||||
for attempt in 1 2 3 4 5 ; do
|
||||
check=`${STAT} -f '%#p %u %g' ${dir} 2> /dev/null`
|
||||
if [ "${check}" = "041777 0 0" ] ; then
|
||||
success=1
|
||||
break
|
||||
elif [ -n "${check}" ] ; then
|
||||
saved=$(${MKTEMP} -d ${dir}-XXXXXXXX)
|
||||
mv ${dir} ${saved}
|
||||
echo "${dir} exists but is insecure. It has been moved into ${saved}" >&2
|
||||
fi
|
||||
|
||||
# if $dir exists and is a symlink (ie protect against a race)
|
||||
if ${MKTEMP} -d ${dir} >& /dev/null ; then
|
||||
chmod 1777 $dir
|
||||
chown root:wheel $dir
|
||||
success=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${success}" -eq 0 ] ; then
|
||||
echo "Could not successfully create ${dir}" >&2
|
||||
fi
|
||||
done
|
||||
|
||||
@FONT_CACHE@ -s &
|
@ -1,232 +0,0 @@
|
||||
#!@shell@
|
||||
|
||||
# vim :set ts=4 sw=4 sts=4 et :
|
||||
|
||||
#
|
||||
# This is just a sample implementation of a slightly less primitive
|
||||
# interface than xinit. It looks for user .xinitrc and .xserverrc
|
||||
# files, then system xinitrc and xserverrc files, else lets xinit choose
|
||||
# its default. The system xinitrc should probably do things like check
|
||||
# for .Xresources files and merge them in, start up a window manager,
|
||||
# and pop a clock and several xterms.
|
||||
#
|
||||
# Site administrators are STRONGLY urged to write nicer versions.
|
||||
#
|
||||
|
||||
unset DBUS_SESSION_BUS_ADDRESS
|
||||
unset SESSION_MANAGER
|
||||
|
||||
|
||||
# Bourne shell does not automatically export modified environment variables
|
||||
# so export the new PATH just in case the user changes the shell
|
||||
export PATH=@PATH@:$PATH
|
||||
|
||||
export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
|
||||
|
||||
userclientrc=$HOME/.xinitrc
|
||||
sysclientrc=@XINITRC@
|
||||
|
||||
userserverrc=$HOME/.xserverrc
|
||||
sysserverrc=@XINITRC@
|
||||
defaultclient=@DEFAULT_CLIENT@ # xterm
|
||||
defaultserver=@DEFAULT_SERVER@
|
||||
defaultclientargs=""
|
||||
defaultserverargs=""
|
||||
defaultdisplay=":0"
|
||||
clientargs=""
|
||||
serverargs=""
|
||||
|
||||
export X11_PREFS_DOMAIN=org.nixos.xquartz".X11"
|
||||
|
||||
# Initialize defaults (this will cut down on "safe" error messages)
|
||||
if ! /usr/bin/defaults read $X11_PREFS_DOMAIN cache_fonts > /dev/null 2>&1 ; then
|
||||
/usr/bin/defaults write $X11_PREFS_DOMAIN cache_fonts -bool true
|
||||
fi
|
||||
|
||||
if ! /usr/bin/defaults read $X11_PREFS_DOMAIN no_auth > /dev/null 2>&1 ; then
|
||||
/usr/bin/defaults write $X11_PREFS_DOMAIN no_auth -bool false
|
||||
fi
|
||||
|
||||
if ! /usr/bin/defaults read $X11_PREFS_DOMAIN nolisten_tcp > /dev/null 2>&1 ; then
|
||||
/usr/bin/defaults write $X11_PREFS_DOMAIN nolisten_tcp -bool true
|
||||
fi
|
||||
|
||||
# First, start caching fonts
|
||||
if [ x`/usr/bin/defaults read $X11_PREFS_DOMAIN cache_fonts` = x1 ] ; then
|
||||
@FONT_CACHE@ &
|
||||
fi
|
||||
|
||||
# a race to create /tmp/.X11-unix
|
||||
@PRIVILEGED_STARTX@
|
||||
|
||||
if [ x`/usr/bin/defaults read $X11_PREFS_DOMAIN no_auth` = x0 ] ; then
|
||||
enable_xauth=1
|
||||
else
|
||||
enable_xauth=0
|
||||
fi
|
||||
|
||||
if [ x`defaults read $X11_PREFS_DOMAIN nolisten_tcp` = x1 ] ; then
|
||||
defaultserverargs="$defaultserverargs -nolisten tcp"
|
||||
fi
|
||||
|
||||
# The second check is the real one. The first is to hopefully avoid
|
||||
# needless syslog spamming.
|
||||
if /usr/bin/defaults read $X11_PREFS_DOMAIN 2> /dev/null | grep -q 'dpi' && /usr/bin/defaults read $X11_PREFS_DOMAIN dpi > /dev/null 2>&1 ; then
|
||||
defaultserverargs="$defaultserverargs -dpi `/usr/bin/defaults read $X11_PREFS_DOMAIN dpi`"
|
||||
fi
|
||||
|
||||
# Automatically determine an unused $DISPLAY
|
||||
d=0
|
||||
while true ; do
|
||||
[ -e /tmp/.X$d-lock ] || break
|
||||
d=$(($d + 1))
|
||||
done
|
||||
defaultdisplay=":$d"
|
||||
unset d
|
||||
|
||||
whoseargs="client"
|
||||
while [ x"$1" != x ]; do
|
||||
case "$1" in
|
||||
# '' required to prevent cpp from treating "/*" as a C comment.
|
||||
/''*|\./''*)
|
||||
if [ "$whoseargs" = "client" ]; then
|
||||
if [ x"$client" = x ] && [ x"$clientargs" = x ]; then
|
||||
client="$1"
|
||||
else
|
||||
clientargs="$clientargs $1"
|
||||
fi
|
||||
else
|
||||
if [ x"$server" = x ] && [ x"$serverargs" = x ]; then
|
||||
server="$1"
|
||||
else
|
||||
serverargs="$serverargs $1"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
--)
|
||||
whoseargs="server"
|
||||
;;
|
||||
*)
|
||||
if [ "$whoseargs" = "client" ]; then
|
||||
clientargs="$clientargs $1"
|
||||
else
|
||||
# display must be the FIRST server argument
|
||||
if [ x"$serverargs" = x ] && \
|
||||
expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
|
||||
display="$1"
|
||||
else
|
||||
serverargs="$serverargs $1"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# process client arguments
|
||||
if [ x"$client" = x ]; then
|
||||
client=$defaultclient
|
||||
|
||||
# For compatibility reasons, only use startxrc if there were no client command line arguments
|
||||
if [ x"$clientargs" = x ]; then
|
||||
if [ -f "$userclientrc" ]; then
|
||||
client=$userclientrc
|
||||
elif [ -f "$sysclientrc" ]; then
|
||||
client=$sysclientrc
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# if no client arguments, use defaults
|
||||
if [ x"$clientargs" = x ]; then
|
||||
clientargs=$defaultclientargs
|
||||
fi
|
||||
|
||||
# process server arguments
|
||||
if [ x"$server" = x ]; then
|
||||
server=$defaultserver
|
||||
|
||||
# For compatibility reasons, only use xserverrc if there were no server command line arguments
|
||||
if [ x"$serverargs" = x -a x"$display" = x ]; then
|
||||
if [ -f "$userserverrc" ]; then
|
||||
server=$userserverrc
|
||||
elif [ -f "$sysserverrc" ]; then
|
||||
server=$sysserverrc
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# if no server arguments, use defaults
|
||||
if [ x"$serverargs" = x ]; then
|
||||
serverargs=$defaultserverargs
|
||||
fi
|
||||
|
||||
# if no display, use default
|
||||
if [ x"$display" = x ]; then
|
||||
display=$defaultdisplay
|
||||
fi
|
||||
|
||||
if [ x"$enable_xauth" = x1 ] ; then
|
||||
if [ x"$XAUTHORITY" = x ]; then
|
||||
XAUTHORITY=$HOME/.Xauthority
|
||||
export XAUTHORITY
|
||||
fi
|
||||
|
||||
removelist=
|
||||
|
||||
# set up default Xauth info for this machine
|
||||
hostname=`/bin/hostname`
|
||||
|
||||
authdisplay=${display:-:0}
|
||||
|
||||
mcookie=`/usr/bin/openssl rand -hex 16`
|
||||
|
||||
if test x"$mcookie" = x; then
|
||||
echo "Couldn't create cookie"
|
||||
exit 1
|
||||
fi
|
||||
dummy=0
|
||||
|
||||
# create a file with auth information for the server. ':0' is a dummy.
|
||||
xserverauthfile=$HOME/.serverauth.$$
|
||||
trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP KILL BUS TERM
|
||||
@XAUTH@ -q -f "$xserverauthfile" << EOF
|
||||
add :$dummy . $mcookie
|
||||
EOF
|
||||
|
||||
xserverauthfilequoted=$(echo ${xserverauthfile} | sed "s/'/'\\\\''/g")
|
||||
serverargs=${serverargs}" -auth '"${xserverauthfilequoted}"'"
|
||||
|
||||
# now add the same credentials to the client authority file
|
||||
# if '$displayname' already exists do not overwrite it as another
|
||||
# server man need it. Add them to the '$xserverauthfile' instead.
|
||||
for displayname in $authdisplay $hostname$authdisplay; do
|
||||
authcookie=`@XAUTH@ list "$displayname" \
|
||||
| sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
|
||||
if [ "z${authcookie}" = "z" ] ; then
|
||||
@XAUTH@ -q << EOF
|
||||
add $displayname . $mcookie
|
||||
EOF
|
||||
removelist="$displayname $removelist"
|
||||
else
|
||||
dummy=$(($dummy+1));
|
||||
@XAUTH@ -q -f "$xserverauthfile" << EOF
|
||||
add :$dummy . $authcookie
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
eval @XINIT@ \"$client\" $clientargs -- \"$server\" $display $serverargs
|
||||
retval=$?
|
||||
|
||||
if [ x"$enable_xauth" = x1 ] ; then
|
||||
if [ x"$removelist" != x ]; then
|
||||
@XAUTH@ remove $removelist
|
||||
fi
|
||||
if [ x"$xserverauthfile" != x ]; then
|
||||
rm -f "$xserverauthfile"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $retval
|
@ -22,7 +22,7 @@ stdenv.mkDerivation {
|
||||
find $fontDirs -type f -o -type l | while read i; do
|
||||
j="''${i##*/}"
|
||||
if ! test -e "$out/share/X11-fonts/''${j}"; then
|
||||
ln -s "$i" "$out/share/X11-fonts/''${j}";
|
||||
cp "$i" "$out/share/X11-fonts/''${j}";
|
||||
fi;
|
||||
done;
|
||||
cd $out/share/X11-fonts/
|
||||
|
@ -1,40 +0,0 @@
|
||||
#!@shell@
|
||||
|
||||
export PATH=@PATH@:$PATH
|
||||
|
||||
userresources=$HOME/.Xresources
|
||||
usermodmap=$HOME/.Xmodmap
|
||||
|
||||
# Fix ridiculously slow key repeat.
|
||||
@XSET@ r rate
|
||||
|
||||
# merge in defaults and keymaps
|
||||
|
||||
if [ -f "$userresources" ]; then
|
||||
if [ -x /usr/bin/cpp ] ; then
|
||||
@XRDB@ -merge "$userresources"
|
||||
else
|
||||
@XRDB@ -nocpp -merge "$userresources"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "$usermodmap" ]; then
|
||||
@XMODMAP@ "$usermodmap"
|
||||
fi
|
||||
|
||||
fontpath="@SYSTEM_FONTS@"
|
||||
[ -e "$HOME"/.fonts/fonts.dir ] && fontpath="$fontpath,$HOME/.fonts"
|
||||
[ -e "$HOME"/Library/Fonts/fonts.dir ] && fontpath="$fontpath,$HOME/Library/Fonts"
|
||||
[ -e /Library/Fonts/fonts.dir ] && fontpath="$fontpath,/Library/Fonts"
|
||||
[ -e /System/Library/Fonts/fonts.dir ] && fontpath="$fontpath,/System/Library/Fonts"
|
||||
@XSET@ fp= "$fontpath"
|
||||
unset fontpath
|
||||
|
||||
if [ -d "${HOME}/.xinitrc.d" ] ; then
|
||||
for f in "${HOME}"/.xinitrc.d/*.sh ; do
|
||||
[ -x "$f" ] && . "$f"
|
||||
done
|
||||
unset f
|
||||
fi
|
||||
|
||||
exec @QUARTZ_WM@
|
Loading…
Reference in New Issue
Block a user