Write a Doom profile
This commit is contained in:
parent
25030d4356
commit
634be49049
3 changed files with 61 additions and 4 deletions
20
cli2.el
Normal file
20
cli2.el
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
;;; cli.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; We skip Doom's normal install and initialization.
|
||||||
|
(require 'straight)
|
||||||
|
|
||||||
|
(defadvice! nix-doom-skip-core-packages (orig-fn &rest args)
|
||||||
|
"HACK: don't install straight and core packages.
|
||||||
|
|
||||||
|
`doom-initialize-core-packages' would no-op out if
|
||||||
|
`straight-recipe-repositories' is set, but we do not want to set
|
||||||
|
it. Just skip it entirely."
|
||||||
|
:override #'doom-initialize-core-packages
|
||||||
|
t)
|
||||||
|
|
||||||
|
(defcli! build-profile-for-nix-build ()
|
||||||
|
"Write a Doom profile."
|
||||||
|
;; HACK: this initializes enough of straight (particularly
|
||||||
|
;; straight--build-cache) to make Doom work (I hope...).
|
||||||
|
(straight-prune-build-cache)
|
||||||
|
(doom-profile-generate))
|
||||||
45
package.nix
45
package.nix
|
|
@ -12,6 +12,7 @@
|
||||||
full ? false,
|
full ? false,
|
||||||
|
|
||||||
callPackages,
|
callPackages,
|
||||||
|
git,
|
||||||
emacsPackagesFor,
|
emacsPackagesFor,
|
||||||
lib,
|
lib,
|
||||||
linkFarm,
|
linkFarm,
|
||||||
|
|
@ -31,8 +32,8 @@ let
|
||||||
#
|
#
|
||||||
# Uses Doom's CLI framework, which does not require anything else is installed
|
# Uses Doom's CLI framework, which does not require anything else is installed
|
||||||
# (not even straight).
|
# (not even straight).
|
||||||
initialDoomDir = linkFarm "minimal-doom-dir" (
|
stage1DoomDir = linkFarm "doom-dir-stage1" (
|
||||||
[{ name = "cli.el"; path = ./cli.el; }]
|
[{ name = "cli.el"; path = ./cli1.el; }]
|
||||||
++ optional (doomInitFile != null) { name = "init.el"; path = doomInitFile; }
|
++ optional (doomInitFile != null) { name = "init.el"; path = doomInitFile; }
|
||||||
++ optional (doomPrivateModule != null) { name = "packages.el"; path = doomPrivateModule; }
|
++ optional (doomPrivateModule != null) { name = "packages.el"; path = doomPrivateModule; }
|
||||||
);
|
);
|
||||||
|
|
@ -47,7 +48,7 @@ let
|
||||||
{
|
{
|
||||||
env = {
|
env = {
|
||||||
EMACS = lib.getExe emacs;
|
EMACS = lib.getExe emacs;
|
||||||
DOOMDIR = initialDoomDir;
|
DOOMDIR = stage1DoomDir;
|
||||||
};
|
};
|
||||||
} ''
|
} ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
|
|
@ -73,6 +74,7 @@ let
|
||||||
undo-fu-session = "https://codeberg.org/ideasman42/emacs-undo-fu-session.git";
|
undo-fu-session = "https://codeberg.org/ideasman42/emacs-undo-fu-session.git";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Step 2: override Emacs packages to respect Doom's pins.
|
||||||
doomEmacsPackages = (emacsPackagesFor emacs).overrideScope (
|
doomEmacsPackages = (emacsPackagesFor emacs).overrideScope (
|
||||||
eself: esuper:
|
eself: esuper:
|
||||||
let
|
let
|
||||||
|
|
@ -208,6 +210,41 @@ let
|
||||||
lib.mapAttrs makePackage doomPackageSet
|
lib.mapAttrs makePackage doomPackageSet
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Step 3: Build an emacsWithPackages, pulling all packages from step 1 from
|
||||||
|
# the set from step 2.
|
||||||
emacsWithPackages = doomEmacsPackages.emacsWithPackages (epkgs: (map (p: epkgs.${p}) (builtins.attrNames doomPackageSet)));
|
emacsWithPackages = doomEmacsPackages.emacsWithPackages (epkgs: (map (p: epkgs.${p}) (builtins.attrNames doomPackageSet)));
|
||||||
|
|
||||||
|
# Step 4: build a Doom profile.
|
||||||
|
stage2DoomDir = linkFarm "doom-dir-stage2" (
|
||||||
|
[{ name = "cli.el"; path = ./cli2.el; }
|
||||||
|
{ name = "packages.el"; path = "${doomIntermediates}/packages.el"; }]
|
||||||
|
++ optional (doomInitFile != null) { name = "init.el"; path = doomInitFile; }
|
||||||
|
);
|
||||||
|
|
||||||
|
# XXX runCommandLocal? (See doomIntermediates.)
|
||||||
|
doomProfile = runCommand "doom-profile"
|
||||||
|
{
|
||||||
|
env = {
|
||||||
|
EMACS = lib.getExe emacsWithPackages;
|
||||||
|
DOOMDIR = stage2DoomDir;
|
||||||
|
# Enable this to troubleshoot failures at this step.
|
||||||
|
#DEBUG = "1";
|
||||||
|
};
|
||||||
|
# Required to avoid Doom erroring out at startup.
|
||||||
|
nativeBuildInputs = [ git ];
|
||||||
|
}
|
||||||
|
# Explicitly create `straight` to get an empty build cache written there
|
||||||
|
# instead of an error printed on Emacs shutdown.
|
||||||
|
''
|
||||||
|
mkdir -p $out/straight
|
||||||
|
export DOOMLOCALDIR=$out
|
||||||
|
${runtimeShell} ${doomSource}/bin/doom build-profile-for-nix-build
|
||||||
|
rm -rf $out/state/logs
|
||||||
|
'';
|
||||||
|
|
||||||
|
# TODO: this generates a blank 90-loaddefs-packages.auto.el, because
|
||||||
|
# `doom-profile--generate-package-autoloads` uses straight--build-cache to
|
||||||
|
# enumerate packages. Do we care, or are package.el autoloads sufficient?
|
||||||
|
|
||||||
in
|
in
|
||||||
emacsWithPackages
|
doomProfile
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue