nixpkgs/pkgs/development/julia-modules/package-closure.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

88 lines
2.2 KiB
Nix

{
lib,
julia,
python3,
runCommand,
augmentedRegistry,
packageNames,
packageOverrides,
packageImplications,
}:
let
juliaExpression = packageNames: ''
import Pkg
Pkg.Registry.add(Pkg.RegistrySpec(path="${augmentedRegistry}"))
import Pkg.Types: Context, PackageSpec
input = ${lib.generators.toJSON { } packageNames}
if isfile("extra_package_names.txt")
append!(input, readlines("extra_package_names.txt"))
end
input = unique(input)
println("Resolving packages: " * join(input, " "))
pkgs = [PackageSpec(pkg) for pkg in input]
ctx = Context()
overrides = Dict{String, String}(${
builtins.concatStringsSep ", " (
lib.mapAttrsToList (name: path: ''"${name}" => "${path}"'') packageOverrides
)
})
${builtins.readFile ./resolve_packages.jl}
open(ENV["out"], "w") do io
for spec in pkgs
println(io, "- name: " * spec.name)
println(io, " uuid: " * string(spec.uuid))
println(io, " version: " * string(spec.version))
if endswith(spec.name, "_jll") && haskey(deps_map, spec.uuid)
println(io, " depends_on: ")
for (dep_name, dep_uuid) in pairs(deps_map[spec.uuid])
println(io, " \"$(dep_name)\": \"$(dep_uuid)\"")
end
end
end
end
'';
in
runCommand "julia-package-closure.yml"
{
buildInputs = [
julia
(python3.withPackages (ps: with ps; [ pyyaml ]))
];
}
''
mkdir home
export HOME=$(pwd)/home
echo "Resolving Julia packages with the following inputs"
echo "Julia: ${julia}"
echo "Registry: ${augmentedRegistry}"
# Prevent a warning where Julia tries to download package server info
export JULIA_PKG_SERVER=""
julia -e '${juliaExpression packageNames}';
# See if we need to add any extra package names based on the closure
# and the packageImplications
python ${./python}/find_package_implications.py "$out" '${
lib.generators.toJSON { } packageImplications
}' extra_package_names.txt
if [ -f extra_package_names.txt ]; then
echo "Re-resolving with additional package names"
julia -e '${juliaExpression packageNames}';
fi
''