4 # The GraalVM derivation to use
7 , executable ? args.pname
8 # JAR used as input for GraalVM derivation, defaults to src
10 , dontUnpack ? (jar == args.src)
11 # Default native-image arguments. You probably don't want to set this,
12 # except in special cases. In most cases, use extraNativeBuildArgs instead
13 , nativeImageBuildArgs ? [
14 (lib.optionalString stdenv.hostPlatform.isDarwin "-H:-CheckToolchain")
15 (lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) "-H:PageSize=64K")
16 "-H:Name=${executable}"
17 "-march=compatibility"
20 # Extra arguments to be passed to the native-image
21 , extraNativeImageBuildArgs ? [ ]
22 # XMX size of GraalVM during build
23 , graalvmXmx ? "-J-Xmx6g"
25 , LC_ALL ? "en_US.UTF-8"
30 extraArgs = builtins.removeAttrs args [
44 stdenv.mkDerivation ({
45 inherit dontUnpack jar;
47 env = { inherit LC_ALL; };
49 nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ graalvmDrv glibcLocales removeReferencesTo ];
51 nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
53 buildPhase = args.buildPhase or ''
56 native-image -jar "$jar" ''${nativeImageBuildArgs[@]}
61 installPhase = args.installPhase or ''
64 install -Dm755 ${executable} -t $out/bin
70 remove-references-to -t ${graalvmDrv} $out/bin/${executable}
71 ${args.postInstall or ""}
74 disallowedReferences = [ graalvmDrv ];
76 passthru = { inherit graalvmDrv; };
79 # default to graalvm's platforms
80 platforms = graalvmDrv.meta.platforms;
81 # default to executable name
82 mainProgram = executable;