Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 julia, 4 python3, 5 runCommand, 6 7 augmentedRegistry, 8 packageNames, 9 packageOverrides, 10 packageImplications, 11}: 12 13let 14 juliaExpression = packageNames: '' 15 import Pkg 16 Pkg.Registry.add(Pkg.RegistrySpec(path="${augmentedRegistry}")) 17 18 import Pkg.Types: Context, PackageSpec 19 20 input = ${lib.generators.toJSON { } packageNames} 21 22 if isfile("extra_package_names.txt") 23 append!(input, readlines("extra_package_names.txt")) 24 end 25 26 input = unique(input) 27 28 println("Resolving packages: " * join(input, " ")) 29 30 pkgs = [PackageSpec(pkg) for pkg in input] 31 32 ctx = Context() 33 34 overrides = Dict{String, String}(${ 35 builtins.concatStringsSep ", " ( 36 lib.mapAttrsToList (name: path: ''"${name}" => "${path}"'') packageOverrides 37 ) 38 }) 39 ${builtins.readFile ./resolve_packages.jl} 40 41 open(ENV["out"], "w") do io 42 for spec in pkgs 43 println(io, "- name: " * spec.name) 44 println(io, " uuid: " * string(spec.uuid)) 45 println(io, " version: " * string(spec.version)) 46 if endswith(spec.name, "_jll") && haskey(deps_map, spec.uuid) 47 println(io, " depends_on: ") 48 for (dep_name, dep_uuid) in pairs(deps_map[spec.uuid]) 49 println(io, " \"$(dep_name)\": \"$(dep_uuid)\"") 50 end 51 end 52 end 53 end 54 ''; 55in 56 57runCommand "julia-package-closure.yml" 58 { 59 buildInputs = [ 60 julia 61 (python3.withPackages (ps: with ps; [ pyyaml ])) 62 ]; 63 } 64 '' 65 mkdir home 66 export HOME=$(pwd)/home 67 68 echo "Resolving Julia packages with the following inputs" 69 echo "Julia: ${julia}" 70 echo "Registry: ${augmentedRegistry}" 71 72 # Prevent a warning where Julia tries to download package server info 73 export JULIA_PKG_SERVER="" 74 75 julia -e '${juliaExpression packageNames}'; 76 77 # See if we need to add any extra package names based on the closure 78 # and the packageImplications 79 python ${./python}/find_package_implications.py "$out" '${ 80 lib.generators.toJSON { } packageImplications 81 }' extra_package_names.txt 82 83 if [ -f extra_package_names.txt ]; then 84 echo "Re-resolving with additional package names" 85 julia -e '${juliaExpression packageNames}'; 86 fi 87 ''