           (re-search-backward "\\(\\[.+\\]\\)" nil t)
           (help-xref-button 1 'help-package pkg-symbol))))))
 
-(defun configuration-layer/get-packages (layers &optional dotfile)
+(defun configuration-layer/get-packages (layers &optional dotfile packages)
   "Read the package lists of LAYERS and dotfile and return a list of packages."
-  (let (result)
+  (let ((result packages))
     (dolist (layer layers)
       (let* ((layer-name (oref layer :name))
              (layer-dir (oref layer :dir))

      (if (oref pkg :protected)
          (princ "\nThis package is protected and cannot be excluded.\n")
        (when (oref pkg :excluded)
          ;; TODO extend excluded support in cfgl-package object to know who is
          ;; excluding the package
          (princ "\nThis packages is excluded and cannot be installed.\n")))
      ;; toggle
      (unless (or (oref pkg :excluded) (eq t (oref pkg :toggle)))

(defvar configuration-layer--layers '()
  "A non-sorted list of `cfgl-layer' objects.")

(defvar configuration-layer--delayed-layers '()
  "A list of layers to check again after first pass of package declaration.")

(defvar configuration-layer--packages '()
  "An alphabetically sorted list of `cfgl-package' objects.")

