forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#147136 from thiagokokada/add-build-graalvm-n…
…ative-image buildGraalvmNativeImage: init
- Loading branch information
Showing
7 changed files
with
102 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ lib, stdenv, graalvmCEPackages, glibcLocales }: | ||
|
||
{ name ? "${args.pname}-${args.version}" | ||
# Final executable name | ||
, 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 ? [ | ||
"-jar" jar | ||
"-H:CLibraryPath=${lib.getLib graalvm}/lib" | ||
(lib.optionalString stdenv.isDarwin "-H:-CheckToolchain") | ||
"-H:Name=${executable}" | ||
"--verbose" | ||
] | ||
# 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 | ||
, ... | ||
} @ args: | ||
|
||
stdenv.mkDerivation (args // { | ||
inherit dontUnpack; | ||
|
||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ graalvm glibcLocales ]; | ||
|
||
nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ]; | ||
|
||
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 | ||
''; | ||
|
||
meta.platforms = lib.attrByPath [ "meta" "platforms" ] graalvm.meta.platforms args; | ||
meta.mainProgram = lib.attrByPath [ "meta" "mainProgram" ] executable args; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters