Require init.el exists

Although a completely empty DOOMDIR seems to work (at least for build
purposes), I doubt Doom actually supports this. And it requires some
extra checks on our side as well.

Just check in a trivial DOOMDIR and use that instead.
This commit is contained in:
Marien Zwart 2024-04-27 14:53:17 +10:00
parent f8fcb9f904
commit 1399755050
No known key found for this signature in database
5 changed files with 8 additions and 15 deletions

View file

@ -37,7 +37,7 @@
makeBinaryWrapper,
}:
let
inherit (lib) optionalAttrs optionalString pathExists;
inherit (lib) optionalAttrs optionalString;
# Step 1: determine which Emacs packages to pull in.
#
@ -225,19 +225,10 @@ let
emacsWithPackages = doomEmacsPackages.emacsWithPackages (epkgs: (map (p: epkgs.${p}) (builtins.attrNames doomPackageSet)));
# Step 4: build a final DOOMDIR with packages.el from step 1.
finalInitFile = let
doomInitFile = "${doomDir}/init.el";
in
if pathExists doomInitFile
then concatText "doom-init" [ ./pre-init.el doomInitFile ]
else ./pre-init.el;
finalInitFile = concatText "doom-init" [ ./pre-init.el "${doomDir}/init.el" ];
finalDoomDir = runCommand "doom-dir" {} ''
mkdir $out
if [[ -n "$(ls -A1 ${doomDir})" ]]; then
ln -s ${doomDir}/* $out/
fi
ln -s ${doomDir}/* $out/
# yasnippet logs an error at startup if snippets/ does not exist.
if ! [[ -e $out/snippets ]]; then
mkdir $out/snippets

2
doomdirs/minimal/init.el Normal file
View file

@ -0,0 +1,2 @@
;; Doom doesn't like a completely empty doom! block.
(doom! :config default)

View file

@ -29,9 +29,9 @@
# Current Doom + NixOS 23.11 requires emacs-overlay: Doom pins
# emacs-fish-completion, which moved from gitlab to github recently
# enough stable nixpkgs pulls it from the wrong source.
doom-minimal = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { doomDir = pkgs.emptyDirectory; });
doom-full = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { full = true; doomDir = pkgs.emptyDirectory; });
doom-example = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { doomDir = ./example; });
doom-minimal = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { doomDir = ./doomdirs/minimal; });
doom-full = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { full = true; doomDir = ./doomdirs/minimal; });
doom-example = pkgsWithEmacsOverlay.callPackage ./doom.nix (common // { doomDir = ./doomdirs/example; });
});
overlays.default = final: prev:
let