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

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

99 lines
3.4 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, fetchurl
, unzip
, runCommand
, darwin
# we need a way to build other dart versions
# than the latest, because flutter might want
# another version
, version ? "2.19.3"
, sources ? let
base = "https://storage.googleapis.com/dart-archive/channels";
x86_64 = "x64";
i686 = "ia32";
aarch64 = "arm64";
in
{
2022-02-20 18:00:08 +00:00
"${version}-aarch64-darwin" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-macos-${aarch64}-release.zip";
2022-09-05 08:37:07 +01:00
sha256 = "sha256-wfUh6rXy8jAC0TVQJzXh4SrV2DQs9SvY8PGtNgZx+cA=";
2022-02-20 18:00:08 +00:00
};
"${version}-x86_64-darwin" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-macos-${x86_64}-release.zip";
2022-09-05 08:37:07 +01:00
sha256 = "sha256-zyu6r8akId/AHpBKH95wJXXu1LD9CKShWYKfppnSRx4=";
2020-11-26 07:49:08 +00:00
};
"${version}-x86_64-linux" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-linux-${x86_64}-release.zip";
2022-09-05 08:37:07 +01:00
sha256 = "sha256-45HE7Y9iO5dI+JfLWF1ikFfBFB+er46bK+EYkyuhFjI=";
2021-01-15 20:32:57 +00:00
};
"${version}-i686-linux" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-linux-${i686}-release.zip";
2022-09-05 08:37:07 +01:00
sha256 = "sha256-IkSJWfAocT1l8F2igAkR+Y5PNYD5PZ0j21D8aJk9JCY=";
2021-01-15 20:32:57 +00:00
};
"${version}-aarch64-linux" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-linux-${aarch64}-release.zip";
2022-09-05 08:37:07 +01:00
sha256 = "sha256-Bt18brbJA/XfiyP5o197HDXMuGm+a1AZx92Thoriv78=";
2020-10-07 03:54:12 +01:00
};
}
}:
2021-01-25 14:36:46 +00:00
assert version != null && version != "";
assert sources != null && (builtins.isAttrs sources);
stdenv.mkDerivation (finalAttrs: {
2019-08-13 22:52:01 +01:00
pname = "dart";
inherit version;
2016-06-03 09:10:13 +01:00
nativeBuildInputs = [ unzip ];
src = sources."${version}-${stdenv.hostPlatform.system}" or (throw "unsupported version/system: ${version}/${stdenv.hostPlatform.system}");
2016-06-03 09:10:13 +01:00
installPhase = ''
mkdir -p $out
cp -R * $out/
echo $libPath
2022-09-05 08:37:07 +01:00
'' + lib.optionalString (stdenv.isLinux) ''
find $out/bin -executable -type f -exec patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) {} \;
2016-06-03 09:10:13 +01:00
'';
libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
2013-04-17 15:35:40 +01:00
dontStrip = true;
passthru.tests = {
testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
PROJECTNAME="dart_test_project"
dart create --no-pub $PROJECTNAME
[[ -d $PROJECTNAME ]]
[[ -f $PROJECTNAME/bin/$PROJECTNAME.dart ]]
touch $out
'';
2018-05-01 19:51:03 +01:00
testCompile = runCommand "dart-test-compile" {
nativeBuildInputs = [ finalAttrs.finalPackage ]
++ lib.optionals stdenv.isDarwin [ darwin.cctools darwin.sigtool ];
} ''
HELLO_MESSAGE="Hello, world!"
echo "void main() => print('$HELLO_MESSAGE');" > hello.dart
dart compile exe hello.dart
PROGRAM_OUT=$(./hello.exe)
[[ "$PROGRAM_OUT" == "$HELLO_MESSAGE" ]]
touch $out
'';
};
meta = with lib; {
homepage = "https://www.dartlang.org/";
2022-10-04 21:35:30 +01:00
maintainers = with maintainers; [ grburst ];
2016-06-03 09:10:13 +01:00
description = "Scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps";
longDescription = ''
Dart is a class-based, single inheritance, object-oriented language
with C-style syntax. It offers compilation to JavaScript, interfaces,
mixins, abstract classes, reified generics, and optional typing.
'';
2022-02-20 18:00:08 +00:00
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.bsd3;
2016-06-03 09:10:13 +01:00
};
})