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