 Used by `doom-packages-install'."
   (doom-initialize-packages)
   (cl-loop for (name . plist)
-           in (doom-get-packages :ignored (if include-ignored-p 'any) :disabled nil)
+           in (doom-get-packages :ignored (if include-ignored-p 'any)
+                                 :disabled nil
+                                 :deps t)
            if (and (or (plist-get plist :pin)
-                       (not (assq name package--builtins)))
-                   (or (not (assq name package-alist))
+                       (not (package-built-in-p name)))
+                   (or (not (doom-package-installed-p name))
                        (doom-package-different-backend-p name)
                        (doom-package-different-recipe-p name)))
            collect (cons name plist)))

                                  (ignored 'any)
                                  (sort t)
                                  changed
                                  backend)
  "Retrieves a list of primary packages (i.e. non-dependencies). Each element is
a cons cell, whose car is the package symbol and whose cdr is the quelpa recipe
(if any).

  :pinned BOOL|ARCHIVE
    Only return packages that are pinned (t), not pinned (nil) or pinned to a
    specific archive (stringp)
  :deps BOOL
    Includes the package's dependencies (t).

The resulting list is sorted unless :sort nil is passed to this function.

Warning: this function is expensive, as it re-evaluates your all packages.el
files."
  (doom-initialize-packages)
  (cl-remove-duplicates
   (cl-loop with packages = (append (mapcar #'list doom-core-packages)
                                    doom-packages)
            for (sym . plist)
            in (if sort
                   (cl-sort (copy-sequence packages) #'string-lessp :key #'car)
                 packages)
            if (and (or (not backend)
                        (eq (doom-package-backend sym t) backend))
                    (or (eq ignored 'any)
                        (let* ((form (plist-get plist :ignore))
                               (value (eval form)))
                          (if ignored value (not value))))
                    (or (eq disabled 'any)
                        (if disabled
                            (plist-get plist :disable)
                          (not (plist-get plist :disable))))
                    (or (eq installed 'any)
                        (if installed
                            (doom-package-installed-p sym)
                          (not (doom-package-installed-p sym))))
                    (or (eq private 'any)
                        (if private
                            (plist-get plist :private)
                          (not (plist-get plist :private))))
                    (or (eq pinned 'any)
                        (cond ((eq pinned 't)
                               (plist-get plist :pin))
                              ((null pinned)
                               (not (plist-get plist :pin)))
                              ((equal (plist-get plist :pin) pinned)))))
            collect (cons sym plist)
            and if (and deps (not (package-built-in-p sym)))
            nconc
            (cl-loop for pkg in (doom-get-dependencies-for sym 'recursive 'noerror)
                     if (or (eq installed 'any)
                            (if installed
                                (doom-package-installed-p pkg)
                              (not (doom-package-installed-p pkg))))
                     collect (cons pkg (cdr (assq pkg doom-packages)))))
   :key #'car))

;;;###autoload
(defun doom-get-package-alist ()
