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

@ -21,6 +21,7 @@ with lib;
"base" "base"
"dict" "dict"
"emacs" "emacs"
"emacs::solarized-theme"
"extra" "extra"
"cpp" "cpp"
"haskell" "haskell"

View file

@ -0,0 +1,79 @@
# Original Source:
# https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init-defaults.nix (49ff2d63e867c09e658c959c0d8a73d641061c30)
# MIT License
# Copyright (c) 2019 Robert Helgesson
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
{ pkgs, ... }:
{
programs.emacs.init.usePackage = {
deadgrep = {
config = ''
(setq deadgrep-executable "${pkgs.ripgrep}/bin/rg")
'';
};
ggtags = {
config = ''
(setq ggtags-executable-directory "${pkgs.global}/bin")
'';
};
idris-mode = {
config = ''
(setq idris-interpreter-path "${pkgs.idris}/bin/idris")
'';
};
lsp-rust = {
config = ''
(setq lsp-rust-rls-server-command "${pkgs.rls}/bin/rls")
'';
};
ob-plantuml = {
config = ''
(setq org-plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar")
'';
};
pandoc-mode = {
config = ''
(setq pandoc-binary "${pkgs.pandoc}/bin/pandoc")
'';
};
plantuml-mode = {
config = ''
(setq plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar")
'';
};
ripgrep = {
config = ''
(setq ripgrep-executable "${pkgs.ripgrep}/bin/rg")
'';
};
};
}

421
options/emacs-init.nix Normal file
View file

@ -0,0 +1,421 @@
# Original Source:
# https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init.nix (b83922825b19de97786c38885e99abb613214e11)
# MIT License
# Copyright (c) 2019 Robert Helgesson
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.emacs.init;
emacsPackageType =
types.coercedTo
types.str
(pkgName: epkgs: [ epkgs.${pkgName} ])
(types.nullOr types.unspecified);
usePackageType = types.submodule ({ name, config, ... }: {
options = {
enable = mkEnableOption "Emacs package ${name}";
package = mkOption {
type = emacsPackageType;
default = name;
description = ''
The package to use for this module. Either the package name
within the Emacs package set or a function taking the Emacs
package set and returning a package.
'';
};
defer = mkOption {
type = types.either types.bool types.ints.positive;
default = false;
description = ''
The <option>:defer</option> setting.
'';
};
demand = mkOption {
type = types.bool;
default = false;
description = ''
The <option>:demand</option> setting.
'';
};
diminish = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The entries to use for <option>:diminish</option>.
'';
};
mode = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The entries to use for <option>:mode</option>.
'';
};
after = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The entries to use for <option>:after</option>.
'';
};
bind = mkOption {
type = types.attrsOf types.str;
default = {};
example = { "M-<up>" = "drag-stuff-up"; "M-<down>" = "drag-stuff-down"; };
description = ''
The entries to use for <option>:bind</option>.
'';
};
bindLocal = mkOption {
type = types.attrsOf (types.attrsOf types.str);
default = {};
example = { helm-command-map = { "C-c h" = "helm-execute-persistent-action"; }; };
description = ''
The entries to use for local keymaps in <option>:bind</option>.
'';
};
bindKeyMap = mkOption {
type = types.attrsOf types.str;
default = {};
example = { "C-c p" = "projectile-command-map"; };
description = ''
The entries to use for <option>:bind-keymap</option>.
'';
};
command = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The entries to use for <option>:commands</option>.
'';
};
config = mkOption {
type = types.lines;
default = "";
description = ''
Code to place in the <option>:config</option> section.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Additional lines to place in the use-package configuration.
'';
};
hook = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The entries to use for <option>:hook</option>.
'';
};
init = mkOption {
type = types.lines;
default = "";
description = ''
The entries to use for <option>:init</option>.
'';
};
assembly = mkOption {
type = types.lines;
readOnly = true;
internal = true;
description = "The final use-package code.";
};
};
config = mkIf config.enable {
assembly =
let
quoted = v: ''"${escape ["\""] v}"'';
mkBindHelper = cmd: prefix: bs:
optionals (bs != {}) (
[ ":${cmd} (${prefix}" ]
++ mapAttrsToList (n: v: " (${quoted n} . ${v})") bs
++ [ ")" ]
);
mkAfter = vs: optional (vs != []) ":after (${toString vs})";
mkCommand = vs: optional (vs != []) ":commands (${toString vs})";
mkDiminish = vs: optional (vs != []) ":diminish (${toString vs})";
mkMode = map (v: ":mode ${v}");
mkBind = mkBindHelper "bind" "";
mkBindLocal = bs:
let
mkMap = n: v: mkBindHelper "bind" ":map ${n}" v;
in
flatten (mapAttrsToList mkMap bs);
mkBindKeyMap = mkBindHelper "bind-keymap" "";
mkHook = map (v: ":hook ${v}");
mkDefer = v:
if isBool v then optional v ":defer t"
else [ ":defer ${toString v}" ];
mkDemand = v: optional v ":demand t";
in
concatStringsSep "\n " (
[ "(use-package ${name}" ]
++ mkAfter config.after
++ mkBind config.bind
++ mkBindKeyMap config.bindKeyMap
++ mkBindLocal config.bindLocal
++ mkCommand config.command
++ mkDefer config.defer
++ mkDemand config.demand
++ mkDiminish config.diminish
++ mkHook config.hook
++ mkMode config.mode
++ optionals (config.init != "") [ ":init" config.init ]
++ optionals (config.config != "") [ ":config" config.config ]
++ optional (config.extraConfig != "") config.extraConfig
) + ")";
};
});
usePackageStr = name: pkgConfStr: ''
(use-package ${name}
${pkgConfStr})
'';
mkRecommendedOption = type: extraDescription: mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Whether to enable recommended ${type} settings.
'' + optionalString (extraDescription != "") ''
</para><para>
${extraDescription}
'';
};
# Recommended GC settings.
gcSettings = ''
(defun hm/reduce-gc ()
"Reduce the frequency of garbage collection."
(setq gc-cons-threshold 402653184
gc-cons-percentage 0.6))
(defun hm/restore-gc ()
"Restore the frequency of garbage collection."
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1))
;; Make GC more rare during init and while minibuffer is active.
(eval-and-compile #'hm/reduce-gc)
(add-hook 'minibuffer-setup-hook #'hm/reduce-gc)
;; But make it more regular after startup and after closing minibuffer.
(add-hook 'emacs-startup-hook #'hm/restore-gc)
(add-hook 'minibuffer-exit-hook #'hm/restore-gc)
;; Avoid unnecessary regexp matching while loading .el files.
(defvar hm/file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(defun hm/restore-file-name-handler-alist ()
"Restores the file-name-handler-alist variable."
(setq file-name-handler-alist hm/file-name-handler-alist)
(makunbound 'hm/file-name-handler-alist))
(add-hook 'emacs-startup-hook #'hm/restore-file-name-handler-alist)
'';
# Whether the configuration makes use of `:diminish`.
hasDiminish = any (p: p.diminish != []) (attrValues cfg.usePackage);
# Whether the configuration makes use of `:bind`.
hasBind = any (p: p.bind != {}) (attrValues cfg.usePackage);
usePackageSetup =
''
(eval-when-compile
(require 'package)
(setq package-archives nil
package-enable-at-startup nil
package--init-file-ensured t)
(require 'use-package)
;; To help fixing issues during startup.
(setq use-package-verbose ${
if cfg.usePackageVerbose then "t" else "nil"
}))
''
+ optionalString hasDiminish ''
;; For :diminish in (use-package).
(require 'diminish)
''
+ optionalString hasBind ''
;; For :bind in (use-package).
(require 'bind-key)
'';
initFile = ''
;;; hm-init.el --- Emacs configuration à la Home Manager.
;;
;; -*- lexical-binding: t; -*-
;;
;;; Commentary:
;;
;; A configuration generated from a Nix based configuration by
;; Home Manager.
;;
;;; Code:
${optionalString cfg.startupTimer ''
;; Remember when configuration started. See bottom for rest of this.
;; Idea taken from http://writequit.org/org/settings.html.
(defconst emacs-start-time (current-time))
''}
${optionalString cfg.recommendedGcSettings gcSettings}
${cfg.prelude}
${usePackageSetup}
''
+ concatStringsSep "\n\n"
(map (getAttr "assembly")
(filter (getAttr "enable")
(attrValues cfg.usePackage)))
+ ''
${cfg.postlude}
${optionalString cfg.startupTimer ''
;; Make a note of how long the configuration part of the start took.
(let ((elapsed (float-time (time-subtract (current-time)
emacs-start-time))))
(message "Loading settings...done (%.3fs)" elapsed))
''}
(provide 'hm-init)
;; hm-init.el ends here
'';
in
{
imports = [ ./emacs-init-defaults.nix ];
options.programs.emacs.init = {
enable = mkEnableOption "Emacs configuration";
recommendedGcSettings = mkRecommendedOption "garbage collection" ''
This will reduce garbage collection frequency during startup and
while the minibuffer is active.
'';
startupTimer = mkEnableOption "Emacs startup duration timer";
prelude = mkOption {
type = types.lines;
default = "";
description = ''
Configuration lines to add in the beginning of
<filename>init.el</filename>.
'';
};
postlude = mkOption {
type = types.lines;
default = "";
description = ''
Configuration lines to add in the end of
<filename>init.el</filename>.
'';
};
usePackageVerbose = mkEnableOption "verbose use-package mode";
usePackage = mkOption {
type = types.attrsOf usePackageType;
default = {};
example = literalExample ''
{
dhall-mode = {
mode = [ '''"\\.dhall\\'"''' ];
};
}
'';
description = ''
Attribute set of use-package configurations.
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = let
finalPackage = (pkgs.emacsWithPackages (epkgs:
let
getPkg = v:
if isFunction v then [ (v epkgs) ]
else optional (isString v && hasAttr v epkgs) epkgs.${v};
in
[ epkgs.use-package ]
++ optional hasBind epkgs.bind-key
++ optional hasBind epkgs.diminish
++ (
concatMap (v: getPkg (v.package))
(builtins.attrValues cfg.usePackage)
)));
in [
((pkgs.emacsPackagesNgGen finalPackage).trivialBuild {
pname = "hm-init";
version = "0";
src = pkgs.writeText "hm-init.el" initFile;
preferLocalBuild = true;
allowSubstitutes = false;
})
];
environment.etc."emacs.d/init.el".text = ''
(require 'hm-init)
(provide 'init)
'';
};
}

View file

@ -5,9 +5,10 @@ with lib;
let let
cfg = config.machine; cfg = config.machine;
metapkgs = (lists.forEach fn = import (toString ../fn.nix) { inherit lib; };
(attrNames (filterAttrs (n: v: v == "regular" ) (readDir ../pkgs/pkgsets))) metapkgs = let
(v: replaceStrings [ ".nix" ] [ "" ] v)); pPath = (toString ./../pkgs/pkgsets);
in (lists.forEach (fn.lsfRec pPath true) (v: replaceStrings [ "${pPath}/" "/" ".nix" ] [ "" "::" "" ] v));
pkgOption = pname: { pkgOption = pname: {
name = pname; name = pname;
value = rec { value = rec {

View file

@ -1,62 +1,165 @@
{ config, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
gitpkgs = import /nixpkgs {}; gitpkgs = import /nixpkgs {};
in { modefiles = lists.forEach
config.machine.pkgsets.emacs.pkgwrap = [ (gitpkgs.emacsWithPackages (epkgs: with epkgs; config.machine.pkgsets.emacs.pkgs)) ]; (attrNames
config.machine.pkgsets.emacs.pkgs = with pkgs; with pkgs.emacsPackages; [ (filterAttrs (n: v: v == "regular")
/* Theming */ (builtins.readDir ./emacs)))
solarized-theme color-theme-sanityinc-tomorrow moe-theme powerline moody minions (v: "./emacs/${v}");
/*General Stuff */ in rec {
rainbow-delimiters # color parenthesis by indentation nixpkgs.overlays = [
color-identifiers-mode (import (builtins.fetchTarball {
/* Python */ url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
company-jedi pylint elpy flycheck-mypy }))
/* Git support */
magit
emms # multimedia support
wsd-mode
plantuml-mode
/* Other Stuff, not yet sorted */
mu4e-alert
google-translate
tramp
transmission
org-plus-contrib orgit ox-gfm ox-rst
easy-jekyll markdown-mode impatient-mode simple-httpd htmlize
eclim
auto-complete
pkgs.aspell pkgs.aspellDicts.en pkgs.aspellDicts.de
use-package diminish bind-key
smartparens
evil-surround evil-indent-textobject evil-cleverparens avy undo-tree
cdlatex # for math expressions
helm
/* LaTeX */ auctex helm-bibtex cdlatex
markdown-mode
flycheck
pkgs.ledger
yaml-mode
company
# Irony is currently broken.
/* C/C++ */ irony company-irony company-irony-c-headers flycheck-irony clang-format pkgs.clang-tools
/* Haskell */ haskell-mode flycheck-haskell
/* Org */ org org-ref pdf-tools org-bullets org-caldav
/* Rust */ rust-mode flycheck-rust racer
/* mail */ messages-are-flowing
/* Nix */ nix-buffer nix-mode nixos-options company-nixos-options nix-sandbox
paganini-theme
json-navigator
spaceline # modeline beautification
winum eyebrowse # window management
auto-compile
/* Maxima */ pkgs.maxima
visual-fill-column
web-mode
melpaStablePackages.idris-mode helm-idris
/* Java */
# projectile yasnippet lsp-mode hydra company-lsp lsp-ui lsp-java dap-mode
cl-lib meghanada autodisass-java-bytecode google-c-style realgud
weechat
]; ];
imports = [
../../options/emacs-init.nix
# modefiles
];
programs.emacs.init = {
enable = true;
recommendedGcSettings = true;
prelude = ''
;; Disable UI Clutter
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1)
(blink-cursor-mode -1)
(setq ring-bell-function 'ignore)
(setq inhibit-startup-buffer-menu t)
(setq use-dialog-box nil)
(setq inhibit-startup-message t)
(setq inhibit-splash-screen t)
(setq initial-scratch-message nil)
(fset 'yes-or-no-p 'y-or-n-p)
(setq-default show-trailing-whitespace t)
;; Save and Backup behaviour
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq create-lockfiles nil)
(setq backup-directory-alist `(("." . "~/.emacs_saves")))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;; Tabs vs Spaces... I like Spaces
(setq-default indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
;; General Functions I want
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;; Global UI related Modes
(global-display-line-numbers-mode)
(setq display-line-numbers-width-start t)
(setq display-line-numbers-grow-only t)
(column-number-mode t)
(global-hl-line-mode t)
(size-indication-mode t)
(show-paren-mode t)
;; Font Config
(defun set-fonts (frame)
(interactive)
"Adjust the font settings of FRAME so Emacs can display emoji and chinese properly."
(set-fontset-font t 'ascii (font-spec :family "DejaVu Sans Mono") frame 'preprend)
(set-fontset-font t 'big5 (font-spec :family "AR PL UMing TW") frame)
(set-fontset-font t 'chinese-gbk (font-spec :family "AR PL UMing CN") frame)
(set-fontset-font t 'symbol (font-spec :family "Symbola") frame 'prepend))
;; For when Emacs is started in GUI mode:
(set-fonts nil)
;; Hook for when a frame is created with emacsclient
;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Frames.html
(add-hook 'after-make-frame-functions 'set-fonts)
'';
};
# machine.pkgsets.emacs.pkgwrap = [(gitpkgs.pkgs.emacsWithPackages (ps: with ps; config.machine.pkgsets.emacs.pkgs))];
#[
# (pkgs.emacsWithPackagesFromUsePackage {
# # config = (concatStringsSep "\n" machine.pkgsets.emacs.config);
# config = ''
# # (package-initialize)
# # (org-babel-load-file "~/.emacs.d/configuration.org")
# '';
# package = pkgs.emacsGit;
# extraEmacsPackages = (ep: with ep; config.machine.pkgsets.emacs.pkgs);
# })
# ];
# machine.pkgsets.emacs.pkgs = with pkgs; with pkgs.emacsPackages; [
# /* Theming */
# solarized-theme color-theme-sanityinc-tomorrow moe-theme powerline moody minions
# /*General Stuff */
# rainbow-delimiters # color parenthesis by indentation
# color-identifiers-mode
# /* Python */
# company-jedi pylint elpy flycheck-mypy
# /* Git support */
# magit
# emms # multimedia support
# wsd-mode
# plantuml-mode
# /* Other Stuff, not yet sorted */
# mu4e-alert
# google-translate
# tramp
# transmission
# org-plus-contrib orgit ox-gfm ox-rst
# easy-jekyll markdown-mode impatient-mode simple-httpd htmlize
# eclim
# auto-complete
# pkgs.aspell pkgs.aspellDicts.en pkgs.aspellDicts.de
# use-package diminish bind-key
# smartparens
# evil-surround evil-indent-textobject evil-cleverparens avy undo-tree
# cdlatex # for math expressions
# helm
# /* LaTeX */ auctex helm-bibtex cdlatex
# markdown-mode
# flycheck
# pkgs.ledger
# yaml-mode
# company
# # Irony is currently broken.
# /* C/C++ */ irony company-irony company-irony-c-headers flycheck-irony clang-format pkgs.clang-tools
# /* Haskell */ haskell-mode flycheck-haskell
# /* Org */ org org-ref pdf-tools org-bullets org-caldav
# /* Rust */ rust-mode flycheck-rust racer
# /* mail */ messages-are-flowing
# /* Nix */ nix-buffer nix-mode nixos-options company-nixos-options nix-sandbox
# paganini-theme
# json-navigator
# spaceline # modeline beautification
# winum eyebrowse # window management
# auto-compile
# /* Maxima */ pkgs.maxima
# visual-fill-column
# web-mode
# melpaStablePackages.idris-mode helm-idris
# /* Java */
# # projectile yasnippet lsp-mode hydra company-lsp lsp-ui lsp-java dap-mode
# cl-lib meghanada autodisass-java-bytecode google-c-style realgud
# weechat
# ];
} }

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)";
};
}

View file

@ -5,7 +5,7 @@ with lib;
let let
cfg = config.machine; cfg = config.machine;
pkgsets = (lists.forEach pkgsets = (lists.forEach
(attrNames (filterAttrs (n: v: v == "regular") (builtins.readDir ./pkgsets))) (attrNames (filterAttrs (n: v: v == "regular") (builtins.readDir (toString ./pkgsets))))
(v: (./. + "/pkgsets/${v}"))); (v: (./. + "/pkgsets/${v}")));
in { in {
imports = pkgsets; imports = pkgsets;
@ -14,10 +14,10 @@ in {
(attrVals cfg.pkgs cfg.pkgsets) (attrVals cfg.pkgs cfg.pkgsets)
(v: v.pkgwrap)); (v: v.pkgwrap));
services.emacs = mkIf (elem "emacs" cfg.pkgs) { # services.emacs = mkIf (elem "emacs" cfg.pkgs) {
defaultEditor = true; # defaultEditor = true;
enable = true; # enable = true;
install = true; # install = true;
package = (elemAt cfg.pkgsets.emacs.pkgwrap 0); # package = (elemAt cfg.pkgsets.emacs.pkgwrap 0);
}; # };
} }