Create Desktop Files with Home Manager

For org-protocol,
https://orgmode.org/worg/org-contrib/org-protocol.html
,
I’m supposed to make this desktop file

[Desktop Entry]
Name=org-protocol
Comment=Intercept calls from emacsclient to trigger custom actions
Categories=Other;
Keywords=org-protocol;
Icon=emacs
Type=Application
Exec=emacsclient -- %u
Terminal=false
StartupWMClass=Emacs
MimeType=x-scheme-handler/org-protocol;

I’ve gotten this far:

let

orgDesktopItem = pkgs.makeDesktopItem {
    name = "org-protocol";
    desktopName = "Org Protocol";
    exec = "emacsclient -- %u";
    terminal = "false";
    mimetype="x-scheme-handler/org-protocol";
  };

in

Here it complains about mimetype. Where can I see the specification for makeDesktopItem to see what its properties are?

Also, where are these files ending up?

Mimetypes is plural and a list:

mimeTypes= [“x-scheme-handler/org-protocol”];

The file ends up in $out/share/applications

Great, thanks, but where can I find a schema that lists all allowed properties?

I guess the source code is the more precise “documentation” https://github.com/NixOS/nixpkgs/blob/c653577537d9b16ffd04e3e2f3bc702cacc1a343/pkgs/build-support/make-desktopitem/default.nix no idea why I can’t find it in the manual beside in the nixos’s changelog.

For folks landing here by search, see

https://nix-community.github.io/home-manager/options.xhtml#opt-xdg.desktopEntries

To create the entry above,

  xdg.desktopEntries.org-protocol = {
    name = "org-protocol";
    exec = "emacsclient -- %u";
    terminal = false;
    type = "Application";
    categories = ["System"];
    mimeType = ["x-scheme-handler/org-protocol"];
  };

The file ends up at ~/.local/state/nix/profiles/home-manager/home-path/share/appl ications/ and that share dir is added to XDG_DATA_DIRS. :beers:

2 Likes