Skip to content

Commit

Permalink
allow to pin packages to specific archive
Browse files Browse the repository at this point in the history
  • Loading branch information
d12frosted committed Jul 15, 2016
1 parent 653da2a commit 0351e56
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/core-configuration-layer.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ LAYER has to be installed for this method to work properly."
(defvar configuration-layer--elpa-archives
'(("melpa" . "melpa.org/packages/")
("org" . "orgmode.org/elpa/")
("gnu" . "elpa.gnu.org/packages/"))
("gnu" . "elpa.gnu.org/packages/")
("melpa-stable" . "stable.melpa.org/packages/"))
"List of ELPA archives required by Spacemacs.")

(defvar configuration-layer-no-layer nil
Expand Down Expand Up @@ -486,13 +487,16 @@ If TOGGLEP is nil then `:toggle' parameter is ignored."
(let* ((name-sym (if (listp pkg) (car pkg) pkg))
(name-str (symbol-name name-sym))
(location (when (listp pkg) (plist-get (cdr pkg) :location)))
(archive (when (listp pkg) (plist-get (cdr pkg) :archive)))
(min-version (when (listp pkg) (plist-get (cdr pkg) :min-version)))
(step (when (listp pkg) (plist-get (cdr pkg) :step)))
(excluded (when (listp pkg) (plist-get (cdr pkg) :excluded)))
(toggle (when (and togglep (listp pkg)) (plist-get (cdr pkg) :toggle)))
(protected (when (listp pkg) (plist-get (cdr pkg) :protected)))
(copyp (not (null obj)))
(obj (if obj obj (cfgl-package name-str :name name-sym))))
(when archive
(configuration-layer/pin-package name-sym archive))
(when location (oset obj :location location))
(when min-version (oset obj :min-version (version-to-list min-version)))
(when step (oset obj :step step))
Expand Down Expand Up @@ -1866,7 +1870,19 @@ FILE-TO-LOAD is an explicit file to load after the installation."
(1+ configuration-layer-error-count))
(setq configuration-layer-error-count 1)))

(defun configuration-layer/pin-package (package archive)
"Pin PACKAGE to ARCHIVE.
When PACKAGE is pinned to specific ARCHIVE, it is installed
exactly from that ARCHIVE.
ARCHIVE must be one of the following symbols: melpa, org, gnu,
melpa-stable."
(let ((archive-name (symbol-name archive)))
(unless (assoc archive-name package-archives)
(error "Archive '%s' is not supported." archive))
(push (cons package archive-name) package-pinned-packages)))

(provide 'core-configuration-layer)

;;; core-configuration-layer.el ends here

0 comments on commit 0351e56

Please sign in to comment.