mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-01 19:33:03 +00:00
43 lines
809 B
Nix
43 lines
809 B
Nix
{ jdk
|
|
, jre
|
|
, pkgs
|
|
}:
|
|
|
|
/* 'Hello world' Java application derivation for use in tests */
|
|
let
|
|
source = pkgs.writeTextDir "src/Hello.java" ''
|
|
class Hello {
|
|
public static void main(String[] args) {
|
|
System.out.println("Hello, world!");
|
|
}
|
|
}
|
|
'';
|
|
in
|
|
pkgs.stdenv.mkDerivation {
|
|
pname = "hello";
|
|
version = "1.0.0";
|
|
|
|
src = source;
|
|
|
|
buildPhase = ''
|
|
runHook preBuildPhase
|
|
${jdk}/bin/javac src/Hello.java
|
|
runHook postBuildPhase
|
|
'';
|
|
installPhase = ''
|
|
runHook preInstallPhase
|
|
|
|
mkdir -p $out/lib
|
|
cp src/Hello.class $out/lib
|
|
|
|
mkdir -p $out/bin
|
|
cat >$out/bin/hello <<EOF;
|
|
#!/usr/bin/env sh
|
|
${jre}/bin/java -cp $out/lib Hello
|
|
EOF
|
|
chmod a+x $out/bin/hello
|
|
|
|
runHook postInstallPhase
|
|
'';
|
|
}
|