From dd99084843ee2d94d2efb127231a6358f0cf0daf Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 16 May 2024 10:14:07 -0500 Subject: [PATCH] buildFHSEnvBubblewrap: allow more varied $DISPLAY syntax The $DISPLAY variable has a format of [host]:num[.screen]. Previously, the number would only be extracted properly if it had the form :num. Allow all forms but correctly discard the unused parts. --- pkgs/build-support/build-fhsenv-bubblewrap/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix index 12f3e7d58552..398a99e80e8c 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix @@ -196,8 +196,10 @@ let x11_args+=(--tmpfs /tmp/.X11-unix) # Try to guess X socket path. This doesn't cover _everything_, but it covers some things. - if [[ "$DISPLAY" == :* ]]; then - display_nr=''${DISPLAY#?} + if [[ "$DISPLAY" == *:* ]]; then + # recover display number from $DISPLAY formatted [host]:num[.screen] + display_nr=''${DISPLAY/#*:} # strip host + display_nr=''${display_nr/%.*} # strip screen local_socket=/tmp/.X11-unix/X$display_nr x11_args+=(--ro-bind-try "$local_socket" "$local_socket") fi