   (let ((obj (configuration-layer/get-layer layer-name)))
     (when obj (memq layer-name configuration-layer--used-layers))))
 
-(defun  configuration-layer/layer-lazy-installp (layer-name)
-  "Return non-nil if LAYER-NAME is the name of a layer to be lazily installed."
-  (let ((obj (configuration-layer/get-layer layer-name)))
-    (when obj (oref obj :lazy-install))))
-
 (defun configuration-layer/package-usedp (name)
   "Return non-nil if NAME is the name of a used package."
   (let ((obj (configuration-layer/get-package name)))

(defun configuration-layer//auto-mode (layer-name mode)
  "Auto mode support of lazily installed layers."
  (let ((layer (configuration-layer/get-layer layer-name)))
    (when (or (null layer)
              (oref layer :lazy-install))
      (configuration-layer//lazy-install-packages layer-name mode)))
  (when (fboundp mode) (funcall mode)))

(defun configuration-layer/filter-objects (objects ffunc)
  "Return a filtered OBJECTS list where each element satisfies FFUNC."
  (reverse (cl-reduce (lambda (acc x)
                     (if (funcall ffunc x) (push x acc) acc))
                   objects
                   :initial-value nil)))

(defun configuration-layer//get-distant-packages (packages usedp)
  "Return the distant packages (ie to be intalled).
If USEDP is non nil then returns only the used packages; if it is nil then
return both used and unused packages."
  (configuration-layer/filter-objects
   packages (lambda (x)
              (let ((pkg (configuration-layer/get-package x)))
                (and (not (memq (oref pkg :location) '(built-in site local)))
                     (not (stringp (oref pkg :location)))
                     (or (null usedp)
                         (and (not (null (oref pkg :owners)))
                              (cfgl-package-enabledp pkg)
                              (not (oref pkg :excluded)))))))))

(defun configuration-layer//get-private-layer-dir (name)
  "Return an absolute path to the private configuration layer string NAME."

            (delq nil
                  (mapcar
                   (lambda (x)
                     (let* ((pkg-name (if (listp x) (car x) x))
                            (pkg (configuration-layer/get-package pkg-name)))
                       (cfgl-package-set-property pkg :lazy-install nil)
                       (when (memq pkg-name
                                   configuration-layer--used-distant-packages)
                         pkg-name)))
                   (oref layer :packages)))))
      (let ((last-buffer (current-buffer))
            (sorted-pkg (configuration-layer//sort-packages inst-pkgs)))
        (spacemacs-buffer/goto-buffer)
        (goto-char (point-max))
        (configuration-layer//install-packages sorted-pkg)
        (configuration-layer//configure-packages sorted-pkg)
        (configuration-layer//load-layer-files layer '("keybindings.el"))
        (oset layer :lazy-install nil)
        (switch-to-buffer last-buffer)))))

(defun configuration-layer//install-packages (packages)
