I have a list of packages that I need to install in a custom variable (in the
early-init.el) like so.
"List of packages to be installed for the Emacs config to work as configured.
The packages will be installed with `timu-func-install-packages'."
:type '(repeat symbol)
The following function checks if a package is installed.
(defun timu-func-packages-installed-p ()
"Check if all packages in `timu-package-list' are installed."
(cl-every #'package-installed-p timu-package-list))
This functions installs a package if it is not installed.
(defun timu-func-require-package (package)
"Install PACKAGE unless already installed."
(unless (memq package timu-package-list)
(add-to-list 'timu-package-list package))
(unless (package-installed-p package)
Install ALL the packages in case they are not installes
(defun timu-func-require-packages (packages)
"Ensure PACKAGES are installed.
Missing packages are installed automatically."
(mapc #'timu-func-require-package packages))
This is the command I the use in my
init.el file to install the packages on demand.
This would be the "one command".
Note that this only installs missing packages. The above functions are helper functions.
(defun timu-func-install-packages ()
"Install all packages listed in `timu-package-list' unless already installed."
;; check for new packages (package versions)
(message "%s" "Reloading packages DB...")
(message "%s" " done.")
;; install the missing packages
I got most of the code from this repo and adjusted it for case: