git.delta.rocks / jrsonnet / refs/commits / cd7c759361f6

difftreelog

fix carry more settings from environment

vurzumxqYaroslav Bolyukin2025-09-05parent: #771ccbb.patch.diff
in: trunk

8 files changed

modifiedCargo.lockdiffbeforeafterboth
737 "cipher",737 "cipher",
738]738]
739
740[[package]]
741name = "cursor-icon"
742version = "1.1.0"
743source = "registry+https://github.com/rust-lang/crates.io-index"
744checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
739745
740[[package]]746[[package]]
741name = "curve25519-dalek"747name = "curve25519-dalek"
1956 "tokio-util",1962 "tokio-util",
1957 "tracing",1963 "tracing",
1958 "tracing-indicatif",1964 "tracing-indicatif",
1965 "vte 0.15.0",
1959]1966]
19601967
1961[[package]]1968[[package]]
3666 "itoa",3673 "itoa",
3667 "log",3674 "log",
3668 "unicode-width 0.1.14",3675 "unicode-width 0.1.14",
3669 "vte",3676 "vte 0.11.1",
3670]3677]
36713678
3672[[package]]3679[[package]]
3680 "vte_generate_state_changes",3687 "vte_generate_state_changes",
3681]3688]
3689
3690[[package]]
3691name = "vte"
3692version = "0.15.0"
3693source = "registry+https://github.com/rust-lang/crates.io-index"
3694checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"
3695dependencies = [
3696 "arrayvec",
3697 "bitflags",
3698 "cursor-icon",
3699 "log",
3700 "memchr",
3701]
36823702
3683[[package]]3703[[package]]
3684name = "vte_generate_state_changes"3704name = "vte_generate_state_changes"
modifiedcrates/fleet-base/src/opts.rsdiffbeforeafterboth
88
9use anyhow::{Context, Result, bail};9use anyhow::{Context, Result, bail};
10use nix_eval::{10use nix_eval::{
11 FetchSettings, FlakeReference, FlakeReferenceParseFlags, FlakeSettings, Value, nix_go,11 FetchSettings, FlakeLockFlags, FlakeReference, FlakeReferenceParseFlags, FlakeSettings, Value,
12 util::assert_warn,12 nix_go, util::assert_warn,
13};13};
14use nom::{14use nom::{
230 &fetch_settings,230 &fetch_settings,
231 )?;231 )?;
232
233 let lock = FlakeLockFlags::new(&flake_settings)?;
234
232 let flake = flake.lock(&fetch_settings)?;235 let flake = flake.lock(&fetch_settings, &flake_settings, &lock)?;
233236
234 let flake = flake.get_attrs(&mut flake_settings)?;237 let flake = flake.get_attrs(&mut flake_settings)?;
235238
modifiedcrates/nix-eval/Cargo.tomldiffbeforeafterboth
19itertools = "0.14.0"19itertools = "0.14.0"
20test-log = { version = "0.2.18", features = ["trace"] }20test-log = { version = "0.2.18", features = ["trace"] }
21tracing-indicatif = { version = "0.3.13", optional = true }21tracing-indicatif = { version = "0.3.13", optional = true }
22vte = { version = "0.15.0", features = ["ansi"] }
2223
23[build-dependencies]24[build-dependencies]
24bindgen = "0.72.0"25bindgen = "0.72.0"
modifiedcrates/nix-eval/src/lib.rsdiffbeforeafterboth
19 alloc_value, c_context, c_context_create, err_code, err_info_msg, eval_state_build,19 alloc_value, c_context, c_context_create, err_code, err_info_msg, eval_state_build,
20 eval_state_builder_new, expr_eval_from_string, fetchers_settings, fetchers_settings_free,20 eval_state_builder_new, expr_eval_from_string, fetchers_settings, fetchers_settings_free,
21 fetchers_settings_new, flake_lock, flake_lock_flags, flake_lock_flags_free,21 fetchers_settings_new, flake_lock, flake_lock_flags, flake_lock_flags_free,
22 flake_lock_flags_new, flake_lock_flags_set_mode_virtual, flake_reference_parse_flags,22 flake_lock_flags_new, flake_reference_parse_flags, flake_reference_parse_flags_free,
23 flake_reference_parse_flags_free, flake_reference_parse_flags_new,23 flake_reference_parse_flags_new, flake_reference_parse_flags_set_base_directory,
24 flake_reference_parse_flags_set_base_directory, flake_settings, flake_settings_free,24 flake_settings, flake_settings_free, flake_settings_new, get_string, init_bool, init_int,
25 flake_settings_new, init_bool, init_int, init_string, locked_flake_free,25 init_string, locked_flake_free, locked_flake_get_output_attrs, set_err_msg, setting_set,
26 locked_flake_get_output_attrs, set_err_msg, setting_set, state_free, value_decref,26 state_free, value_decref, value_incref,
27 value_incref,
226 fn new() -> Result<Self> {225 fn new() -> Result<Self> {
227 let mut ctx = NixContext::new();226 let mut ctx = NixContext::new();
228 let store = ctx227 let store = ctx
229 .run_in_context(|c| unsafe { nix_raw::store_open(c, c"daemon".as_ptr(), null_mut()) })228 .run_in_context(|c| unsafe { nix_raw::store_open(c, c"auto".as_ptr(), null_mut()) })
230 .map(Store)?;229 .map(Store)?;
231230
232 let builder = ctx.run_in_context(|c| unsafe { eval_state_builder_new(c, store.0) })?;231 let builder = ctx.run_in_context(|c| unsafe { eval_state_builder_new(c, store.0) })?;
232 ctx.run_in_context(|c| {
233 unsafe { nix_raw::eval_state_builder_load(c, builder) }
234 // eval_s
235 })?;
233 ctx.run_in_context(|c| {236 ctx.run_in_context(|c| {
234 unsafe {237 unsafe {
235 nix_raw::eval_state_builder_set_eval_setting(238 nix_raw::eval_state_builder_set_eval_setting(
363 }366 }
364 }367 }
365}368}
366struct FlakeLockFlags(*mut flake_lock_flags);369pub struct FlakeLockFlags(*mut flake_lock_flags);
367impl FlakeLockFlags {370impl FlakeLockFlags {
368 fn new(settings: &mut FlakeSettings) -> Result<Self> {371 pub fn new(settings: &FlakeSettings) -> Result<Self> {
369 let o = with_default_context(|c, _| unsafe { flake_lock_flags_new(c, settings.0) })372 let o = with_default_context(|c, _| unsafe { flake_lock_flags_new(c, settings.0) })
370 .map(Self)?;373 .map(Self)?;
371 with_default_context(|c, _| unsafe { flake_lock_flags_set_mode_virtual(c, o.0) })?;374 // with_default_context(|c, _| unsafe { flake_lock_flags_set_mode_virtual(c, o.0) })?;
372375
373 Ok(o)376 Ok(o)
374 }377 }
432435
433 Ok((Self(out), fragment))436 Ok((Self(out), fragment))
434 }437 }
435 #[instrument(name = "lock-flake", skip(self, fetch))]438 #[instrument(name = "lock-flake", skip(self, fetch, flake, lock))]
436 pub fn lock(&mut self, fetch: &FetchSettings) -> Result<LockedFlake> {439 pub fn lock(
437 let mut settings = FlakeSettings::new()?;440 &mut self,
438 let lock_flags = FlakeLockFlags::new(&mut settings)?;441 fetch: &FetchSettings,
442 flake: &FlakeSettings,
443 lock: &FlakeLockFlags,
444 ) -> Result<LockedFlake> {
439 with_default_context(|c, es| unsafe {445 with_default_context(|c, es| unsafe { flake_lock(c, fetch.0, flake.0, es, lock.0, self.0) })
440 flake_lock(c, fetch.0, settings.0, es, lock_flags.0, self.0)
441 })
442 .map(LockedFlake)446 .map(LockedFlake)
443 }447 }
611 .expect("get_type should not fail");615 .expect("get_type should not fail");
612 NixType::from_int(ty)616 NixType::from_int(ty)
613 }617 }
618 fn builtin_to_string(&self) -> Result<Self> {
619 let builtin = Self::eval("builtins.toString")?;
620 builtin.call(self.clone())
621 }
614 pub fn to_string(&self) -> Result<String> {622 pub fn to_string(&self) -> Result<String> {
623 let mut str_out = String::new();
624 with_default_context(|c, _| unsafe {
615 Ok(self.to_realised_string()?.as_str().to_owned())625 get_string(c, self.0, Some(copy_nix_str), (&raw mut str_out).cast())
626 })?;
627
628 Ok(str_out)
616 }629 }
617 pub fn to_realised_string(&self) -> Result<RealisedString> {630 pub fn to_realised_string(&self) -> Result<RealisedString> {
618 with_default_context(|c, es| unsafe { nix_raw::string_realise(c, es, self.0, false) })631 with_default_context(|c, es| unsafe { nix_raw::string_realise(c, es, self.0, false) })
751 self.clone()764 self.clone()
752 };765 };
753 // to_string here blocks until the path is built766 // to_string here blocks until the path is built
754 let drv_path = tokio::task::spawn_blocking(move || v.get_field("outPath")?.to_string())767 let drv_path =
768 tokio::task::spawn_blocking(move || v.builtin_to_string()?.to_realised_string())
755 .await769 .await
756 .expect("should not fail")?;770 .expect("spawn should not fail")?;
757 Ok(PathBuf::from(drv_path))771 Ok(PathBuf::from(drv_path.as_str()))
758 }772 }
759 pub fn as_json<T: DeserializeOwned>(&self) -> Result<T> {773 pub fn as_json<T: DeserializeOwned>(&self) -> Result<T> {
760 let to_json = Self::eval("builtins.toJSON")?;774 let to_json = Self::eval("builtins.toJSON")?;
835849
836pub fn init_libraries() {850pub fn init_libraries() {
837 unsafe { nix_raw::GC_allow_register_threads() };851 unsafe { nix_raw::GC_allow_register_threads() };
852 unsafe {
853 nix_raw::GC_init();
854 };
838855
839 let mut ctx = NixContext::new();856 let mut ctx = NixContext::new();
840 ctx.run_in_context(|c| unsafe { nix_raw::libutil_init(c) })857 ctx.run_in_context(|c| unsafe { nix_raw::libutil_init(c) })
modifiedcrates/nix-eval/src/logging.ccdiffbeforeafterboth
60extern "C" {60extern "C" {
61void apply_tracing_logger() {61void apply_tracing_logger() {
62 logger = std::make_unique<TracingLogger>();62 logger = std::make_unique<TracingLogger>();
63 // verbosity = lvlVomit;
63}64}
64}65}
6566
modifiedcrates/nix-eval/src/logging.rsdiffbeforeafterboth
8};8};
9#[cfg(feature = "indicatif")]9#[cfg(feature = "indicatif")]
10use tracing_indicatif::span_ext::IndicatifSpanExt as _;10use tracing_indicatif::span_ext::IndicatifSpanExt as _;
11use vte::Parser;
1112
12#[derive(Debug)]13#[derive(Debug)]
13enum ActivityType {14enum ActivityType {
374 }375 }
375 };376 };
376 if !s.trim().is_empty() {377 if !s.trim().is_empty() {
378 let s = ansi_filter(s);
377 #[cfg(feature = "indicatif")]379 #[cfg(feature = "indicatif")]
378 {380 {
379 span.pb_set_message(s);381 span.pb_set_message(s);
413 match (&res, self.fields.as_slice()) {415 match (&res, self.fields.as_slice()) {
414 // ResultType::FileLinked => todo!(),416 // ResultType::FileLinked => todo!(),
415 (ResultType::BuildLogLine, [Str(s)]) => {417 (ResultType::BuildLogLine, [Str(s)]) => {
418 let s = ansi_filter(s);
416 info!("{s:?}");419 info!("{s}");
417 }420 }
418 // ResultType::UntrustedPath => todo!(),421 // ResultType::UntrustedPath => todo!(),
419 // ResultType::CorruptedPath => todo!(),422 // ResultType::CorruptedPath => todo!(),
468 }471 }
469}472}
473
474struct AnsiFiltered {
475 output: String,
476}
477impl vte::Perform for AnsiFiltered {
478 fn print(&mut self, c: char) {
479 self.output.push(c);
480 }
481
482 fn execute(&mut self, byte: u8) {
483 // We don't want \r, bells, etc
484 if byte == b'\n' {
485 self.output.push('\n');
486 } else if byte == b'\t' {
487 // TODO: align output to the correct multiplier?
488 self.output.push('\t');
489 }
490 }
491
492 fn osc_dispatch(&mut self, _params: &[&[u8]], _bell_terminated: bool) {}
493 fn esc_dispatch(&mut self, _intermediates: &[u8], _ignore: bool, _byte: u8) {}
494
495 fn csi_dispatch(
496 &mut self,
497 params: &vte::Params,
498 _intermediates: &[u8],
499 _ignore: bool,
500 action: char,
501 ) {
502 use std::fmt::Write;
503 if action != 'm' {
504 // Only plain colors are enabled, everything other might corrupt the output
505 return;
506 }
507 self.output.push_str("IDK\x1b[");
508 for (i, par) in params.iter().enumerate() {
509 if i != 0 {
510 let _ = write!(self.output, ";");
511 }
512 for (i, sub) in par.iter().enumerate() {
513 if i != 0 {
514 let _ = write!(self.output, ":");
515 }
516 let _ = write!(self.output, "{sub}");
517 }
518 }
519 self.output.push(action);
520 }
521}
522fn ansi_filter(i: &str) -> String {
523 let mut out = AnsiFiltered {
524 output: String::new(),
525 };
526 let mut parser = Parser::new();
527
528 // For some reason it gets stuck with longer inputs
529 for chunk in i.as_bytes().chunks(50) {
530 parser.advance(&mut out, chunk);
531 }
532
533 out.output
534}
470535
471#[cxx::bridge]536#[cxx::bridge]
472pub mod nix_logging_cxx {537pub mod nix_logging_cxx {
modifiedflake.lockdiffbeforeafterboth
104 "nixpkgs-regression": "nixpkgs-regression"104 "nixpkgs-regression": "nixpkgs-regression"
105 },105 },
106 "locked": {106 "locked": {
107 "lastModified": 1757000273,107 "lastModified": 1757031817,
108 "owner": "deltarocks",108 "owner": "deltarocks",
109 "repo": "nix",109 "repo": "nix",
110 "rev": "eba1f549ec21208cf98343f1351a95e2e6eb3fbb",110 "rev": "2261305161dc02496c8aedcdda14ace04b9b1dc1",
111 "type": "github"111 "type": "github"
112 },112 },
113 "original": {113 "original": {
modifiedlib/flakePart.nixdiffbeforeafterboth

no syntactic changes