Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pin packages to specific archive #6575

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions core/core-configuration-layer.el
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ is not set for the given SLOT."
(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 @@ -560,6 +561,7 @@ If TOGGLEP is nil then `:toggle' parameter is ignored."
(pkg-name-str (symbol-name pkg-name))
(layer (unless (eq 'dotfile layer-name)
(configuration-layer/get-layer layer-name)))
(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)))
(toggle (when (listp pkg) (plist-get (cdr pkg) :toggle)))
Expand All @@ -584,6 +586,8 @@ If TOGGLEP is nil then `:toggle' parameter is ignored."
(cfgl-package-set-property obj :excluded
(and (configuration-layer/layer-usedp layer-name)
(or excluded (oref obj :excluded))))
(when archive
(configuration-layer/pin-package pkg-name archive))
(when location
(if (and (listp location)
(eq (car location) 'recipe)
Expand Down Expand Up @@ -1965,8 +1969,8 @@ to select one."
(cadr (assq 'built-in stats))))
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
(let ((buffer-read-only nil))
(spacemacs-buffer//center-line)
(insert "\n")))))
(spacemacs-buffer//center-line)
(insert "\n")))))

(defun configuration-layer/load-or-install-protected-package
(pkg &optional log file-to-load)
Expand Down Expand Up @@ -2010,6 +2014,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