Add tex module

This commit is contained in:
Yan Lin 2025-10-03 20:40:37 +02:00
parent 2fff6aa766
commit 666261a731
4 changed files with 77 additions and 9 deletions

View file

@ -1,11 +1,11 @@
{ config, pkgs, nixvim, claude-code, firefox-addons, ... }: { config, pkgs, nixvim, claude-code, firefox-addons, ... }:
{ {
imports = [ imports = [
nixvim.homeModules.nixvim nixvim.homeModules.nixvim
../../modules/nvim.nix ../../modules/nvim.nix
../../modules/tmux.nix ../../modules/tmux.nix
../../modules/zsh.nix ../../modules/zsh.nix
../../modules/ssh.nix ../../modules/ssh.nix
../../modules/git.nix ../../modules/git.nix
../../modules/lazygit.nix ../../modules/lazygit.nix
@ -19,6 +19,7 @@
../../modules/dictionary.nix ../../modules/dictionary.nix
../../modules/yt-dlp.nix ../../modules/yt-dlp.nix
../../modules/claude-code.nix ../../modules/claude-code.nix
../../modules/tex.nix
../../config/fonts.nix ../../config/fonts.nix
]; ];
@ -184,7 +185,6 @@
hidden-bar # Menu bar organizer (macOS-only) hidden-bar # Menu bar organizer (macOS-only)
# Development and build tools # Development and build tools
texlive.combined.scheme-full
python312 python312
uv uv
lazysql lazysql

View file

@ -4,6 +4,7 @@
imports = [ imports = [
../home-default.nix ../home-default.nix
../../../modules/syncthing.nix ../../../modules/syncthing.nix
../../../modules/tex.nix
]; ];
# hs-specific home configuration # hs-specific home configuration
@ -30,7 +31,6 @@
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
texlive.combined.scheme-full
]; ];
} }

View file

@ -5,12 +5,13 @@
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# Import the common NixOS home configuration # Import the common NixOS home configuration
imports = [ imports = [
../home-default.nix ../home-default.nix
../../../modules/firefox.nix ../../../modules/firefox.nix
../../../modules/plasma.nix ../../../modules/plasma.nix
../../../modules/syncthing.nix ../../../modules/syncthing.nix
../../../modules/ghostty.nix ../../../modules/ghostty.nix
../../../modules/tex.nix
plasma-manager.homeModules.plasma-manager plasma-manager.homeModules.plasma-manager
]; ];
@ -32,7 +33,6 @@
# For example, laptop-specific aliases or scripts # For example, laptop-specific aliases or scripts
home.packages = with pkgs; [ home.packages = with pkgs; [
texlive.combined.scheme-full
keepassxc keepassxc
obsidian obsidian
]; ];

68
modules/tex.nix Normal file
View file

@ -0,0 +1,68 @@
{ config, pkgs, lib, ... }:
{
# Install TeXLive
home.packages = with pkgs; [
texlive.combined.scheme-full
];
# Shell aliases for LaTeX compilation
programs.zsh.shellAliases = {
# Clean auxiliary LaTeX files
mkpdf-clean = "latexmk -C";
};
# Shell functions for LaTeX compilation
programs.zsh.initContent = ''
# Build PDF with latexmk
# Usage: mkpdf [file.tex]
# If no argument provided, builds all .tex files in current directory
function mkpdf() {
local tex_file="''${1}"
local output_dir="./out"
if [[ -z "$tex_file" ]]; then
# Build all .tex files in current directory
local tex_files=(*.tex)
if [[ ''${#tex_files[@]} -eq 0 ]] || [[ ! -f "''${tex_files[0]}" ]]; then
echo "No .tex files found in current directory"
return 1
fi
for file in "''${tex_files[@]}"; do
echo "Building $file..."
latexmk -pdf -bibtex -shell-escape -interaction=nonstopmode \
-output-directory="$output_dir" -f "$file"
done
else
if [[ ! -f "$tex_file" ]]; then
echo "File not found: $tex_file"
return 1
fi
latexmk -pdf -bibtex -shell-escape -interaction=nonstopmode \
-output-directory="$output_dir" -f "$tex_file"
fi
}
# Continuous compilation mode - watch and auto-rebuild
# Usage: mkpdf-watch <file.tex>
function mkpdf-watch() {
local tex_file="''${1}"
local output_dir="./out"
if [[ -z "$tex_file" ]]; then
echo "Usage: mkpdf-watch <file.tex>"
return 1
fi
if [[ ! -f "$tex_file" ]]; then
echo "File not found: $tex_file"
return 1
fi
latexmk -pdf -pvc -view=none -shell-escape -interaction=nonstopmode \
-output-directory="$output_dir" -f "$tex_file"
}
'';
}