Skip to content

Commit 4398440

Browse files
committed
deno: 1.46.3 -> 2.0.0
Updates deno to v2. Slight refactor of fetcher code for grabbing librusty_v8. Updated the update scripts to use new Deno v2 interfaces and pull latest toml dependency from jsr rather than the deno.land registry. Added release note.
1 parent e57567d commit 4398440

File tree

8 files changed

+100
-83
lines changed

8 files changed

+100
-83
lines changed

nixos/doc/manual/release-notes/rl-2411.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205

206206
- `grafana` has been updated to version 11.1. This version doesn't support setting `http_addr` to a hostname anymore, an IP address is expected.
207207

208+
- `deno` has been updated to v2 which has breaking changes.
209+
208210
- `knot-dns` has been updated to version 3.4.x. Check the [migration guide](https://www.knot-dns.cz/docs/latest/html/migration.html#upgrade-3-3-x-to-3-4-x) for breaking changes.
209211

210212
- `services.kubernetes.kubelet.clusterDns` now accepts a list of DNS resolvers rather than a single string, bringing the module more in line with the upstream Kubelet configuration schema.

pkgs/by-name/de/deno/fetchers.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# not a stable interface, do not reference outside the deno package but make a
2+
# copy if you need
3+
{
4+
lib,
5+
stdenv,
6+
fetchurl,
7+
}:
8+
9+
{
10+
fetchLibrustyV8 =
11+
args:
12+
fetchurl {
13+
name = "librusty_v8-${args.version}";
14+
url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${stdenv.hostPlatform.rust.rustcTarget}.a.gz";
15+
sha256 = args.shas.${stdenv.hostPlatform.system};
16+
meta = {
17+
inherit (args) version;
18+
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
19+
};
20+
};
21+
}
Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
# auto-generated file -- DO NOT EDIT!
2-
{ lib, stdenv, fetchurl }:
2+
{ fetchLibrustyV8 }:
33

4-
let
5-
fetch_librusty_v8 = args: fetchurl {
6-
name = "librusty_v8-${args.version}";
7-
url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${stdenv.hostPlatform.rust.rustcTarget}.a.gz";
8-
sha256 = args.shas.${stdenv.hostPlatform.system};
9-
meta = {
10-
inherit (args) version;
11-
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
12-
};
13-
};
14-
in
15-
fetch_librusty_v8 {
16-
version = "0.105.0";
4+
fetchLibrustyV8 {
5+
version = "0.106.0";
176
shas = {
18-
x86_64-linux = "sha256-9yON4DNPxm4IUZSLZp9VZtzSRPPWX1tEuQLVJmN8cLs=";
19-
aarch64-linux = "sha256-5vAjw2vimjCHKPxjIp5vcwMCWUUDYVlk4QyOeEI0DLY=";
20-
x86_64-darwin = "sha256-o4WRkg4ptiJTNMkorn5K+P8xOJwpChM5PqkZCjP076g=";
21-
aarch64-darwin = "sha256-ZuWBnvxu1PgDtjtguxtj3BhFO01AChlbjAS0kZUws3A=";
7+
x86_64-linux = "sha256-jLYl/CJp2Z+Ut6qZlh6u+CtR8KN+ToNTB+72QnVbIKM=";
8+
aarch64-linux = "sha256-uAkBMg6JXA+aILd8TzDtuaEdM3Axiw43Ad5tZzxNt5w=";
9+
x86_64-darwin = "sha256-60aR0YvQT8KyacY8J3fWKZcf9vny51VUB19NVpurS/A=";
10+
aarch64-darwin = "sha256-pd/I6Mclj2/r/uJTIywnolPKYzeLu1c28d/6D56vkzQ=";
2211
};
2312
}

pkgs/by-name/de/deno/package.nix

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@
99
installShellFiles,
1010
libiconv,
1111
darwin,
12-
librusty_v8 ? callPackage ./librusty_v8.nix { },
12+
librusty_v8 ? callPackage ./librusty_v8.nix {
13+
inherit (callPackage ./fetchers.nix { }) fetchLibrustyV8;
14+
},
1315
}:
16+
17+
let
18+
canExecute = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
19+
in
1420
rustPlatform.buildRustPackage rec {
1521
pname = "deno";
16-
version = "1.46.3";
22+
version = "2.0.0";
1723

1824
src = fetchFromGitHub {
1925
owner = "denoland";
2026
repo = "deno";
2127
rev = "refs/tags/v${version}";
22-
hash = "sha256-AM6SjcIHo6Koxcnznhkv3cXoKaMy2TEVpiWe/bczDuA=";
28+
hash = "sha256-3PfAjn2zWgxJOYgKwR7lvXu+rIENIHBMPwMM6dWNgR4=";
2329
};
2430

25-
cargoHash = "sha256-D+CZpb6OTzM5Il0k8GQB7qSONy4myE5yKlaSkLLqHT8=";
31+
cargoHash = "sha256-3r5B9yWXKO/8ah+Etflws8RnlRTAdaaC5HZMlZduyHE=";
2632

2733
postPatch = ''
2834
# upstream uses lld on aarch64-darwin for faster builds
@@ -54,14 +60,13 @@ rustPlatform.buildRustPackage rec {
5460
])
5561
);
5662

57-
# work around "error: unknown warning group '-Wunused-but-set-parameter'"
58-
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unknown-warning-option";
59-
6063
buildAndTestSubdir = "cli";
6164

65+
# work around "error: unknown warning group '-Wunused-but-set-parameter'"
66+
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unknown-warning-option";
6267
# The v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem
6368
# To avoid this we pre-download the file and export it via RUSTY_V8_ARCHIVE
64-
RUSTY_V8_ARCHIVE = librusty_v8;
69+
env.RUSTY_V8_ARCHIVE = librusty_v8;
6570

6671
# Tests have some inconsistencies between runs with output integration tests
6772
# Skipping until resolved
@@ -71,15 +76,15 @@ rustPlatform.buildRustPackage rec {
7176
find ./target -name libswc_common${stdenv.hostPlatform.extensions.sharedLibrary} -delete
7277
'';
7378

74-
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
79+
postInstall = lib.optionalString (canExecute) ''
7580
installShellCompletion --cmd deno \
7681
--bash <($out/bin/deno completions bash) \
7782
--fish <($out/bin/deno completions fish) \
7883
--zsh <($out/bin/deno completions zsh)
7984
'';
8085

81-
doInstallCheck = true;
82-
installCheckPhase = ''
86+
doInstallCheck = canExecute;
87+
installCheckPhase = lib.optionalString (canExecute) ''
8388
runHook preInstallCheck
8489
$out/bin/deno --help
8590
$out/bin/deno --version | grep "deno ${version}"

pkgs/by-name/de/deno/tests/default.nix

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,54 @@
1-
{ deno, runCommand, lib, testers }:
1+
{
2+
deno,
3+
runCommand,
4+
lib,
5+
testers,
6+
}:
27
let
38
testDenoRun =
49
name:
5-
{ args ? ""
6-
, dir ? ./. + "/${name}"
7-
, file ? "index.ts"
8-
, expected ? ""
9-
, expectFailure ? false
10+
{
11+
args ? "",
12+
dir ? ./. + "/${name}",
13+
file ? "index.ts",
14+
expected ? "",
15+
expectFailure ? false,
1016
}:
1117
let
1218
command = "deno run ${args} ${dir}/${file}";
1319
in
14-
runCommand "deno-test-${name}" { nativeBuildInputs = [ deno ]; meta.timeout = 60; } ''
15-
HOME=$(mktemp -d)
16-
if output=$(${command} 2>&1); then
17-
if [[ $output =~ '${expected}' ]]; then
18-
echo "Test '${name}' passed"
19-
touch $out
20+
runCommand "deno-test-${name}"
21+
{
22+
nativeBuildInputs = [ deno ];
23+
meta.timeout = 60;
24+
}
25+
''
26+
HOME=$(mktemp -d)
27+
if output=$(${command} 2>&1); then
28+
if [[ $output =~ '${expected}' ]]; then
29+
echo "Test '${name}' passed"
30+
touch $out
31+
else
32+
echo -n ${lib.escapeShellArg command} >&2
33+
echo " output did not match what was expected." >&2
34+
echo "The expected was:" >&2
35+
echo '${expected}' >&2
36+
echo "The output was:" >&2
37+
echo "$output" >&2
38+
exit 1
39+
fi
2040
else
41+
if [[ "${toString expectFailure}" == "1" ]]; then
42+
echo "Test '${name}' failed as expected"
43+
touch $out
44+
exit 0
45+
fi
2146
echo -n ${lib.escapeShellArg command} >&2
22-
echo " output did not match what was expected." >&2
23-
echo "The expected was:" >&2
24-
echo '${expected}' >&2
25-
echo "The output was:" >&2
47+
echo " returned a non-zero exit code." >&2
2648
echo "$output" >&2
2749
exit 1
2850
fi
29-
else
30-
if [[ "${toString expectFailure}" == "1" ]]; then
31-
echo "Test '${name}' failed as expected"
32-
touch $out
33-
exit 0
34-
fi
35-
echo -n ${lib.escapeShellArg command} >&2
36-
echo " returned a non-zero exit code." >&2
37-
echo "$output" >&2
38-
exit 1
39-
fi
40-
'';
51+
'';
4152
in
4253
(lib.mapAttrs testDenoRun {
4354
basic = {
@@ -59,8 +70,8 @@ in
5970
expectFailure = true;
6071
dir = ./read-file;
6172
};
62-
}) //
63-
{
73+
})
74+
// {
6475
version = testers.testVersion {
6576
package = deno;
6677
command = "deno --version";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import file from "./data.json" assert { type: "json" };
1+
import file from "./data.json" with { type: "json" };
22
console.log(file.msg);

pkgs/by-name/de/deno/update/common.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ interface GHRelease {
33
}
44

55
const decode = (buffer: Uint8Array) => new TextDecoder("utf-8").decode(buffer);
6-
const decodeTrim = (b: Uint8Array) => decode(b).trimEnd();
76
export const run = async (command: string, args: string[]) => {
8-
const cmd = Deno.run({
9-
cmd: [command, ...args],
10-
stdout: "piped",
11-
stderr: "piped",
12-
});
13-
if (!(await cmd.status()).success) {
14-
const error = await cmd.stderrOutput().then(decodeTrim);
7+
const cmd = new Deno.Command(command, { args });
8+
const { code, stdout, stderr } = await cmd.output();
9+
if (code !== 0) {
10+
const error = decode(stderr).trimEnd();
1511
// Known error we can ignore
1612
if (error.includes("'allow-unsafe-native-code-during-evaluation'")) {
1713
// Extract the target sha256 out of the error
@@ -26,7 +22,7 @@ export const run = async (command: string, args: string[]) => {
2622
}
2723
throw new Error(error);
2824
}
29-
return cmd.output().then(decodeTrim);
25+
return decode(stdout).trimEnd();
3026
};
3127

3228
// Exports

pkgs/by-name/de/deno/update/librusty_v8.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as toml from "https://deno.land/std@0.202.0/toml/mod.ts";
1+
import * as toml from "jsr:@std/[email protected]";
22
import { getExistingVersion, logger, run, write } from "./common.ts";
33

44
const log = logger("librusty_v8");
@@ -40,22 +40,15 @@ fetchurl {
4040

4141
const templateDeps = (version: string, deps: PrefetchResult[]) =>
4242
`# auto-generated file -- DO NOT EDIT!
43-
{ lib, stdenv, fetchurl }:
43+
{ fetchLibrustyV8 }:
4444
45-
let
46-
fetch_librusty_v8 = args: fetchurl {
47-
name = "librusty_v8-\${args.version}";
48-
url = "https://github.com/denoland/rusty_v8/releases/download/v\${args.version}/librusty_v8_release_\${stdenv.hostPlatform.rust.rustcTarget}.a.gz";
49-
sha256 = args.shas.\${stdenv.hostPlatform.system};
50-
meta = {
51-
inherit (args) version;
52-
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
53-
};
54-
};
55-
in
56-
fetch_librusty_v8 {
45+
fetchLibrustyV8 {
5746
version = "${version}";
5847
shas = {
48+
x86_64-linux = "sha256-jLYl/CJp2Z+Ut6qZlh6u+CtR8KN+ToNTB+72QnVbIKM=";
49+
aarch64-linux = "sha256-uAkBMg6JXA+aILd8TzDtuaEdM3Axiw43Ad5tZzxNt5w=";
50+
x86_64-darwin = "sha256-60aR0YvQT8KyacY8J3fWKZcf9vny51VUB19NVpurS/A=";
51+
aarch64-darwin = "sha256-pd/I6Mclj2/r/uJTIywnolPKYzeLu1c28d/6D56vkzQ=";
5952
${deps.map(({ arch, sha256 }) => ` ${arch.nix} = "${sha256}";`).join("\n")}
6053
};
6154
}

0 commit comments

Comments
 (0)