buildGraalvmNativeImage: use lib.extendMkDerivation
Co-authored-by: Philip Taron <philip.taron@gmail.com>
This commit is contained in:
parent
de57db2293
commit
4d134f63fd
@ -2,95 +2,107 @@
|
||||
lib,
|
||||
stdenv,
|
||||
glibcLocales,
|
||||
# The GraalVM derivation to use
|
||||
graalvmDrv,
|
||||
removeReferencesTo,
|
||||
executable ? args.pname,
|
||||
# JAR used as input for GraalVM derivation, defaults to src
|
||||
jar ? args.src,
|
||||
dontUnpack ? (jar == args.src),
|
||||
# Default native-image arguments. You probably don't want to set this,
|
||||
# except in special cases. In most cases, use extraNativeBuildArgs instead
|
||||
nativeImageBuildArgs ? [
|
||||
(lib.optionalString stdenv.hostPlatform.isDarwin "-H:-CheckToolchain")
|
||||
(lib.optionalString (
|
||||
stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64
|
||||
) "-H:PageSize=64K")
|
||||
"-H:Name=${executable}"
|
||||
"-march=compatibility"
|
||||
"--verbose"
|
||||
],
|
||||
# Extra arguments to be passed to the native-image
|
||||
extraNativeImageBuildArgs ? [ ],
|
||||
# XMX size of GraalVM during build
|
||||
graalvmXmx ? "-J-Xmx6g",
|
||||
meta ? { },
|
||||
LC_ALL ? "en_US.UTF-8",
|
||||
...
|
||||
}@args:
|
||||
graalvmPackages,
|
||||
}:
|
||||
|
||||
let
|
||||
extraArgs = builtins.removeAttrs args [
|
||||
"lib"
|
||||
"stdenv"
|
||||
"glibcLocales"
|
||||
"jar"
|
||||
"dontUnpack"
|
||||
"LC_ALL"
|
||||
"meta"
|
||||
"buildPhase"
|
||||
"nativeBuildInputs"
|
||||
"installPhase"
|
||||
"postInstall"
|
||||
lib.extendMkDerivation {
|
||||
constructDrv = stdenv.mkDerivation;
|
||||
|
||||
excludeDrvArgNames = [
|
||||
"executable"
|
||||
"extraNativeImageBuildArgs"
|
||||
"graalvmDrv"
|
||||
"graalvmXmx"
|
||||
"nativeImageBuildArgs"
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation (
|
||||
{
|
||||
inherit dontUnpack jar;
|
||||
|
||||
env = { inherit LC_ALL; };
|
||||
extendDrvArgs =
|
||||
finalAttrs:
|
||||
{
|
||||
dontUnpack ? true,
|
||||
strictDeps ? true,
|
||||
__structuredAttrs ? true,
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
||||
graalvmDrv
|
||||
glibcLocales
|
||||
removeReferencesTo
|
||||
];
|
||||
# The GraalVM derivation to use
|
||||
graalvmDrv ? graalvmPackages.graalvm-ce,
|
||||
|
||||
nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
|
||||
executable ? finalAttrs.meta.mainProgram,
|
||||
|
||||
buildPhase =
|
||||
args.buildPhase or ''
|
||||
runHook preBuild
|
||||
# Default native-image arguments. You probably don't want to set this,
|
||||
# except in special cases. In most cases, use extraNativeBuildArgs instead
|
||||
nativeImageBuildArgs ? [
|
||||
(lib.optionalString stdenv.hostPlatform.isDarwin "-H:-CheckToolchain")
|
||||
(lib.optionalString (
|
||||
stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64
|
||||
) "-H:PageSize=64K")
|
||||
"-H:Name=${executable}"
|
||||
"-march=compatibility"
|
||||
"--verbose"
|
||||
],
|
||||
|
||||
native-image -jar "$jar" ''${nativeImageBuildArgs[@]}
|
||||
# Extra arguments to be passed to the native-image
|
||||
extraNativeImageBuildArgs ? [ ],
|
||||
|
||||
runHook postBuild
|
||||
# XMX size of GraalVM during build
|
||||
graalvmXmx ? "-J-Xmx6g",
|
||||
|
||||
env ? { },
|
||||
meta ? { },
|
||||
passthru ? { },
|
||||
...
|
||||
}@args:
|
||||
{
|
||||
env = {
|
||||
LC_ALL = "en_US.UTF-8";
|
||||
} // env;
|
||||
|
||||
inherit dontUnpack strictDeps __structuredAttrs;
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
||||
graalvmDrv
|
||||
glibcLocales
|
||||
removeReferencesTo
|
||||
];
|
||||
|
||||
# `nativeBuildInputs` does not allow `graalvmDrv`'s propagatedBuildInput to reach here this package.
|
||||
# As its `propagatedBuildInputs` is required for the build process with `native-image`, we must add it here as well.
|
||||
buildInputs = [ graalvmDrv ];
|
||||
|
||||
nativeImageArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
|
||||
|
||||
buildPhase =
|
||||
args.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
native-image -jar "$src" ''${nativeImageArgs[@]}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase =
|
||||
args.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 ${executable} -t $out/bin
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
remove-references-to -t ${graalvmDrv} $out/bin/${executable}
|
||||
${args.postInstall or ""}
|
||||
'';
|
||||
|
||||
installPhase =
|
||||
args.installPhase or ''
|
||||
runHook preInstall
|
||||
disallowedReferences = [ graalvmDrv ];
|
||||
|
||||
install -Dm755 ${executable} -t $out/bin
|
||||
passthru = {
|
||||
inherit graalvmDrv;
|
||||
} // passthru;
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
remove-references-to -t ${graalvmDrv} $out/bin/${executable}
|
||||
${args.postInstall or ""}
|
||||
'';
|
||||
|
||||
disallowedReferences = [ graalvmDrv ];
|
||||
|
||||
passthru = { inherit graalvmDrv; };
|
||||
|
||||
meta = {
|
||||
# default to graalvm's platforms
|
||||
platforms = graalvmDrv.meta.platforms;
|
||||
# default to executable name
|
||||
mainProgram = executable;
|
||||
} // meta;
|
||||
}
|
||||
// extraArgs
|
||||
)
|
||||
meta = {
|
||||
# default to graalvm's platforms
|
||||
inherit (graalvmDrv.meta) platforms;
|
||||
} // meta;
|
||||
};
|
||||
}
|
||||
|
@ -5747,10 +5747,7 @@ with pkgs;
|
||||
openjdk_headless = jdk_headless;
|
||||
|
||||
graalvmPackages = recurseIntoAttrs (callPackage ../development/compilers/graalvm { });
|
||||
buildGraalvmNativeImage =
|
||||
(callPackage ../build-support/build-graalvm-native-image {
|
||||
graalvmDrv = graalvmPackages.graalvm-ce;
|
||||
}).override;
|
||||
buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { };
|
||||
|
||||
openshot-qt = libsForQt5.callPackage ../applications/video/openshot-qt { };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user