.emacs.d/init.d/basics/package-management.el

74 lines
2.7 KiB
EmacsLisp
Raw Normal View History

;;; package-management.el --- Initialize package management -*- lexical-binding: t; -*-
2019-10-14 17:38:14 +02:00
2020-03-31 16:26:32 +02:00
;; Time-stamp: <2020-03-30T00:21:50+0200>
2019-10-14 17:38:14 +02:00
;;; Commentary:
;; * Set up straight
;; * Set up use-package.
2019-10-14 17:38:14 +02:00
;;; Code:
;; Workaround for < 26.3 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341>.
(when (and (< emacs-major-version 27)
(not (string= emacs-version "26.3")))
(defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
;; Define variables for straight.
(customize-set-variable
'straight-use-package-by-default t
"Makes use-package invoke straight.el to install the package.")
(customize-set-variable 'straight-cache-autoloads t
"Cache the autoloads of all packages in a single file.")
(customize-set-variable 'straight-vc-git-default-clone-depth 1
2020-03-19 00:31:21 +01:00
"Make shallow clones to save space.")
;; Remove once 353bdc04f449355d3321801592d1b53e8a9b21c3 is in master.
(customize-set-variable 'straight-repository-branch "develop")
;; Bootstrap straight.
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(require 'straight) ; Shut up flycheck.
2019-10-14 17:38:14 +02:00
(add-hook 'after-init-hook #'straight-prune-build) ; Remove unnused packages.
2019-10-14 17:38:14 +02:00
;; Isolate package configurations.
(straight-use-package 'use-package)
(defun my/straight-check-last-update ()
"Notify if 7 days have passed since the last package was built."
(let ((days 7)
(mtime-seconds (time-to-seconds
(file-attribute-modification-time
(file-attributes (straight--build-dir))))))
(when (> (- (time-to-seconds) mtime-seconds)
(* 60 60 24 days))
(message "The last package update was more than %d days ago." days))))
(add-hook 'emacs-startup-hook #'my/straight-check-last-update)
(defun my/straight-update-repos ()
"Update MELPA, ELPA and Emacsmirror."
(interactive)
(straight-pull-package 'melpa)
(straight-pull-package 'gnu-elpa-mirror)
(straight-pull-package 'emacsmirror-mirror))
;; ;; Autocompile files on load.
;; (use-package auto-compile
;; :custom (load-prefer-newer t) ; Use uncompiled file if it is newer.
;; :config (auto-compile-on-load-mode))
2019-10-14 17:38:14 +02:00
(provide 'basics/package-management)
;;; package-management.el ends here