Install core packages early

This commit is contained in:
Henrik Lissner 2020-05-15 05:32:11 -04:00
parent 87e279ce61
commit 76b133fd98
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 69 additions and 45 deletions

View file

@ -102,51 +102,62 @@ package's name as a symbol, and whose CDR is the plist supplied to its
;; ;;
;;; Bootstrappers ;;; Bootstrappers
(defun doom--ensure-straight ()
(cl-destructuring-bind (&key pin recipe &allow-other-keys)
(doom-package-get 'straight)
(let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el"))
(repo-url (concat "http" (if gnutls-verify-error "s")
"://github.com/"
(or (plist-get recipe :repo) "raxod502/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch))
(call (if doom-debug-mode #'doom-exec-process #'doom-call-process)))
(if (not (file-directory-p repo-dir))
(message "Installing straight...")
;; TODO Rethink this clumsy workaround
(let ((default-directory repo-dir))
(unless (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) pin)
(delete-directory repo-dir 'recursive)
(message "Updating straight..."))))
(unless (file-directory-p repo-dir)
(cond
((eq straight-vc-git-default-clone-depth 'full)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir))
((null pin)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir
"--depth" (number-to-string straight-vc-git-default-clone-depth)
"--branch" straight-repository-branch))
((integerp straight-vc-git-default-clone-depth)
(make-directory repo-dir t)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "checkout" "-b" straight-repository-branch)
(funcall call "git" "remote" "add" "origin" repo-url)
(funcall call "git" "fetch" "origin" pin
"--depth" (number-to-string straight-vc-git-default-clone-depth))
(funcall call "git" "checkout" "--detach" pin)))))
(require 'straight (concat repo-dir "/straight.el"))
(doom-log "Initializing recipes")
(with-temp-buffer
(insert-file-contents (doom-path repo-dir "bootstrap.el"))
;; Don't install straight for us -- we've already done that -- only set
;; up its recipe repos for us.
(eval-region (search-forward "(require 'straight)")
(point-max))))))
(defun doom-initialize-core-packages (&optional force-p) (defun doom-initialize-core-packages (&optional force-p)
"Ensure `straight' is installed and was compiled with this version of Emacs." "Ensure `straight' is installed and was compiled with this version of Emacs."
(when (or force-p (null (bound-and-true-p straight-recipe-repositories))) (when (or force-p (null (bound-and-true-p straight-recipe-repositories)))
(doom-log "Initializing straight") (doom-log "Initializing straight")
(cl-destructuring-bind (&key pin recipe &allow-other-keys) (let ((doom-disabled-packages nil)
(let ((doom-packages (doom-package-list nil 'core-only))) (doom-packages (doom-package-list nil 'core-only)))
(doom-package-get 'straight)) (doom--ensure-straight)
(let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) (doom-log "Installing core packages")
(repo-url (concat "http" (if gnutls-verify-error "s") (dolist (package doom-packages)
"://github.com/" (cl-destructuring-bind (name &key recipe &allow-other-keys)
(or (plist-get recipe :repo) "raxod502/straight.el"))) package
(branch (or (plist-get recipe :branch) straight-repository-branch)) (when recipe
(call (if doom-debug-mode #'doom-exec-process #'doom-call-process))) (straight-override-recipe (cons name recipe)))
(if (not (file-directory-p repo-dir)) (straight-use-package name))))))
(message "Installing straight...")
;; TODO Rethink this clumsy workaround
(let ((default-directory repo-dir))
(unless (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) pin)
(delete-directory repo-dir 'recursive)
(message "Updating straight..."))))
(unless (file-directory-p repo-dir)
(cond
((eq straight-vc-git-default-clone-depth 'full)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir))
((null pin)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir
"--depth" (number-to-string straight-vc-git-default-clone-depth)
"--branch" straight-repository-branch))
((integerp straight-vc-git-default-clone-depth)
(make-directory repo-dir t)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "checkout" "-b" straight-repository-branch)
(funcall call "git" "remote" "add" "origin" repo-url)
(funcall call "git" "fetch" "origin" pin
"--depth" (number-to-string straight-vc-git-default-clone-depth))
(funcall call "git" "checkout" "--detach" pin)))))
(require 'straight (concat repo-dir "/straight.el"))
(doom-log "Initializing recipes")
(with-temp-buffer
(insert-file-contents (doom-path repo-dir "bootstrap.el"))
;; Don't install straight for us -- we've already done that -- only set
;; up its recipe repos for us.
(eval-region (search-forward "(require 'straight)")
(point-max)))))))
(defun doom-initialize-packages (&optional force-p) (defun doom-initialize-packages (&optional force-p)
"Process all packages, essential and otherwise, if they haven't already been. "Process all packages, essential and otherwise, if they haven't already been.
@ -348,7 +359,11 @@ ones."
for doom--current-module = key for doom--current-module = key
do (doom--read-packages path nil 'noerror))) do (doom--read-packages path nil 'noerror)))
(doom--read-packages private-packages all-p 'noerror))) (doom--read-packages private-packages all-p 'noerror)))
(reverse doom-packages))) (cl-remove-if-not
(if core-only-p
(lambda (pkg) (eq (plist-get (cdr pkg) :type) 'core))
#'identity)
(nreverse doom-packages))))
(defun doom-package-pinned-list () (defun doom-package-pinned-list ()
"Return an alist mapping package names (strings) to pinned commits (strings)." "Return an alist mapping package names (strings) to pinned commits (strings)."
@ -405,7 +420,7 @@ ones."
;;; Module package macros ;;; Module package macros
(cl-defmacro package! (cl-defmacro package!
(name &rest plist &key built-in recipe ignore _pin _disable) (name &rest plist &key built-in recipe ignore _type _pin _disable)
"Declares a package and how to install it (if applicable). "Declares a package and how to install it (if applicable).
This macro is declarative and does not load nor install packages. It is used to This macro is declarative and does not load nor install packages. It is used to
@ -416,6 +431,15 @@ Only use this macro in a module's packages.el file.
Accepts the following properties: Accepts the following properties:
:type core|local|built-in|virtual
Specifies what kind of package this is. Can be a symbol or a list thereof.
`core' = this is a protected package and cannot be disabled!
`local' = this package is being modified in-place. This package's repo is
unshallowed and will be skipped when you update packages.
`built-in' = this package is already built-in (otherwise, will be
installed)
`virtual' = this package is not tracked by Doom's package manager. It won't
be installed or uninstalled. Use this to pin 2nd order dependencies.
:recipe RECIPE :recipe RECIPE
Specifies a straight.el recipe to allow you to acquire packages from external Specifies a straight.el recipe to allow you to acquire packages from external
sources. See https://github.com/raxod502/straight.el#the-recipe-format for sources. See https://github.com/raxod502/straight.el#the-recipe-format for

View file

@ -7,7 +7,7 @@
;; core-packages.el ;; core-packages.el
(package! straight (package! straight
;; :type 'core :type 'core
:recipe `(:host github :recipe `(:host github
:repo "raxod502/straight.el" :repo "raxod502/straight.el"
:branch ,straight-repository-branch :branch ,straight-repository-branch
@ -18,7 +18,7 @@
;; core-modules.el ;; core-modules.el
(package! use-package (package! use-package
;; :type 'core :type 'core
:pin "c873d5529c9c80cb58222f22873a4f081c307cb2") :pin "c873d5529c9c80cb58222f22873a4f081c307cb2")
;; core-ui.el ;; core-ui.el