From d018f767e169950f02aeb95802c972c7b58772fc Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Wed, 26 Apr 2023 01:25:34 -0400 Subject: [PATCH] xquartz: Fix package to be compatible with current xorg.xorgserver --- pkgs/servers/x11/xquartz/10-fontdir.sh | 7 + pkgs/servers/x11/xquartz/98-user.sh | 6 + pkgs/servers/x11/xquartz/X11 | 20 -- pkgs/servers/x11/xquartz/default.nix | 139 +++++++------- pkgs/servers/x11/xquartz/patch_plist.rb | 47 ----- pkgs/servers/x11/xquartz/privileged | 43 ----- pkgs/servers/x11/xquartz/startx | 232 ------------------------ pkgs/servers/x11/xquartz/xinitrc | 40 ---- 8 files changed, 76 insertions(+), 458 deletions(-) create mode 100755 pkgs/servers/x11/xquartz/10-fontdir.sh create mode 100755 pkgs/servers/x11/xquartz/98-user.sh delete mode 100755 pkgs/servers/x11/xquartz/X11 delete mode 100644 pkgs/servers/x11/xquartz/patch_plist.rb delete mode 100755 pkgs/servers/x11/xquartz/privileged delete mode 100755 pkgs/servers/x11/xquartz/startx delete mode 100755 pkgs/servers/x11/xquartz/xinitrc diff --git a/pkgs/servers/x11/xquartz/10-fontdir.sh b/pkgs/servers/x11/xquartz/10-fontdir.sh new file mode 100755 index 000000000000..616b530175e9 --- /dev/null +++ b/pkgs/servers/x11/xquartz/10-fontdir.sh @@ -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 diff --git a/pkgs/servers/x11/xquartz/98-user.sh b/pkgs/servers/x11/xquartz/98-user.sh new file mode 100755 index 000000000000..3d3c5611eb45 --- /dev/null +++ b/pkgs/servers/x11/xquartz/98-user.sh @@ -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 diff --git a/pkgs/servers/x11/xquartz/X11 b/pkgs/servers/x11/xquartz/X11 deleted file mode 100755 index e6bb87fab3fe..000000000000 --- a/pkgs/servers/x11/xquartz/X11 +++ /dev/null @@ -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 diff --git a/pkgs/servers/x11/xquartz/default.nix b/pkgs/servers/x11/xquartz/default.nix index ad4d5603a135..3c2cf20eba54 100644 --- a/pkgs/servers/x11/xquartz/default.nix +++ b/pkgs/servers/x11/xquartz/default.nix @@ -1,4 +1,4 @@ -{ 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" @@ -46,13 +46,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 @@ -79,26 +79,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 +113,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 < $out/etc/X11/xinit/xinitrc.d/99-quartz-wm.sh < /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 & diff --git a/pkgs/servers/x11/xquartz/startx b/pkgs/servers/x11/xquartz/startx deleted file mode 100755 index b4afebce57c7..000000000000 --- a/pkgs/servers/x11/xquartz/startx +++ /dev/null @@ -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 diff --git a/pkgs/servers/x11/xquartz/xinitrc b/pkgs/servers/x11/xquartz/xinitrc deleted file mode 100755 index 276aeca7c846..000000000000 --- a/pkgs/servers/x11/xquartz/xinitrc +++ /dev/null @@ -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@