nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 130 lines 4.1 kB view raw
1{ 2 lib, 3 runCommand, 4 5 cacert, 6 curl, 7 git, 8 julia, 9 python3, 10 stdenv, 11 12 closureYaml, 13 extraLibs, 14 juliaCpuTarget, 15 overridesToml, 16 packageImplications, 17 project, 18 precompile, 19 registry, 20}: 21 22let 23 # On darwin, we don't want to specify JULIA_SSL_CA_ROOTS_PATH. If we do (using a -bin julia derivation, which is the 24 # only kind darwin currently supports), you get an error like this: 25 # 26 # GitError(Code:ERROR, Class:SSL, Your Julia is built with a SSL/TLS engine that libgit2 doesn't know how to configure 27 # to use a file or directory of certificate authority roots, but your environment specifies one via the SSL_CERT_FILE 28 # variable. If you believe your system's root certificates are safe to use, you can `export JULIA_SSL_CA_ROOTS_PATH=""` 29 # in your environment to use those instead.) 30 setJuliaSslCaRootsPath = 31 if stdenv.targetPlatform.isDarwin then 32 ''export JULIA_SSL_CA_ROOTS_PATH=""'' 33 else 34 ''export JULIA_SSL_CA_ROOTS_PATH="${cacert}/etc/ssl/certs/ca-bundle.crt"''; 35 36in 37 38runCommand "julia-depot" 39 { 40 nativeBuildInputs = [ 41 curl 42 git 43 julia 44 (python3.withPackages (ps: with ps; [ pyyaml ])) 45 ] 46 ++ extraLibs; 47 inherit precompile project registry; 48 } 49 ( 50 '' 51 export HOME=$(pwd) 52 53 echo "Building Julia depot and project with the following inputs" 54 echo "Julia: ${julia}" 55 echo "Project: $project" 56 echo "Registry: $registry" 57 echo "Overrides ${overridesToml}" 58 59 mkdir -p $out/project 60 export JULIA_PROJECT="$out/project" 61 cp "$project/Manifest.toml" "$JULIA_PROJECT/Manifest.toml" 62 cp "$project/Project.toml" "$JULIA_PROJECT/Project.toml" 63 64 mkdir -p $out/depot/artifacts 65 export JULIA_DEPOT_PATH="$out/depot" 66 cp ${overridesToml} $out/depot/artifacts/Overrides.toml 67 68 # These can be useful to debug problems 69 # export JULIA_DEBUG=Pkg,loading 70 71 ${setJuliaSslCaRootsPath} 72 73 # Only precompile if configured to below 74 export JULIA_PKG_PRECOMPILE_AUTO=0 75 '' 76 + lib.optionalString (juliaCpuTarget != null) '' 77 export JULIA_CPU_TARGET="${juliaCpuTarget}" 78 '' 79 + '' 80 # Prevent a warning where Julia tries to download package server info 81 export JULIA_PKG_SERVER="" 82 83 # See if we need to add any extra package names based on the closure 84 # and the packageImplications. We're using the full closure YAML here since 85 # it's available, which is slightly weird, but it should work just as well 86 # for finding the extra packages we need to add 87 python ${./python}/find_package_implications.py "${closureYaml}" '${ 88 lib.generators.toJSON { } packageImplications 89 }' extra_package_names.txt 90 91 # Work around new git security features added in git 2.44.1 92 # See https://github.com/NixOS/nixpkgs/issues/315890 93 git config --global --add safe.directory '*' 94 95 # Tell Julia to use the Git binary we provide, rather than internal libgit2. 96 export JULIA_PKG_USE_CLI_GIT="true" 97 98 # At time of writing, this appears to be the only way to turn precompiling's 99 # terminal output into standard logging, so opportunistically do that. 100 # (Note this is different from JULIA_CI). 101 export CI=true 102 103 julia -e ' \ 104 import Pkg 105 import Pkg.Types: PRESERVE_NONE 106 107 Pkg.Registry.add(Pkg.RegistrySpec(path="${registry}")) 108 109 # No need to Pkg.activate() since we set JULIA_PROJECT above 110 println("Running Pkg.instantiate()") 111 Pkg.instantiate() 112 113 # Build is a separate step from instantiate. 114 # Needed for packages like Conda.jl to set themselves up. 115 println("Running Pkg.build()") 116 Pkg.build() 117 118 if "precompile" in keys(ENV) && ENV["precompile"] != "0" && ENV["precompile"] != "" 119 if isdefined(Sys, :CPU_NAME) 120 println("Precompiling with CPU_NAME = " * Sys.CPU_NAME) 121 end 122 123 Pkg.precompile() 124 end 125 126 # Remove the registry to save space 127 Pkg.Registry.rm("General") 128 ' 129 '' 130 )