add code mime files

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-02-07 13:16:42 +01:00
parent 72c13294e6
commit ea18558cb3

View File

@@ -1,10 +1,15 @@
# Mime type associations for the system. # Mime type associations for the system.
{lib, ...}: {
lib,
pkgs,
...
}:
with lib; let with lib; let
defaultApps = { defaultApps = {
# check desktop files here: `ls $(echo $XDG_DATA_DIRS| sed "s/:/ /g")` # check desktop files here: `ls $(echo $XDG_DATA_DIRS| sed "s/:/ /g")`
browser = ["brave.desktop"]; browser = ["brave.desktop"];
text = ["org.gnome.TextEditor.desktop"]; text = ["org.gnome.TextEditor.desktop"];
code = ["nvim-ghostty.desktop"];
image = ["imv-dir.desktop"]; image = ["imv-dir.desktop"];
audio = ["mpv.desktop"]; audio = ["mpv.desktop"];
video = ["mpv.desktop"]; video = ["mpv.desktop"];
@@ -18,6 +23,41 @@ with lib; let
mimeMap = { mimeMap = {
text = ["text/plain"]; text = ["text/plain"];
code = [
"text/x-csrc"
"text/x-chdr"
"text/x-c++src"
"text/x-c++hdr"
"text/x-rust"
"text/x-go"
"text/x-java"
"text/x-csharp"
"text/x-python"
"application/x-shellscript"
"text/javascript"
"application/javascript"
"text/css"
"text/x-php"
"text/x-ruby"
"application/json"
"application/xml"
"text/xml"
"text/x-yaml"
"application/x-yaml"
"application/toml"
"text/x-nix"
"text/markdown"
"text/x-dockerfile"
"application/x-yaml"
"text/x-terraform"
"application/x-perl"
"text/x-lua"
"text/x-haskell"
];
image = [ image = [
"image/bmp" "image/bmp"
"image/gif" "image/gif"
@@ -79,11 +119,22 @@ with lib; let
discord = ["x-scheme-handler/discord"]; discord = ["x-scheme-handler/discord"];
}; };
nvim-ghostty = pkgs.makeDesktopItem {
name = "nvim-ghostty";
desktopName = "Neovim (Ghostty)";
exec = "ghostty -e nvim %F";
terminal = false;
categories = ["Development" "TextEditor"];
mimeTypes = mimeMap.code ++ mimeMap.text;
};
associations = with lists; associations = with lists;
listToAttrs (flatten (mapAttrsToList listToAttrs (flatten (mapAttrsToList
(key: map (type: attrsets.nameValuePair type defaultApps."${key}")) (key: map (type: attrsets.nameValuePair type defaultApps."${key}"))
mimeMap)); mimeMap));
in { in {
home.packages = [nvim-ghostty];
xdg = { xdg = {
configFile."mimeapps.list".force = true; configFile."mimeapps.list".force = true;
mimeApps = { mimeApps = {