refactor(init): Refactor package installation process
Refactors package installation to be slightly more sane, for example package-refresh-contents will only be called if packages are missing. Removes some other old cruft, too, and paves way for a slightly different initialisation process.
This commit is contained in:
parent
5fcabc204a
commit
99d9981dd9
2 changed files with 50 additions and 44 deletions
88
init.el
88
init.el
|
@ -1,18 +1,18 @@
|
||||||
;; Configure package manager
|
;;; 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 'package)
|
||||||
(package-initialize)
|
(require 'seq)
|
||||||
|
|
||||||
;; Add Marmalade repo
|
;; 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 '("marmalade" . "https://marmalade-repo.org/packages/"))
|
||||||
|
|
||||||
;; ... and melpa. Melpa packages that exist on marmalade will have
|
|
||||||
;; precendence.
|
|
||||||
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
|
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
|
||||||
|
|
||||||
;; And load things!
|
;; This variable controls all packages that should be installed.
|
||||||
(package-refresh-contents)
|
(setq-local desired-packages
|
||||||
|
|
||||||
(defvar my-pkgs
|
|
||||||
'(;; elisp libraries
|
'(;; elisp libraries
|
||||||
dash
|
dash
|
||||||
dash-functional
|
dash-functional
|
||||||
|
@ -57,49 +57,49 @@
|
||||||
undo-tree
|
undo-tree
|
||||||
uuidgen
|
uuidgen
|
||||||
yaml-mode
|
yaml-mode
|
||||||
)
|
))
|
||||||
"A list of packages to install at launch.")
|
|
||||||
|
|
||||||
(dolist (p my-pkgs)
|
(defun installable-packages (pkg-list)
|
||||||
(when (not (package-installed-p p))
|
"Filter out not-yet installed packages from package list."
|
||||||
(package-install p)))
|
(seq-filter (lambda (p) (not (package-installed-p p))) pkg-list))
|
||||||
|
|
||||||
;; Are we on a mac?
|
(defun install-needed-packages (pkg-list)
|
||||||
(setq is-mac (equal system-type 'darwin))
|
(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."))))
|
||||||
|
|
||||||
;; Or on Linux?
|
;; Run package installation!
|
||||||
(setq is-linux (equal system-type 'gnu/linux))
|
(install-needed-packages desired-packages)
|
||||||
|
|
||||||
;; What's the home folder?
|
|
||||||
(defvar home-dir)
|
|
||||||
(setq home-dir (expand-file-name "~"))
|
|
||||||
|
|
||||||
(add-to-list 'load-path (concat user-emacs-directory "init"))
|
|
||||||
|
|
||||||
(mapc 'require '(functions
|
|
||||||
settings
|
|
||||||
modes
|
|
||||||
bindings
|
|
||||||
eshell-setup
|
|
||||||
haskell-setup
|
|
||||||
rust-setup
|
|
||||||
))
|
|
||||||
|
|
||||||
(add-to-list 'load-path (concat user-emacs-directory "scripts"))
|
|
||||||
|
|
||||||
|
;; Configure a few basics before moving on to package-specific initialisation.
|
||||||
(setq custom-file (concat user-emacs-directory "init/custom.el"))
|
(setq custom-file (concat user-emacs-directory "init/custom.el"))
|
||||||
(load custom-file)
|
(load custom-file)
|
||||||
|
|
||||||
;; Local configuration
|
(defvar home-dir)
|
||||||
(load-file-if-exists "~/.emacs.d/init/local.el")
|
(setq home-dir (expand-file-name "~"))
|
||||||
|
|
||||||
;; Load magnars' string manipulation library
|
|
||||||
(require 's)
|
|
||||||
|
|
||||||
;; Seed RNG
|
;; Seed RNG
|
||||||
(random t)
|
(random t)
|
||||||
|
|
||||||
(put 'upcase-region 'disabled nil)
|
;; Add 'init' folder that contains other settings to load.
|
||||||
|
(add-to-list 'load-path (concat user-emacs-directory "init"))
|
||||||
|
|
||||||
;; Configure smart mode line
|
;; Load configuration that makes use of installed packages:
|
||||||
(sml/setup)
|
|
||||||
|
|
||||||
|
;; Emacs will automatically initialise all installed packages.
|
||||||
|
;; After initialisation, proceed to load configuration that requires packages:
|
||||||
|
(defun load-other-settings ()
|
||||||
|
(mapc 'require '(theme
|
||||||
|
functions
|
||||||
|
settings
|
||||||
|
modes
|
||||||
|
bindings
|
||||||
|
eshell-setup
|
||||||
|
haskell-setup
|
||||||
|
rust-setup
|
||||||
|
)))
|
||||||
|
|
||||||
|
(add-hook 'after-init-hook 'load-other-settings)
|
||||||
|
|
6
init/theme.el
Normal file
6
init/theme.el
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
;;; theme.el --- Editor theming. -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Configure smart mode line
|
||||||
|
(sml/setup)
|
||||||
|
|
||||||
|
(provide 'theme)
|
Loading…
Reference in a new issue