nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 println(io, " tree_hash: " * string(spec.tree_hash))
47 if endswith(spec.name, "_jll") && haskey(deps_map, spec.uuid)
48 println(io, " depends_on: ")
49 for (dep_name, dep_uuid) in pairs(deps_map[spec.uuid])
50 println(io, " \"$(dep_name)\": \"$(dep_uuid)\"")
51 end
52 end
53 println(io, " deps: ")
54 for (dep_name, dep_uuid) in pairs(deps_map[spec.uuid])
55 println(io, " - name: \"$(dep_name)\"")
56 println(io, " uuid: \"$(dep_uuid)\"")
57 end
58 if spec.name in input
59 println(io, " is_input: true")
60 end
61 end
62 end
63 '';
64in
65
66runCommand "julia-package-closure.yml"
67 {
68 buildInputs = [
69 julia
70 (python3.withPackages (ps: with ps; [ pyyaml ]))
71 ];
72 }
73 ''
74 mkdir home
75 export HOME=$(pwd)/home
76
77 echo "Resolving Julia packages with the following inputs"
78 echo "Julia: ${julia}"
79 echo "Registry: ${augmentedRegistry}"
80
81 # Prevent a warning where Julia tries to download package server info
82 export JULIA_PKG_SERVER=""
83
84 julia -e '${juliaExpression packageNames}';
85
86 # See if we need to add any extra package names based on the closure
87 # and the packageImplications
88 python ${./python}/find_package_implications.py "$out" '${
89 lib.generators.toJSON { } packageImplications
90 }' extra_package_names.txt
91
92 if [ -f extra_package_names.txt ]; then
93 echo "Re-resolving with additional package names"
94 julia -e '${juliaExpression packageNames}';
95 fi
96 ''