summary refs log tree commit diff
path: root/pkgs/development/web/deno
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/web/deno')
-rw-r--r--pkgs/development/web/deno/default.nix75
-rw-r--r--pkgs/development/web/deno/deps.nix12
-rw-r--r--pkgs/development/web/deno/librusty_v8.nix21
-rw-r--r--pkgs/development/web/deno/update/common.ts34
-rw-r--r--pkgs/development/web/deno/update/deps.ts79
-rw-r--r--pkgs/development/web/deno/update/librusty_v8.ts92
-rw-r--r--pkgs/development/web/deno/update/src.ts10
-rwxr-xr-xpkgs/development/web/deno/update/update.ts17
8 files changed, 177 insertions, 163 deletions
diff --git a/pkgs/development/web/deno/default.nix b/pkgs/development/web/deno/default.nix
index 3a0583628f0..d1a6330df7b 100644
--- a/pkgs/development/web/deno/default.nix
+++ b/pkgs/development/web/deno/default.nix
@@ -1,70 +1,79 @@
 { stdenv
-, fetchurl
+, lib
+, callPackage
 , fetchFromGitHub
 , rust
 , rustPlatform
 , installShellFiles
+, libiconv
+, libobjc
 , Security
 , CoreServices
+, Metal
+, Foundation
+, QuartzCore
+, librusty_v8 ? callPackage ./librusty_v8.nix { }
 }:
-let
-  deps = import ./deps.nix { };
-  arch = rust.toRustTarget stdenv.hostPlatform;
-  rustyV8Lib = with deps.rustyV8Lib; fetchurl {
-    url = "https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${arch}.a";
-    sha256 = sha256s."${stdenv.hostPlatform.system}";
-    meta = { inherit version; };
-  };
-in
+
 rustPlatform.buildRustPackage rec {
   pname = "deno";
-  version = "1.3.1";
+  version = "1.12.1";
 
   src = fetchFromGitHub {
     owner = "denoland";
     repo = pname;
     rev = "v${version}";
-    sha256 = "1j5ajasng380p5a7nkk9ag5zp9ybwfz7b2z42lyk1wfg0pcd6j0r";
-    fetchSubmodules = true;
+    sha256 = "sha256-kNwRnoUkX2dmj6ii9fRu/Hv4V3/sz6ag+wUPf93tmTQ=";
   };
-  cargoSha256 = "0ba7afk4n7k170cqwy0gjc53vz6bjc176s9w1wln6yfhh55fyw6x";
+  cargoSha256 = "sha256-5ukTSzDFCkBQ1UFfnpz1fFzJSHBYUoZAvhPGMkr/fIs=";
 
   # Install completions post-install
   nativeBuildInputs = [ installShellFiles ];
 
-  buildInputs = stdenv.lib.optionals stdenv.isDarwin [ Security CoreServices ];
+  buildAndTestSubdir = "cli";
+
+  buildInputs = lib.optionals stdenv.isDarwin
+    [ libiconv libobjc Security CoreServices Metal Foundation QuartzCore ];
 
   # The rusty_v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem
   # To avoid this we pre-download the file and place it in the locations it will require it in advance
-  preBuild = ''
-    _rusty_v8_setup() {
-      for v in "$@"; do
-        dir="target/$v/gn_out/obj"
-        mkdir -p "$dir" && cp "${rustyV8Lib}" "$dir/librusty_v8.a"
-      done
-    }
+  preBuild =
+    let arch = rust.toRustTarget stdenv.hostPlatform; in
+    ''
+      _librusty_v8_setup() {
+        for v in "$@"; do
+          install -D ${librusty_v8} "target/$v/gn_out/obj/librusty_v8.a"
+        done
+      }
 
-    # Copy over the `librusty_v8.a` file inside target/XYZ/gn_out/obj, symlink not allowed
-    _rusty_v8_setup "debug" "release" "${arch}/release"
-  '';
+      # Copy over the `librusty_v8.a` file inside target/XYZ/gn_out/obj, symlink not allowed
+      _librusty_v8_setup "debug" "release" "${arch}/release"
+    '';
 
   # Tests have some inconsistencies between runs with output integration tests
   # Skipping until resolved
   doCheck = false;
 
-  # TODO: Move to enhanced installShellCompletion when merged: PR #83630
   postInstall = ''
-    $out/bin/deno completions bash > deno.bash
-    $out/bin/deno completions fish > deno.fish
-    $out/bin/deno completions zsh  > _deno
-    installShellCompletion deno.{bash,fish} --zsh _deno
+    installShellCompletion --cmd deno \
+      --bash <($out/bin/deno completions bash) \
+      --fish <($out/bin/deno completions fish) \
+      --zsh <($out/bin/deno completions zsh)
+  '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    runHook preInstallCheck
+    $out/bin/deno --help
+    $out/bin/deno --version | grep "deno ${version}"
+    runHook postInstallCheck
   '';
 
   passthru.updateScript = ./update/update.ts;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = "https://deno.land/";
-    changelog = "${src.meta.homepage}/releases/tag/v${version}";
+    changelog = "https://github.com/denoland/deno/releases/tag/v${version}";
     description = "A secure runtime for JavaScript and TypeScript";
     longDescription = ''
       Deno aims to be a productive and secure scripting environment for the modern programmer.
@@ -77,6 +86,6 @@ rustPlatform.buildRustPackage rec {
     '';
     license = licenses.mit;
     maintainers = with maintainers; [ jk ];
-    platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+    platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
   };
 }
diff --git a/pkgs/development/web/deno/deps.nix b/pkgs/development/web/deno/deps.nix
deleted file mode 100644
index 2fd88235a8e..00000000000
--- a/pkgs/development/web/deno/deps.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-# auto-generated file -- DO NOT EDIT!
-{}:
-rec {
-  rustyV8Lib = {
-    version = "0.8.1";
-    sha256s = {
-      x86_64-linux = "0nwssdbwscwkh2w9zhlvaj562z19g5icg2yi00fyw8glws69cd6p";
-      aarch64-linux = "0mwd4ix511dzxpah1p2c47a1qhvff0d3kyilc3yra99fa1s0gyxy";
-      x86_64-darwin = "04s4x0n85rxnncy4jsl1ak3rdgb4a3lhqg8h53mvvjmsazsj1q70";
-    };
-  };
-}
diff --git a/pkgs/development/web/deno/librusty_v8.nix b/pkgs/development/web/deno/librusty_v8.nix
new file mode 100644
index 00000000000..a85d2bf76f2
--- /dev/null
+++ b/pkgs/development/web/deno/librusty_v8.nix
@@ -0,0 +1,21 @@
+# auto-generated file -- DO NOT EDIT!
+{ rust, stdenv, fetchurl }:
+
+let
+  arch = rust.toRustTarget stdenv.hostPlatform;
+  fetch_librusty_v8 = args: fetchurl {
+    name = "librusty_v8-${args.version}";
+    url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${arch}.a";
+    sha256 = args.shas.${stdenv.hostPlatform.system};
+    meta = { inherit (args) version; };
+  };
+in
+fetch_librusty_v8 {
+  version = "0.25.3";
+  shas = {
+    x86_64-linux = "sha256-Z3lEJT3QVhP8PoDiM6Fw0sm5rXWvasBqASBO5tZA5zM=";
+    aarch64-linux = "sha256-pbcd1zV7IIEqCIp8vsRiO0KBGrOv52SvMZ4gthxuN/I=";
+    x86_64-darwin = "sha256-BwYdgd1kK8EQFfDc9RgtNvwvx7agt9hYNVmBGwHoqz0=";
+    aarch64-darwin = "sha256-/RHeNuR7VjhfwdjZXWMMX3UnweAjJblSCUq9eIwGvWc=";
+  };
+}
diff --git a/pkgs/development/web/deno/update/common.ts b/pkgs/development/web/deno/update/common.ts
index d8956b21d16..1b4e3509ea7 100644
--- a/pkgs/development/web/deno/update/common.ts
+++ b/pkgs/development/web/deno/update/common.ts
@@ -3,12 +3,15 @@ interface GHRelease {
 }
 
 const decode = (buffer: Uint8Array) => new TextDecoder("utf-8").decode(buffer);
-const run = async (command: string, args: string[]) => {
-  const cmd = Deno.run(
-    { cmd: [command, ...args], stdout: "piped", stderr: "piped" },
-  );
+const decodeTrim = (b: Uint8Array) => decode(b).trimEnd();
+export const run = async (command: string, args: string[]) => {
+  const cmd = Deno.run({
+    cmd: [command, ...args],
+    stdout: "piped",
+    stderr: "piped",
+  });
   if (!(await cmd.status()).success) {
-    const error = await cmd.stderrOutput().then((b) => decode(b).trimEnd());
+    const error = await cmd.stderrOutput().then(decodeTrim);
     // Known error we can ignore
     if (error.includes("'allow-unsafe-native-code-during-evaluation'")) {
       // Extract the target sha256 out of the error
@@ -23,26 +26,16 @@ const run = async (command: string, args: string[]) => {
     }
     throw new Error(error);
   }
-  return cmd.output().then((b) => decode(b).trimEnd());
+  return cmd.output().then(decodeTrim);
 };
 
 // Exports
 export const versionRegExp = /\d+\.\d+\.\d+/;
-export const sha256RegExp = /[a-z0-9]{52}/;
-
-export async function commit(
-  name: string,
-  oldVer: string,
-  newVer: string,
-  files: string[],
-) {
-  await run("git", ["add", ...files]);
-  await run("git", ["commit", "-m", `${name}: ${oldVer} -> ${newVer}`]);
-}
+export const sha256RegExp = /[a-z0-9]{52}|sha256-.{44}/;
 
 export const getExistingVersion = async (filePath: string) =>
-  read(filePath).then((s) =>
-    s.match(genValueRegExp("version", versionRegExp))?.shift() || ""
+  read(filePath).then(
+    (s) => s.match(genValueRegExp("version", versionRegExp))?.shift() || "",
   );
 
 export const getLatestVersion = (owner: string, repo: string) =>
@@ -58,8 +51,5 @@ export const genValueRegExp = (key: string, regex: RegExp) =>
 export const logger = (name: string) =>
   (...a: any) => console.log(`[${name}]`, ...a);
 
-export const nixPrefetch = (args: string[]) => run("nix-prefetch", args);
-export const nixPrefetchURL = (args: string[]) => run("nix-prefetch-url", args);
-
 export const read = Deno.readTextFile;
 export const write = Deno.writeTextFile;
diff --git a/pkgs/development/web/deno/update/deps.ts b/pkgs/development/web/deno/update/deps.ts
deleted file mode 100644
index beedeade3a8..00000000000
--- a/pkgs/development/web/deno/update/deps.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import {
-  getExistingVersion,
-  genValueRegExp,
-  logger,
-  nixPrefetchURL,
-  versionRegExp,
-  write,
-} from "./common.ts";
-
-const log = logger("deps");
-
-export interface Architecture {
-  nix: string;
-  rust: string;
-}
-interface PrefetchResult {
-  arch: Architecture;
-  sha256: string;
-}
-
-const getRustyV8Version = async (
-  owner: string,
-  repo: string,
-  version: string,
-) =>
-  fetch(
-    `https://github.com/${owner}/${repo}/raw/${version}/core/Cargo.toml`,
-  )
-    .then((res) => res.text())
-    .then((txt) =>
-      txt.match(genValueRegExp("rusty_v8", versionRegExp))?.shift()
-    );
-
-const archShaTasks = (version: string, arches: Architecture[]) =>
-  arches.map(async (arch: Architecture): Promise<PrefetchResult> => {
-    log("Fetching:", arch.nix);
-    const sha256 = await nixPrefetchURL(
-      [`https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${arch.rust}.a`],
-    );
-    log("Done:    ", arch.nix);
-    return { arch, sha256 };
-  });
-
-const templateDeps = (version: string, deps: PrefetchResult[]) =>
-  `# auto-generated file -- DO NOT EDIT!
-{}:
-rec {
-  rustyV8Lib = {
-    version = "${version}";
-    sha256s = {
-${deps.map((d) => `      ${d.arch.nix} = "${d.sha256}";`).join("\n")}
-    };
-  };
-}
-`;
-
-export async function updateDeps(
-  filePath: string,
-  owner: string,
-  repo: string,
-  denoVersion: string,
-  arches: Architecture[],
-) {
-  log("Starting deps update");
-  // 0.0.0
-  const version = await getRustyV8Version(owner, repo, denoVersion);
-  if (typeof version !== "string") {
-    throw "no rusty_v8 version";
-  }
-  log("rusty_v8 version:", version);
-  const existingVersion = await getExistingVersion(filePath);
-  if (version === existingVersion) {
-    log("Version already matches latest, skipping...");
-    return;
-  }
-  const archShaResults = await Promise.all(archShaTasks(version, arches));
-  await write(filePath, templateDeps(version, archShaResults));
-  log("Finished deps update");
-}
diff --git a/pkgs/development/web/deno/update/librusty_v8.ts b/pkgs/development/web/deno/update/librusty_v8.ts
new file mode 100644
index 00000000000..dee3277c581
--- /dev/null
+++ b/pkgs/development/web/deno/update/librusty_v8.ts
@@ -0,0 +1,92 @@
+import {
+  genValueRegExp,
+  getExistingVersion,
+  logger,
+  run,
+  versionRegExp,
+  write,
+} from "./common.ts";
+
+const log = logger("librusty_v8");
+
+export interface Architecture {
+  nix: string;
+  rust: string;
+}
+interface PrefetchResult {
+  arch: Architecture;
+  sha256: string;
+}
+
+const getLibrustyV8Version = async (
+  owner: string,
+  repo: string,
+  version: string,
+) =>
+  fetch(`https://github.com/${owner}/${repo}/raw/${version}/core/Cargo.toml`)
+    .then((res) => res.text())
+    .then((txt) =>
+      txt.match(genValueRegExp("rusty_v8", versionRegExp))?.shift()
+    );
+
+const fetchArchShaTasks = (version: string, arches: Architecture[]) =>
+  arches.map(
+    async (arch: Architecture): Promise<PrefetchResult> => {
+      log("Fetching:", arch.nix);
+      const sha256 = await run("nix-prefetch", [
+        `
+{ fetchurl }:
+fetchurl {
+  url = "https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${arch.rust}.a";
+}
+`,
+      ]);
+      log("Done:    ", arch.nix);
+      return { arch, sha256 };
+    },
+  );
+
+const templateDeps = (version: string, deps: PrefetchResult[]) =>
+  `# auto-generated file -- DO NOT EDIT!
+{ rust, stdenv, fetchurl }:
+
+let
+  arch = rust.toRustTarget stdenv.hostPlatform;
+  fetch_librusty_v8 = args: fetchurl {
+    name = "librusty_v8-\${args.version}";
+    url = "https://github.com/denoland/rusty_v8/releases/download/v\${args.version}/librusty_v8_release_\${arch}.a";
+    sha256 = args.shas.\${stdenv.hostPlatform.system};
+    meta = { inherit (args) version; };
+  };
+in
+fetch_librusty_v8 {
+  version = "${version}";
+  shas = {
+${deps.map(({ arch, sha256 }) => `    ${arch.nix} = "${sha256}";`).join("\n")}
+  };
+}
+`;
+
+export async function updateLibrustyV8(
+  filePath: string,
+  owner: string,
+  repo: string,
+  denoVersion: string,
+  arches: Architecture[],
+) {
+  log("Starting librusty_v8 update");
+  // 0.0.0
+  const version = await getLibrustyV8Version(owner, repo, denoVersion);
+  if (typeof version !== "string") {
+    throw "no librusty_v8 version";
+  }
+  log("librusty_v8 version:", version);
+  const existingVersion = await getExistingVersion(filePath);
+  if (version === existingVersion) {
+    log("Version already matches latest, skipping...");
+    return;
+  }
+  const archShaResults = await Promise.all(fetchArchShaTasks(version, arches));
+  await write(filePath, templateDeps(version, archShaResults));
+  log("Finished deps update");
+}
diff --git a/pkgs/development/web/deno/update/src.ts b/pkgs/development/web/deno/update/src.ts
index fae15acd0d2..3bfae27c21c 100644
--- a/pkgs/development/web/deno/update/src.ts
+++ b/pkgs/development/web/deno/update/src.ts
@@ -1,8 +1,8 @@
 import {
   genValueRegExp,
   logger,
-  nixPrefetch,
   read,
+  run,
   sha256RegExp,
   versionRegExp,
   write,
@@ -16,10 +16,11 @@ interface Replacer {
 const log = logger("src");
 
 const prefetchSha256 = (nixpkgs: string, version: string) =>
-  nixPrefetch(["-f", nixpkgs, "deno.src", "--rev", version]);
+  run("nix-prefetch", ["-f", nixpkgs, "deno.src", "--rev", version]);
 const prefetchCargoSha256 = (nixpkgs: string) =>
-  nixPrefetch(
-    [`{ sha256 }: (import ${nixpkgs} {}).deno.cargoDeps.overrideAttrs (_: { outputHash = sha256; })`],
+  run(
+    "nix-prefetch",
+    [`{ sha256 }: (import ${nixpkgs} {}).deno.cargoDeps.overrideAttrs (_: { inherit sha256; })`],
   );
 
 const replace = (str: string, replacers: Replacer[]) =>
@@ -53,7 +54,6 @@ export async function updateSrc(
     [
       genVerReplacer("version", trimVersion),
       genShaReplacer("sha256", sha256),
-      genShaReplacer("cargoSha256", ""), // Empty ready for prefetchCargoSha256
     ],
   );
   log("Fetching cargoSha256 for:", sha256);
diff --git a/pkgs/development/web/deno/update/update.ts b/pkgs/development/web/deno/update/update.ts
index 18d45148013..27e1d86ee86 100755
--- a/pkgs/development/web/deno/update/update.ts
+++ b/pkgs/development/web/deno/update/update.ts
@@ -2,13 +2,8 @@
 /*
 #!nix-shell -i "deno run --allow-net --allow-run --allow-read --allow-write" -p deno git nix-prefetch
 */
-import {
-  commit,
-  getExistingVersion,
-  getLatestVersion,
-  logger,
-} from "./common.ts";
-import { Architecture, updateDeps } from "./deps.ts";
+import { getExistingVersion, getLatestVersion, logger } from "./common.ts";
+import { Architecture, updateLibrustyV8 } from "./librusty_v8.ts";
 import { updateSrc } from "./src.ts";
 
 const log = logger("update");
@@ -19,11 +14,12 @@ const owner = "denoland";
 const repo = "deno";
 const denoDir = `${nixpkgs}/pkgs/development/web/${repo}`;
 const src = `${denoDir}/default.nix`;
-const deps = `${denoDir}/deps.nix`;
+const librusty_v8 = `${denoDir}/librusty_v8.nix`;
 const architectures: Architecture[] = [
   { nix: "x86_64-linux", rust: "x86_64-unknown-linux-gnu" },
   { nix: "aarch64-linux", rust: "aarch64-unknown-linux-gnu" },
   { nix: "x86_64-darwin", rust: "x86_64-apple-darwin" },
+  { nix: "aarch64-darwin", rust: "aarch64-apple-darwin" },
 ];
 
 log("Updating deno");
@@ -41,10 +37,7 @@ if (trimVersion === existingVersion) {
 
 const tasks = [
   updateSrc(src, nixpkgs, version),
-  updateDeps(deps, owner, repo, version, architectures),
+  updateLibrustyV8(librusty_v8, owner, repo, version, architectures),
 ];
 await Promise.all(tasks);
 log("Updating deno complete");
-log("Commiting");
-await commit(repo, existingVersion, trimVersion, [src, deps]);
-log("Done");