|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + lib, |
| 4 | + callPackage, |
| 5 | + fetchFromGitHub, |
| 6 | + rustPlatform, |
| 7 | + cmake, |
| 8 | + protobuf, |
| 9 | + installShellFiles, |
| 10 | + libiconv, |
| 11 | + darwin, |
| 12 | + librusty_v8 ? callPackage ./librusty_v8.nix { |
| 13 | + inherit (callPackage ../fetchers.nix { }) fetchLibrustyV8; |
| 14 | + }, |
| 15 | +}: |
| 16 | +rustPlatform.buildRustPackage rec { |
| 17 | + pname = "deno"; |
| 18 | + version = "1.46.3"; |
| 19 | + |
| 20 | + src = fetchFromGitHub { |
| 21 | + owner = "denoland"; |
| 22 | + repo = "deno"; |
| 23 | + rev = "refs/tags/v${version}"; |
| 24 | + hash = "sha256-AM6SjcIHo6Koxcnznhkv3cXoKaMy2TEVpiWe/bczDuA="; |
| 25 | + }; |
| 26 | + |
| 27 | + cargoHash = "sha256-D+CZpb6OTzM5Il0k8GQB7qSONy4myE5yKlaSkLLqHT8="; |
| 28 | + |
| 29 | + postPatch = '' |
| 30 | + # upstream uses lld on aarch64-darwin for faster builds |
| 31 | + # within nix lld looks for CoreFoundation rather than CoreFoundation.tbd and fails |
| 32 | + substituteInPlace .cargo/config.toml --replace "-fuse-ld=lld " "" |
| 33 | + ''; |
| 34 | + |
| 35 | + # uses zlib-ng but can't dynamically link yet |
| 36 | + # https://github.com/rust-lang/libz-sys/issues/158 |
| 37 | + nativeBuildInputs = [ |
| 38 | + # required by libz-ng-sys crate |
| 39 | + cmake |
| 40 | + # required by deno_kv crate |
| 41 | + protobuf |
| 42 | + installShellFiles |
| 43 | + ]; |
| 44 | + buildInputs = lib.optionals stdenv.isDarwin ( |
| 45 | + [ |
| 46 | + libiconv |
| 47 | + darwin.libobjc |
| 48 | + ] |
| 49 | + ++ (with darwin.apple_sdk_11_0.frameworks; [ |
| 50 | + Security |
| 51 | + CoreServices |
| 52 | + Metal |
| 53 | + MetalPerformanceShaders |
| 54 | + Foundation |
| 55 | + QuartzCore |
| 56 | + ]) |
| 57 | + ); |
| 58 | + |
| 59 | + buildAndTestSubdir = "cli"; |
| 60 | + |
| 61 | + # work around "error: unknown warning group '-Wunused-but-set-parameter'" |
| 62 | + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unknown-warning-option"; |
| 63 | + # The v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem |
| 64 | + # To avoid this we pre-download the file and export it via RUSTY_V8_ARCHIVE |
| 65 | + env.RUSTY_V8_ARCHIVE = librusty_v8; |
| 66 | + |
| 67 | + # Tests have some inconsistencies between runs with output integration tests |
| 68 | + # Skipping until resolved |
| 69 | + doCheck = false; |
| 70 | + |
| 71 | + preInstall = '' |
| 72 | + find ./target -name libswc_common${stdenv.hostPlatform.extensions.sharedLibrary} -delete |
| 73 | + ''; |
| 74 | + |
| 75 | + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' |
| 76 | + installShellCompletion --cmd deno \ |
| 77 | + --bash <($out/bin/deno completions bash) \ |
| 78 | + --fish <($out/bin/deno completions fish) \ |
| 79 | + --zsh <($out/bin/deno completions zsh) |
| 80 | + ''; |
| 81 | + |
| 82 | + doInstallCheck = true; |
| 83 | + installCheckPhase = '' |
| 84 | + runHook preInstallCheck |
| 85 | + $out/bin/deno --help |
| 86 | + $out/bin/deno --version | grep "deno ${version}" |
| 87 | + runHook postInstallCheck |
| 88 | + ''; |
| 89 | + |
| 90 | + passthru.tests = callPackage ./tests { }; |
| 91 | + |
| 92 | + meta = with lib; { |
| 93 | + homepage = "https://deno.land/"; |
| 94 | + changelog = "https://github.com/denoland/deno/releases/tag/v${version}"; |
| 95 | + description = "Secure runtime for JavaScript and TypeScript"; |
| 96 | + longDescription = '' |
| 97 | + Deno aims to be a productive and secure scripting environment for the modern programmer. |
| 98 | + Deno will always be distributed as a single executable. |
| 99 | + Given a URL to a Deno program, it is runnable with nothing more than the ~15 megabyte zipped executable. |
| 100 | + Deno explicitly takes on the role of both runtime and package manager. |
| 101 | + It uses a standard browser-compatible protocol for loading modules: URLs. |
| 102 | + Among other things, Deno is a great replacement for utility scripts that may have been historically written with |
| 103 | + bash or python. |
| 104 | + ''; |
| 105 | + license = licenses.mit; |
| 106 | + mainProgram = "deno"; |
| 107 | + maintainers = with maintainers; [ jk ]; |
| 108 | + platforms = [ |
| 109 | + "x86_64-linux" |
| 110 | + "aarch64-linux" |
| 111 | + "x86_64-darwin" |
| 112 | + "aarch64-darwin" |
| 113 | + ]; |
| 114 | + # NOTE: `aligned_alloc` error on darwin SDK < 10.15. Can't do usual overrideSDK with rust toolchain in current implementation. |
| 115 | + # Should be fixed with darwin SDK refactor and can be revisited. |
| 116 | + badPlatforms = [ "x86_64-darwin" ]; |
| 117 | + }; |
| 118 | +} |
0 commit comments