Start moving emacs configuration to nix.

This commit is contained in:
Kevin Baensch 2019-11-11 18:41:30 +01:00
parent 0d9fa5b37e
commit 986ca7f5cd
11 changed files with 841 additions and 67 deletions

View file

@ -0,0 +1,19 @@
{ config, ... }:
mkIf (elem "emacs-company" config.machine.pkgs) {
programs.emacs.init.usePackage.company = {
enable = true;
diminish = [ "company-mode" ];
hook = [ "(after-init . global-company-mode)" ];
bind = { "\t" = "'company-complete-common"; };
config = ''
(setq company-idle-delay 0.3
company-show-numbers t)
'';
extraConfig = ''
:bind (:map company-mode-map
([remap completion-at-point] . company-complete-common)
([remap complete-symbol] . company-complete-common))
'';
};
}

View file

@ -0,0 +1,28 @@
{ config, ... }:
mkIf (elem "emacs-flyspell" config.machine.pkgs) {
programs.emacs.init.usePackage.flyspell = {
enable = true;
diminish = [ "flyspell-mode" ];
command = [ "flyspell-mode" "flyspell-prog-mode" ];
hook = [];
bind = {
"C-M-<tab>" = "flyspell-switch-dictionary";
"C-c f" = "ispell-word";
};
config = ''
;; Make flyspell less verbose and disable annoying keybind
(setq flyspell-issue-message-flag nil
flyspell-issue-welcome-flag nil
flyspell-use-meta-tab nil)
(defun flyspell-switch-dictionary ()
(interactive)
(let* ((dic ispell-current-dictionary)
(change (if (string= dic "deutsch8") "english" "deutsch8")))
(ispell-change-dictionary change)
(message "Dictionary switched to %s" change)
))
'';
};
}

100
pkgs/pkgsets/emacs/mu4e.nix Normal file
View file

@ -0,0 +1,100 @@
{ config, lib, pkgs, ... }:
with lib;
mkIf (elem "emacs-mu4e" config.machine.pkgs) {
programs.emacs.init.usePackage.mu4e = {
enable = true;
package = epkgs: null;
command = [ "mu4e" ];
diminish = [ "mu4e-mode" ];
hook = [
"('mu4e-view-mode-hook #'visual-line-mode)"
"('mu4e-compose-mode-hook 'flyspell-mode)"
];
bind = { "\t" = "'company-complete-common"; };
config = ''
(setq mail-user-agent 'mu4e-user-agent)
(setq org-mu4e-link-query-in-headers-mode t)
(setq mu4e-maildir "~/.mail/Mail")
(setq mu4e-get-mail-command "${pkgs.isync}/bin/mbsync -a")
(setq mu4e-context-policy 'pick-first)
(setq mu4e-change-filenames-when-moving t)
(setq starttls-use-gnutls t)
(setq message-send-mail-function 'smtpmail-send-it)
(setq mu4e-update-interval 300)
(setq mu4e-use-fancy-chars t)
(setq mu4e-view-show-addresses t)
(setq mu4e-headers-show-threads t)
(setq mu4e-headers-skip-duplicates t)
(setq mail-user-agent 'mu4e-user-agent)
(defvaralias 'mu4e-compose-signature 'message-signature)
(setq-default mu4e-save-multiple-attachments-without-asking t)
(setq-default mu4e-view-show-addresses t)
(setq-default mu4e-confirm-quit nil)
(setq-default mu4e-hide-index-messages t)
(setq-default mu4e-index-update-in-background t)
(setq mu4e-compose-in-new-frame nil)
;;rename files when moving
;;NEEDED FOR MBSYNC
(setq mu4e-change-filenames-when-moving t)
(setq mu4e-html2text-command "iconv -c -t utf-8 | ${pkgs.pandoc}/bin/pandoc -f html -t plain")
(setq mu4e-view-show-images t)
(when (fboundp 'imagemagick-register-types)
(imagemagick-register-types))
(setq message-kill-buffer-on-exit t)
(setq mu4e-contexts
`(${map
(rec { name, fullName, address, sServer, sPort, sUser ? address }: ''
,(make-mu4e-context
:name ${name}
:vars '((user-mail-address . ${address} )
(user-full-name . ${fullName} )
(mu4e-sent-folder . "/Sent")
(mu4e-drafts-folder . "/Drafts")
(mu4e-trash-folder . "/Deleted")
(mu4e-refile-folder . "/Archiv")
(smtpmail-smtp-user . ${sUser} )
(smtpmail-auth-credentials . (expand-file-name "~/mail/secret/.authinfo.gpg"))
(smtpmail-default-smtp-server . ${sServer} )
(smtpmail-smtp-server . ${sServer} )
(smtpmail-stream-type . starttls)
(smtpmail-smtp-service . ${sPort} )
)
)
'';
)
(import "${config.machine.secretPath}/secrets.nix").mu4e}
))
(defun my-browse-url-firefox-privately (url &optional new-window)
"Make firefox open URL in private-browsing window."
(interactive (browse-url-interactive-arg "URL: "))
(let ((process-environment (browse-url-process-environment)))
(apply 'start-process
(concat "firefox " url)
nil
browse-url-firefox-program
(list "-private-window" url))))
(setq browse-url-browser-function 'my-browse-url-firefox-privately)
(add-to-list 'mu4e-view-actions
'("ViewInBrowser" . mu4e-action-view-in-browser) t)
'';
extraConfig = ''
:load-path ${pkgs.mu4e}/share/emacs/site-lisp/mu4e
'';
};
programs.emacs.init.usePackage.mu4e-alert = {
enable = true;
hook = [ "'after-init-hook" = "#'mu4e-alert-enable-mode-line-display" ];
};
environment.systemPackages = [
mu4e
isync
];
}

View file

@ -0,0 +1,14 @@
{ config, ... }:
mkIf (elem "emacs-poerline" config.machine.pkgs) {
programs.emacs.init.usePackage.solarized-theme = {
enable = true;
config = ''
;; color palette from https://github.com/kuanyui/moe-theme.el/blob/master/moe-theme.el#L283
(set-face-attribute 'mode-line nil :background "#afd7ff" :foreground "#005f87")
(set-face-attribute 'mode-line-buffer-id nil :background "#afd7ff" :foreground "#080808")
(set-face-attribute 'minibuffer-prompt nil :foreground "#5fafd7" :background "#3a3a3a")
(powerline-default-theme)
'';
};
}

View file

@ -0,0 +1,8 @@
{ config, ... }:
mkIf (elem "emacs-solarized-theme" config.machine.pkgs) {
programs.emacs.init.usePackage.solarized-theme = {
enable = true;
config = "(load-theme 'solarized-dark t)";
};
}