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 Aug 1, 2016
1 parent cce0213 commit 80b8882
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/core-configuration-layer.el
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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-exclude-all-layers nil
Expand Down Expand Up @@ -499,6 +500,7 @@ 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)))
Expand All @@ -518,6 +520,8 @@ If TOGGLEP is nil then `:toggle' parameter is ignored."
(configuration-layer/get-layer-local-dir
(oref layer :name))
name-str name-str)))))
(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 @@ -1934,6 +1938,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
5 changes: 5 additions & 0 deletions doc/LAYERS.org
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ as follows:
:fetcher github
:repo "some/repo"))

;; A pinned package
(some-package :archive melpa-stable)

;; An excluded package
(some-package :excluded t)
))
Expand All @@ -338,6 +341,8 @@ currently supports packages on ELPA compliant repositories, local packages and
MELPA recipes (through the Quelpa package). See the [[https://github.com/milkypostman/melpa#recipe-format][MELPA documentation]] for more
information about recipes.

By using =:archive= attribute one can pin specific package to specific archive.

Packages may be /excluded/ by setting the =:excluded= property to true. This
will prevent the package from being installed even if it is used by another
layer.
Expand Down

0 comments on commit 80b8882

Please sign in to comment.