nix-doom-emacs-unstraightened/cli2.el
Marien Zwart 4f0f6fc607
Disable doom-initialize-core-packages at runtime
...by moving the existing hack from the CLI to init.el.

It's not really necessary to do this as early as init.el, but I'm coming
around to using init.el modifications as an alternative to using Doom's
profile loader. So we might as well do this in the same place.

This is not sufficient to make doom/help-packages work, but gets us one
step closer...
2024-04-08 21:11:36 +10:00

62 lines
2.6 KiB
EmacsLisp

;;; cli.el -*- lexical-binding: t; -*-
;; We skip Doom's normal install and initialization.
(require 'straight)
(defcli! build-profile-loader-for-nix-build
((profile-name ("-n" form) "Profile name.")
(profile-directory ("-p" dir) "Profile data directory.")
(profile-doom-dir ("-d" dir) "DOOMDIR"))
"Write Doom's profile loader."
(let ((new-profiles `((,profile-name
(user-emacs-directory . ,doom-emacs-dir)
(doom-profile-data-dir . ,profile-directory)
("DOOMDIR" . ,profile-doom-dir)))))
(doom-profiles-save new-profiles)))
;; Doom runs this with package.el activated, but suppresses activation during
;; normal startup. Store the side effects of activation in the profile to avoid
;; (slow) package activation during normal startup.
;;
;; package-activate-1 does:
;; - Load autoloads. Duplicated by generate-unstraightened-autoloads.
;; - Add to load-path. Doom already stores load-path.
;; - Add Info node. TODO.
;; - Add name to package-activated-list. Stored below.
(defun generate-unstraightened-autoloads ()
"Like doom-profile--generate-package-autoloads but for package.el."
(doom-autoloads--scan
(mapcar (lambda (s)
(format "%s.el"
(package--autoloads-file-name (package-get-descriptor s))))
;; Packages are (currently...) pushed onto package-activated-list as
;; they are activated. Reverse the list here so packages activated
;; first get their autoloads loaded first.
;;
;; An example package that requires this is geiser-guile: it calls
;; geiser-activate-implementation from autoloads, requiring geiser's
;; autoloads are loaded first.
(nreverse
(seq-difference package-activated-list
(mapcar #'intern-soft
doom-autoloads-excluded-packages))))
doom-autoloads-excluded-files
'literal))
(add-to-list
'doom-profile-generators
'("90-loaddefs-unstraightened.auto.el" . generate-unstraightened-autoloads))
(add-to-list 'doom-autoloads-cached-vars 'package-activated-list)
(defcli! build-profile-for-nix-build ()
"Write a Doom profile."
;; HACK: this initializes enough of straight (particularly
;; straight--build-cache, which doom-profile--generate-package-autoloads hits)
;; to make Doom work.
;;
;; TODO: remove doom-profile--generate-package-autoloads?
;; Because there are no straight-built packages, it generates an empty file.
(straight-prune-build-cache)
(doom-profile-generate))