deps: upgrade dependencies
This commit is contained in:
1241
Cargo.lock
generated
1241
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,6 @@ edition = "2024"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
convert_case = "0.8"
|
||||
convert_case = "0.11"
|
||||
quote = "1.0"
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
|
||||
@@ -12,7 +12,7 @@ nix-compat = { git = "https://git.snix.dev/snix/snix.git", version = "0.1.0", fe
|
||||
|
||||
# REPL
|
||||
anyhow = "1.0"
|
||||
rustyline = "14.0"
|
||||
rustyline = "17.0"
|
||||
|
||||
# Logging
|
||||
tracing = "0.1"
|
||||
@@ -31,7 +31,7 @@ itertools = "0.14"
|
||||
|
||||
regex = "1.11"
|
||||
|
||||
deno_core = "0.376"
|
||||
deno_core = "0.385"
|
||||
deno_error = "0.7"
|
||||
|
||||
nix-nar = "0.3"
|
||||
@@ -40,29 +40,28 @@ hex = "0.4"
|
||||
|
||||
base64 = "0.22"
|
||||
|
||||
# Fetcher dependencies
|
||||
reqwest = { version = "0.12", features = ["blocking", "rustls-tls"], default-features = false }
|
||||
reqwest = { version = "0.13", features = ["blocking", "rustls"], default-features = false }
|
||||
tar = "0.4"
|
||||
flate2 = "1.0"
|
||||
xz2 = "0.1"
|
||||
bzip2 = "0.5"
|
||||
zip = "2.2"
|
||||
bzip2 = "0.6"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
toml = "0.8"
|
||||
dirs = "5.0"
|
||||
# spec 1.0.0
|
||||
toml = "0.9.9"
|
||||
dirs = "6.0"
|
||||
tempfile = "3.24"
|
||||
rusqlite = { version = "0.33", features = ["bundled"] }
|
||||
rusqlite = { version = "0.38", features = ["bundled"] }
|
||||
|
||||
rnix = "0.12"
|
||||
rowan = "0.15"
|
||||
rnix = "0.13"
|
||||
rowan = "0.16"
|
||||
|
||||
nix-js-macros = { path = "../nix-js-macros" }
|
||||
ere = "0.2.4"
|
||||
num_enum = "0.7.5"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
criterion = { version = "0.8", features = ["html_reports"] }
|
||||
|
||||
[[bench]]
|
||||
name = "basic_ops"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod utils;
|
||||
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use std::hint::black_box;
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use utils::eval;
|
||||
|
||||
fn bench_arithmetic(c: &mut Criterion) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod utils;
|
||||
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use std::hint::black_box;
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use utils::eval;
|
||||
|
||||
fn bench_builtin_math(c: &mut Criterion) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod utils;
|
||||
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use std::hint::black_box;
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use nix_js::context::Context;
|
||||
use utils::compile;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod utils;
|
||||
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use std::hint::black_box;
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use utils::eval;
|
||||
|
||||
fn bench_non_recursive(c: &mut Criterion) {
|
||||
|
||||
@@ -64,7 +64,10 @@ impl<Ctx: DowngradeContext> Downgrade<Ctx> for Expr {
|
||||
IfElse(ifelse) => ifelse.downgrade(ctx),
|
||||
Select(select) => select.downgrade(ctx),
|
||||
Str(str) => str.downgrade(ctx),
|
||||
Path(path) => path.downgrade(ctx),
|
||||
PathAbs(path) => path.downgrade(ctx),
|
||||
PathRel(path) => path.downgrade(ctx),
|
||||
PathHome(path) => path.downgrade(ctx),
|
||||
PathSearch(path) => path.downgrade(ctx),
|
||||
Literal(lit) => lit.downgrade(ctx),
|
||||
Lambda(lambda) => lambda.downgrade(ctx),
|
||||
LegacyLet(let_) => let_.downgrade(ctx),
|
||||
@@ -119,72 +122,53 @@ impl<Ctx: DowngradeContext> Downgrade<Ctx> for ast::IfElse {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ctx: DowngradeContext> Downgrade<Ctx> for ast::Path {
|
||||
macro_rules! path {
|
||||
($ty:ident) => {
|
||||
impl<Ctx: DowngradeContext> Downgrade<Ctx> for ast::$ty {
|
||||
fn downgrade(self, ctx: &mut Ctx) -> Result<ExprId> {
|
||||
let span = self.syntax().text_range();
|
||||
downgrade_path(self.parts(), span, ctx)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
path!(PathAbs);
|
||||
path!(PathRel);
|
||||
path!(PathHome);
|
||||
impl<Ctx: DowngradeContext> Downgrade<Ctx> for ast::PathSearch {
|
||||
fn downgrade(self, ctx: &mut Ctx) -> Result<ExprId> {
|
||||
let span = self.syntax().text_range();
|
||||
let parts = self
|
||||
.parts()
|
||||
.map(|part| match part {
|
||||
ast::InterpolPart::Literal(lit) => Ok(ctx.new_expr(
|
||||
Str {
|
||||
val: lit.to_string(),
|
||||
span: lit.syntax().text_range(),
|
||||
}
|
||||
.to_ir(),
|
||||
)),
|
||||
ast::InterpolPart::Interpolation(interpol) => {
|
||||
interpol.expr().unwrap().downgrade(ctx)
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
let expr = if parts.len() == 1 {
|
||||
let part = parts.into_iter().next().unwrap();
|
||||
if let &Ir::Str(Str { ref val, span }) = ctx.get_ir(part)
|
||||
&& let Some(path) = val.strip_prefix("<").map(|path| &path[..path.len() - 1])
|
||||
{
|
||||
ctx.replace_ir(
|
||||
part,
|
||||
Str {
|
||||
val: path.to_string(),
|
||||
span,
|
||||
}
|
||||
.to_ir(),
|
||||
);
|
||||
let sym = ctx.new_sym("findFile".into());
|
||||
let find_file = ctx.new_expr(Builtin { inner: sym, span }.to_ir());
|
||||
let sym = ctx.new_sym("nixPath".into());
|
||||
let nix_path = ctx.new_expr(Builtin { inner: sym, span }.to_ir());
|
||||
let call = ctx.new_expr(
|
||||
Call {
|
||||
func: find_file,
|
||||
arg: nix_path,
|
||||
span,
|
||||
}
|
||||
.to_ir(),
|
||||
);
|
||||
return Ok(ctx.new_expr(
|
||||
Call {
|
||||
func: call,
|
||||
arg: part,
|
||||
span,
|
||||
}
|
||||
.to_ir(),
|
||||
));
|
||||
} else {
|
||||
part
|
||||
}
|
||||
} else {
|
||||
let path = {
|
||||
let temp = self.content().unwrap();
|
||||
let text = temp.text();
|
||||
ctx.new_expr(
|
||||
ConcatStrings {
|
||||
parts,
|
||||
Str {
|
||||
val: text[1..text.len() - 1].to_string(),
|
||||
span,
|
||||
force_string: false,
|
||||
}
|
||||
.to_ir(),
|
||||
)
|
||||
};
|
||||
Ok(ctx.new_expr(Path { expr, span }.to_ir()))
|
||||
let sym = ctx.new_sym("findFile".into());
|
||||
let find_file = ctx.new_expr(Builtin { inner: sym, span }.to_ir());
|
||||
let sym = ctx.new_sym("nixPath".into());
|
||||
let nix_path = ctx.new_expr(Builtin { inner: sym, span }.to_ir());
|
||||
let call = ctx.new_expr(
|
||||
Call {
|
||||
func: find_file,
|
||||
arg: nix_path,
|
||||
span,
|
||||
}
|
||||
.to_ir(),
|
||||
);
|
||||
Ok(ctx.new_expr(
|
||||
Call {
|
||||
func: call,
|
||||
arg: path,
|
||||
span,
|
||||
}
|
||||
.to_ir(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1318,3 +1302,36 @@ fn finalize_pending_value<Ctx: DowngradeContext, const ALLOW_DYN: bool>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn downgrade_path(
|
||||
parts: impl IntoIterator<Item = ast::InterpolPart<ast::PathContent>>,
|
||||
span: rnix::TextRange,
|
||||
ctx: &mut impl DowngradeContext,
|
||||
) -> Result<ExprId> {
|
||||
let parts = parts
|
||||
.into_iter()
|
||||
.map(|part| match part {
|
||||
ast::InterpolPart::Literal(lit) => Ok(ctx.new_expr(
|
||||
Str {
|
||||
val: lit.text().to_string(),
|
||||
span: lit.syntax().text_range(),
|
||||
}
|
||||
.to_ir(),
|
||||
)),
|
||||
ast::InterpolPart::Interpolation(interpol) => interpol.expr().unwrap().downgrade(ctx),
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let expr = if parts.len() == 1 {
|
||||
parts.into_iter().next().unwrap()
|
||||
} else {
|
||||
ctx.new_expr(
|
||||
ConcatStrings {
|
||||
parts,
|
||||
span,
|
||||
force_string: false,
|
||||
}
|
||||
.to_ir(),
|
||||
)
|
||||
};
|
||||
Ok(ctx.new_expr(Path { expr, span }.to_ir()))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::fs::{self, File};
|
||||
use std::fs;
|
||||
use std::io::Cursor;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -11,7 +11,6 @@ pub enum ArchiveFormat {
|
||||
TarXz,
|
||||
TarBz2,
|
||||
Tar,
|
||||
Zip,
|
||||
}
|
||||
|
||||
impl ArchiveFormat {
|
||||
@@ -28,9 +27,6 @@ impl ArchiveFormat {
|
||||
if url.ends_with(".tar") {
|
||||
return ArchiveFormat::Tar;
|
||||
}
|
||||
if url.ends_with(".zip") {
|
||||
return ArchiveFormat::Zip;
|
||||
}
|
||||
|
||||
if data.len() >= 2 && data[0] == 0x1f && data[1] == 0x8b {
|
||||
return ArchiveFormat::TarGz;
|
||||
@@ -41,15 +37,12 @@ impl ArchiveFormat {
|
||||
if data.len() >= 3 && &data[0..3] == b"BZh" {
|
||||
return ArchiveFormat::TarBz2;
|
||||
}
|
||||
if data.len() >= 4 && &data[0..4] == b"PK\x03\x04" {
|
||||
return ArchiveFormat::Zip;
|
||||
}
|
||||
|
||||
ArchiveFormat::TarGz
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_archive(data: &[u8], dest: &Path) -> Result<PathBuf, ArchiveError> {
|
||||
pub fn extract_tarball(data: &[u8], dest: &Path) -> Result<PathBuf, ArchiveError> {
|
||||
let format = ArchiveFormat::detect("", data);
|
||||
|
||||
let temp_dir = dest.join("_extract_temp");
|
||||
@@ -60,7 +53,6 @@ pub fn extract_archive(data: &[u8], dest: &Path) -> Result<PathBuf, ArchiveError
|
||||
ArchiveFormat::TarXz => extract_tar_xz(data, &temp_dir)?,
|
||||
ArchiveFormat::TarBz2 => extract_tar_bz2(data, &temp_dir)?,
|
||||
ArchiveFormat::Tar => extract_tar(data, &temp_dir)?,
|
||||
ArchiveFormat::Zip => extract_zip(data, &temp_dir)?,
|
||||
}
|
||||
|
||||
strip_single_toplevel(&temp_dir, dest)
|
||||
@@ -93,36 +85,6 @@ fn extract_tar(data: &[u8], dest: &Path) -> Result<(), ArchiveError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn extract_zip(data: &[u8], dest: &Path) -> Result<(), ArchiveError> {
|
||||
let cursor = Cursor::new(data);
|
||||
let mut archive = zip::ZipArchive::new(cursor)?;
|
||||
|
||||
for i in 0..archive.len() {
|
||||
let mut file = archive.by_index(i)?;
|
||||
let outpath = dest.join(file.mangled_name());
|
||||
|
||||
if file.is_dir() {
|
||||
fs::create_dir_all(&outpath)?;
|
||||
} else {
|
||||
if let Some(parent) = outpath.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
let mut outfile = File::create(&outpath)?;
|
||||
std::io::copy(&mut file, &mut outfile)?;
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
if let Some(mode) = file.unix_mode() {
|
||||
fs::set_permissions(&outpath, fs::Permissions::from_mode(mode))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn strip_single_toplevel(temp_dir: &Path, dest: &Path) -> Result<PathBuf, ArchiveError> {
|
||||
let entries: Vec<_> = fs::read_dir(temp_dir)?
|
||||
.filter_map(|e| e.ok())
|
||||
@@ -185,21 +147,19 @@ fn copy_dir_recursive(src: &Path, dst: &Path) -> Result<(), std::io::Error> {
|
||||
|
||||
pub fn extract_tarball_to_temp(data: &[u8]) -> Result<(PathBuf, tempfile::TempDir), ArchiveError> {
|
||||
let temp_dir = tempfile::tempdir()?;
|
||||
let extracted_path = extract_archive(data, temp_dir.path())?;
|
||||
let extracted_path = extract_tarball(data, temp_dir.path())?;
|
||||
Ok((extracted_path, temp_dir))
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ArchiveError {
|
||||
IoError(std::io::Error),
|
||||
ZipError(zip::result::ZipError),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ArchiveError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ArchiveError::IoError(e) => write!(f, "I/O error: {}", e),
|
||||
ArchiveError::ZipError(e) => write!(f, "ZIP error: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,9 +171,3 @@ impl From<std::io::Error> for ArchiveError {
|
||||
ArchiveError::IoError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<zip::result::ZipError> for ArchiveError {
|
||||
fn from(e: zip::result::ZipError) -> Self {
|
||||
ArchiveError::ZipError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,6 @@ impl<Ctx: RuntimeContext> Runtime<Ctx> {
|
||||
);
|
||||
JsRuntime::init_platform(
|
||||
Some(v8::new_default_platform(0, false).make_shared()),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1137,7 +1137,6 @@ fn toml_to_nix(value: toml::Value) -> std::result::Result<NixJsonValue, NixRunti
|
||||
}
|
||||
|
||||
#[deno_core::op2]
|
||||
#[to_v8]
|
||||
pub(super) fn op_from_json(
|
||||
#[string] json_str: String,
|
||||
) -> std::result::Result<NixJsonValue, NixRuntimeError> {
|
||||
@@ -1147,7 +1146,6 @@ pub(super) fn op_from_json(
|
||||
}
|
||||
|
||||
#[deno_core::op2]
|
||||
#[to_v8]
|
||||
pub(super) fn op_from_toml(
|
||||
#[string] toml_str: String,
|
||||
) -> std::result::Result<NixJsonValue, NixRuntimeError> {
|
||||
|
||||
Reference in New Issue
Block a user