nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 unzip,
6 bintools,
7 versionCheckHook,
8 runCommand,
9 cctools,
10 darwin,
11 sources ? import ./sources.nix { inherit fetchurl; },
12 version ? sources.versionUsed,
13}:
14
15assert sources != null && (builtins.isAttrs sources);
16stdenv.mkDerivation (finalAttrs: {
17 pname = "dart";
18 inherit version;
19
20 nativeBuildInputs = [ unzip ];
21
22 src =
23 sources."${version}-${stdenv.hostPlatform.system}"
24 or (throw "unsupported version/system: ${version}/${stdenv.hostPlatform.system}");
25
26 installPhase = ''
27 runHook preInstall
28
29 rm LICENSE
30 cp -R . $out
31 ''
32 + lib.optionalString (stdenv.hostPlatform.isLinux) ''
33 find $out/bin -executable -type f -exec patchelf --set-interpreter ${bintools.dynamicLinker} {} \;
34 ''
35 + ''
36 runHook postInstall
37 '';
38
39 dontStrip = true;
40
41 doInstallCheck = true;
42
43 nativeInstallCheckInputs = [ versionCheckHook ];
44
45 passthru = {
46 fetchGitHashesScript = ./fetch-git-hashes.py;
47 updateScript = ./update.sh;
48 tests = {
49 testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
50 PROJECTNAME="dart_test_project"
51 dart create --no-pub $PROJECTNAME
52
53 [[ -d $PROJECTNAME ]]
54 [[ -f $PROJECTNAME/bin/$PROJECTNAME.dart ]]
55 touch $out
56 '';
57
58 testCompile =
59 runCommand "dart-test-compile"
60 {
61 nativeBuildInputs = [
62 finalAttrs.finalPackage
63 ]
64 ++ lib.optionals stdenv.hostPlatform.isDarwin [
65 cctools
66 darwin.sigtool
67 ];
68 }
69 ''
70 HELLO_MESSAGE="Hello, world!"
71 echo "void main() => print('$HELLO_MESSAGE');" > hello.dart
72 dart compile exe hello.dart
73 PROGRAM_OUT=$(./hello.exe)
74
75 [[ "$PROGRAM_OUT" == "$HELLO_MESSAGE" ]]
76 touch $out
77 '';
78 };
79 };
80
81 meta = {
82 homepage = "https://dart.dev";
83 maintainers = [ ];
84 description = "Scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps";
85 longDescription = ''
86 Dart is a class-based, single inheritance, object-oriented language
87 with C-style syntax. It offers compilation to JavaScript, interfaces,
88 mixins, abstract classes, reified generics, and optional typing.
89 '';
90 mainProgram = "dart";
91 platforms = [
92 "x86_64-linux"
93 "aarch64-linux"
94 "x86_64-darwin"
95 "aarch64-darwin"
96 ];
97 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
98 license = lib.licenses.bsd3;
99 teams = [ lib.teams.flutter ];
100 };
101})