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,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
glibcLocales,
|
glibcLocales,
|
||||||
# The GraalVM derivation to use
|
|
||||||
graalvmDrv,
|
|
||||||
removeReferencesTo,
|
removeReferencesTo,
|
||||||
executable ? args.pname,
|
graalvmPackages,
|
||||||
# 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:
|
|
||||||
|
|
||||||
let
|
lib.extendMkDerivation {
|
||||||
extraArgs = builtins.removeAttrs args [
|
constructDrv = stdenv.mkDerivation;
|
||||||
"lib"
|
|
||||||
"stdenv"
|
excludeDrvArgNames = [
|
||||||
"glibcLocales"
|
"executable"
|
||||||
"jar"
|
"extraNativeImageBuildArgs"
|
||||||
"dontUnpack"
|
"graalvmDrv"
|
||||||
"LC_ALL"
|
"graalvmXmx"
|
||||||
"meta"
|
"nativeImageBuildArgs"
|
||||||
"buildPhase"
|
|
||||||
"nativeBuildInputs"
|
|
||||||
"installPhase"
|
|
||||||
"postInstall"
|
|
||||||
];
|
];
|
||||||
in
|
|
||||||
stdenv.mkDerivation (
|
|
||||||
{
|
|
||||||
inherit dontUnpack jar;
|
|
||||||
|
|
||||||
env = { inherit LC_ALL; };
|
extendDrvArgs =
|
||||||
|
finalAttrs:
|
||||||
|
{
|
||||||
|
dontUnpack ? true,
|
||||||
|
strictDeps ? true,
|
||||||
|
__structuredAttrs ? true,
|
||||||
|
|
||||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
# The GraalVM derivation to use
|
||||||
graalvmDrv
|
graalvmDrv ? graalvmPackages.graalvm-ce,
|
||||||
glibcLocales
|
|
||||||
removeReferencesTo
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
|
executable ? finalAttrs.meta.mainProgram,
|
||||||
|
|
||||||
buildPhase =
|
# Default native-image arguments. You probably don't want to set this,
|
||||||
args.buildPhase or ''
|
# except in special cases. In most cases, use extraNativeBuildArgs instead
|
||||||
runHook preBuild
|
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 =
|
disallowedReferences = [ graalvmDrv ];
|
||||||
args.installPhase or ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
install -Dm755 ${executable} -t $out/bin
|
passthru = {
|
||||||
|
inherit graalvmDrv;
|
||||||
|
} // passthru;
|
||||||
|
|
||||||
runHook postInstall
|
meta = {
|
||||||
'';
|
# default to graalvm's platforms
|
||||||
|
inherit (graalvmDrv.meta) platforms;
|
||||||
postInstall = ''
|
} // meta;
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|||||||
@ -5747,10 +5747,7 @@ with pkgs;
|
|||||||
openjdk_headless = jdk_headless;
|
openjdk_headless = jdk_headless;
|
||||||
|
|
||||||
graalvmPackages = recurseIntoAttrs (callPackage ../development/compilers/graalvm { });
|
graalvmPackages = recurseIntoAttrs (callPackage ../development/compilers/graalvm { });
|
||||||
buildGraalvmNativeImage =
|
buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { };
|
||||||
(callPackage ../build-support/build-graalvm-native-image {
|
|
||||||
graalvmDrv = graalvmPackages.graalvm-ce;
|
|
||||||
}).override;
|
|
||||||
|
|
||||||
openshot-qt = libsForQt5.callPackage ../applications/video/openshot-qt { };
|
openshot-qt = libsForQt5.callPackage ../applications/video/openshot-qt { };
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user