[darwin] Add nix-darwin for work laptop
Adds nix-darwin Simplifies emacs tree-sitter Probably breaks vterm on linux :(
This commit is contained in:
@@ -10,62 +10,21 @@ let
|
||||
sha256 = "sha256-vHwgENjip2+AFzs4oZfnKEAJKwf5Zid7fakImvxxQUw=";
|
||||
};
|
||||
|
||||
# Pre-built tree-sitter grammars for common languages
|
||||
treeSitterGrammars = with pkgs.tree-sitter-grammars; [
|
||||
# Core languages
|
||||
tree-sitter-bash
|
||||
tree-sitter-c
|
||||
tree-sitter-cpp
|
||||
tree-sitter-css
|
||||
tree-sitter-html
|
||||
tree-sitter-javascript
|
||||
tree-sitter-json
|
||||
tree-sitter-markdown
|
||||
tree-sitter-python
|
||||
tree-sitter-rust
|
||||
tree-sitter-yaml
|
||||
|
||||
# Configuration and markup
|
||||
tree-sitter-dockerfile
|
||||
tree-sitter-nix
|
||||
tree-sitter-toml
|
||||
|
||||
# Development tools and frameworks
|
||||
tree-sitter-elisp
|
||||
tree-sitter-typescript
|
||||
tree-sitter-tsx
|
||||
tree-sitter-go
|
||||
tree-sitter-java
|
||||
tree-sitter-lua
|
||||
tree-sitter-make
|
||||
tree-sitter-sql
|
||||
|
||||
# Additional useful languages
|
||||
tree-sitter-haskell
|
||||
tree-sitter-ruby
|
||||
tree-sitter-scala
|
||||
tree-sitter-clojure
|
||||
tree-sitter-scheme
|
||||
tree-sitter-latex
|
||||
tree-sitter-org-nvim
|
||||
tree-sitter-vim
|
||||
tree-sitter-regex
|
||||
tree-sitter-comment
|
||||
];
|
||||
# Default emacs configuration with vterm support
|
||||
defaultEmacsPackage = pkgs.emacs-macport.pkgs.withPackages (epkgs: [
|
||||
epkgs.vterm
|
||||
epkgs.treesit-grammars.with-all-grammars
|
||||
]);
|
||||
in
|
||||
{
|
||||
config = {
|
||||
home.packages = [
|
||||
(pkgs.emacs.pkgs.withPackages (epkgs: [
|
||||
epkgs.vterm
|
||||
]))
|
||||
|
||||
pkgs.emacs-all-the-icons-fonts
|
||||
pkgs.fira-code
|
||||
pkgs.fontconfig
|
||||
pkgs.graphviz
|
||||
pkgs.isort
|
||||
pkgs.libvterm # native vterm library
|
||||
#pkgs.libvterm # native vterm library
|
||||
pkgs.nerd-fonts.fira-code
|
||||
pkgs.nerd-fonts.droid-sans-mono
|
||||
pkgs.nil # nix lsp language server
|
||||
@@ -76,38 +35,17 @@ in
|
||||
pkgs.python3
|
||||
];
|
||||
|
||||
programs.emacs = {
|
||||
enable = true;
|
||||
package = defaultEmacsPackage;
|
||||
};
|
||||
|
||||
fonts.fontconfig.enable = true;
|
||||
|
||||
# Mount emacs and tree-sitter grammars from nix store
|
||||
home.file = {
|
||||
"${config.xdg.configHome}/emacs".source = doomEmacs;
|
||||
} // lib.listToAttrs (lib.flatten (map (grammar:
|
||||
let
|
||||
# Extract just the language name from the package name
|
||||
grammarName = let
|
||||
fullName = grammar.pname or (lib.getName grammar);
|
||||
# Remove "tree-sitter-" prefix and "-grammar" suffix
|
||||
cleaned = lib.removePrefix "tree-sitter-" fullName;
|
||||
final = lib.removeSuffix "-grammar" cleaned;
|
||||
in final;
|
||||
in [
|
||||
# Place grammars where Emacs tree-sitter expects them
|
||||
{
|
||||
name = ".local/share/doom/etc/tree-sitter/libtree-sitter-${grammarName}.so";
|
||||
value.source = "${grammar}/parser";
|
||||
}
|
||||
# Also place in standard tree-sitter location as backup
|
||||
{
|
||||
name = ".local/share/tree-sitter/bin/libtree-sitter-${grammarName}.so";
|
||||
value.source = "${grammar}/parser";
|
||||
}
|
||||
] ++ lib.optionals (builtins.pathExists "${grammar}/queries") [
|
||||
{
|
||||
name = ".local/share/tree-sitter/queries/${grammarName}";
|
||||
value.source = "${grammar}/queries";
|
||||
}
|
||||
]
|
||||
) treeSitterGrammars));
|
||||
};
|
||||
|
||||
home.sessionPath = [
|
||||
"${config.xdg.configHome}/emacs/bin"
|
||||
@@ -116,19 +54,12 @@ in
|
||||
home.sessionVariables = {
|
||||
DOOMDIR = "${config.xdg.configHome}/doom";
|
||||
DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
|
||||
# Set tree-sitter grammar directory to use pre-built grammars
|
||||
TREE_SITTER_DIR = "${config.xdg.dataHome}/tree-sitter";
|
||||
};
|
||||
|
||||
home.activation.doomConfig = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
# Always remove and recreate the symlink to ensure it points to the source directory
|
||||
rm -rf "${config.xdg.configHome}/doom"
|
||||
ln -sf "${config.home.homeDirectory}/nixos-configs/home/modules/emacs/doom" "${config.xdg.configHome}/doom"
|
||||
|
||||
# Run doom sync to apply any configuration changes
|
||||
if command -v doom >/dev/null 2>&1; then
|
||||
doom sync
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user