2021-11-23 14:56:37 +00:00
|
|
|
{ lib, stdenv, graalvmCEPackages, glibcLocales }:
|
|
|
|
|
|
|
|
{ name ? "${args.pname}-${args.version}"
|
|
|
|
# Final executable name
|
2021-11-23 15:35:55 +00:00
|
|
|
, executable ? args.pname
|
2021-11-23 14:56:37 +00:00
|
|
|
# JAR used as input for GraalVM derivation, defaults to src
|
|
|
|
, jar ? args.src
|
|
|
|
, dontUnpack ? (jar == args.src)
|
2021-11-23 20:36:57 +00:00
|
|
|
# Default native-image arguments. You probably don't want to set this,
|
|
|
|
# except in special cases. In most cases, use extraNativeBuildArgs instead
|
|
|
|
, nativeImageBuildArgs ? [
|
|
|
|
"-jar" jar
|
|
|
|
"-H:CLibraryPath=${lib.getLib graalvm}/lib"
|
|
|
|
(lib.optionalString stdenv.isDarwin "-H:-CheckToolchain")
|
|
|
|
"-H:Name=${executable}"
|
|
|
|
"--verbose"
|
|
|
|
]
|
2021-11-23 14:56:37 +00:00
|
|
|
# Extra arguments to be passed to the native-image
|
|
|
|
, extraNativeImageBuildArgs ? [ ]
|
|
|
|
# XMX size of GraalVM during build
|
|
|
|
, graalvmXmx ? "-J-Xmx6g"
|
|
|
|
# The GraalVM to use
|
|
|
|
, graalvm ? graalvmCEPackages.graalvm11-ce
|
2021-12-27 22:49:52 +00:00
|
|
|
, meta ? { }
|
2021-11-23 14:56:37 +00:00
|
|
|
, ...
|
|
|
|
} @ args:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (args // {
|
|
|
|
inherit dontUnpack;
|
|
|
|
|
|
|
|
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ graalvm glibcLocales ];
|
|
|
|
|
2021-11-23 20:36:57 +00:00
|
|
|
nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
|
2021-11-23 14:56:37 +00:00
|
|
|
|
|
|
|
buildPhase = args.buildPhase or ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
native-image ''${nativeImageBuildArgs[@]}
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = args.installPhase or ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
install -Dm755 ${executable} -t $out/bin
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-12-27 22:49:52 +00:00
|
|
|
meta = {
|
|
|
|
# default to graalvm's platforms
|
|
|
|
platforms = graalvm.meta.platforms;
|
|
|
|
# default to executable name
|
|
|
|
mainProgram = executable;
|
|
|
|
} // meta;
|
2021-11-23 14:56:37 +00:00
|
|
|
})
|