np/templates/rde/hosts/julia.nix
copilot-swe-agent[bot] 2a5a1acd62 Fix runtime errors and improve robustness in host configs and scripts
- Fix KeyError in julia.nix when Project.toml lacks deps table
- Fix incorrect uv args in python.nix (remove --run + --add-flags combination)
- Remove redundant 'uv add ipython' from sync branch in python.nix
- Fix relative paths in project-scripts.nix (./scripts -> ../scripts)
- Fix initProject.sh to check file existence before git add
- Add RVER validation in updateDeps.sh with proper error handling
- Add tool availability checks in updateDeps.sh (uv, julia, devenv)
- Add flake.nix backup before modification in updateDeps.sh
- Ensure updateDeps.sh runs from repository root

Co-authored-by: dwinkler1 <22460147+dwinkler1@users.noreply.github.com>
2026-01-11 19:48:19 +00:00

66 lines
2.2 KiB
Nix

# Julia-related host configurations
#
# This module defines all Julia-related commands available in the dev shell.
# Julia is configured with project-local package management.
#
# Available commands (when Julia is enabled):
# - <name>-jl: Launch Julia REPL with project environment
# - <name>-pluto: Launch Pluto.jl notebook server
# - <name>-initJl: Initialize Julia project and install Pluto
#
# How it works:
# - All commands use --project=. to activate local Project.toml
# - JULIA_NUM_THREADS=auto enables multi-threading
# - Packages are managed via Julia's built-in Pkg manager
#
# Project setup:
# 1. Run <name>-initJl to create Project.toml
# 2. Add packages: julia --project=. -e 'using Pkg; Pkg.add("PackageName")'
# 3. Packages are stored in Project.toml and Manifest.toml
#
# Dependencies: julia-bin (configured in flake.nix)
config: pkgs: {
# jl: Julia REPL with project environment
# Activates local Project.toml for package management
# Use Pkg.add("PackageName") to install packages
jl = {
enable = config.enabledLanguages.julia;
path = {
value = "${pkgs.julia-bin}/bin/julia";
args = ["--add-flags" "--project=."];
};
};
# initJl: Initialize Julia project
# Creates Project.toml and installs Pluto.jl notebook
# Run this once to set up Julia package management
initJl = {
enable = config.enabledLanguages.julia;
path = {
value = "${pkgs.julia-bin}/bin/julia";
args = ["--add-flags" "--project=. -e 'using Pkg; Pkg.instantiate(); Pkg.add(\"Pluto\")'"];
};
};
# pluto: Launch Pluto.jl interactive notebook
# Auto-installs Pluto if not present in Project.toml
# Opens browser with notebook interface
# Notebooks are reactive - cells update automatically
pluto = let
runPluto = ''
import Pkg; import TOML; Pkg.instantiate();
proj = isfile("Project.toml") ? TOML.parsefile(Base.active_project()) : Dict();
deps = get(proj, "deps", Dict());
if !haskey(deps, "Pluto")
Pkg.add("Pluto");
end
import Pluto; Pluto.run();
'';
in {
enable = config.enabledLanguages.julia;
path = {
value = "${pkgs.julia-bin}/bin/julia";
args = ["--add-flags" "--project=. -e '${runPluto}'"];
};
};
}