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