nix-doom-emacs-unstraightened/build-helpers/build-profile
2024-04-28 12:26:05 +10:00

67 lines
2.7 KiB
Text
Executable file

#!/usr/bin/env doomscript
;; -*- lexical-binding: t; -*-
;; Copyright 2024 Google LLC
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; 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. Doom already stores Info-directory-list.
;; - 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)))