From 76b133fd9802ef3bb601d3ac155eb01512023baa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 05:32:11 -0400 Subject: [PATCH] Install core packages early --- core/core-packages.el | 110 +++++++++++++++++++++++++----------------- core/packages.el | 4 +- 2 files changed, 69 insertions(+), 45 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index bbcbfd1de..ddf7e19a9 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -102,51 +102,62 @@ package's name as a symbol, and whose CDR is the plist supplied to its ;; ;;; 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) "Ensure `straight' is installed and was compiled with this version of Emacs." (when (or force-p (null (bound-and-true-p straight-recipe-repositories))) (doom-log "Initializing straight") - (cl-destructuring-bind (&key pin recipe &allow-other-keys) - (let ((doom-packages (doom-package-list nil 'core-only))) - (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))))))) + (let ((doom-disabled-packages nil) + (doom-packages (doom-package-list nil 'core-only))) + (doom--ensure-straight) + (doom-log "Installing core packages") + (dolist (package doom-packages) + (cl-destructuring-bind (name &key recipe &allow-other-keys) + package + (when recipe + (straight-override-recipe (cons name recipe))) + (straight-use-package name)))))) (defun doom-initialize-packages (&optional force-p) "Process all packages, essential and otherwise, if they haven't already been. @@ -348,7 +359,11 @@ ones." for doom--current-module = key do (doom--read-packages path nil '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 () "Return an alist mapping package names (strings) to pinned commits (strings)." @@ -405,7 +420,7 @@ ones." ;;; Module package macros (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). 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: + :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 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 diff --git a/core/packages.el b/core/packages.el index fba82b326..cd6ebc6e0 100644 --- a/core/packages.el +++ b/core/packages.el @@ -7,7 +7,7 @@ ;; core-packages.el (package! straight - ;; :type 'core + :type 'core :recipe `(:host github :repo "raxod502/straight.el" :branch ,straight-repository-branch @@ -18,7 +18,7 @@ ;; core-modules.el (package! use-package - ;; :type 'core + :type 'core :pin "c873d5529c9c80cb58222f22873a4f081c307cb2") ;; core-ui.el