nix-doom-emacs-unstraightened/build-helpers/build-profile
Marien Zwart 45568feecf
Tweak comment, dropping stale TODO
Buliding an empty autoloads file is harmless. Removing it would only
have been useful if I was able to skip straight.el initialization
entirely: now that I'm storing its build cache it no longer helps.
2024-04-27 20:02:15 +10:00

53 lines
2.1 KiB
Text
Executable file

#!/usr/bin/env doomscript
;; -*- lexical-binding: t; -*-
;; We skip Doom's normal install and initialization.
(require 'straight)
;; 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 ()
"Write a Doom profile."
;; Load our generated profile's init.el. Both to get the profile right and to
;; load the advice to make Doom not install straight.
(load! doom-module-init-file doom-user-dir t)
;; Trigger a write of straight's build cache (which we write into the profile
;; and load again later).
(straight-prune-build-cache)
(doom-profile-generate))
(run! "build-profile" (cdr (member "--" argv)))