about summary refs log tree commit diff
path: root/init.el
blob: 345e43859ca1720454d9acf36c55100c880d4a21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;;; init.el --- Package bootstrapping. -*- lexical-binding: t; -*-

;; This file bootstraps the Emacs setup by going through package installations.
;; After all packages are installed, local configuration is loaded.

(require 'package)
(require 'seq)

;; Configure Marmalade and MELPA repositories. Packages available on Marmalade
;; will have precedence.
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)

;; This variable controls all packages that should be installed.
(defvar desired-packages
  '(;; elisp libraries
    dash
    dash-functional
    ht
    s

    ;; editor packages
    ace-jump-mode
    ace-window
    browse-kill-ring
    cargo
    company
    dockerfile-mode
    erlang
    exwm
    flycheck
    geiser
    go-mode
    gruber-darker-theme
    haskell-mode
    helm
    helm-exwm
    helm-pass
    hi2
    idle-highlight-mode
    magit
    markdown-mode+
    multi-term
    multiple-cursors
    nix-mode
    paredit
    password-store
    pg
    puppet-mode
    racer
    racket-mode
    rainbow-delimiters
    rainbow-mode
    restclient
    rust-mode
    smart-mode-line
    string-edit
    slime
    switch-window
    terraform-mode
    undo-tree
    uuidgen
    yaml-mode
    which-key
    ))

(defun installable-packages (pkg-list)
  "Filter out not-yet installed packages from package list."
  (seq-filter (lambda (p) (not (package-installed-p p))) pkg-list))

(defun install-needed-packages (pkg-list)
  (let ((to-install (installable-packages pkg-list)))
    (if (< 0 (length to-install))
        (progn (package-refresh-contents)
               (mapcar #'package-install to-install))
      (message "No new packages to install."))))

;; Run package installation!
(install-needed-packages desired-packages)

;; Configure a few basics before moving on to package-specific initialisation.
(setq custom-file (concat user-emacs-directory "init/custom.el"))
(load custom-file)

(defvar home-dir)
(setq home-dir (expand-file-name "~"))

;; Seed RNG
(random t)

;; Add 'init' folder that contains other settings to load.
(add-to-list 'load-path (concat user-emacs-directory "init"))

;; Load configuration that makes use of installed packages:

;; Emacs will automatically initialise all installed packages.
;; After initialisation, proceed to load configuration that requires packages:
(defun load-other-settings ()
  (mapc 'require '(nixos
                   look-and-feel
                   functions
                   settings
                   modes
                   bindings
                   eshell-setup
                   haskell-setup
                   rust-setup
                   )))

(add-hook 'after-init-hook 'load-other-settings)