{ config, lib, pkgs, unstable-pkgs, mypkgs, ... }: with lib; let xsession-enable = config.my.xsession.enable; optional-dependencies = config.my.emacs.optional-dependencies; unstable-epkgs = unstable-pkgs.emacsPackagesNg; # Optional config (draws too much dependencies on some platforms) optional-configs = if optional-dependencies then [ { file = ./haskell-pack/haskell-pack.el; pkgs = epkgs: with epkgs; [ haskell-mode ghci-completion ]; } ] else [ ]; configs = [ { file = ./init.el; pkgs = epkgs: with epkgs; [ use-package ]; } { file = ./theme-pack/theme-pack.el; pkgs = epkgs: with epkgs; [ s deferred dash smart-mode-line spacemacs-theme mypkgs.emacs-powerline ]; } { file = ./prelude-pack/prelude-pack.el; pkgs = epkgs: with epkgs; [ crux projectile helm ]; } { file = ./mail-pack/mail-pack.el; pkgs = epkgs: with epkgs; [ creds dash s offlineimap async google-contacts notmuch ]; } { file = ./weechat-pack/weechat-pack.el; pkgs = epkgs: with epkgs; [ weechat ]; } { file = ./buffer-pack/buffer-pack.el; pkgs = epkgs: with epkgs; [ move-text dockerfile-mode projectile dash markdown-mode iedit markdown-toc yaml-mode multiple-cursors git-gutter buffer-move company ace-window iy-go-to-char s git-gutter popwin ht ]; } { file = ./git-pack/git-pack.el; pkgs = epkgs: with epkgs; [ fullframe magit magit-popup git-gutter magithub ]; } { file = ./prog-mode-pack/prog-mode-pack.el; pkgs = epkgs: with epkgs; [ crux smartscan ]; } { file = ./helm-pack/helm-pack.el; pkgs = epkgs: [ epkgs.helm ]; } { file = ./help-pack/help-pack.el; pkgs = epkgs: with epkgs; [ which-key helpful ]; } { file = ./popup-pack/popup-pack.el; pkgs = epkgs: []; } { file = ./modeline-pack/modeline-pack.el; pkgs = epkgs: with epkgs; [ dash s diminish ]; } { file = ./shell-pack/shell-pack.el; pkgs = epkgs: [ epkgs.popwin ]; } { file = ./orgmode-pack/orgmode-pack.el; pkgs = epkgs: with epkgs; [ org ac-math smartscan dash auto-complete ]; } { file = ./python-pack/python-pack.el; pkgs = epkgs: [ unstable-epkgs.elpy epkgs.smartparens ]; } { file = ./twitter-pack/twitter-pack.el; pkgs = epkgs: with epkgs; [ twittering-mode ]; } { file = ./lisp-pack/lisp-pack.el; pkgs = epkgs: with epkgs; [ eval-sexp-fu paredit fold-dwim cider ]; } { file = ./elisp-pack/elisp-pack.el; pkgs = epkgs: with epkgs; [ bug-hunter el-mock goto-last-change dash aggressive-indent overseer page-break-lines request-deferred # emr ]; } { file = ./puppet-pack/puppet-pack.el; pkgs = epkgs: with epkgs; [ puppet-mode ]; } { file = ./blog-pack/blog-pack.el; pkgs = epkgs: with epkgs; [ org2jekyll kv ]; } { file = ./wiki-pack/wiki-pack.el; pkgs = epkgs: with epkgs; [ mediawiki ox-mediawiki ]; } { file = ./irc-pack/irc-pack.el; pkgs = epkgs: with epkgs; [ dash creds ]; } { file = ./mercurial-pack/mercurial-pack.el; pkgs = epkgs: with epkgs; [ monky ]; } { file = ./conkeror-pack/conkeror-pack.el; pkgs = epkgs: with epkgs; [ conkeror-minor-mode ]; } { file = ./pres-pack/pres-pack.el; pkgs = epkgs: with epkgs; [ ox-reveal ]; } { file = ./browser-pack/browser-pack.el; pkgs = epkgs: with epkgs; [ restclient ]; } { file = ./scratch-pack/scratch-pack.el; pkgs = epkgs: with epkgs; [ htmlize google-this hydra ]; } { file = ./viewer-pack/viewer-pack.el; pkgs = epkgs: [ ]; } { file = ./marmalade-pack/marmalade-pack.el; pkgs = epkgs: with epkgs; [ marmalade-client ]; } { file = ./nix-pack/nix-pack.el; pkgs = epkgs: with epkgs; [ nix-mode smartscan ]; } { file = ./macro-pack/macro-pack.el; pkgs = epkgs: [ ]; } { file = ./devops-pack/devops-pack.el; pkgs = epkgs: with epkgs; [ terraform-mode ]; } { file = ./nounou/employeur.el; pkgs = epkgs: [ ]; } ] ++ optional-configs; # raw file content raw_configs = [ { pkgs = epkgs: with epkgs; [ rust-mode ]; raw = with pkgs; '' (require 'rust-mode) (add-hook 'rust-mode-hook (lambda () (setq indent-tabs-mode nil))) (define-key rust-mode-map (kbd "C-c C-c") 'rust-run) (custom-set-variables '(rust-rustfmt-bin "${rustfmt}/bin/rustfmt") '(rust-cargo-bin "${cargo}/bin/cargo") '(rust-format-on-save t)) (provide 'rust-pack) ''; } ]; # system packages emacs' config depends upon # On some platform, compiling those are too heavy optional-runtime-dependencies = if optional-dependencies then [ pkgs.shellcheck ] else [ ]; extra-runtime-packages = with pkgs; [ ag aspell notmuch cask git arcanist python3Packages.tox ] ++ optional-runtime-dependencies; cfg = config.my.emacs; in { options.my.emacs = { optional-dependencies = mkEnableOption "Install emacs with optional dependencies"; }; config = { programs.emacs = with pkgs; { enable = true; # emacs no x if no x session package = if xsession-enable then emacs26 else emacs26-nox; # nevertheless, install the deps extraPackages = epkgs: concatMap (config: config.pkgs epkgs) configs ++ concatMap (config: config.pkgs epkgs) raw_configs ++ extra-runtime-packages; }; services.emacs.enable = true; # Inline the packs into the init.el home.file.".emacs.d/init.el" = { text = ( foldl ( soFar: config: soFar + readFile config.file + "\n" ) "" configs ) + ( foldl ( soFar: config: soFar + config.raw + "\n" ) "" raw_configs ) + ( readFile ./end.el ); }; }; }