# Best way to install and use julia on Nix/NixoS

**URL:** <https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948>\
**Category:** General Usage\
**Tags:** installation, nixos\
**Created:** [February 8, 2024, 8:04pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948 "2024-02-08T20:04:58Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sparsetacus](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Sparsetacus](https://discourse.julialang.org/u/Sparsetacus)\
**Post date:** [February 8, 2024, 8:04pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/1 "2024-02-08T20:04:58Z")

</div>

Hi there,

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.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [February 8, 2024, 8:28pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/2 "2024-02-08T20:28:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sparsetacus](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Sparsetacus](https://discourse.julialang.org/u/Sparsetacus)\
**Post date:** [February 8, 2024, 8:39pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/3 "2024-02-08T20:39:08Z")

</div>

Ok. So basically what you say is that `julia-bin` is ok but need an overlay just to get the latest version ?

Why not just using the `unstable.julia-bin` package in a stable nix ?

I know it is not recommended but using `1.9` does not disturb me. I am not bleeding edge in my use of julia.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [February 8, 2024, 8:53pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/4 "2024-02-08T20:53:12Z")

</div>

> [@Sparsetacus](#):
>
> Why not just using the `unstable.julia-bin` package in a stable nix ?

If you have `unstable` nixpkgs, then sure, you can use `unstable.julia-bin` to get the latest Julia release.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [February 8, 2024, 9:05pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/5 "2024-02-08T21:05:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sparsetacus](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@Sparsetacus](https://discourse.julialang.org/u/Sparsetacus)\
**Post date:** [February 8, 2024, 9:11pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/6 "2024-02-08T21:11:08Z")

</div>

Ok noted. Thanks !

---

<div class="post-metadata">

**Author:** ![gumbel](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@gumbel](https://discourse.julialang.org/u/gumbel)\
**Post date:** [March 5, 2024, 3:12am UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/7 "2024-03-05T03:12:05Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [March 5, 2024, 3:12am UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/8 "2024-03-05T03:12:51Z")

</div>

yes. Do not use your OS to install Julia packages.

---

<div class="post-metadata">

**Author:** ![gumbel](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@gumbel](https://discourse.julialang.org/u/gumbel)\
**Post date:** [March 5, 2024, 3:41am UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/9 "2024-03-05T03:41:00Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 5, 2024, 4:00am UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/10 "2024-03-05T04:00:31Z")

</div>

I think @thomasjm wrote `julia.withPackages`, maybe he can explain the state of that project.

---

<div class="post-metadata">

**Author:** ![Stephen\_Eglen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_eglen/32/12349_2.png) [@Stephen\_Eglen](https://discourse.julialang.org/u/Stephen_Eglen)\
**Post date:** [March 12, 2024, 5:02pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/11 "2024-03-12T17:02:55Z")

</div>

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
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

```

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 12, 2024, 5:51pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/12 "2024-03-12T17:51:52Z")

</div>

I haven’t tried [this code](https://gist.github.com/konfou/d12c0a26fc0d3b432dc9d23c86701fcb) but it purports to fix GR.

Fwiw I have no problems with CairoMakie or WGLMakie.

---

<div class="post-metadata">

**Author:** ![Stephen\_Eglen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_eglen/32/12349_2.png) [@Stephen\_Eglen](https://discourse.julialang.org/u/Stephen_Eglen)\
**Post date:** [March 13, 2024, 2:10pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/13 "2024-03-13T14:10:59Z")

</div>

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.

> <https://gist.github.com/konfou/d12c0a26fc0d3b432dc9d23c86701fcb>

---

<div class="post-metadata">

**Author:** ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)\
**Post date:** [March 13, 2024, 5:02pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/14 "2024-03-13T17:02:11Z")

</div>

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.

```bash

#!/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

```

---

<div class="post-metadata">

**Author:** ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)\
**Post date:** [March 13, 2024, 5:08pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/15 "2024-03-13T17:08:44Z")

</div>

You can also use the following patchset to get a shell.nix which will build Julia on NixOS:

> <https://github.com/sjkelly/julia/commit/1a216b37888aff4e8e99143d74ade24931731813>

> <https://github.com/sjkelly/julia/commit/f4b8f21b0359b734067cb6aa510298f53caac124>
>
> Works with dependencies provided by Binary Builder, but needs to be
> extended to …build dependencies from source.

---

<div class="post-metadata">

**Author:** ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)\
**Post date:** [March 26, 2024, 3:23pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/16 "2024-03-26T15:23:06Z")

</div>

I also realized since 22.05 you can use: [GitHub - Mic92/nix-ld: Run unpatched dynamic binaries on NixOS](https://github.com/Mic92/nix-ld)

This seems to be a much smoother experience.

---

<div class="post-metadata">

**Author:** ![aaryansinhaa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaryansinhaa/32/218223_2.png) [@aaryansinhaa](https://discourse.julialang.org/u/aaryansinhaa)\
**Post date:** [August 13, 2025, 12:12pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/17 "2025-08-13T12:12:59Z")

</div>

When you search julia on NixOS packages, I would recommend you to only use the `julia-bin`, if you want up-to-date julia, I faced several issues with the package: `julia`, `julia_110`,` julia-lts`

Specially when you have to instantiate projects.

And I would recommend to install julia packages using only the julia’s package manager, and do not handle this at the OS level.

Enjoy the declarative build!

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [September 12, 2025, 6:15am UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/18 "2025-09-12T06:15:20Z")

</div>

Improvements to native Julia installation on Nix are merged: [Julia.withPackages improvements by thomasjm · Pull Request #433332 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/433332)

EDIT: If you also use Python or R the way packages are installed using a nix expression might be confusing so here a quick guide

# Julia

```julia-auto
# Nix compiled julia (possibly cached)
pkgs.julia.withPackages ["DataFrames" "StatsBase"]
# or Julia provided binary
pkgs.julia-bin.withPackages ["DataFrames" "StatsBase"]
# or LTS (binary?)
pkgs.julia-lts.withPackages ["DataFrames" "StatsBase"]

```

# R

```julia-auto
pkgs.rWrapper.override{ packages = with pkgs.rPackages; [ggplot2 dplyr xts]; }

```

# Python

```julia-auto
pkgs.python3.withPackages (python-pkgs: [
      python-pkgs.pandas
      python-pkgs.requests
    ])

```

---

<div class="post-metadata">

**Author:** ![gumbel](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@gumbel](https://discourse.julialang.org/u/gumbel)\
**Post date:** [November 1, 2025, 9:42pm UTC](https://discourse.julialang.org/t/best-way-to-install-and-use-julia-on-nix-nixos/109948/19 "2025-11-01T21:42:32Z")

</div>

This is excellent. Thank you!

It fixes the only major annoyance for us on NixOS, and we use plenty of languages and ecosystems.
