home: move mimetype lists into eparate module

This commit is contained in:
Aly Raffauf 2024-07-06 19:49:07 -04:00
parent 90916b08d3
commit 7fa9990542
2 changed files with 316 additions and 290 deletions

View file

@ -4,17 +4,29 @@
pkgs, pkgs,
... ...
}: { }: {
config = lib.mkIf config.ar.home.defaultApps.enable { config = let
cfg = config.ar.home.defaultApps;
inherit
(import ./mimetypes.nix)
audioFiles
browserFiles
documentFiles
editorFiles
imageFiles
videoFiles
;
in
lib.mkIf cfg.enable {
dconf = { dconf = {
enable = true; enable = true;
settings = { settings = {
"org/cinnamon/desktop/applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}"; "org/cinnamon/desktop/applications/terminal".exec = "${lib.getExe cfg.terminal}";
"org/cinnamon/desktop/default-applications/terminal".exec = "${lib.getExe config.ar.home.defaultApps.terminal}"; "org/cinnamon/desktop/default-applications/terminal".exec = "${lib.getExe cfg.terminal}";
}; };
}; };
home = { home = {
packages = with config.ar.home.defaultApps; [ packages = with cfg; [
audioPlayer audioPlayer
editor editor
fileManager fileManager
@ -27,9 +39,9 @@
]; ];
sessionVariables = { sessionVariables = {
BROWSER = "${lib.getExe config.ar.home.defaultApps.webBrowser}"; BROWSER = "${lib.getExe cfg.webBrowser}";
EDITOR = "${lib.getExe config.ar.home.defaultApps.terminalEditor}"; EDITOR = "${lib.getExe cfg.terminalEditor}";
TERMINAL = "${lib.getExe config.ar.home.defaultApps.terminal}"; TERMINAL = "${lib.getExe cfg.terminal}";
}; };
}; };
@ -38,238 +50,32 @@
enable = true; enable = true;
defaultApplications = let defaultApplications = let
mkDefaults = files: desktopFile: lib.genAttrs files (_: [desktopFile]);
audioTypes = audioTypes =
lib.genAttrs [ mkDefaults audioFiles
"application/mpeg4-iod" "defaultAudioPlayer.desktop";
"application/mpeg4-muxcodetable"
"application/mxf"
"application/ogg"
"application/vnd.apple.mpegurl"
"application/vnd.ms-asf"
"application/vnd.rn-realmedia-vbr"
"application/vnd.rn-realmedia"
"application/x-extension-m4a"
"application/x-flac"
"application/x-ogg"
"application/x-streamingmedia"
"audio/3gpp"
"audio/3gpp2"
"audio/aac"
"audio/ac3"
"audio/amr-wb"
"audio/amr"
"audio/basic"
"audio/dv"
"audio/eac3"
"audio/flac"
"audio/m4a"
"audio/midi"
"audio/mp1"
"audio/mp2"
"audio/mp3"
"audio/mp4"
"audio/mpeg"
"audio/mpegurl"
"audio/mpg"
"audio/ogg"
"audio/opus"
"audio/scpls"
"audio/vnd.dolby.heaac.1"
"audio/vnd.dolby.heaac.2"
"audio/vnd.dolby.mlp"
"audio/vnd.dts.hd"
"audio/vnd.dts"
"audio/vnd.rn-realaudio"
"audio/wav"
"audio/webm"
"audio/x-aac"
"audio/x-aiff"
"audio/x-ape"
"audio/x-flac"
"audio/x-gsm"
"audio/x-it"
"audio/x-m4a"
"audio/x-matroska"
"audio/x-mod"
"audio/x-mp1"
"audio/x-mp2"
"audio/x-mp3"
"audio/x-mpeg"
"audio/x-mpegurl"
"audio/x-mpg"
"audio/x-ms-asf"
"audio/x-ms-wma"
"audio/x-musepack"
"audio/x-opus+ogg"
"audio/x-pn-aiff"
"audio/x-pn-au"
"audio/x-pn-realaudio"
"audio/x-pn-wav"
"audio/x-real-audio"
"audio/x-realaudio"
"audio/x-s3m"
"audio/x-scpls"
"audio/x-shorten"
"audio/x-speex"
"audio/x-tta"
"audio/x-vorbis"
"audio/x-vorbis+ogg"
"audio/x-wav"
"audio/x-wavpack"
"audio/x-xm"
"x-content/audio-cdda"
"x-content/audio-player"
]
(_: ["defaultAudioPlayer.desktop"]);
browserTypes = browserTypes =
lib.genAttrs [ mkDefaults browserFiles
"application/vnd.mozilla.xul+xml" "defaultWebBrowser.desktop";
"application/x-extension-htm"
"application/x-extension-html"
"application/x-extension-shtml"
"application/x-extension-xht"
"application/x-extension-xhtml"
"application/xhtml+xml"
"text/html"
"text/xml"
"x-scheme-handler/chrome"
"x-scheme-handler/ftp"
"x-scheme-handler/http"
"x-scheme-handler/http"
"x-scheme-handler/https"
]
(_: ["defaultWebBrowser.desktop"]);
documentTypes = documentTypes =
lib.genAttrs [ mkDefaults documentFiles
"application/illustrator" "defaultPdfViewer.desktop";
"application/oxps"
"application/pdf"
"application/postscript"
"application/vnd.comicbook-rar"
"application/vnd.comicbook+zip"
"application/vnd.ms-xpsdocument"
"application/x-bzdvi"
"application/x-bzpdf"
"application/x-bzpostscript"
"application/x-cb7"
"application/x-cbr"
"application/x-cbt"
"application/x-cbz"
"application/x-dvi"
"application/x-ext-cb7"
"application/x-ext-cbr"
"application/x-ext-cbt"
"application/x-ext-cbz"
"application/x-ext-djv"
"application/x-ext-djvu"
"application/x-ext-dvi"
"application/x-ext-eps"
"application/x-ext-pdf"
"application/x-ext-ps"
"application/x-gzdvi"
"application/x-gzpdf"
"application/x-gzpostscript"
"application/x-xzpdf"
"image/tiff"
"image/vnd.djvu"
"image/x-bzeps"
"image/x-eps"
"image/x-gzeps"
]
(_: ["defaultPdfViewer.desktop"]);
editorTypes = editorTypes =
lib.genAttrs [ mkDefaults editorFiles
"application/json" "defaultEditor.desktop";
"application/x-shellscript"
"application/x-shellscript"
"text/markdown"
"text/plain"
"text/x-python"
]
(_: ["defaultEditor.desktop"]);
folderTypes = {"inode/directory" = "defaultFileManager.desktop";}; folderTypes = {"inode/directory" = "defaultFileManager.desktop";};
imageTypes = imageTypes =
lib.genAttrs [ mkDefaults imageFiles
"image/bmp" "defaultImageViewer.desktop";
"image/gif"
"image/jpeg"
"image/jpg"
"image/pjpeg"
"image/png"
"image/svg+xml-compressed"
"image/svg+xml"
"image/tiff"
"image/vnd.wap.wbmp"
"image/webp"
"image/x-bmp"
"image/x-gray"
"image/x-icb"
"image/x-icns"
"image/x-ico"
"image/x-pcx"
"image/x-png"
"image/x-portable-anymap"
"image/x-portable-bitmap"
"image/x-portable-graymap"
"image/x-portable-pixmap"
"image/x-xbitmap"
"image/x-xpixmap"
]
(_: ["defaultImageViewer.desktop"]);
videoTypes = videoTypes =
lib.genAttrs [ mkDefaults videoFiles
"application/mpeg4-iod" "defaultVideoPlayer.desktop";
"application/mpeg4-muxcodetable"
"application/vnd.apple.mpegurl"
"application/x-extension-m4a"
"application/x-extension-mp4"
"application/x-flash-video"
"application/x-matroska"
"video/3gp"
"video/3gpp"
"video/3gpp2"
"video/divx"
"video/dv"
"video/fli"
"video/flv"
"video/mp2t"
"video/mp4"
"video/mp4v-es"
"video/mpeg-system"
"video/mpeg"
"video/msvideo"
"video/ogg"
"video/quicktime"
"video/vnd.mpegurl"
"video/vnd.rn-realvideo"
"video/webm"
"video/x-avi"
"video/x-flc"
"video/x-fli"
"video/x-flv"
"video/x-m4v"
"video/x-matroska"
"video/x-mpeg-system"
"video/x-mpeg"
"video/x-mpeg2"
"video/x-ms-asf"
"video/x-ms-wm"
"video/x-ms-wmv"
"video/x-ms-wmx"
"video/x-msvideo"
"video/x-nsv"
"video/x-ogm+ogg"
"video/x-theora"
"video/x-theora+ogg"
"x-content/video-dvd"
]
(_: ["defaultVideoPlayer.desktop"]);
in in
audioTypes audioTypes
// browserTypes // browserTypes
@ -290,13 +96,13 @@
}; };
}; };
in { in {
defaultAudioPlayer = mkDefaultEntry "Audio Player" config.ar.home.defaultApps.audioPlayer; defaultAudioPlayer = mkDefaultEntry "Audio Player" cfg.audioPlayer;
defaultEditor = mkDefaultEntry "Editor" config.ar.home.defaultApps.editor; defaultEditor = mkDefaultEntry "Editor" cfg.editor;
defaultFileManager = mkDefaultEntry "File Manager" config.ar.home.defaultApps.fileManager; defaultFileManager = mkDefaultEntry "File Manager" cfg.fileManager;
defaultImageViewer = mkDefaultEntry "Image Viewer" config.ar.home.defaultApps.imageViewer; defaultImageViewer = mkDefaultEntry "Image Viewer" cfg.imageViewer;
defaultPdfViewer = mkDefaultEntry "PDF Viewer" config.ar.home.defaultApps.pdfViewer; defaultPdfViewer = mkDefaultEntry "PDF Viewer" cfg.pdfViewer;
defaultVideoPlayer = mkDefaultEntry "Video Player" config.ar.home.defaultApps.videoPlayer; defaultVideoPlayer = mkDefaultEntry "Video Player" cfg.videoPlayer;
defaultWebBrowser = mkDefaultEntry "Web Browser" config.ar.home.defaultApps.webBrowser; defaultWebBrowser = mkDefaultEntry "Web Browser" cfg.webBrowser;
}; };
}; };
}; };

View file

@ -0,0 +1,220 @@
{
audioFiles = [
"application/mpeg4-iod"
"application/mpeg4-muxcodetable"
"application/mxf"
"application/ogg"
"application/vnd.apple.mpegurl"
"application/vnd.ms-asf"
"application/vnd.rn-realmedia-vbr"
"application/vnd.rn-realmedia"
"application/x-extension-m4a"
"application/x-flac"
"application/x-ogg"
"application/x-streamingmedia"
"audio/3gpp"
"audio/3gpp2"
"audio/aac"
"audio/ac3"
"audio/amr-wb"
"audio/amr"
"audio/basic"
"audio/dv"
"audio/eac3"
"audio/flac"
"audio/m4a"
"audio/midi"
"audio/mp1"
"audio/mp2"
"audio/mp3"
"audio/mp4"
"audio/mpeg"
"audio/mpegurl"
"audio/mpg"
"audio/ogg"
"audio/opus"
"audio/scpls"
"audio/vnd.dolby.heaac.1"
"audio/vnd.dolby.heaac.2"
"audio/vnd.dolby.mlp"
"audio/vnd.dts.hd"
"audio/vnd.dts"
"audio/vnd.rn-realaudio"
"audio/wav"
"audio/webm"
"audio/x-aac"
"audio/x-aiff"
"audio/x-ape"
"audio/x-flac"
"audio/x-gsm"
"audio/x-it"
"audio/x-m4a"
"audio/x-matroska"
"audio/x-mod"
"audio/x-mp1"
"audio/x-mp2"
"audio/x-mp3"
"audio/x-mpeg"
"audio/x-mpegurl"
"audio/x-mpg"
"audio/x-ms-asf"
"audio/x-ms-wma"
"audio/x-musepack"
"audio/x-opus+ogg"
"audio/x-pn-aiff"
"audio/x-pn-au"
"audio/x-pn-realaudio"
"audio/x-pn-wav"
"audio/x-real-audio"
"audio/x-realaudio"
"audio/x-s3m"
"audio/x-scpls"
"audio/x-shorten"
"audio/x-speex"
"audio/x-tta"
"audio/x-vorbis"
"audio/x-vorbis+ogg"
"audio/x-wav"
"audio/x-wavpack"
"audio/x-xm"
"x-content/audio-cdda"
"x-content/audio-player"
];
browserFiles = [
"application/vnd.mozilla.xul+xml"
"application/x-extension-htm"
"application/x-extension-html"
"application/x-extension-shtml"
"application/x-extension-xht"
"application/x-extension-xhtml"
"application/xhtml+xml"
"text/html"
"text/xml"
"x-scheme-handler/chrome"
"x-scheme-handler/ftp"
"x-scheme-handler/http"
"x-scheme-handler/http"
"x-scheme-handler/https"
];
documentFiles = [
"application/illustrator"
"application/oxps"
"application/pdf"
"application/postscript"
"application/vnd.comicbook-rar"
"application/vnd.comicbook+zip"
"application/vnd.ms-xpsdocument"
"application/x-bzdvi"
"application/x-bzpdf"
"application/x-bzpostscript"
"application/x-cb7"
"application/x-cbr"
"application/x-cbt"
"application/x-cbz"
"application/x-dvi"
"application/x-ext-cb7"
"application/x-ext-cbr"
"application/x-ext-cbt"
"application/x-ext-cbz"
"application/x-ext-djv"
"application/x-ext-djvu"
"application/x-ext-dvi"
"application/x-ext-eps"
"application/x-ext-pdf"
"application/x-ext-ps"
"application/x-gzdvi"
"application/x-gzpdf"
"application/x-gzpostscript"
"application/x-xzpdf"
"image/tiff"
"image/vnd.djvu"
"image/x-bzeps"
"image/x-eps"
"image/x-gzeps"
];
editorFiles = [
"application/json"
"application/x-shellscript"
"application/x-shellscript"
"text/markdown"
"text/plain"
"text/x-python"
];
imageFiles = [
"image/bmp"
"image/gif"
"image/jpeg"
"image/jpg"
"image/pjpeg"
"image/png"
"image/svg+xml-compressed"
"image/svg+xml"
"image/tiff"
"image/vnd.wap.wbmp"
"image/webp"
"image/x-bmp"
"image/x-gray"
"image/x-icb"
"image/x-icns"
"image/x-ico"
"image/x-pcx"
"image/x-png"
"image/x-portable-anymap"
"image/x-portable-bitmap"
"image/x-portable-graymap"
"image/x-portable-pixmap"
"image/x-xbitmap"
"image/x-xpixmap"
];
videoFiles = [
"application/mpeg4-iod"
"application/mpeg4-muxcodetable"
"application/vnd.apple.mpegurl"
"application/x-extension-m4a"
"application/x-extension-mp4"
"application/x-flash-video"
"application/x-matroska"
"video/3gp"
"video/3gpp"
"video/3gpp2"
"video/divx"
"video/dv"
"video/fli"
"video/flv"
"video/mp2t"
"video/mp4"
"video/mp4v-es"
"video/mpeg-system"
"video/mpeg"
"video/msvideo"
"video/ogg"
"video/quicktime"
"video/vnd.mpegurl"
"video/vnd.rn-realvideo"
"video/webm"
"video/x-avi"
"video/x-flc"
"video/x-fli"
"video/x-flv"
"video/x-m4v"
"video/x-matroska"
"video/x-mpeg-system"
"video/x-mpeg"
"video/x-mpeg2"
"video/x-ms-asf"
"video/x-ms-wm"
"video/x-ms-wmv"
"video/x-ms-wmx"
"video/x-msvideo"
"video/x-nsv"
"video/x-ogm+ogg"
"video/x-theora"
"video/x-theora+ogg"
"x-content/video-dvd"
];
}