Hey Julia friends. I’ve been trying to figure this out this morning in response to a student who is using NixOS and has convinced me to give it a try. In general on NixOS nothing is in the filesystem where things expect them to be (like in /lib or /usr/lib/ or /usr/bin/ or anything like that).
This means if you download precompiled binaries off the internet they generally won’t run. So if you want to use juliaup in your home directory on a NixOS machine, here’s how I got it working (apparently, tested to work for some very mild test cases).
- enable nix-ld on your NixOS config via
programs.nix-ld.enable = true;
- Make sure you have a .bashrc file (might not if you have a brand new machine, if needed do
echo "" > ~/.bashrc
- install juliaup according to the instructions on julialang.org
- run julia via the following command (or create a shell script)
NIX_LD_LIBRARY_PATH=~/.julia/juliaup/julia-1.11.5+0.x64.linux.gnu/lib/julia julia
nix-ld uses this environment variable to add to the “real” LD_LIBRARY_PATH when it loads julia, thereby avoiding having you link to some system version of stuff… In particular without it you’ll get an error about libcurl when doing package operations. Vscode julia language server cannot load on recent nixos
Now, you’re going to have to be responsible for changing this path when you update julia. So maybe make yourself a ~/bin/julianix script and update the script when you update julia.
Have a good time using Julia on NixOS!
EDIT: added this little shell script which auto-determines the directory from the default julia:
#!/usr/bin/env bash
VERS=$(juliaup status | sed -n -e "s/ *\*.* 1/1/p")
NIX_LD_LIBRARY_PATH=~/.julia/juliaup/${VERS}/lib/julia ~/.juliaup/bin/julia "$@"