From 0f80026223c733c45df6fa6d7937fb62eacc1cf3 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sun, 31 Mar 2024 17:28:34 +1100 Subject: [PATCH] Pass profile dirs as args instead of profiles.el Writing profiles.el was borderline unreadable. `doom-profiles-autodetect` was effectively just reading in the entire file: accepting the paths we want in the profile as individual args and putting them together on the Emacs side is easy enough. Accidentally fixes a bug: `user-emacs-directory` should end in a directory separator. We now get the right value for free by using the path we're running Doom CLI out of. --- cli2.el | 10 ++++++++-- doom.nix | 14 +++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cli2.el b/cli2.el index bbb23a0..1d0fc8a 100644 --- a/cli2.el +++ b/cli2.el @@ -12,9 +12,15 @@ it. Just skip it entirely." :override #'doom-initialize-core-packages t) -(defcli! build-profile-loader-for-nix-build () +(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 (doom-profiles-autodetect))) + (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))) (defcli! build-profile-for-nix-build () diff --git a/doom.nix b/doom.nix index d543946..52cd901 100644 --- a/doom.nix +++ b/doom.nix @@ -257,22 +257,14 @@ let # Required to avoid Doom erroring out at startup. nativeBuildInputs = [ git ]; } '' - mkdir $out - - echo ' - ((${profileName} (user-emacs-directory . "${doomSource}") - (doom-profile-data-dir . "'$out'/profile") - ("DOOMDIR" . "${finalDoomDir}"))) - ' > profiles.el - - mkdir $out/loader + mkdir $out $out/loader $out/profile export DOOMPROFILELOADFILE=$out/loader/init.el - export DOOMPROFILELOADPATH=$PWD/profiles.el export DOOMLOCALDIR=$(mktemp -d) # Prevent error on Emacs shutdown writing empty build cache. mkdir $DOOMLOCALDIR/straight - ${runtimeShell} ${doomSource}/bin/doom build-profile-loader-for-nix-build + ${runtimeShell} ${doomSource}/bin/doom build-profile-loader-for-nix-build \ + -n "${profileName}" -p "$out/profile" -d "${finalDoomDir}" # With DOOMPROFILE set, doom-state-dir and friends are HOME-relative. export HOME=$(mktemp -d)