summaryrefslogtreecommitdiff
path: root/workerd.nix
blob: 401d544fdf447a7b849be2a6cd7d23ccbc67474e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  lib,
  stdenvNoCC,
  fetchurl,
  autoPatchelfHook,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "workerd";
  version = "1.20240423.0";

  src = let
    baseUrl = "https://github.com/cloudflare/workerd/releases/download/v${finalAttrs.version}";
  in
    fetchurl
    {
      x86_64-linux = {
        url = "${baseUrl}/workerd-linux-64.gz";
        hash = "sha256-gXqTFp+u9j+nOtwfowEUUk1QaxrhyqO8fFzZFGchAvk=";
      };

      aarch64-linux = {
        url = "${baseUrl}/workerd-linux-arm64.gz";
        hash = "sha256-6IynAN/xp8hieeMEuYbrv9X6edoTzKYZqCOcTPUy12o=";
      };
    }
    .${stdenvNoCC.hostPlatform.system}
    or (throw "${stdenvNoCC.hostPlatform.system} is not supported!");

  nativeBuildInputs = [autoPatchelfHook];

  dontConfigure = true;
  dontBuild = true;
  doCheck = false;

  unpackCmd = ''
    runHook preUnpack

    dest="$(stripHash $curSrc)"
    cp "$curSrc" "$dest"
    gzip -d "$dest"
    mkdir source
    mv ''${dest/.gz/} source/

    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 workerd-* $out/bin/workerd

    runHook postInstall
  '';

  meta = with lib; {
    mainProgram = "workerd";
    description = "The JavaScript / Wasm runtime that powers Cloudflare Workers";
    homepage = "https://github.com/cloudflare/workerd";
    changelog = "https://github.com/cloudflare/workerd/releases/tag/v${finalAttrs.version}";
    license = licenses.asl20;
    maintainers = with maintainers; [getchoo];
    platforms = ["x86_64-linux" "aarch64-linux"];
  };
})