1{ stdenv
2, lib
3, fetchurl
4, unzip
5, runCommand
6, cctools
7, darwin
8, sources ? import ./sources.nix {inherit fetchurl;}
9, version ? sources.versionUsed
10}:
11
12assert sources != null && (builtins.isAttrs sources);
13stdenv.mkDerivation (finalAttrs: {
14 pname = "dart";
15 inherit version;
16
17 nativeBuildInputs = [ unzip ];
18
19 src = sources."${version}-${stdenv.hostPlatform.system}" or (throw "unsupported version/system: ${version}/${stdenv.hostPlatform.system}");
20
21 installPhase = ''
22 mkdir -p $out
23 cp -R * $out/
24 echo $libPath
25 '' + lib.optionalString (stdenv.isLinux) ''
26 find $out/bin -executable -type f -exec patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) {} \;
27 '';
28
29 libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
30 dontStrip = true;
31 passthru = {
32 updateScript = ./update.sh;
33 tests = {
34 testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
35 PROJECTNAME="dart_test_project"
36 dart create --no-pub $PROJECTNAME
37
38 [[ -d $PROJECTNAME ]]
39 [[ -f $PROJECTNAME/bin/$PROJECTNAME.dart ]]
40 touch $out
41 '';
42
43 testCompile = runCommand "dart-test-compile" {
44 nativeBuildInputs = [ finalAttrs.finalPackage ]
45 ++ lib.optionals stdenv.isDarwin [ cctools darwin.sigtool ];
46 } ''
47 HELLO_MESSAGE="Hello, world!"
48 echo "void main() => print('$HELLO_MESSAGE');" > hello.dart
49 dart compile exe hello.dart
50 PROGRAM_OUT=$(./hello.exe)
51
52 [[ "$PROGRAM_OUT" == "$HELLO_MESSAGE" ]]
53 touch $out
54 '';
55 };
56 };
57
58 meta = with lib; {
59 homepage = "https://dart.dev";
60 maintainers = with maintainers; [ grburst ];
61 description = "Scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps";
62 longDescription = ''
63 Dart is a class-based, single inheritance, object-oriented language
64 with C-style syntax. It offers compilation to JavaScript, interfaces,
65 mixins, abstract classes, reified generics, and optional typing.
66 '';
67 platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
68 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
69 license = licenses.bsd3;
70 };
71})