2019-10-14 17:38:14 +02:00
|
|
|
;;; package-management.el --- Initialize package management. -*- lexical-binding: t; -*-
|
|
|
|
|
2020-02-26 23:08:02 +01:00
|
|
|
;; Time-stamp: <2020-02-26T23:05:38+0100>
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; * Sets up package sources and their priorities.
|
|
|
|
;; * Sets up use-package.
|
|
|
|
;; * Compile elisp files.
|
|
|
|
;; * Update packages.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-02-26 23:08:02 +01:00
|
|
|
(require 'basics/global-variables)
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
(require 'package)
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("melpa" . "https://melpa.org/packages/") t)
|
|
|
|
(setq package-archive-priorities '(
|
|
|
|
("melpa-stable" . 30)
|
|
|
|
("gnu" . 20)
|
|
|
|
("melpa" . 10)
|
|
|
|
))
|
|
|
|
|
|
|
|
;; Workaround for 26.2 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341>.
|
|
|
|
(defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
|
|
|
|
|
2019-12-26 07:06:00 +01:00
|
|
|
(when (< emacs-major-version 27)
|
|
|
|
(package-initialize))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;; Add path for custom packages.
|
2020-02-26 23:08:24 +01:00
|
|
|
(add-to-list 'load-path (concat user-emacs-directory "custom-packages/"))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;; Install use-package if necessary.
|
|
|
|
(unless (package-installed-p 'use-package)
|
|
|
|
(package-refresh-contents)
|
|
|
|
(package-install 'use-package))
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
(require 'use-package))
|
|
|
|
|
|
|
|
;; Always install packages if they are not present.
|
2019-12-26 07:06:00 +01:00
|
|
|
(use-package use-package-ensure
|
|
|
|
:ensure nil
|
2019-10-14 17:38:14 +02:00
|
|
|
|
2019-12-26 07:06:00 +01:00
|
|
|
:custom
|
|
|
|
(use-package-always-ensure t)
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Autocompile files as needed.
|
2019-10-14 17:38:14 +02:00
|
|
|
(use-package auto-compile
|
|
|
|
:custom
|
|
|
|
;; Use uncompiled file if it is newer than the compiled one.
|
|
|
|
(load-prefer-newer t)
|
2019-12-26 07:06:00 +01:00
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
:config
|
|
|
|
(auto-compile-on-load-mode))
|
|
|
|
|
2019-11-30 00:01:05 +01:00
|
|
|
;; Tool for updating the GNU ELPA keyring.
|
|
|
|
(use-package gnu-elpa-keyring-update
|
|
|
|
:config
|
2019-12-04 07:07:48 +01:00
|
|
|
(defvar my/keyring-last-access
|
|
|
|
(time-to-seconds
|
2020-02-26 23:08:24 +01:00
|
|
|
(file-attribute-access-time
|
|
|
|
(file-attributes gnu-elpa-keyring-update--keyring)))
|
2019-12-04 07:07:48 +01:00
|
|
|
"Last access time for the GNU ELPA keyring.")
|
|
|
|
|
|
|
|
;; Only update keyring if atime (mtime with relatime) is > 1 week ago.
|
|
|
|
(if (> (- (time-to-seconds) my/keyring-last-access) (* 60 60 24 7))
|
|
|
|
(gnu-elpa-keyring-update))
|
2019-11-30 00:01:05 +01:00
|
|
|
)
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
;; Update packages if at least 7 days have passed.
|
|
|
|
(use-package auto-package-update
|
|
|
|
:custom
|
|
|
|
(auto-package-update-delete-old-versions t)
|
|
|
|
(auto-package-update-interval 7)
|
|
|
|
(auto-package-update-hide-results nil)
|
|
|
|
:config
|
|
|
|
(auto-package-update-maybe))
|
|
|
|
|
2020-02-24 22:01:43 +01:00
|
|
|
;; Install Emacs packages directly from source.
|
|
|
|
(use-package quelpa
|
2020-02-26 23:08:02 +01:00
|
|
|
:demand t
|
|
|
|
:custom ((quelpa-self-upgrade-p nil)
|
2020-02-24 22:01:43 +01:00
|
|
|
(quelpa-update-melpa-p nil)
|
|
|
|
(quelpa-checkout-melpa-p nil))
|
2020-02-26 23:08:02 +01:00
|
|
|
:config
|
|
|
|
(defvar my/quelpa-last-upgrade-file
|
|
|
|
(concat user-emacs-directory "quelpa/last_upgrade")
|
|
|
|
"File with the timestamp of the last quelpa upgrade.")
|
|
|
|
|
|
|
|
(defun my/quelpa-maybe-upgrade ()
|
|
|
|
"Upgrade quelpa packages if the last upgrade was > 7 days ago."
|
|
|
|
(when (or (not (file-exists-p my/quelpa-last-upgrade-file))
|
|
|
|
(> (- (time-to-seconds)
|
|
|
|
(my/file-last-modification my/quelpa-last-upgrade-file))
|
|
|
|
(* 60 60 24 7)))
|
|
|
|
(quelpa-upgrade-all)
|
|
|
|
(write-region "" nil my/quelpa-last-upgrade-file)))
|
|
|
|
|
|
|
|
:hook (after-init . my/quelpa-maybe-upgrade)
|
2020-02-24 22:01:43 +01:00
|
|
|
)
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
(provide 'basics/package-management)
|
|
|
|
;;; package-management.el ends here
|