         (when (file-exists-p pkg-file)
           (load pkg-file)
           (dolist (pkg (eval (intern (format "%s-packages" (symbol-name sym)))))
-            (unless (member pkg dotspacemacs-excluded-packages)
-              (contribsys//add-layer-to-hash pkg sym spacemacs-all-packages))))
+            (contribsys//add-excluded-packages sym)
+            (contribsys//add-layer-to-hash pkg sym spacemacs-all-packages)))
         ;; extensions
         (when (file-exists-p ext-file)
           (load ext-file)
           (dolist (pkg (eval (intern (format "%s-pre-extensions"
                                              (symbol-name sym)))))
-            (unless (member pkg dotspacemacs-excluded-packages)
-              (contribsys//add-layer-to-hash
-               pkg sym spacemacs-all-pre-extensions)))
+            (contribsys//add-excluded-packages sym)
+            (contribsys//add-layer-to-hash pkg sym
+                                           spacemacs-all-pre-extensions))
           (dolist (pkg (eval (intern (format "%s-post-extensions"
                                              (symbol-name sym)))))
-            (unless (member pkg dotspacemacs-excluded-packages)
-              (contribsys//add-layer-to-hash
-               pkg sym spacemacs-all-post-extensions)))))))
+            (contribsys//add-excluded-packages sym)
+            (contribsys//add-layer-to-hash pkg sym
+                                           spacemacs-all-post-extensions))))))
+  (contribsys//filter-out-excluded-packages)
   ;; number of chuncks for the loading screen
   (let ((total (+ (ht-size spacemacs-all-packages)
                   (ht-size spacemacs-all-pre-extensions)

(defvar spacemacs-contrib-categories '()
  "List of strings corresponding to category names. A category is a
sub-directory of the contribution directory.")

(defvar dotspacemacs-configuration-layer-path '()
  "List of additional paths where to look for configuration layers.


(defun contribsys/discover-contrib-layers-in-dir (dir)
  "Fill the hash table `spacemacs-contrib-layer-paths' where the key is the
layer symbol and the value is its path for all layers found in directory DIR.

Also fill the list of excluded packages `spacemacs-excluded-packages-from-layers'
declared at the layer level."
  (message "Looking for contribution layers in %s" dir)
  (ignore-errors
    (let ((files (directory-files dir nil nil 'nosort))
          (filter-out (append spacemacs-contrib-categories '("." ".."))))
      (dolist (f files)
        (when (and (file-directory-p (concat dir f))
                   (not (member f filter-out)))
          (message "-> Discovered contribution layer: %s" f)
          (puthash (intern f) dir spacemacs-contrib-layer-paths))))))

(defun contribsys/load-layers ()
  "Load all declared layers."
