GLMakie and nixOS

Just a quick question here, sorry if this is not the right place for it. Has anyone managed to use GLMakie in nixos? Wanted to try out this distro but it seems julia has some issues with it, seems they explicitly say some packages (notably Plots) do not work. In particular with julia-1.10.2, trying to set up an empty environment with GLMakie I get a failure at precompilation:

Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to "/home/pablom/.julia/compiled/v1.10/GLMakie/jl_wXJ2dw".
β”Œ Warning:     GLFW couldn't create an OpenGL window.
β”‚     This likely means, you don't have an OpenGL capable Graphic Card,
β”‚     or you don't have an OpenGL 3.3 capable video driver installed.
β”‚     Have a look at the troubleshooting section in the GLMakie readme:
β”‚     https://github.com/MakieOrg/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
β”” @ GLMakie ~/.julia/packages/GLMakie/QyIWu/src/screen.jl:250
ERROR: LoadError: GLFWError (API_UNAVAILABLE): GLX: No GLXFBConfigs returned
Stacktrace:
  [1] _ErrorCallbackWrapper(code::Int32, description::Cstring)
    @ GLFW ~/.julia/packages/GLFW/BWxfF/src/callback.jl:43
  [2] CreateWindow(width::Int64, height::Int64, title::String, monitor::GLFW.Monitor, share::GLFW.Window)
    @ GLFW ~/.julia/packages/GLFW/BWxfF/src/glfw3.jl:499
  [3] GLFW.Window(; name::String, resolution::Tuple{Int64, Int64}, debugging::Bool, major::Int64, minor::Int64, windowhints::Vector{Tuple{UInt32, Integer}}, contexthints::Vector{Tuple{UInt32, Integer}}, visible::Bool, focus::Bool, fullscreen::Bool, monitor::Nothing, share::GLFW.Window)
    @ GLFW ~/.julia/packages/GLFW/BWxfF/src/glfw3.jl:344
  [4] Window
    @ ~/.julia/packages/GLFW/BWxfF/src/glfw3.jl:302 [inlined]
  [5] empty_screen(debugging::Bool; reuse::Bool)
    @ GLMakie ~/.julia/packages/GLMakie/QyIWu/src/screen.jl:241
  [6] empty_screen
    @ ~/.julia/packages/GLMakie/QyIWu/src/screen.jl:222 [inlined]
  [7] singleton_screen(debugging::Bool)
    @ GLMakie ~/.julia/packages/GLMakie/QyIWu/src/screen.jl:329
  [8] macro expansion
    @ ~/.julia/packages/GLMakie/QyIWu/src/precompiles.jl:21 [inlined]
  [9] macro expansion
    @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
 [10] macro expansion
    @ ~/.julia/packages/GLMakie/QyIWu/src/precompiles.jl:18 [inlined]
 [11] macro expansion
    @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:140 [inlined]
 [12] top-level scope
    @ ~/.julia/packages/GLMakie/QyIWu/src/precompiles.jl:16
 [13] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [14] include(x::String)
    @ GLMakie ~/.julia/packages/GLMakie/QyIWu/src/GLMakie.jl:1
 [15] top-level scope
    @ ~/.julia/packages/GLMakie/QyIWu/src/GLMakie.jl:79
 [16] include
    @ ./Base.jl:495 [inlined]
 [17] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [18] top-level scope
    @ stdin:3
in expression starting at /home/pablom/.julia/packages/GLMakie/QyIWu/src/precompiles.jl:15
in expression starting at /home/pablom/.julia/packages/GLMakie/QyIWu/src/GLMakie.jl:1
in expression starting at stdin:

I do have an nvidia card with nvidia drivers setup and openGL enabled

glxinfo | grep "OpenGL version"
OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.0.2

And this works on the same hardware in arch-linux. Is this just a fundamental incompatibility between nixos and GLMakie?

You just need to tell Julia where to find the opengl driver. One way to do that:

LD_LIBRARY_PATH=/run/opengl-driver/lib/ julia

There is also GitHub - nix-community/nixGL: A wrapper tool for nix OpenGL application [maintainer=@guibou] which I haven’t tried.

4 Likes

thanks, works like a charm :slight_smile:

1 Like

Another option is to install Julia using something like scientific-fhs. A more sustainable, long-term solution is needed for Julia-Nix integration but scientific-fhs works pretty well for the time being.

1 Like