I am a julia user new to Nix environment. And I am wondering what is the best way to install julia and use it under this platform. I see 3 ways :
using julia package from Nix pkgs;
using julia-bin package from Nix pkgs;
using the classic downloadable file of julia and using some FHS tools or other approach to use it under Nix.
I am wondering because julia’s packages from linux distributions have often bad reputation concerning julia (I experienced it), but with nix it is not possible to use it out of the box after download.
I don’t know if this topic is more suitable for here, a julia discourse, or nix/nixos one.
If you are on nixos-unstable, you can just install julia-bin to get the latest Julia (1.10.0 currently).
If you’re on a stable nixos release like 23.11, julia-bin is Julia 1.9, so you’ll want to use an overlay to get the newer Julia 1.10. Read the nixpkgs docs to learn about using overlays. When the next Julia release comes out you can (hopefully) just bump the version and specify the new sha256.
I would say that Julia 1.10 is worth it even if you aren’t using any new features. 1.10 has package loading (e.g. time for using X) roughly 2x faster than 1.9.
Is julia-bin and installing packages inside Julia more stable right now than using Nix to build a Julia with all bundled packages, i.e. julia.withPackages?
Thanks, can you elaborate on this? Previously using julia-bin had quite a few glitches, e.g. Gadfly + Cairo were unable to find local fonts and PDFs were therefore broken (on Nix/NixOS).
Hi,
I’ve been able to get julia running using the julia-bin package, but I’ve had no joy getting Plots.jl with GR (on either X11 or Wayland) to work. Has anyone got this working?
julia> using Plots
julia> plot(1:100)
env: ‘/home/stephen/.julia/artifacts/7f59a0ec3d19c98dce30a3ba8ea9cbd8824ce4a6/bin/gksqt’: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
Thank you for sharing that code on github. I found that with a small tweak to account for the change in pathname of whether the gksqt is stored, it now works on both X11 and Wayland.
This is likely because you need to patchelf the binaries installed from Artifacts.jl. The script below should also allow you to use juliaup to install Julia versions. You just need to run this anytime you install/update a binary from Julia.
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p patchelf parallel
# Based on scripts by cstich, et. al.
# Fixes up Julia Artifacts on NixOS
# Discussion: https://discourse.julialang.org/t/build-julia-on-nixos/35129/21
PKG_DIR=~/.julia/
patchelf_job() {
ARTIFACT=$1
ORIGINAL_PERMISSIONS=$(stat -c "%a" $ARTIFACT)
chmod +w $ARTIFACT
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $ARTIFACT
chmod $ORIGINAL_PERMISSIONS $ARTIFACT
}
export -f patchelf_job
echo "Patching..."
find ~/src/julia/usr/* $PKG_DIR/artifacts/*/bin $PKG_DIR/juliaup/* -type f | parallel patchelf_job {} > /dev/null 2>&1