julia.withPackages: add juliaCpuTarget option
This commit is contained in:
parent
078f1251c0
commit
b69b526e6d
@ -67,3 +67,14 @@ nix-shell -p 'julia.withPackages ["Plots"]' --run julia
|
|||||||
|
|
||||||
This normally points at a special augmented version of the Julia [General packages registry](https://github.com/JuliaRegistries/General).
|
This normally points at a special augmented version of the Julia [General packages registry](https://github.com/JuliaRegistries/General).
|
||||||
If you want to use a bleeding-edge version to pick up the latest package updates, you can plug in a later revision than the one in Nixpkgs.
|
If you want to use a bleeding-edge version to pick up the latest package updates, you can plug in a later revision than the one in Nixpkgs.
|
||||||
|
|
||||||
|
* `juliaCpuTarget`: Allows you to set `JULIA_CPU_TARGET` when precompiling. Has no effect if `precompile=false`.
|
||||||
|
|
||||||
|
You may want to use this if you're building a Julia depot that will end up in a Nix cache and used on machines with
|
||||||
|
different CPUs.
|
||||||
|
|
||||||
|
Why? Julia will detect the CPU microarchitecture of the build machine and include this information in the precompiled
|
||||||
|
`*.ji` files. Starting in 1.10 Julia became more strict about checking the CPU target compatibility, so it may reject
|
||||||
|
your precompiled files if they were compiled on a different machine.
|
||||||
|
A good option to provide wide compatibility is to set this to `"generic"`, although this may reduce performance.
|
||||||
|
You can also set a semicolon-separated list of multiple different targets. See the Julia documentation for details.
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{ lib
|
{ callPackage
|
||||||
, callPackage
|
|
||||||
, runCommand
|
|
||||||
, fetchgit
|
, fetchgit
|
||||||
, fontconfig
|
, fontconfig
|
||||||
, git
|
, git
|
||||||
|
, lib
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
|
, python3
|
||||||
|
, runCommand
|
||||||
|
, system
|
||||||
, writeText
|
, writeText
|
||||||
, writeTextFile
|
, writeTextFile
|
||||||
, python3
|
|
||||||
|
|
||||||
# Artifacts dependencies
|
# Artifacts dependencies
|
||||||
, fetchurl
|
, fetchurl
|
||||||
@ -23,11 +24,12 @@
|
|||||||
|
|
||||||
# Other overridable arguments
|
# Other overridable arguments
|
||||||
, extraLibs ? []
|
, extraLibs ? []
|
||||||
, precompile ? true
|
, juliaCpuTarget ? null
|
||||||
, setDefaultDepot ? true
|
, makeTransitiveDependenciesImportable ? false # Used to support symbol indexing
|
||||||
, makeWrapperArgs ? ""
|
, makeWrapperArgs ? ""
|
||||||
, packageOverrides ? {}
|
, packageOverrides ? {}
|
||||||
, makeTransitiveDependenciesImportable ? false # Used to support symbol indexing
|
, precompile ? true
|
||||||
|
, setDefaultDepot ? true
|
||||||
}:
|
}:
|
||||||
|
|
||||||
packageNames:
|
packageNames:
|
||||||
@ -35,7 +37,6 @@ packageNames:
|
|||||||
let
|
let
|
||||||
util = callPackage ./util.nix {};
|
util = callPackage ./util.nix {};
|
||||||
|
|
||||||
|
|
||||||
# Some Julia packages require access to Python. Provide a Nixpkgs version so it
|
# Some Julia packages require access to Python. Provide a Nixpkgs version so it
|
||||||
# doesn't try to install its own.
|
# doesn't try to install its own.
|
||||||
pythonToUse = let
|
pythonToUse = let
|
||||||
@ -152,7 +153,7 @@ let
|
|||||||
# Build a Julia project and depot. The project contains Project.toml/Manifest.toml, while the
|
# Build a Julia project and depot. The project contains Project.toml/Manifest.toml, while the
|
||||||
# depot contains package build products (including the precompiled libraries, if precompile=true)
|
# depot contains package build products (including the precompiled libraries, if precompile=true)
|
||||||
projectAndDepot = callPackage ./depot.nix {
|
projectAndDepot = callPackage ./depot.nix {
|
||||||
inherit closureYaml extraLibs overridesToml packageImplications precompile;
|
inherit closureYaml extraLibs juliaCpuTarget overridesToml packageImplications precompile;
|
||||||
julia = juliaWrapped;
|
julia = juliaWrapped;
|
||||||
registry = minimalRegistry;
|
registry = minimalRegistry;
|
||||||
packageNames = if makeTransitiveDependenciesImportable
|
packageNames = if makeTransitiveDependenciesImportable
|
||||||
|
@ -9,17 +9,18 @@
|
|||||||
|
|
||||||
, closureYaml
|
, closureYaml
|
||||||
, extraLibs
|
, extraLibs
|
||||||
|
, juliaCpuTarget
|
||||||
, overridesToml
|
, overridesToml
|
||||||
, packageNames
|
|
||||||
, packageImplications
|
, packageImplications
|
||||||
|
, packageNames
|
||||||
, precompile
|
, precompile
|
||||||
, registry
|
, registry
|
||||||
}:
|
}:
|
||||||
|
|
||||||
runCommand "julia-depot" {
|
runCommand "julia-depot" {
|
||||||
nativeBuildInputs = [curl git julia (python3.withPackages (ps: with ps; [pyyaml]))] ++ extraLibs;
|
nativeBuildInputs = [curl git julia (python3.withPackages (ps: with ps; [pyyaml]))] ++ extraLibs;
|
||||||
inherit precompile registry;
|
inherit precompile registry;
|
||||||
} ''
|
} (''
|
||||||
export HOME=$(pwd)
|
export HOME=$(pwd)
|
||||||
|
|
||||||
echo "Building Julia depot and project with the following inputs"
|
echo "Building Julia depot and project with the following inputs"
|
||||||
@ -42,7 +43,9 @@ runCommand "julia-depot" {
|
|||||||
|
|
||||||
# Only precompile if configured to below
|
# Only precompile if configured to below
|
||||||
export JULIA_PKG_PRECOMPILE_AUTO=0
|
export JULIA_PKG_PRECOMPILE_AUTO=0
|
||||||
|
'' + lib.optionalString (juliaCpuTarget != null) ''
|
||||||
|
export JULIA_CPU_TARGET="${juliaCpuTarget}"
|
||||||
|
'' + ''
|
||||||
# Prevent a warning where Julia tries to download package server info
|
# Prevent a warning where Julia tries to download package server info
|
||||||
export JULIA_PKG_SERVER=""
|
export JULIA_PKG_SERVER=""
|
||||||
|
|
||||||
@ -84,6 +87,10 @@ runCommand "julia-depot" {
|
|||||||
Pkg.instantiate()
|
Pkg.instantiate()
|
||||||
|
|
||||||
if "precompile" in keys(ENV) && ENV["precompile"] != "0" && ENV["precompile"] != ""
|
if "precompile" in keys(ENV) && ENV["precompile"] != "0" && ENV["precompile"] != ""
|
||||||
|
if isdefined(Sys, :CPU_NAME)
|
||||||
|
println("Precompiling with CPU_NAME = " * Sys.CPU_NAME)
|
||||||
|
end
|
||||||
|
|
||||||
Pkg.precompile()
|
Pkg.precompile()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -91,4 +98,4 @@ runCommand "julia-depot" {
|
|||||||
# Remove the registry to save space
|
# Remove the registry to save space
|
||||||
Pkg.Registry.rm("General")
|
Pkg.Registry.rm("General")
|
||||||
'
|
'
|
||||||
''
|
'')
|
||||||
|
Loading…
Reference in New Issue
Block a user