 of all excluded packages."
   (let (result)
     (dolist (layer layers)
-      (let* ((layer-sym (car layer))
-             (excl-var (intern (format "%s-excluded-packages"
-                                       (symbol-name layer-sym)))))
+      (let ((excl-var (intern (format "%S-excluded-packages"
+                                      (oref layer :name)))))
         (when (boundp excl-var)
           (mapc (lambda (x) (push x result)) (eval excl-var)))))
     result))


(defun configuration-layer//load-layer-files (layer files)
  "Load the files of list FILES for the given LAYER."
  (let* ((sym (car layer))
         (dir (plist-get (cdr layer) :dir)))
    (dolist (file files)
      (let ((file (concat dir file)))
        (if (file-exists-p file) (load file))))))

(defsubst configuration-layer//add-layer-to-hash (pkg layer hash)
  "Add LAYER to the list value stored in HASH with key PKG."


(defun configuration-layer/init-layers ()
  "Declare default layers and user layers from the dotfile by filling the
`configuration-layer-used-layers' variable."
  (setq configuration-layer-paths (configuration-layer//discover-layers))
  (if (eq 'all dotspacemacs-configuration-layers)
      (setq dotspacemacs-configuration-layers
            ;; spacemacs is contained in configuration-layer-paths
            (ht-keys configuration-layer-paths))
    (setq configuration-layer-used-layers
          (list (configuration-layer//make-used-layer 'spacemacs))))
  (setq configuration-layer-used-layers
        (append (configuration-layer//declare-used-layers
                 dotspacemacs-configuration-layers) configuration-layer-used-layers)))

(defun configuration-layer//declare-used-layers (layers)
  "Declare the passed configuration LAYERS.
LAYERS is a list of layer symbols."
  (reduce (lambda (acc elt) (push elt acc))
          (mapcar 'configuration-layer//make-used-layer (reverse layers))
          :initial-value nil))

(defun configuration-layer//make-used-layer (layer)
  "Return an cfgl-layer object based on LAYER."
  (let* ((name-sym (if (listp layer) (car layer) layer))
         (name-str (symbol-name name-sym))
         (base-dir (configuration-layer/get-layer-path name-sym))
         (variables (when (listp layer)
                      (spacemacs/mplist-get layer :variables))))
    (if base-dir
        (let* ((dir (format "%s%s/" base-dir name-str))
               (ext-dir (format "%sextensions/" dir)))
          (cfgl-layer name-str
                      :name name-sym
                      :dir dir
                      :ext-dir ext-dir
                      :variables variables))
      (spacemacs-buffer/warning "Cannot find layer %S !" name-sym)
      nil)))

(defun configuration-layer//set-layers-variables (layers)
  "Set the configuration variables for the passed LAYERS."
  (dolist (layer layers)
    (let ((variables (oref layer :variables)))
      (while variables
        (let ((var (pop variables)))
          (if (consp variables)
