git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit4ff5f304b9db4a85ad5da67cbcae8802fd574bcb authorSamuel Dionne-Riel <samuel@dionne-riel.com> dateSat 1 Sep 2018, 13:42 (8 years ago) parent4477cf0
1 file changed+7−1
nixos/modules/services/misc/nixos-manual.nix+7−1
nixos/modules/services/misc/nixos-manual.nix+7−1
@@ -44,7 +44,13 @@ let
4444 helpScript = pkgs.writeScriptBin "nixos-help"
4545 ''
4646 #! ${pkgs.runtimeShell} -e
47− browser="$BROWSER"
47+ # Finds first executable browser in a colon-separated list.
48+ # (see how xdg-open defines BROWSER)
49+ browser="$(
50+ IFS=: ; for b in $BROWSER; do
51+ [ -n "$(type -P "$b" || true)" ] && echo "$b" && break
52+ done
53+ )"
4854 if [ -z "$browser" ]; then
4955 browser="$(type -P xdg-open || true)"
5056 if [ -z "$browser" ]; then