nixos-config/modules/applications.nix

93 lines
3.0 KiB
Nix
Raw Normal View History

2021-06-11 15:52:11 +04:00
{ pkgs, config, lib, ... }: {
2020-02-17 17:00:59 +04:00
options.defaultApplications = lib.mkOption {
type = lib.types.attrs;
description = "Preferred applications";
};
config = rec {
defaultApplications = {
term = {
2020-08-04 16:11:45 +04:00
cmd = "${pkgs.alacritty}/bin/alacritty";
desktop = "alacritty";
2020-02-17 17:00:59 +04:00
};
editor = {
2021-06-11 15:52:11 +04:00
cmd =
"${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient -c $@";
2020-02-17 17:00:59 +04:00
desktop = "emacsclient";
};
browser = {
cmd = "${pkgs.firefox-wayland}/bin/firefox";
desktop = "firefox";
};
fm = {
cmd = "${pkgs.gnome3.nautilus}/bin/nautilus";
desktop = "org.gnome.Nautilus";
2020-02-17 17:00:59 +04:00
};
2021-06-07 19:22:59 +04:00
matrix = {
cmd = "${pkgs.nheko}/bin/nheko";
desktop = "nheko";
};
2020-02-17 17:00:59 +04:00
monitor = {
cmd = "${pkgs.gnome3.gnome-system-monitor}/bin/gnome-system-monitor";
desktop = "gnome-system-monitor";
2020-02-17 17:00:59 +04:00
};
archive = {
cmd = "${pkgs.gnome3.file-roller}/bin/file-roller";
desktop = "org.gnome.FileRoller";
2020-02-17 17:00:59 +04:00
};
mail = {
2020-12-26 00:46:40 +04:00
cmd = "${pkgs.gnome3.geary}/bin/geary";
desktop = "org.gnome.Geary";
2020-02-17 17:00:59 +04:00
};
text_processor = {
cmd = "${pkgs.abiword}/bin/abiword";
desktop = "abiword";
};
spreadsheet = {
cmd = "${pkgs.gnumeric}/bin/gnumeric";
desktop = "gnumeric";
};
};
2021-01-21 22:13:53 +04:00
environment.sessionVariables = {
EDITOR = config.defaultApplications.editor.cmd;
VISUAL = config.defaultApplications.editor.cmd;
};
2021-06-11 15:52:11 +04:00
home-manager.users.balsoft = {
home.activation."mimeapps-remove" = {
before = [ "checkLinkTargets" ];
after = [ ];
data = "rm -f /home/balsoft/.config/mimeapps.list";
};
xdg.mimeApps = {
enable = true;
defaultApplications = with config.defaultApplications;
builtins.mapAttrs (name: value:
if value ? desktop then [ "${value.desktop}.desktop" ] else value) {
"text/html" = browser;
"image/*" = { desktop = "org.gnome.eog"; };
"application/zip" = archive;
"application/rar" = archive;
"application/7z" = archive;
"application/*tar" = archive;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/mailto" = mail;
"x-scheme-handler/matrix" = matrix;
"application/pdf" = { desktop = "org.kde.okular"; };
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" =
text_processor;
"application/msword" = text_processor;
"application/vnd.oasis.opendocument.text" = text_processor;
"text/csv" = spreadsheet;
"application/vnd.oasis.opendocument.spreadsheet" = spreadsheet;
"text/plain" =
editor; # This actually makes Emacs an editor for everything... XDG is wierd
};
};
2020-06-21 22:48:26 +04:00
};
2020-02-17 17:00:59 +04:00
};
}