2021-01-15 20:22:01 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, unzip
|
2023-03-16 12:25:34 +00:00
|
|
|
, runCommand
|
|
|
|
, darwin
|
|
|
|
# we need a way to build other dart versions
|
|
|
|
# than the latest, because flutter might want
|
|
|
|
# another version
|
|
|
|
, version ? "2.19.3"
|
2021-06-16 02:42:30 +01:00
|
|
|
, sources ? let
|
2018-02-18 12:10:51 +00:00
|
|
|
base = "https://storage.googleapis.com/dart-archive/channels";
|
2020-02-27 12:21:35 +00:00
|
|
|
x86_64 = "x64";
|
|
|
|
i686 = "ia32";
|
|
|
|
aarch64 = "arm64";
|
2023-03-16 12:25:34 +00:00
|
|
|
in
|
2021-01-15 20:22:01 +00:00
|
|
|
{
|
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
|
|
|
};
|
2021-01-15 20:22:01 +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
|
|
|
};
|
2021-01-15 20:22:01 +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-15 20:22:01 +00:00
|
|
|
}
|
|
|
|
}:
|
2020-02-27 12:21:35 +00:00
|
|
|
|
2021-01-25 14:36:46 +00:00
|
|
|
assert version != null && version != "";
|
|
|
|
assert sources != null && (builtins.isAttrs sources);
|
|
|
|
|
2023-03-16 12:25:34 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "dart";
|
|
|
|
inherit version;
|
2016-06-03 09:10:13 +01:00
|
|
|
|
2021-06-16 02:42:30 +01:00
|
|
|
nativeBuildInputs = [ unzip ];
|
2018-02-18 12:10:51 +00:00
|
|
|
|
2018-08-20 20:11:29 +01:00
|
|
|
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) ''
|
2020-09-17 19:33:17 +01:00
|
|
|
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
|
|
|
'';
|
|
|
|
|
2021-01-15 20:22:01 +00:00
|
|
|
libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
|
2013-04-17 15:35:40 +01:00
|
|
|
dontStrip = true;
|
2023-03-16 12:25:34 +00:00
|
|
|
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
|
|
|
|
2023-03-16 12:25:34 +00: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
|
|
|
|
'';
|
|
|
|
};
|
2021-01-15 20:22:01 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
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" ];
|
2022-10-15 16:07:45 +01:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2020-02-27 12:21:35 +00:00
|
|
|
license = licenses.bsd3;
|
2016-06-03 09:10:13 +01:00
|
|
|
};
|
2023-03-16 12:25:34 +00:00
|
|
|
})
|