nixpkgs/pkgs/development/compilers/ballerina/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Nix
Raw Normal View History

2022-07-12 12:43:04 +00:00
{ ballerina, lib, writeText, runCommand, makeWrapper, fetchzip, stdenv, openjdk }:
2022-07-07 06:41:08 +00:00
let
2023-10-29 08:25:50 +00:00
version = "2201.8.2";
2022-07-07 06:41:08 +00:00
codeName = "swan-lake";
in stdenv.mkDerivation {
pname = "ballerina";
inherit version;
src = fetchzip {
url = "https://dist.ballerina.io/downloads/${version}/ballerina-${version}-${codeName}.zip";
2023-10-29 08:25:50 +00:00
hash = "sha256-vTrVcWo7fjcj9oZqIzvVTTynf4dSh5D7PAUYj3Vs8Gg=";
2022-07-07 06:41:08 +00:00
};
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
cp -rv distributions/ballerina-${version} $out
runHook postInstall
'';
preFixup = ''
2023-03-17 13:04:01 +00:00
wrapProgram $out/bin/bal --set JAVA_HOME ${openjdk}
2022-07-07 06:41:08 +00:00
'';
2022-07-12 12:43:04 +00:00
passthru.tests.smokeTest = let
helloWorld = writeText "hello-world.bal" ''
import ballerina/io;
public function main() {
io:println("Hello, World!");
}
'';
in runCommand "ballerina-${version}-smoketest" { } ''
${ballerina}/bin/bal run ${helloWorld} >$out
read result <$out
[[ $result = "Hello, World!" ]]
'';
2022-07-07 06:41:08 +00:00
meta = with lib; {
description = "An open-source programming language for the cloud";
license = licenses.asl20;
platforms = openjdk.meta.platforms;
maintainers = with maintainers; [ eigengrau ];
sourceProvenance = with sourceTypes; [ binaryBytecode ];
};
}