158 lines
4 KiB
Nix
158 lines
4 KiB
Nix
{ pkgs
|
|
, config
|
|
, lib
|
|
, ...
|
|
}:
|
|
with lib; let
|
|
cfg = config.eboskma.programs.emacs;
|
|
|
|
tangleEmacsConfig = initFile: pkgs.runCommand "tangled-emacs-${initFile}" { } ''
|
|
cp ${./config.org} ./config.org
|
|
${cfg.package}/bin/emacs --batch --quick --load org ./config.org --funcall org-babel-tangle
|
|
cp ${initFile} $out
|
|
'';
|
|
|
|
emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage {
|
|
config =
|
|
let
|
|
tangledOrgConfig = tangleEmacsConfig "init.el";
|
|
in
|
|
builtins.readFile tangledOrgConfig;
|
|
|
|
defaultInitFile = true;
|
|
package = cfg.package;
|
|
alwaysEnsure = true;
|
|
alwaysTangle = true;
|
|
extraEmacsPackages = epkgs: with epkgs; [
|
|
vterm
|
|
(treesit-grammars.with-grammars (p: with p; [
|
|
tree-sitter-bash
|
|
tree-sitter-c
|
|
tree-sitter-c-sharp
|
|
tree-sitter-css
|
|
tree-sitter-cmake
|
|
tree-sitter-comment
|
|
tree-sitter-commonlisp
|
|
tree-sitter-cpp
|
|
tree-sitter-css
|
|
tree-sitter-cuda
|
|
tree-sitter-devicetree
|
|
tree-sitter-dockerfile
|
|
tree-sitter-dot
|
|
tree-sitter-eex
|
|
tree-sitter-elisp
|
|
tree-sitter-elixir
|
|
tree-sitter-embedded-template
|
|
tree-sitter-erlang
|
|
tree-sitter-fish
|
|
tree-sitter-glsl
|
|
tree-sitter-go
|
|
tree-sitter-gomod
|
|
tree-sitter-gowork
|
|
tree-sitter-graphql
|
|
tree-sitter-haskell
|
|
tree-sitter-hcl
|
|
tree-sitter-heex
|
|
tree-sitter-html
|
|
tree-sitter-http
|
|
tree-sitter-javascript
|
|
tree-sitter-jsdoc
|
|
tree-sitter-json
|
|
tree-sitter-latex
|
|
tree-sitter-llvm
|
|
tree-sitter-lua
|
|
tree-sitter-make
|
|
tree-sitter-markdown
|
|
tree-sitter-markdown-inline
|
|
tree-sitter-nix
|
|
(tree-sitter-nu.overrideAttrs (_prevAttr: {
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "nushell";
|
|
repo = "tree-sitter-nu";
|
|
rev = "307559b6a3885ef0c55bcd5e23e9e164a7ce03bd";
|
|
sha256 = "RuvR2Yb2CTxpxyXgr+2uUQa9N75sIhYlS9moyedZo8A=";
|
|
};
|
|
}))
|
|
tree-sitter-pioasm
|
|
tree-sitter-python
|
|
tree-sitter-query
|
|
tree-sitter-regex
|
|
tree-sitter-rst
|
|
tree-sitter-ruby
|
|
tree-sitter-rust
|
|
tree-sitter-scheme
|
|
tree-sitter-scss
|
|
tree-sitter-sql
|
|
tree-sitter-surface
|
|
tree-sitter-svelte
|
|
tree-sitter-toml
|
|
tree-sitter-tsx
|
|
tree-sitter-typescript
|
|
tree-sitter-verilog
|
|
tree-sitter-yaml
|
|
tree-sitter-zig
|
|
]))
|
|
emacsql
|
|
emacsql-sqlite
|
|
];
|
|
};
|
|
|
|
orgProtocolDesktop = pkgs.makeDesktopItem {
|
|
name = "org-protocol";
|
|
desktopName = "Emacs Org Protocol Handler";
|
|
icon = "emacs";
|
|
categories = [ "Development" "TextEditor" ];
|
|
keywords = [ "org-protocol" ];
|
|
type = "Application";
|
|
exec = "${emacsWithPackages}/bin/emacsclient -- %u";
|
|
terminal = false;
|
|
mimeTypes = [ "x-scheme-handler/org-protocol" ];
|
|
startupWMClass = "Emacs";
|
|
};
|
|
in
|
|
{
|
|
options.eboskma.programs.emacs = {
|
|
enable = mkEnableOption "activate emacs";
|
|
|
|
package = mkPackageOption pkgs "emacs" { };
|
|
|
|
daemon = mkOption {
|
|
description = "Whether to enable emacs daemon";
|
|
type = types.bool;
|
|
default = true;
|
|
example = false;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
programs.emacs = {
|
|
enable = true;
|
|
package = emacsWithPackages;
|
|
};
|
|
|
|
services.emacs = mkIf cfg.daemon {
|
|
enable = true;
|
|
package = emacsWithPackages;
|
|
client.enable = true;
|
|
socketActivation.enable = true;
|
|
defaultEditor = true;
|
|
};
|
|
|
|
home.file."emacs.d/early-init.el".source = tangleEmacsConfig "early-init.el";
|
|
|
|
home.packages = with pkgs; [
|
|
(texlive.combine {
|
|
inherit (texlive) scheme-small wrapfig ulem capt-of;
|
|
})
|
|
orgProtocolDesktop
|
|
nodePackages.bash-language-server
|
|
aspell
|
|
lldb
|
|
(nil.overrideAttrs (_: { doCheck = false; }))
|
|
nixpkgs-fmt
|
|
python3
|
|
] ++
|
|
(with aspellDicts; [ en en-computers en-science fy nl ]);
|
|
|
|
};
|
|
}
|