Julia: Difference between revisions

imported>Samuela
No edit summary
Added an example using the withPackages function
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''tl;dr''' Use the <code>julia_16-bin</code> package.
[https://julialang.org/ Julia] is a programming language, that aims to create an unprecedented combination of ease-of-use, power, and efficiency in a single language.


Tracking 1.7 support here: https://github.com/NixOS/nixpkgs/issues/148339.
== Installation And Versions ==
You can install the newest version of Julia either with <code>julia-bin</code> (the derivation which downloads the binary) or <code>julia</code> (the derivation which builds Julia from the source). From the end-user perspective, -bin packages should be indistinguishable from source-built ones.


There are a number of other <code>julia*</code> attributes but most of them are broken. Work is ongoing to add macOS support (https://github.com/NixOS/nixpkgs/issues/123394).
== Packages ==


Explanation:
Julia packages can be installed via nix using the <code>julia.withPackages</code> function. For example:<syntaxhighlight lang="nix">
* -stable packages are for Julia LTS versions, which are very old at this point. I believe 1.0-ish. You probably want something more recent.
{pkgs, ...}:
* -bin packages are not built from source directly, but are instead built off of the official binaries released by Julia. Building Julia from source has proven to be quite a nightmare, so the -bin packages take the easy route. From the end-user perspective, -bin packages should be indistinguishable from source built ones.
let
  myjulia = (pkgs.julia.withPackages [
    "Plots"
  ]);
in
{
 
environment.systemPackages = [ myjulia ];
 
home.packages = [ myjulia ]; # if using home manager
}
</syntaxhighlight>
You can also install packages the [https://docs.julialang.org/en/v1/stdlib/Pkg/ without nix.]
 
Some Julia packages expect binaries to be installed on your system. Until a better solution is found, you can run Julia inside [[Distrobox]].
 
Most notably, Julia Plots does not work. You can use [http://gadflyjl.org/stable/ Gadfly] instead.
 
As of April 2026, the above statement is no longer accurate. [https://docs.juliaplots.org/stable/ Julia Plots] does seem to work with no additional configuration.  
 
Another solution is to enable [https://github.com/nix-community/nix-ld nix-ld], see also [https://nix.dev/guides/faq#how-to-run-non-nix-executables here].


[[Category:Applications]]
[[Category:Languages]]
[[Category:Languages]]