Change:
When "set as default browser" is clicked from within Firefox, it places a custom .desktop file in , and points to this from in the same directory. This file launches Firefox without the wrapper when it's opened using xdg-open. The result is that if xdg-open is used when no Firefox window exists, it will be opened without environment variables set correctly, and without plugins.
This is a great example why wrappers are error prone.
Is there a easy way to fix this? I don't see one
The easy way is to use a non-absolute path in the .desktop file, i.e. . This also ensures that after an upgrade, the new Firefox will be invoked.
This .desktop file is generated by Firefox when "set as default browser" is clicked - it's not one of nixpkgs's .desktop files. That'd involve a patch (which would have to be kept up to date with each Firefox release).
Right, shouldn't be hard to do.
Testing a patch now...
I can't see the patch anywhere -- did it work?
Chromium .desktop file includes and suffers from the same problem.
This is handled and detected with mimetypes.
Would be really nice to fix this one, any takers?
I think I have solved it for Firefox; as for Chromium — apparently it is non-trivial to test for me (StumpWM, not a DE)
There's still no obvious way to set the default browser that I can find - anyone know what the status is here?
A possibly reasonable option in the case of Firefox would be to disable the default browser check using the preferences file, and write a custom dialog for selecting the default browser in the wrapper itself, a very rough basis being: According to a google, similar should work for Chrome/Chromium, except passing instead of messing with config files. Opinions?
Is there no way to trick firefox into thinking its executable name is the wrapper ?
Yes: but this needs some testing, and it affects many browsers.
I fixed the wrapper to work with (), but we get another issue. When we update firefox, we end up with a different /nix path, which firefox considers as a different browser. If you restart firefox (for example when installing addons) then you get the not-your-default-browser" warning. Investaigating MOZAPPLAUNCHER as solution, but I start to think that may be the most general solution.

Discussion:
, desktopName ? # browserName with first letter capitalized (lib.toUpper (lib.substring 0 1 browserName) + lib.substring 1 (-1) browserName) , nameSuffix ? "" <del> , icon ? browserName, libtrick ? true </del> <ins> , icon ? browserName </ins> }: let

gst-plugins = with gst_all; [ gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-ffmpeg ]; gtk_modules = [ libcanberra_gtk2 ]; <del> in stdenv.mkDerivation { </del> <ins> in stdenv.mkDerivation { </ins> inherit name; desktopItem = makeDesktopItem { name = browserName; <del> exec = browserName + " %U"; </del> <ins> exec = "${browserName}${nameSuffix} %U"; </ins> inherit icon; comment = ""; <del> desktopName = desktopName; </del> <ins> desktopName = "${desktopName}${nameSuffix}"; </ins> genericName = "Web Browser"; categories = "Application;Network;WebBrowser;"; mimeType = stdenv.lib.concatStringsSep ";" [

exit 1 fi <del> makeWrapper "${browser}/bin/${browserName}"  </del> <ins> makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")"  </ins> "$out/bin/${browserName}${nameSuffix}"  --suffix-each MOZ_PLUGIN_PATH ':' "$plugins"  --suffix LD_LIBRARY_PATH ':' "$libs"  --suffix-each GTK_PATH ':' "$gtk_modules"  --suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))"  --prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))"  <del> --set MOZ_OBJDIR "$(ls -d "${browser}/lib/${browserName}"*)"  </del> <ins> --suffix PATH ':' "$out/bin"  --set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}"  </ins> ${lib.optionalString (!ffmpegSupport) ''--prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"''} <del> ${ lib.optionalString libtrick '' libdirname="$(echo "${browser}/lib/${browserName}"*)" libdirbasename="$(basename "$libdirname")" mkdir -p "$out/lib/$libdirbasename" ln -s "$libdirname"/* "$out/lib/$libdirbasename" script_location="$(mktemp "$out/lib/$libdirbasename/${browserName}${nameSuffix}.XXXXXX")" mv "$out/bin/${browserName}${nameSuffix}" "$script_location" ln -s "$script_location" "$out/bin/${browserName}${nameSuffix}" '' } </del> if [ -e "${browser}/share/icons" ]; then mkdir -p "$out/share" ln -s "${browser}/share/icons" "$out/share/icons" else mkdir -p "$out/share/icons/hicolor/128x128/apps" <del> ln -s "$out/lib/$libdirbasename/browser/icons/mozicon128.png"  </del> <ins> ln -s "${browser}/lib/${browserName}-"*"/browser/icons/mozicon128.png"  </ins> "$out/share/icons/hicolor/128x128/apps/${browserName}.png" fi <del> mkdir -p $out/share/applications cp $desktopItem/share/applications/* $out/share/applications </del> <ins> install -D -t $out/share/applications $desktopItem/share/applications/* </ins> # For manpages, in case the program supplies them mkdir -p $out/nix-support