Test against init.el with all module flags enabled
Detect module flags by walking package.el files. This still does not build all dependencies, because some are enabled only if some flag or other module is disabled. But this should be close.
This commit is contained in:
parent
78ad78072d
commit
f48edf8b34
3 changed files with 46 additions and 6 deletions
|
|
@ -15,9 +15,21 @@
|
||||||
;; See the License for the specific language governing permissions and
|
;; See the License for the specific language governing permissions and
|
||||||
;; limitations under the License.
|
;; limitations under the License.
|
||||||
|
|
||||||
|
;; Simple recursive walk of packages.el to extract (modulep! +flag)
|
||||||
|
;;
|
||||||
|
;; Does not cover (modulep! :cat mod +flag). That is: assumes each flag is
|
||||||
|
;; referenced at least once by shortened form in the module itself.
|
||||||
|
;;
|
||||||
|
;; No attempt at efficiency, but package.el files are small...
|
||||||
|
|
||||||
|
(defun walk-package-exp (l)
|
||||||
|
(cond ((not (consp l)) nil)
|
||||||
|
((and (= 2 (length l)) (eq 'modulep! (car l))) (cdr l))
|
||||||
|
(t (mapcan #'walk-package-exp l))))
|
||||||
|
|
||||||
(defcli! full-init
|
(defcli! full-init
|
||||||
((output-directory ("-o" dir) "Directory to write init.el into.")
|
((output-directory ("-o" dir) "Directory to write init.el into.")
|
||||||
(&flag full? ("--full")))
|
(&flag flags? ("--flags")))
|
||||||
"Write init.el with all modules."
|
"Write init.el with all modules."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert ";;; init.el -*- no-byte-compile: t; -*-
|
(insert ";;; init.el -*- no-byte-compile: t; -*-
|
||||||
|
|
@ -30,8 +42,18 @@
|
||||||
(let ((cat (car kp))
|
(let ((cat (car kp))
|
||||||
(name (cdr kp)))
|
(name (cdr kp)))
|
||||||
(when name
|
(when name
|
||||||
(if full?
|
(if-let ((flags?)
|
||||||
(error "unimplemented")
|
(packages-path (doom-module-locate-path
|
||||||
|
cat name doom-module-packages-file))
|
||||||
|
(tree (with-temp-buffer
|
||||||
|
(insert "(\n")
|
||||||
|
(insert-file-contents packages-path)
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert ")\n")
|
||||||
|
(goto-char (point-min))
|
||||||
|
(read (current-buffer))))
|
||||||
|
(flags (walk-package-exp tree)))
|
||||||
|
(insert (format " %s %s\n" cat (cons name flags)))
|
||||||
(insert (format " %s %s\n" cat name))))))
|
(insert (format " %s %s\n" cat name))))))
|
||||||
(insert ")\n")
|
(insert ")\n")
|
||||||
(write-region nil nil (expand-file-name "init.el" output-directory))))
|
(write-region nil nil (expand-file-name "init.el" output-directory))))
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ let
|
||||||
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
||||||
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
||||||
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
||||||
fullDoomDir = (makeDoomPackages (common // { doomDir = emptyDirectory; })).doomDirWithAllModules;
|
allModsDoomDir = (makeDoomPackages (common // { doomDir = emptyDirectory; })).doomDirWithAllModules;
|
||||||
|
allFlagsDoomDir = (makeDoomPackages (common // { doomDir = emptyDirectory; })).doomDirWithAllModulesAndFlags;
|
||||||
doomTest = name: init: doomArgs: testers.testEqualContents {
|
doomTest = name: init: doomArgs: testers.testEqualContents {
|
||||||
assertion = "name = ${name}; modules = ${toPretty {} init}; args = ${toPretty {} doomArgs};";
|
assertion = "name = ${name}; modules = ${toPretty {} init}; args = ${toPretty {} doomArgs};";
|
||||||
expected = writeText "doom-expected" "Doom functions";
|
expected = writeText "doom-expected" "Doom functions";
|
||||||
|
|
@ -66,7 +67,8 @@ in {
|
||||||
minimalEmacs = (makeDoomPackages (common // {
|
minimalEmacs = (makeDoomPackages (common // {
|
||||||
doomDir = minimalDoomDir;
|
doomDir = minimalDoomDir;
|
||||||
})).emacsWithDoom;
|
})).emacsWithDoom;
|
||||||
full = mkDoom { doomDir = fullDoomDir; };
|
allModules = mkDoom { doomDir = allModsDoomDir; };
|
||||||
|
allModulesAndFlags = mkDoom { doomDir = allFlagsDoomDir; };
|
||||||
example = mkDoom { doomDir = ./doomdirs/example; };
|
example = mkDoom { doomDir = ./doomdirs/example; };
|
||||||
example-without-loader = mkDoom {
|
example-without-loader = mkDoom {
|
||||||
doomDir = ./doomdirs/example;
|
doomDir = ./doomdirs/example;
|
||||||
|
|
|
||||||
18
default.nix
18
default.nix
|
|
@ -71,6 +71,22 @@ let
|
||||||
${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/full-init} -o $out
|
${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/full-init} -o $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
doomDirWithAllModulesAndFlags = runCommandLocal "doom-full-init"
|
||||||
|
{
|
||||||
|
env = {
|
||||||
|
EMACS = lib.getExe emacs;
|
||||||
|
# Enable this to troubleshoot failures at this step.
|
||||||
|
#DEBUG = "1";
|
||||||
|
};
|
||||||
|
# We set DOOMLOCALDIR somewhere harmless below to stop Doom from trying to
|
||||||
|
# create it somewhere read-only.
|
||||||
|
} ''
|
||||||
|
mkdir $out
|
||||||
|
export DOOMLOCALDIR=$(mktemp -d)
|
||||||
|
${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/full-init} --flags -o $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
|
||||||
# Step 1: determine which Emacs packages to pull in.
|
# Step 1: determine which Emacs packages to pull in.
|
||||||
#
|
#
|
||||||
# Inputs: Doom, original DOOMDIR (only init.el and packages.el are used).
|
# Inputs: Doom, original DOOMDIR (only init.el and packages.el are used).
|
||||||
|
|
@ -426,5 +442,5 @@ let
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit doomDirWithAllModules doomEmacs emacsWithDoom;
|
inherit doomDirWithAllModules doomDirWithAllModulesAndFlags doomEmacs emacsWithDoom;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue