2023-09-12 08:44:05 -06:00
|
|
|
{ runCommand
|
|
|
|
, emacsWithPackagesFromUsePackage
|
|
|
|
, pkgs
|
|
|
|
, makeWrapper
|
|
|
|
, writeTextDir
|
|
|
|
, emacs
|
2024-05-23 21:09:15 -06:00
|
|
|
, emacsPkg ? pkgs.emacs-gtk
|
2024-05-21 14:34:44 -06:00
|
|
|
, isUnstable
|
2023-09-12 08:44:05 -06:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
let
|
2022-08-25 12:21:35 -06:00
|
|
|
# Generate a .el file from our emacs.org.
|
2023-09-12 08:44:05 -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 'emacs.org' config from: ${emacsConfig}")
|
|
|
|
(load "${emacsConfig}/emacs.el")
|
|
|
|
'';
|
|
|
|
emacsInitDir = "${emacsInit}/share/emacs/site-lisp";
|
|
|
|
|
2024-05-21 14:34:44 -06:00
|
|
|
unstablePkgs = if isUnstable then with pkgs; [ htmx-lsp ] else [ ];
|
|
|
|
|
2022-08-25 12:21:35 -06:00
|
|
|
# Binaries that are needed in emacs
|
|
|
|
emacsDepList = with pkgs; [
|
2024-05-21 13:53:47 -06:00
|
|
|
elmPackages.elm
|
|
|
|
elmPackages.elm-format
|
|
|
|
elmPackages.elm-language-server
|
|
|
|
go-font
|
2024-05-21 13:29:36 -06:00
|
|
|
gopls
|
|
|
|
gotools
|
2024-05-21 13:53:47 -06:00
|
|
|
graphviz
|
2024-05-23 07:44:17 -06:00
|
|
|
haskellPackages.lsp
|
2024-05-21 13:53:47 -06:00
|
|
|
ispell
|
2024-05-24 11:15:37 -06:00
|
|
|
isync
|
2024-05-21 14:47:10 -06:00
|
|
|
nil
|
2024-05-21 14:34:44 -06:00
|
|
|
nixpkgs-fmt
|
|
|
|
nodePackages.prettier
|
2024-05-21 13:53:47 -06:00
|
|
|
nodePackages.typescript-language-server
|
2024-05-23 19:34:15 -06:00
|
|
|
nodejs
|
2024-05-21 13:29:36 -06:00
|
|
|
perlPackages.PLS
|
2024-05-21 14:34:44 -06:00
|
|
|
rubyPackages.solargraph
|
|
|
|
sleek
|
2024-05-21 13:53:47 -06:00
|
|
|
texlive.combined.scheme-full
|
2024-05-21 14:34:44 -06:00
|
|
|
tree-sitter
|
2024-05-21 14:49:44 -06:00
|
|
|
typescript
|
2024-05-21 14:34:44 -06:00
|
|
|
] ++ unstablePkgs;
|
2023-07-11 09:12:50 -06:00
|
|
|
in
|
2023-09-12 08:44:05 -06:00
|
|
|
emacsWithPackagesFromUsePackage {
|
|
|
|
config = ./emacs.org;
|
2022-08-25 12:21:35 -06:00
|
|
|
|
2023-09-12 08:44:05 -06:00
|
|
|
alwaysEnsure = true;
|
|
|
|
alwaysTangle = true;
|
2022-08-25 12:21:35 -06:00
|
|
|
|
2023-09-12 08:44:05 -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}'
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
}
|