Make neovim wrapper .desktop optional

The neovim package installs an nvim.desktop file in .../share/applications/; however, I think this should be optional since it is not necessary if neovim is used only in the terminal. In addition, there are plenty of GUI options for neovim (neovim-gtk, neovim-qt, neovide, etc.)

Would a PR be accepted making the .desktop install optional? Should I tag someone or start a discussion here or on github?

(First time nixos user here, learning how things are done).

Thanks!

2 Likes

Thanks for asking this question! I am not too familiar about PR etiquette with nix, so I will defer to others about that. I suppose the question is: are there parallels in other packages, in which the desktop file is optional?

I am curious, though, what advantages there are in removing this file? Put another way, what is a scenario in which a user would desire its removal? Perhaps it is cluttering up the menus, or it doesn’t work as intended?

I doubt there are any conventions about this specific thing since it is such an obscure request. So the decision whether to accept a PR for this feature would fall to the maintainers of the package.

Personally, I would consider the costs compared to benefits (with alternatives in mind) and reject it:

Costs

  • Added complexity to the package expression.
  • People might disable the launcher not realizing that it would also break file associations.

Benefits

  • ÂżOne? user’s non-critical (purely cosmetic) use case would be satisfied.

Alternatives

  • User can ignore the launcher or move it to a separate screen.

  • User can do something like the following in their NixOS configuration to hide the launcher from the Shell:

    { config, lib, pkgs, ... }:
    {
      environment.systemPackages = [
        (lib.hiPrio (pkgs.runCommand "nvim.desktop-hide" { } ''
          mkdir -p "$out/share/applications"
          cat "${config.programs.neovim.finalPackage}/share/applications/nvim.desktop" > "$out/share/applications/nvim.desktop"
          echo "Hidden=1" >> "$out/share/applications/nvim.desktop"
        ''))
      ];
    }
    

    Or use NoDisplay instead of Hidden if you want file associations to keep working.

  • Use some Menu editor app to do the same as above non-declaratively.

  • …

6 Likes

There are a few “papercuts” for me:

  1. It says “Neovim Wrapper” which is kind of weird. I expect “Neovim”, if anything.
  2. When I double-click it, it opens a very tiny window that is basically unusable (maybe the wrapper doesn’t take my screen resolution into account? See screenshot below.)
  3. I only use vim (or neovim) in CLI scenarios; VSCode covers all of my needs in a graphical context. Having an extra GUI icon for Neovim is not useful to me, so I’m interested in the aesthetics of a clean setup.
  4. EDIT: When I use the app switcher, it shows “xterm” instead of neovim (see additional screenshot below).

Thank you @jtojnar for the Alternatives–very illuminating!

1 Like

Could do:

(drv: pkgs.symlinkJoin {
  name = drv.name;
  paths = [ drv ];
  postBuild = "rm -rf $out/share/applications";
}) pkgs.neovim;

I use something similar for the opposite; to remove apps from CLI.

Unfortunately, you can only easily override the unwrapped package when using the programs.neovim.package NixOS option, so that will not work.

Did you perhaps uninstall Console. GLib will try to open terminal apps in few well known terminal emulators.

You could make it support Black Box with something like (untested):

environment.systemPackages = [
  (pkgs.writeShellScriptBin "xdg-terminal-exec" ''
    exec "${lib.getExe pkgs.blackbox-terminal}" -- "$@"
  '')
];
3 Likes

For the record, yes, I did uninstall Console.

Thanks for the assistance. I’ve removed the wrapper on my system via @jtojnar 's hiPrio systemPackages addition. Works well enough for me :slight_smile: