julia.withPackages: fix artifact fixupPhase on darwin
This commit is contained in:
@@ -134,11 +134,16 @@ let
|
||||
"${juliaWrapped}/bin/julia" \
|
||||
"${if lib.versionAtLeast julia.version "1.7" then ./extract_artifacts.jl else ./extract_artifacts_16.jl}" \
|
||||
'${lib.generators.toJSON {} (import ./extra-libs.nix)}' \
|
||||
'${lib.generators.toJSON {} (stdenv.hostPlatform.isDarwin)}' \
|
||||
"$out"
|
||||
'';
|
||||
|
||||
# Import the artifacts Nix to build Overrides.toml (IFD)
|
||||
artifacts = import artifactsNix { inherit lib fetchurl pkgs glibc stdenv; };
|
||||
artifacts = import artifactsNix ({
|
||||
inherit lib fetchurl pkgs stdenv;
|
||||
} // lib.optionalAttrs (!stdenv.targetPlatform.isDarwin) {
|
||||
inherit glibc;
|
||||
});
|
||||
overridesJson = writeTextFile {
|
||||
name = "Overrides.json";
|
||||
text = lib.generators.toJSON {} artifacts;
|
||||
|
||||
@@ -32,22 +32,30 @@ archive_extensions = [
|
||||
".zip"
|
||||
]
|
||||
|
||||
def get_archive_derivation(uuid, artifact_name, url, sha256, closure_dependencies_dag, dependency_uuids, extra_libs):
|
||||
def get_archive_derivation(uuid, artifact_name, url, sha256, closure_dependencies_dag, dependency_uuids, extra_libs, is_darwin):
|
||||
depends_on = set()
|
||||
if closure_dependencies_dag.has_node(uuid):
|
||||
depends_on = set(closure_dependencies_dag.get_dependencies(uuid)).intersection(dependency_uuids)
|
||||
|
||||
other_libs = extra_libs.get(uuid, [])
|
||||
|
||||
fixup = f"""fixupPhase = let
|
||||
libs = lib.concatMap (lib.mapAttrsToList (k: v: v.path))
|
||||
if is_darwin:
|
||||
fixup = f"""fixupPhase = let
|
||||
libs = lib.concatMap (lib.mapAttrsToList (k: v: v.path))
|
||||
[{" ".join(["uuid-" + x for x in depends_on])}];
|
||||
in ''
|
||||
find $out -type f -executable -exec \
|
||||
patchelf --set-rpath \$ORIGIN:\$ORIGIN/../lib:${{lib.makeLibraryPath (["$out" glibc] ++ libs ++ (with pkgs; [{" ".join(other_libs)}]))}} {{}} \;
|
||||
find $out -type f -executable -exec \
|
||||
patchelf --set-interpreter ${{glibc}}/lib/ld-linux-x86-64.so.2 {{}} \;
|
||||
''"""
|
||||
in ''
|
||||
|
||||
''"""
|
||||
else:
|
||||
fixup = f"""fixupPhase = let
|
||||
libs = lib.concatMap (lib.mapAttrsToList (k: v: v.path))
|
||||
[{" ".join(["uuid-" + x for x in depends_on])}];
|
||||
in ''
|
||||
find $out -type f -executable -exec \
|
||||
patchelf --set-rpath \$ORIGIN:\$ORIGIN/../lib:${{lib.makeLibraryPath (["$out" glibc] ++ libs ++ (with pkgs; [{" ".join(other_libs)}]))}} {{}} \;
|
||||
find $out -type f -executable -exec \
|
||||
patchelf --set-interpreter ${{glibc}}/lib/ld-linux-x86-64.so.2 {{}} \;
|
||||
''"""
|
||||
|
||||
return f"""stdenv.mkDerivation {{
|
||||
name = "{artifact_name}";
|
||||
@@ -73,7 +81,7 @@ def get_plain_derivation(url, sha256):
|
||||
}}"""
|
||||
|
||||
def process_item(args):
|
||||
item, julia_path, extract_artifacts_script, closure_dependencies_dag, dependency_uuids, extra_libs = args
|
||||
item, julia_path, extract_artifacts_script, closure_dependencies_dag, dependency_uuids, extra_libs, is_darwin = args
|
||||
uuid, src = item
|
||||
lines = []
|
||||
|
||||
@@ -94,7 +102,7 @@ def process_item(args):
|
||||
|
||||
parsed_url = urlparse(url)
|
||||
if any(parsed_url.path.endswith(x) for x in archive_extensions):
|
||||
derivation = get_archive_derivation(uuid, artifact_name, url, sha256, closure_dependencies_dag, dependency_uuids, extra_libs)
|
||||
derivation = get_archive_derivation(uuid, artifact_name, url, sha256, closure_dependencies_dag, dependency_uuids, extra_libs, is_darwin)
|
||||
else:
|
||||
derivation = get_plain_derivation(url, sha256)
|
||||
|
||||
@@ -113,7 +121,8 @@ def main():
|
||||
julia_path = Path(sys.argv[3])
|
||||
extract_artifacts_script = Path(sys.argv[4])
|
||||
extra_libs = json.loads(sys.argv[5])
|
||||
out_path = Path(sys.argv[6])
|
||||
is_darwin = json.loads(sys.argv[6])
|
||||
out_path = Path(sys.argv[7])
|
||||
|
||||
with open(dependencies_path, "r") as f:
|
||||
dependencies = yaml.safe_load(f)
|
||||
@@ -133,13 +142,17 @@ def main():
|
||||
closure_dependencies_dag.add_node(uuid, dependencies=contents["depends_on"].values())
|
||||
|
||||
with open(out_path, "w") as f:
|
||||
f.write("{ lib, fetchurl, glibc, pkgs, stdenv }:\n\n")
|
||||
if is_darwin:
|
||||
f.write("{ lib, fetchurl, pkgs, stdenv }:\n\n")
|
||||
else:
|
||||
f.write("{ lib, fetchurl, glibc, pkgs, stdenv }:\n\n")
|
||||
|
||||
f.write("rec {\n")
|
||||
|
||||
with multiprocessing.Pool(10) as pool:
|
||||
# Create args tuples for each item
|
||||
process_args = [
|
||||
(item, julia_path, extract_artifacts_script, closure_dependencies_dag, dependency_uuids, extra_libs)
|
||||
(item, julia_path, extract_artifacts_script, closure_dependencies_dag, dependency_uuids, extra_libs, is_darwin)
|
||||
for item in dependencies.items()
|
||||
]
|
||||
for s in pool.map(process_item, process_args):
|
||||
|
||||
Reference in New Issue
Block a user