xorgserver: set log-dir to /var/log instead of the Nix store

Xorg creates the log-dir in its output path because X crashes if it can't write
to its logfile. On a regular distro, this dir would be installed into the root
to prevent that from happening but with Nix, it sits in the read-only Nix store.
Ironically, when Xorg tries to write here, it fails and crashes.

To make Xorg log to /var/log, we have to stop the build script from trying to
create the log-dir as the sandbox doesn't (and shouldn't) have access to /var.

This creates a runtime dependency on /var when running as root but that should
exist on any Linux system (on NixOS, journald always creates /var/log).

Previously, the startx displayManager required some workarounds for logfiles
which are obsolete now.

patchPhase -> postPatch because overriding the patchPhase prevents patches from
being applied

Atemu a5ea1b6f c72c02ab

+40 -1
+32
pkgs/servers/x11/xorg/dont-create-logdir-during-build.patch
··· 1 + --- 2 + hw/xfree86/Makefile.am | 1 - 3 + hw/xfree86/Makefile.in | 1 - 4 + 2 files changed, 2 deletions(-) 5 + 6 + diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am 7 + index 9aeaea1..dcca3b8 100644 8 + --- a/hw/xfree86/Makefile.am 9 + +++ b/hw/xfree86/Makefile.am 10 + @@ -100,7 +100,6 @@ EXTRA_DIST = xorgconf.cpp 11 + 12 + # Without logdir, X will post an error on the terminal and will not start 13 + install-data-local: 14 + - $(AM_V_GEN)$(MKDIR_P) $(DESTDIR)$(logdir) 15 + if CYGWIN 16 + $(INSTALL_DATA) libXorg.exe.a $(DESTDIR)$(libdir)/libXorg.exe.a 17 + endif 18 + diff --git a/hw/xfree86/Makefile.in b/hw/xfree86/Makefile.in 19 + index c4fceee..74da8f1 100644 20 + --- a/hw/xfree86/Makefile.in 21 + +++ b/hw/xfree86/Makefile.in 22 + @@ -1161,7 +1161,6 @@ uninstall-am: uninstall-binPROGRAMS uninstall-local \ 23 + 24 + # Without logdir, X will post an error on the terminal and will not start 25 + install-data-local: 26 + - $(AM_V_GEN)$(MKDIR_P) $(DESTDIR)$(logdir) 27 + @CYGWIN_TRUE@ $(INSTALL_DATA) libXorg.exe.a $(DESTDIR)$(libdir)/libXorg.exe.a 28 + 29 + install-exec-hook: 30 + -- 31 + 2.25.4 32 +
+8 -1
pkgs/servers/x11/xorg/overrides.nix
··· 571 571 attrs = 572 572 if (abiCompat == null || lib.hasPrefix abiCompat version) then 573 573 attrs_passed // { 574 - buildInputs = attrs_passed.buildInputs ++ [ libdrm.dev ]; patchPhase = '' 574 + buildInputs = attrs_passed.buildInputs ++ [ libdrm.dev ]; postPatch = '' 575 575 for i in dri3/*.c 576 576 do 577 577 sed -i -e "s|#include <drm_fourcc.h>|#include <libdrm/drm_fourcc.h>|" $i ··· 626 626 if (!isDarwin) 627 627 then { 628 628 outputs = [ "out" "dev" ]; 629 + patches = [ 630 + # The build process tries to create the specified logdir when building. 631 + # 632 + # We set it to /var/log which can't be touched from inside the sandbox causing the build to hard-fail 633 + ./dont-create-logdir-during-build.patch 634 + ]; 629 635 buildInputs = commonBuildInputs ++ [ libdrm mesa ]; 630 636 propagatedBuildInputs = attrs.propagatedBuildInputs or [] ++ [ libpciaccess epoxy ] ++ commonPropagatedBuildInputs ++ lib.optionals stdenv.isLinux [ 631 637 udev ··· 642 648 "--with-xkb-bin-directory=${self.xkbcomp}/bin" 643 649 "--with-xkb-path=${self.xkeyboardconfig}/share/X11/xkb" 644 650 "--with-xkb-output=$out/share/X11/xkb/compiled" 651 + "--with-log-dir=/var/log" 645 652 "--enable-glamor" 646 653 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 647 654 "--disable-tls"