Complete guide for installing and setting up the T programming language.
The recommended way to install Nix is with the official installer:
# Multi-user installation (recommended)
sh <(curl -L https://nixos.org/nix/install) --daemon
# Single-user installation (alternative)
sh <(curl -L https://nixos.org/nix/install) --no-daemonNote: Multi-user installation requires sudo privileges and is more robust for development.
First, ensure WSL2 is installed:
# In PowerShell (Administrator)
wsl --installThen inside WSL2 Ubuntu:
sh <(curl -L https://nixos.org/nix/install) --daemonnix --version
# Should output: nix (Nix) 2.x.xT uses Nix flakes for reproducible builds. Enable them by adding to your Nix configuration:
# Create config directory if it doesn't exist
mkdir -p ~/.config/nix
# Enable flakes
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confFor NixOS users, add to
/etc/nixos/configuration.nix:
nix.settings.experimental-features = [ "nix-command" "flakes" ];# Choose a directory for T (e.g., ~/projects)
mkdir -p ~/projects
cd ~/projects
# Clone the repository
git clone https://github.com/b-rodrigues/tlang.git
cd tlangThe Nix flake provides a complete, isolated development environment:
nix developFirst run will take several minutes to: - Download and compile OCaml toolchain - Build Apache Arrow and dependencies - Set up development tools (dune, menhir, etc.)
All dependencies are cached in the Nix store
(/nix/store/) and reused for future sessions.
Expected output:
warning: creating lock file '/home/user/projects/tlang/flake.lock'
...
(nix development shell activated)
Inside the development environment:
dune buildThis compiles: - Lexer and parser - Evaluator and runtime - Standard library packages - REPL
Expected output:
File "src/repl.ml", line 1, characters 0-0:
Building...
Build artifacts are placed in _build/default/.
dune exec src/repl.exeYou should see:
T Language REPL (Alpha 0.1)
Type 'exit' to quit
>
> 2 + 3
5
> [1, 2, 3] |> sum
6
> type(42)
"Int"
> exit
If all commands work, installation is successful! 🎉
Verify everything works correctly:
dune runtestExpected behavior: - All tests should pass - Golden tests compare T output against R results - Test execution may take 1-2 minutes
Every time you want to work with T:
cd ~/projects/tlang
nix developIf flake.nix changes (e.g., after pulling updates):
nix flake update
nix developdune clean
dune buildAutomatically enter the Nix shell when entering the directory:
# Install direnv
nix-env -iA nixpkgs.direnv
# Enable direnv in your shell (bash/zsh)
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc # for bash
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc # for zsh
# Create .envrc in tlang directory
cd ~/projects/tlang
echo "use flake" > .envrc
direnv allowNow cd tlang automatically activates the
environment.
T doesn’t yet have a public binary cache, but you can set one up locally for your team:
# In nix.conf
substituters = https://cache.nixos.org/ https://your-cache.example.com/
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=The Nix installation may not have updated your PATH. Try:
source ~/.nix-profile/etc/profile.d/nix.shOr restart your terminal.
Flakes aren’t enabled. Double-check
~/.config/nix/nix.conf:
cat ~/.config/nix/nix.conf
# Should contain: experimental-features = nix-command flakesNix is building dependencies from source. This is normal on first run. Check progress:
nix develop --show-traceOr use a faster binary cache (if available).
Clean and rebuild:
dune clean
rm -rf _build
dune buildIf errors persist, check: - You’re inside nix develop
shell - OCaml version: ocaml --version should be 4.14+ -
Dune version: dune --version should be 3.0+
T uses Apache Arrow C GLib bindings. If you see linking errors:
# Inside nix develop
pkg-config --modversion arrow-glib
# Should output: 10.0.0 or similarThe Nix flake ensures Arrow is available; these errors usually indicate you’re not in the Nix shell.
Some tests require R (for golden test comparisons). Check test logs:
dune runtest --verboseKnown issues: - Floating-point precision differences across platforms - R package availability for comparison tests
/home/user/...), not Windows mount
(/mnt/c/...)T works natively on NixOS:
# Add to configuration.nix or home-manager
environment.systemPackages = with pkgs; [
# T will be added to nixpkgs eventually
];For now, use nix develop as above.
Now that T is installed:
rm -rf ~/projects/tlang# Remove just T's dependencies (preserves other Nix packages)
nix-store --gc
# Or remove all unused packages
nix-collect-garbage -d# For multi-user install
sudo rm -rf /nix
sudo rm /etc/profile.d/nix.sh
sudo rm /etc/nix
# For single-user install
rm -rf ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.config/nixReady to start? Head to the Getting Started Guide!