Skip to content

Commit dfce2bc

Browse files
committed
deno_1: init at 1.46.3
Add a pre v2 copy of deno as deno_1 to provide some stability until our next release and until 1.46 is fully abandoned soon. deno_1 is expected to be removed prior to 24.11. Added a release note.
1 parent 4398440 commit dfce2bc

File tree

12 files changed

+228
-1
lines changed

12 files changed

+228
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
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.
208+
- `deno` has been updated to v2 which has breaking changes. Upstream will be abandoning v1 soon but for now you can use `deno_1` if you are yet to migrate (will be removed prior to cutting a final 24.11 release).
209209

210210
- `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.
211211

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# auto-generated file -- DO NOT EDIT!
2+
{ fetchLibrustyV8 }:
3+
4+
fetchLibrustyV8 {
5+
version = "0.105.0";
6+
shas = {
7+
x86_64-linux = "sha256-9yON4DNPxm4IUZSLZp9VZtzSRPPWX1tEuQLVJmN8cLs=";
8+
aarch64-linux = "sha256-5vAjw2vimjCHKPxjIp5vcwMCWUUDYVlk4QyOeEI0DLY=";
9+
x86_64-darwin = "sha256-o4WRkg4ptiJTNMkorn5K+P8xOJwpChM5PqkZCjP076g=";
10+
aarch64-darwin = "sha256-ZuWBnvxu1PgDtjtguxtj3BhFO01AChlbjAS0kZUws3A=";
11+
};
12+
}

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

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(1 + 1)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
deno,
3+
runCommand,
4+
lib,
5+
testers,
6+
}:
7+
let
8+
testDenoRun =
9+
name:
10+
{
11+
args ? "",
12+
dir ? ./. + "/${name}",
13+
file ? "index.ts",
14+
expected ? "",
15+
expectFailure ? false,
16+
}:
17+
let
18+
command = "deno run ${args} ${dir}/${file}";
19+
in
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
40+
else
41+
if [[ "${toString expectFailure}" == "1" ]]; then
42+
echo "Test '${name}' failed as expected"
43+
touch $out
44+
exit 0
45+
fi
46+
echo -n ${lib.escapeShellArg command} >&2
47+
echo " returned a non-zero exit code." >&2
48+
echo "$output" >&2
49+
exit 1
50+
fi
51+
'';
52+
in
53+
(lib.mapAttrs testDenoRun {
54+
basic = {
55+
dir = ./.;
56+
file = "basic.ts";
57+
expected = "2";
58+
};
59+
import-json = {
60+
expected = "hello from JSON";
61+
};
62+
import-ts = {
63+
expected = "hello from ts";
64+
};
65+
read-file = {
66+
args = "--allow-read";
67+
expected = "hello from a file";
68+
};
69+
fail-read-file = {
70+
expectFailure = true;
71+
dir = ./read-file;
72+
};
73+
})
74+
// {
75+
version = testers.testVersion {
76+
package = deno;
77+
command = "deno --version";
78+
};
79+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "msg": "hello from JSON" }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import file from "./data.json" assert { type: "json" };
2+
console.log(file.msg);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { sayHello } from "./lib.ts"
2+
3+
sayHello("ts")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function sayHello(thing: string) {
2+
console.log(`hello from ${thing}`);
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello from a file

0 commit comments

Comments
 (0)