A CoPilot generated script to auto-populate needed packages to compile a LuaLaTeX file without getting all the packages
```bash #!/bin/bash # Initialize an empty string for packages packages="" # Loop until no missing .sty files are found while true; do # Attempt to compile the LuaLaTeX document missing_sty=$(guix shell texlive-scheme-basic $packages -- lualatex -file-line-error -halt-on-error -interaction=nonstopmode main.tex 2>&1 | grep "! LaTeX Error: File \`.*.sty' not found." | cut --delimiter '`' -f 2 | cut --delimiter "." -f 1) # Break the loop if no missing .sty files are detected if [ -z "$missing_sty" ]; then echo "Compilation successful, no missing .sty files." break fi # Prepend 'texlive-' to the missing .sty file name and add it to the packages string package_name=$(echo $missing_sty | sed 's/^/texlive-/g') packages="$packages $package_name" # Inform the user which package is being added echo "Adding missing package: $package_name" done # Final message echo "All required packages have been included." ```