xin/configs/emacs.nix

69 lines
1.7 KiB
Nix
Raw Normal View History

2023-07-11 09:12:50 -06:00
{
runCommand,
emacsWithPackagesFromUsePackage,
pkgs,
lib,
makeWrapper,
mu,
writeTextDir,
emacs,
emacsPkg ? pkgs.emacsPgtkNativeComp,
...
}: let
2022-08-25 12:21:35 -06:00
muDir = "${mu}/share/emacs/site-lisp/mu4e";
# Generate a .el file from our emacs.org.
2023-07-11 09:12:50 -06:00
emacsConfig = runCommand "emacsConfig" {} ''
2022-08-25 12:21:35 -06:00
mkdir -p $out
cp -v ${./emacs.org} $out/emacs.org
cd $out
${emacs}/bin/emacs --batch -Q -q \
--debug-init \
-l org emacs.org \
-f org-babel-tangle
if [ $? != 0 ]; then
echo "Generating failed!"
exit 1;
else
echo "Generated org config!"
fi
'';
# init.el to load my config and other dependencies.
emacsInit = writeTextDir "share/emacs/site-lisp/init.el" ''
(message "Loading my 'mu4e' from: ${muDir}")
(add-to-list 'load-path "${muDir}")
(load "${muDir}/mu4e.el")
(message "Loading my 'emacs.org' config from: ${emacsConfig}")
(load "${emacsConfig}/emacs.el")
'';
emacsInitDir = "${emacsInit}/share/emacs/site-lisp";
# Binaries that are needed in emacs
emacsDepList = with pkgs; [
go-font
graphviz
ispell
isync
mu
texlive.combined.scheme-full
];
2023-07-11 09:12:50 -06:00
in
emacsWithPackagesFromUsePackage {
config = ./emacs.org;
2022-08-25 12:21:35 -06:00
2023-07-11 09:12:50 -06:00
alwaysEnsure = true;
alwaysTangle = true;
2022-08-25 12:21:35 -06:00
2023-07-11 09:12:50 -06:00
package = emacsPkg.overrideAttrs (oa: {
nativeBuildInputs = oa.nativeBuildInputs ++ [makeWrapper emacsConfig];
postInstall = ''
${oa.postInstall}
wrapProgram $out/bin/emacs \
--prefix PATH : ${pkgs.lib.makeBinPath emacsDepList} \
--add-flags '--init-directory ${emacsInitDir}'
'';
});
}