[darwin] Add nix-darwin for work laptop

Adds nix-darwin
Simplifies emacs tree-sitter
Probably breaks vterm on linux :(
This commit is contained in:
2025-09-22 17:21:45 -07:00
parent 5591087be1
commit d3664fcf9d
6 changed files with 197 additions and 122 deletions

61
home/home-darwin-work.nix Normal file
View File

@@ -0,0 +1,61 @@
{ config, lib, pkgs, globalInputs, system, ... }:
let
customPkgs = pkgs.callPackage ../packages {};
in
{
# Provide arguments to role modules
_module.args = { inherit customPkgs; };
# Home Manager configuration for Darwin work laptop
# Corporate-friendly setup with essential development tools
home.username = lib.mkForce "johno";
home.homeDirectory = lib.mkForce "/Users/johno";
home.stateVersion = "24.05";
# Roles temporarily disabled to avoid kubectl dependency
# Override Darwin-incompatible settings from base role
programs.rbw.settings.pinentry = lib.mkForce pkgs.pinentry_mac;
# Re-enable bash with bashrcExtra to append rather than replace
programs.bash = {
enable = true;
initExtra = ''
source ~/Development/config_files/square/bashrc
# Generated by Hermit; START; DO NOT EDIT.
if [[ $- == *i* ]]; then
HERMIT_ROOT_BIN="''${HERMIT_ROOT_BIN:-"$HOME/bin/hermit"}"
eval "$(test -x $HERMIT_ROOT_BIN && $HERMIT_ROOT_BIN shell-hooks --print --bash)"
fi
# Generated by Hermit; END; DO NOT EDIT.
'';
};
programs.zsh = {
enable = true;
initContent = ''
source ~/Development/config_files/square/zshrc
# Generated by Hermit; START; DO NOT EDIT.
if [[ -o interactive ]]; then
HERMIT_ROOT_BIN="''${HERMIT_ROOT_BIN:-"$HOME/bin/hermit"}"
eval "$(test -x $HERMIT_ROOT_BIN && $HERMIT_ROOT_BIN shell-hooks --print --zsh)"
fi
# Generated by Hermit; END; DO NOT EDIT.
'';
};
# Keep SSH and Git disabled to avoid conflicts with work environment
programs.ssh.enable = lib.mkForce false;
programs.git.enable = lib.mkForce false;
programs.rbw.enable = lib.mkForce false;
home.shell.enableShellIntegration = true;
imports = [
./modules/emacs
./modules/tmux
];
}

View File

@@ -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
'';
};
}