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.

Changed files
+7 -1
nixos
modules
services
+7 -1
nixos/modules/services/misc/nixos-manual.nix
···
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