difftreelog
fix makeArray should be lazy
in: master
7 files changed
crates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -32,6 +32,8 @@
Reverse(Box<ReverseArray>),
/// Returned by `std.map` call
Mapped(MappedArray),
+ /// Returned by `std.repeat` call
+ Repeated(RepeatedArray),
}
impl ArrValue {
@@ -51,6 +53,10 @@
Self::Eager(EagerArray(values))
}
+ pub fn repeated(data: ArrValue, repeats: usize) -> Option<Self> {
+ Some(Self::Repeated(RepeatedArray::new(data, repeats)?))
+ }
+
pub fn bytes(bytes: IBytes) -> Self {
Self::Bytes(BytesArray(bytes))
}
@@ -76,7 +82,11 @@
// TODO: benchmark for an optimal value, currently just a arbitrary choice
const ARR_EXTEND_THRESHOLD: usize = 100;
- if a.len() + b.len() > ARR_EXTEND_THRESHOLD {
+ if a.is_empty() {
+ b
+ } else if b.is_empty() {
+ a
+ } else if a.len() + b.len() > ARR_EXTEND_THRESHOLD {
Self::Extended(Cc::new(ExtendedArray::new(a, b)))
} else if let (Some(a), Some(b)) = (a.iter_cheap(), b.iter_cheap()) {
let mut out = Vec::with_capacity(a.len() + b.len());
@@ -189,10 +199,8 @@
(ArrValue::Lazy(a), ArrValue::Lazy(b)) => Cc::ptr_eq(&a.0, &b.0),
(ArrValue::Expr(a), ArrValue::Expr(b)) => Cc::ptr_eq(&a.0, &b.0),
(ArrValue::Eager(a), ArrValue::Eager(b)) => Cc::ptr_eq(&a.0, &b.0),
- (ArrValue::Extended(a), ArrValue::Extended(b)) => Cc::ptr_eq(&a, &b),
+ (ArrValue::Extended(a), ArrValue::Extended(b)) => Cc::ptr_eq(a, b),
(ArrValue::Range(a), ArrValue::Range(b)) => a == b,
- (ArrValue::Slice(_), ArrValue::Slice(_)) => false,
- (ArrValue::Reverse(_), ArrValue::Reverse(_)) => false,
_ => false,
}
}
@@ -203,6 +211,7 @@
ArrValue::Extended(v) => v.a.is_cheap() && v.b.is_cheap(),
ArrValue::Slice(r) => r.inner.is_cheap(),
ArrValue::Reverse(i) => i.0.is_cheap(),
+ ArrValue::Repeated(v) => v.is_cheap(),
ArrValue::Expr(_) | ArrValue::Lazy(_) | ArrValue::Mapped(_) => false,
}
}
crates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/spec.rs
+++ b/crates/jrsonnet-evaluator/src/arr/spec.rs
@@ -740,6 +740,96 @@
}
// impl MappedArray
+#[derive(Trace, Debug)]
+pub struct RepeatedArrayInner {
+ data: ArrValue,
+ repeats: usize,
+ total_len: usize,
+}
+#[derive(Trace, Debug, Clone)]
+pub struct RepeatedArray(Cc<RepeatedArrayInner>);
+impl RepeatedArray {
+ pub fn new(data: ArrValue, repeats: usize) -> Option<Self> {
+ let total_len = data.len().checked_mul(repeats)?;
+ Some(Self(Cc::new(RepeatedArrayInner {
+ data,
+ repeats,
+ total_len,
+ })))
+ }
+ pub fn is_cheap(&self) -> bool {
+ self.0.data.is_cheap()
+ }
+}
+
+type RepeatedArrayIter<'t> = impl DoubleEndedIterator<Item = Result<Val>> + ExactSizeIterator + 't;
+type RepeatedArrayLazyIter<'t> =
+ impl DoubleEndedIterator<Item = Thunk<Val>> + ExactSizeIterator + 't;
+type RepeatedArrayCheapIter<'t> = impl DoubleEndedIterator<Item = Val> + ExactSizeIterator + 't;
+impl ArrayLike for RepeatedArray {
+ type Iter<'t> = RepeatedArrayIter<'t>;
+ type IterLazy<'t> = RepeatedArrayLazyIter<'t>;
+ type IterCheap<'t> = RepeatedArrayCheapIter<'t>;
+
+ fn len(&self) -> usize {
+ self.0.total_len
+ }
+
+ fn get(&self, index: usize) -> Result<Option<Val>> {
+ if index > self.0.total_len {
+ return Ok(None);
+ }
+ self.0.data.get(index % self.0.data.len())
+ }
+
+ fn get_lazy(&self, index: usize) -> Option<Thunk<Val>> {
+ if index > self.0.total_len {
+ return None;
+ }
+ self.0.data.get_lazy(index % self.0.data.len())
+ }
+
+ fn get_cheap(&self, index: usize) -> Option<Val> {
+ if index > self.0.total_len {
+ return None;
+ }
+ self.0.data.get_cheap(index % self.0.data.len())
+ }
+
+ fn evaluated(&self) -> Result<Vec<Val>> {
+ let mut data = self.0.data.evaluated()?;
+ let data_range = 0..data.len();
+ for _ in 1..self.0.repeats {
+ data.extend_from_within(data_range.clone());
+ }
+ Ok(data)
+ }
+
+ fn iter(&self) -> RepeatedArrayIter<'_> {
+ (0..self.0.total_len)
+ .map(|i| self.get(i))
+ .map(Result::transpose)
+ .map(Option::unwrap)
+ }
+
+ fn iter_lazy(&self) -> RepeatedArrayLazyIter<'_> {
+ (0..self.0.total_len)
+ .map(|i| self.get_lazy(i))
+ .map(Option::unwrap)
+ }
+
+ fn iter_cheap(&self) -> Option<RepeatedArrayCheapIter<'_>> {
+ if !self.0.data.is_cheap() {
+ return None;
+ }
+ Some(
+ (0..self.0.total_len)
+ .map(|i| self.get_cheap(i))
+ .map(Option::unwrap),
+ )
+ }
+}
+
macro_rules! impl_iter_enum {
($n:ident => $v:ident) => {
pub enum $n<'t> {
@@ -752,6 +842,7 @@
Extended(Box<<ExtendedArray as ArrayLike>::$v<'t>>),
Reverse(Box<<ReverseArray as ArrayLike>::$v<'t>>),
Mapped(Box<<MappedArray as ArrayLike>::$v<'t>>),
+ Repeated(Box<<RepeatedArray as ArrayLike>::$v<'t>>),
}
};
}
@@ -768,6 +859,7 @@
Self::Extended(e) => e.$m($($ident)*),
Self::Reverse(e) => e.$m($($ident)*),
Self::Mapped(e) => e.$m($($ident)*),
+ Self::Repeated(e) => e.$m($($ident)*),
}
};
}
@@ -785,6 +877,7 @@
ArrValue::Extended(e) => $e::Extended(Box::new($($wrap!)?(e.$c()))),
ArrValue::Reverse(e) => $e::Reverse(Box::new($($wrap!)?(e.$c()))),
ArrValue::Mapped(e) => $e::Mapped(Box::new($($wrap!)?(e.$c()))),
+ ArrValue::Repeated(e) => $e::Repeated(Box::new($($wrap!)?(e.$c()))),
}
};
}
@@ -827,6 +920,7 @@
}
Self::Reverse(e) => e.len(),
Self::Mapped(e) => e.len(),
+ Self::Repeated(e) => e.len(),
}
}
}
crates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -12,7 +12,9 @@
native::NativeDesc,
parse::{parse_default_function_call, parse_function_call},
};
-use crate::{evaluate, gc::TraceBox, typed::Any, Context, ContextBuilder, Result, Val};
+use crate::{
+ evaluate, evaluate_trivial, gc::TraceBox, typed::Any, Context, ContextBuilder, Result, Val,
+};
pub mod arglike;
pub mod builtin;
@@ -80,6 +82,10 @@
) -> Result<Context> {
parse_function_call(call_ctx, self.ctx.clone(), &self.params, args, tailstrict)
}
+
+ pub fn evaluate_trivial(&self) -> Option<Val> {
+ evaluate_trivial(&self.body)
+ }
}
/// Represents a Jsonnet function value, including plain functions and user-provided builtins.
@@ -201,4 +207,11 @@
pub const fn identity() -> Self {
Self::Id
}
+
+ pub fn evaluate_trivial(&self) -> Option<Val> {
+ match self {
+ FuncVal::Normal(n) => n.evaluate_trivial(),
+ _ => None,
+ }
+ }
}
crates/jrsonnet-stdlib/src/arrays.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/arrays.rs
+++ b/crates/jrsonnet-stdlib/src/arrays.rs
@@ -1,23 +1,41 @@
use jrsonnet_evaluator::{
- error::Result,
+ error::{ErrorKind::RuntimeError, Result},
function::{builtin, FuncVal},
throw,
- typed::{Any, BoundedUsize, Either2, NativeFn, Typed, VecVal},
- val::{equals, ArrValue, IndexableVal},
+ typed::{Any, BoundedI32, BoundedUsize, Either2, NativeFn, Typed},
+ val::{equals, ArrValue, IndexableVal, StrValue},
Either, IStr, Val,
};
use jrsonnet_gcmodule::Cc;
#[builtin]
-pub fn builtin_make_array(sz: usize, func: NativeFn<((f64,), Any)>) -> Result<VecVal> {
- let mut out = Vec::with_capacity(sz);
- for i in 0..sz {
- out.push(func(i as f64)?.0);
+pub fn builtin_make_array(sz: BoundedI32<0, { i32::MAX }>, func: FuncVal) -> Result<ArrValue> {
+ if *sz == 0 {
+ return Ok(ArrValue::empty());
+ }
+ if let Some(trivial) = func.evaluate_trivial() {
+ let mut out = Vec::with_capacity(*sz as usize);
+ for _ in 0..*sz {
+ out.push(trivial.clone())
+ }
+ Ok(ArrValue::eager(Cc::new(out)))
+ } else {
+ Ok(ArrValue::range_exclusive(0, *sz).map(func))
}
- Ok(VecVal(Cc::new(out)))
}
#[builtin]
+pub fn builtin_repeat(what: Either![IStr, ArrValue], count: usize) -> Result<Any> {
+ Ok(Any(match what {
+ Either2::A(s) => Val::Str(StrValue::Flat(s.repeat(count).into())),
+ Either2::B(arr) => Val::Arr(
+ ArrValue::repeated(arr, count)
+ .ok_or_else(|| RuntimeError("repeated length overflow".into()))?,
+ ),
+ }))
+}
+
+#[builtin]
pub fn builtin_slice(
indexable: IndexableVal,
index: Option<BoundedUsize<0, { i32::MAX as usize }>>,
crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth1use std::{2 cell::{Ref, RefCell, RefMut},3 collections::HashMap,4 rc::Rc,5};67use jrsonnet_evaluator::{8 error::{ErrorKind::*, Result},9 function::{builtin::Builtin, CallLocation, FuncVal, TlaArg},10 gc::{GcHashMap, TraceBox},11 tb,12 trace::PathResolver,13 Context, ContextBuilder, IStr, ObjValue, ObjValueBuilder, State, Thunk, Val,14};15use jrsonnet_gcmodule::{Cc, Trace};16use jrsonnet_parser::Source;1718mod expr;19mod types;20pub use types::*;21mod arrays;22pub use arrays::*;23mod math;24pub use math::*;25mod operator;26pub use operator::*;27mod sort;28pub use sort::*;29mod hash;30pub use hash::*;31mod encoding;32pub use encoding::*;33mod objects;34pub use objects::*;35mod manifest;36pub use manifest::*;37mod parse;38pub use parse::*;39mod strings;40pub use strings::*;41mod misc;42pub use misc::*;4344pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> ObjValue {45 let mut builder = ObjValueBuilder::new();4647 let expr = expr::stdlib_expr();48 let eval = jrsonnet_evaluator::evaluate(ContextBuilder::dangerous_empty_state().build(), &expr)49 .expect("stdlib.jsonnet should have no errors")50 .as_obj()51 .expect("stdlib.jsonnet should evaluate to object");5253 builder.with_super(eval);5455 for (name, builtin) in [56 // Types57 ("type", builtin_type::INST),58 ("isString", builtin_is_string::INST),59 ("isNumber", builtin_is_number::INST),60 ("isBoolean", builtin_is_boolean::INST),61 ("isObject", builtin_is_object::INST),62 ("isArray", builtin_is_array::INST),63 ("isFunction", builtin_is_function::INST),64 // Arrays65 ("makeArray", builtin_make_array::INST),66 ("slice", builtin_slice::INST),67 ("map", builtin_map::INST),68 ("flatMap", builtin_flatmap::INST),69 ("filter", builtin_filter::INST),70 ("foldl", builtin_foldl::INST),71 ("foldr", builtin_foldr::INST),72 ("range", builtin_range::INST),73 ("join", builtin_join::INST),74 ("reverse", builtin_reverse::INST),75 ("any", builtin_any::INST),76 ("all", builtin_all::INST),77 ("member", builtin_member::INST),78 ("count", builtin_count::INST),79 // Math80 ("abs", builtin_abs::INST),81 ("sign", builtin_sign::INST),82 ("max", builtin_max::INST),83 ("min", builtin_min::INST),84 ("modulo", builtin_modulo::INST),85 ("floor", builtin_floor::INST),86 ("ceil", builtin_ceil::INST),87 ("log", builtin_log::INST),88 ("pow", builtin_pow::INST),89 ("sqrt", builtin_sqrt::INST),90 ("sin", builtin_sin::INST),91 ("cos", builtin_cos::INST),92 ("tan", builtin_tan::INST),93 ("asin", builtin_asin::INST),94 ("acos", builtin_acos::INST),95 ("atan", builtin_atan::INST),96 ("exp", builtin_exp::INST),97 ("mantissa", builtin_mantissa::INST),98 ("exponent", builtin_exponent::INST),99 // Operator100 ("mod", builtin_mod::INST),101 ("primitiveEquals", builtin_primitive_equals::INST),102 ("equals", builtin_equals::INST),103 ("format", builtin_format::INST),104 // Sort105 ("sort", builtin_sort::INST),106 // Hash107 ("md5", builtin_md5::INST),108 #[cfg(feature = "exp-more-hashes")]109 ("sha256", builtin_sha256::INST),110 // Encoding111 ("encodeUTF8", builtin_encode_utf8::INST),112 ("decodeUTF8", builtin_decode_utf8::INST),113 ("base64", builtin_base64::INST),114 ("base64Decode", builtin_base64_decode::INST),115 ("base64DecodeBytes", builtin_base64_decode_bytes::INST),116 // Objects117 ("objectFieldsEx", builtin_object_fields_ex::INST),118 ("objectHasEx", builtin_object_has_ex::INST),119 // Manifest120 ("escapeStringJson", builtin_escape_string_json::INST),121 ("manifestJsonEx", builtin_manifest_json_ex::INST),122 ("manifestYamlDoc", builtin_manifest_yaml_doc::INST),123 // Parsing124 ("parseJson", builtin_parse_json::INST),125 ("parseYaml", builtin_parse_yaml::INST),126 // Strings127 ("codepoint", builtin_codepoint::INST),128 ("substr", builtin_substr::INST),129 ("char", builtin_char::INST),130 ("strReplace", builtin_str_replace::INST),131 ("splitLimit", builtin_splitlimit::INST),132 ("asciiUpper", builtin_ascii_upper::INST),133 ("asciiLower", builtin_ascii_lower::INST),134 ("findSubstr", builtin_find_substr::INST),135 ("parseInt", builtin_parse_int::INST),136 ("parseOctal", builtin_parse_octal::INST),137 ("parseHex", builtin_parse_hex::INST),138 // Misc139 ("length", builtin_length::INST),140 ("startsWith", builtin_starts_with::INST),141 ("endsWith", builtin_ends_with::INST),142 ]143 .iter()144 .cloned()145 {146 builder147 .member(name.into())148 .hide()149 .value(Val::Func(FuncVal::StaticBuiltin(builtin)))150 .expect("no conflict");151 }152153 builder154 .member("extVar".into())155 .hide()156 .value(Val::Func(FuncVal::Builtin(Cc::new(tb!(builtin_ext_var {157 settings: settings.clone()158 })))))159 .expect("no conflict");160 builder161 .member("native".into())162 .hide()163 .value(Val::Func(FuncVal::Builtin(Cc::new(tb!(builtin_native {164 settings: settings.clone()165 })))))166 .expect("no conflict");167 builder168 .member("trace".into())169 .hide()170 .value(Val::Func(FuncVal::Builtin(Cc::new(tb!(builtin_trace {171 settings172 })))))173 .expect("no conflict");174175 builder176 .member("id".into())177 .hide()178 .value(Val::Func(FuncVal::Id))179 .expect("no conflict");180181 builder.build()182}183184pub trait TracePrinter {185 fn print_trace(&self, loc: CallLocation, value: IStr);186}187188pub struct StdTracePrinter {189 resolver: PathResolver,190}191impl StdTracePrinter {192 pub fn new(resolver: PathResolver) -> Self {193 Self { resolver }194 }195}196impl TracePrinter for StdTracePrinter {197 fn print_trace(&self, loc: CallLocation, value: IStr) {198 eprint!("TRACE:");199 if let Some(loc) = loc.0 {200 let locs = loc.0.map_source_locations(&[loc.1]);201 eprint!(202 " {}:{}",203 match loc.0.source_path().path() {204 Some(p) => self.resolver.resolve(p),205 None => loc.0.source_path().to_string(),206 },207 locs[0].line208 );209 }210 eprintln!(" {}", value);211 }212}213214pub struct Settings {215 /// Used for `std.extVar`216 pub ext_vars: HashMap<IStr, TlaArg>,217 /// Used for `std.native`218 pub ext_natives: HashMap<IStr, Cc<TraceBox<dyn Builtin>>>,219 /// Helper to add globals without implementing custom ContextInitializer220 pub globals: GcHashMap<IStr, Thunk<Val>>,221 /// Used for `std.trace`222 pub trace_printer: Box<dyn TracePrinter>,223 /// Used for `std.thisFile`224 pub path_resolver: PathResolver,225}226227fn extvar_source(name: &str, code: impl Into<IStr>) -> Source {228 let source_name = format!("<extvar:{}>", name);229 Source::new_virtual(source_name.into(), code.into())230}231232#[derive(Trace)]233pub struct ContextInitializer {234 // When we don't need to support legacy-this-file, we can reuse same context for all files235 #[cfg(not(feature = "legacy-this-file"))]236 context: Context,237 // Otherwise, we can only keep first stdlib layer, and then stack thisFile on top of it238 #[cfg(feature = "legacy-this-file")]239 stdlib_obj: ObjValue,240 settings: Rc<RefCell<Settings>>,241}242impl ContextInitializer {243 pub fn new(s: State, resolver: PathResolver) -> Self {244 let settings = Settings {245 ext_vars: Default::default(),246 ext_natives: Default::default(),247 globals: Default::default(),248 trace_printer: Box::new(StdTracePrinter::new(resolver.clone())),249 path_resolver: resolver,250 };251 let settings = Rc::new(RefCell::new(settings));252 Self {253 #[cfg(not(feature = "legacy-this-file"))]254 context: {255 let mut context = ContextBuilder::with_capacity(s, 1);256 context.bind(257 "std".into(),258 Thunk::evaluated(Val::Obj(stdlib_uncached(settings.clone()))),259 );260 context.build()261 },262 #[cfg(feature = "legacy-this-file")]263 stdlib_obj: stdlib_uncached(settings.clone()),264 settings,265 }266 }267 pub fn settings(&self) -> Ref<Settings> {268 self.settings.borrow()269 }270 pub fn settings_mut(&self) -> RefMut<Settings> {271 self.settings.borrow_mut()272 }273 pub fn add_ext_var(&self, name: IStr, value: Val) {274 self.settings_mut()275 .ext_vars276 .insert(name, TlaArg::Val(value));277 }278 pub fn add_ext_str(&self, name: IStr, value: IStr) {279 self.settings_mut()280 .ext_vars281 .insert(name, TlaArg::String(value));282 }283 pub fn add_ext_code(&self, name: &str, code: impl Into<IStr>) -> Result<()> {284 let code = code.into();285 let source = extvar_source(name, code.clone());286 let parsed = jrsonnet_parser::parse(287 &code,288 &jrsonnet_parser::ParserSettings {289 source: source.clone(),290 },291 )292 .map_err(|e| ImportSyntaxError {293 path: source,294 error: Box::new(e),295 })?;296 // self.data_mut().volatile_files.insert(source_name, code);297 self.settings_mut()298 .ext_vars299 .insert(name.into(), TlaArg::Code(parsed));300 Ok(())301 }302 pub fn add_native(&self, name: IStr, cb: Cc<TraceBox<dyn Builtin>>) {303 self.settings_mut().ext_natives.insert(name, cb);304 }305}306impl jrsonnet_evaluator::ContextInitializer for ContextInitializer {307 #[cfg(not(feature = "legacy-this-file"))]308 fn initialize(&self, _s: State, _source: Source) -> jrsonnet_evaluator::Context {309 let out = self.context.clone();310 let globals = &self.settings().globals;311 if globals.is_empty() {312 return out;313 }314315 let mut out = ContextBuilder::extend(out);316 for (k, v) in globals.iter() {317 out.bind(k.clone(), v.clone());318 }319 out.build()320 }321 #[cfg(feature = "legacy-this-file")]322 fn initialize(&self, s: State, source: Source) -> Context {323 use jrsonnet_evaluator::val::StrValue;324325 let mut builder = ObjValueBuilder::new();326 builder.with_super(self.stdlib_obj.clone());327 builder328 .member("thisFile".into())329 .hide()330 .value(Val::Str(StrValue::Flat(331 match source.source_path().path() {332 Some(p) => self.settings().path_resolver.resolve(p).into(),333 None => source.source_path().to_string().into(),334 },335 )))336 .expect("this object builder is empty");337 let stdlib_with_this_file = builder.build();338339 let mut context = ContextBuilder::with_capacity(s, 1);340 context.bind(341 "std".into(),342 Thunk::evaluated(Val::Obj(stdlib_with_this_file)),343 );344 for (k, v) in self.settings().globals.iter() {345 context.bind(k.clone(), v.clone());346 }347 context.build()348 }349 fn as_any(&self) -> &dyn std::any::Any {350 self351 }352}353354pub trait StateExt {355 /// This method was previously implemented in jrsonnet-evaluator itself356 fn with_stdlib(&self);357 fn add_global(&self, name: IStr, value: Thunk<Val>);358}359360impl StateExt for State {361 fn with_stdlib(&self) {362 let initializer = ContextInitializer::new(self.clone(), PathResolver::new_cwd_fallback());363 self.settings_mut().context_initializer = tb!(initializer)364 }365 fn add_global(&self, name: IStr, value: Thunk<Val>) {366 self.settings()367 .context_initializer368 .as_any()369 .downcast_ref::<ContextInitializer>()370 .expect("not standard context initializer")371 .settings_mut()372 .globals373 .insert(name, value);374 }375}crates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/std.jsonnet
+++ b/crates/jrsonnet-stdlib/src/std.jsonnet
@@ -27,13 +27,6 @@
split(str, c):: std.splitLimit(str, c, -1),
- repeat(what, count)::
- local joiner =
- if std.isString(what) then ''
- else if std.isArray(what) then []
- else error 'std.repeat first argument must be an array or a string';
- std.join(joiner, std.makeArray(count, function(i) what)),
-
mapWithIndex(func, arr)::
if !std.isFunction(func) then
error ('std.mapWithIndex first param must be function, got ' + std.type(func))
nix/jrsonnet-release.nixdiffbeforeafterboth--- /dev/null
+++ b/nix/jrsonnet-release.nix
@@ -0,0 +1,24 @@
+{ lib, fetchFromGitHub, rustPlatform, runCommand, makeWrapper }:
+
+
+rustPlatform.buildRustPackage rec {
+ pname = "jrsonnet";
+ version = "5f0f8de9f52f961e2ff162e0a3fd4ca20a275f1d";
+
+ src = fetchFromGitHub {
+ owner = "CertainLach";
+ repo = pname;
+ rev = version;
+ hash = lib.fakeHash;
+ };
+
+ cargoTestFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
+ cargoBuildFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
+
+ buildInputs = [ makeWrapper ];
+
+ postInstall = ''
+ mv $out/bin/jrsonnet $out/bin/jrsonnet-release
+ wrapProgram $out/bin/jrsonnet-release --add-flags "--max-stack=200000 --os-stack=200000"
+ '';
+}