Use doomscript instead of cli.el for dumping

Removes the need to build a stage1 DOOMDIR, we can just use the user's
DOOMDIR directly.

The same approach should work for the next stage, removing the need to
leave our cli.el in the final DOOMDIR.
This commit is contained in:
Marien Zwart 2024-04-25 16:09:42 +10:00
parent 6c394ec081
commit e41bb2e0e5
No known key found for this signature in database
2 changed files with 11 additions and 12 deletions

View file

@ -1,11 +1,14 @@
;;; cli.el -*- lexical-binding: t; -*-
#!/usr/bin/env doomscript
;; -*- lexical-binding: t; -*-
(require 'json)
(defcli! dump-for-nix-build
(defcli! dump
((output-directory ("-o" dir) "Directory to dump into.")
(&flag full? ("--full")))
"Dump intermediates for nix-doom-emacs-unstraightened."
;; Load the user's init.el, or we'll dump only core packages.
(load! doom-module-init-file doom-user-dir t)
(let* ((all-packages (doom-package-list full?))
;; For built-in packages, the :ignore property is the location of the
;; built-in library, which is a Nix store path. We do not want that
@ -49,3 +52,5 @@
(when (not (plist-get p :disable))
(insert "(package! " (symbol-name (car kp)) " :ignore t)\n"))))
(write-region nil nil (expand-file-name "packages.el" output-directory)))))
(run! "dump" (cdr (member "--" argv)))

View file

@ -38,25 +38,19 @@
makeBinaryWrapper,
}:
let
inherit (lib) optional optionalAttrs optionalString;
inherit (lib) optionalAttrs optionalString;
doomInitFile = "${doomDir}/init.el";
doomPrivateModule = "${doomDir}/packages.el";
# Step 1: determine which Emacs packages to pull in.
#
# Inputs: unpatched Doom, a DOOMDIR with the provided init.el and packages.el.
# Inputs: Doom, original DOOMDIR (only init.el and packages.el are used).
# Outputs:
# - Packages Doom normally loads using Straight (as json)
# - modified packages.el that claims all packages are system-installed
#
# Uses Doom's CLI framework, which does not require anything else is installed
# (not even straight).
stage1DoomDir = linkFarm "doom-dir-stage1" (
[{ name = "cli.el"; path = ./cli1.el; }]
++ optional (lib.pathExists doomInitFile) { name = "init.el"; path = doomInitFile; }
++ optional (lib.pathExists doomPrivateModule) { name = "packages.el"; path = doomPrivateModule; }
);
# XXX this may need to be runCommandLocal just in case conditionals an init.el
# / packages.el evaluate differently on build systems.
@ -64,7 +58,7 @@ let
{
env = {
EMACS = lib.getExe emacs;
DOOMDIR = stage1DoomDir;
DOOMDIR = "${doomDir}";
# Enable this to troubleshoot failures at this step.
#DEBUG = "1";
};
@ -73,7 +67,7 @@ let
} ''
mkdir $out
export DOOMLOCALDIR=$(mktemp -d)
${runtimeShell} ${doomSource}/bin/doom dump-for-nix-build \
${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/dump} \
${optionalString full "--full"} -o $out
'';