Joining the discussion very late, I currently have a simple (and dirty) Nix expression to download and patch a binary Julia release:
# vim: set ts=8 sw=2 sts=2 et:
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
stdenv.mkDerivation rec {
pname = "julia_bin";
version = "1.5.2";
src = fetchurl {
url = "https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-${version}-linux-x86_64.tar.gz";
# Use `nix-prefetch-url` to get the hash.
sha256 = "0c26b11qy4csws6vvi27lsl0nmqszaf7lk1ya0jrg8zgvkx099vd";
};
nativeBuildInputs = [ autoPatchelfHook ];
# Stripping the shared libraries breaks dynamic loading.
dontStrip = true;
installPhase = ''
mkdir -p $out
tar -x -C $out -f $src --strip-components 1
# Lacks a string table, so we are unable to patch it.
rm $out/lib/julia/libccalltest.so.debug
# Patch for pre-compilation as the Nix store file time stamps are pinned to the start of the epoch.
sed -i 's/\(ftime != trunc(ftime_req, digits=6)\)$/\1 \&\& ftime != 1.0/' $out/share/julia/base/loading.jl
grep '&& ftime != 1.0$' $out/share/julia/base/loading.jl > /dev/null || exit 1
'';
meta = with stdenv.lib; {
description =
"High-level performance-oriented dynamical language for technical computing";
homepage = "https://julialang.org";
license = licenses.mit;
platforms = platforms.linux;
};
}
This works well for most use cases, even with the Julia package manager as it provides its own standalone libraries for most packages these days. However, it falls flat on its face for something like FFMPEG.jl that lifts in its own binaries.
Getting the package manager to work even for these cases should be as simple as patching Pkg.jl
’s Artifacts.jl
here along with pretty much the same lines as rustup
does with its Nix expression and a patch to dynamically use patchelf
to swap out the interpreter for the dynamic one provided by Nix.
However, this would require rebuilding the Julia system image, which is where I got stuck and I will have to abandon this project until I am less bogged down at work – weeks, probably… What I fear is that this may require building Julia from source to get that system image, but I was unaware that @cstich had an expression for a more modern Julia version than the somewhat ancient 1.3 version that is in nixpkgs
. So perhaps my hour of digging today can lead to someone else getting it working more swiftly?
Personally, while I would be happy to have support for Julia with packages in Nix, I honestly do not mind that much having only the (patched) Julia binary managed by Nix as the Julia package ecosystem these days is more than nice enough to manage dependencies on a project by project basis without having to resort to nix-shell
.