Hello!
Here I would like to create a topic about the use of Julia on NixOS, and open the contact with other Julia users under NixOS or those using the Nix package manager. First, just a short introduction about why the use of Julia with this operating system might not be so trivial:
NixOS is a distribution that has a different way to install packages to have a kind of purely reproducible working environment. This means that it doesn’t follow the FHS (file hierarchical system) of unix/linux.
To give an example of what it implies in the case of python, a typical installation with pip or conda of a python package might not work, since it is usually looking for files on specific directories (on a prescribed FHS like /usr/lib, /usr/share/ … or similar) to resolve dependencies. Actually, it happens that these dependencies are (or can be) in the system but not there (when conda/pip are looking for them).
Julia compiler itself can be easily installed (as simple as: nix-env -iA nixos.julia_11
for version 1.1) but the Julia’s built-in package manager usually has difficulties to build the packages and organize their dependencies. The NixOS people provided a solution for those cases, as in this operating system it is possible to run a program on a virtual environment that fulfil the FHS. This is useful to use, for example, conda on NixOS on a smooth way, or installations depending on it (for example here.
More and less this is the idea or direction to overcome the problem also in Julia, but still the users may need some support, so I have open this topic to share our experiences or difficulties. Here I give some links to discussion about Julia within the NixOS community:
- Main Discussion (sometimes very technical)
- Typical problems to overcome
- Also this one
- Kind of solution at the end of this thread
Inside Julia world we had discussions about support of Nix package manager:
The current solution, based on create an FHD environment, that aims to solve our problems is close to this piece of code to be added in our NixOS configuration of overlays (kindly provided by other user):
{pkgs, stdenv, ...}:
with pkgs;
let
julia = julia_11;
d = version: "v${lib.concatStringsSep "." (lib.take 2 (lib.splitString "." version))}";
extraLibs = [
# ImageMagick.jl ==========================
imagemagickBig
# HDF5.jl =================================
hdf5
# Cairo.jl ================================
cairo gettext pango.out glib.out
# Gtk.jl ==================================
gtk3 gdk_pixbuf
# GZip.jl required by DataFrames.jl =======
gzip zlib
# GR.jl which runs without Xrender & Xext =
# but cannot save files ===================
xorg.libXt xorg.libX11 xorg.libXrender xorg.libXext glfw freetype
# Flux.jl =================================
cudatoolkit linuxPackages.nvidia_x11 git gitRepo gnupg autoconf curl
procps gnumake utillinux m4 gperf unzip libGLU_combined ncurses5 stdenv.cc binutils
xorg.libXi xorg.libXmu freeglut xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib
# Arpack.jl ===============================
arpack gfortran.cc
(pkgs.runCommand "openblas64_" {} ''
mkdir -p "$out"/lib/
ln -s ${openblasCompat}/lib/libopenblas.so "$out"/lib/libopenblas64_.so.0
'')
];
in
stdenv.mkDerivation rec {
name = "julia-env";
version = julia.version;
nativeBuildInputs = [ makeWrapper cacert git pkgconfig which ];
buildInputs = [
julia
/* jupyterEnv # my custom jupyter */
] ++ extraLibs;
phases = [ "installPhase" ];
installPhase = ''
export CUDA_PATH="${cudatoolkit}"
export LD_LIBRARY_PATH=${lib.makeLibraryPath extraLibs}
# pushd $JULIA_PKGDIR/${d version}
makeWrapper ${julia}/bin/julia $out/bin/julia \
--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH" \
--prefix LD_LIBRARY_PATH ":" "${linuxPackages.nvidia_x11}/lib" \
--set CUDA_PATH "${cudatoolkit}" \
--set JULIA_PKGDIR $JULIA_PKGDIR
'';
}
Kind regards!