From 4ff5f304b9db4a85ad5da67cbcae8802fd574bcb Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel <samuel@dionne-riel.com> Date: Sat, 1 Sep 2018 13:42:47 -0400 Subject: [PATCH] nixos/manual: nixos-help knows about colon-separated BROWSER This is the semantics as understood by `xdg-open`. Using these semantics on a non-colon-separated variable works because it acts as if it was a one element long list. This fixes an issue where it would try to exec `google-chrome-beta:google-chrome:chromium:firefox` on a system configured with these semantics in mind. --- nixos/modules/services/misc/nixos-manual.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nixos-manual.nix b/nixos/modules/services/misc/nixos-manual.nix index 3916c3052e8b..993b59590bb0 100644 --- a/nixos/modules/services/misc/nixos-manual.nix +++ b/nixos/modules/services/misc/nixos-manual.nix @@ -44,7 +44,13 @@ let helpScript = pkgs.writeScriptBin "nixos-help" '' #! ${pkgs.runtimeShell} -e - browser="$BROWSER" + # Finds first executable browser in a colon-separated list. + # (see how xdg-open defines BROWSER) + browser="$( + IFS=: ; for b in $BROWSER; do + [ -n "$(type -P "$b" || true)" ] && echo "$b" && break + done + )" if [ -z "$browser" ]; then browser="$(type -P xdg-open || true)" if [ -z "$browser" ]; then