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
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -738,6 +738,12 @@
 ]
 
 [[package]]
+name = "cursor-icon"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
+
+[[package]]
 name = "curve25519-dalek"
 version = "4.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1956,6 +1962,7 @@
  "tokio-util",
  "tracing",
  "tracing-indicatif",
+ "vte 0.15.0",
 ]
 
 [[package]]
@@ -3666,7 +3673,7 @@
  "itoa",
  "log",
  "unicode-width 0.1.14",
- "vte",
+ "vte 0.11.1",
 ]
 
 [[package]]
@@ -3681,6 +3688,19 @@
 ]
 
 [[package]]
+name = "vte"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"
+dependencies = [
+ "arrayvec",
+ "bitflags",
+ "cursor-icon",
+ "log",
+ "memchr",
+]
+
+[[package]]
 name = "vte_generate_state_changes"
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
modifiedcrates/fleet-base/src/opts.rsdiffbeforeafterboth
--- a/crates/fleet-base/src/opts.rs
+++ b/crates/fleet-base/src/opts.rs
@@ -8,8 +8,8 @@
 
 use anyhow::{Context, Result, bail};
 use nix_eval::{
-	FetchSettings, FlakeReference, FlakeReferenceParseFlags, FlakeSettings, Value, nix_go,
-	util::assert_warn,
+	FetchSettings, FlakeLockFlags, FlakeReference, FlakeReferenceParseFlags, FlakeSettings, Value,
+	nix_go, util::assert_warn,
 };
 use nom::{
 	Parser,
@@ -229,8 +229,11 @@
 			&parse,
 			&fetch_settings,
 		)?;
-		let flake = flake.lock(&fetch_settings)?;
 
+		let lock = FlakeLockFlags::new(&flake_settings)?;
+
+		let flake = flake.lock(&fetch_settings, &flake_settings, &lock)?;
+
 		let flake = flake.get_attrs(&mut flake_settings)?;
 
 		let builtins_field = Value::eval("builtins")?;
modifiedcrates/nix-eval/Cargo.tomldiffbeforeafterboth
--- a/crates/nix-eval/Cargo.toml
+++ b/crates/nix-eval/Cargo.toml
@@ -19,6 +19,7 @@
 itertools = "0.14.0"
 test-log = { version = "0.2.18", features = ["trace"] }
 tracing-indicatif = { version = "0.3.13", optional = true }
+vte = { version = "0.15.0", features = ["ansi"] }
 
 [build-dependencies]
 bindgen = "0.72.0"
modifiedcrates/nix-eval/src/lib.rsdiffbeforeafterboth
--- a/crates/nix-eval/src/lib.rs
+++ b/crates/nix-eval/src/lib.rs
@@ -19,12 +19,11 @@
 	alloc_value, c_context, c_context_create, err_code, err_info_msg, eval_state_build,
 	eval_state_builder_new, expr_eval_from_string, fetchers_settings, fetchers_settings_free,
 	fetchers_settings_new, flake_lock, flake_lock_flags, flake_lock_flags_free,
-	flake_lock_flags_new, flake_lock_flags_set_mode_virtual, flake_reference_parse_flags,
-	flake_reference_parse_flags_free, flake_reference_parse_flags_new,
-	flake_reference_parse_flags_set_base_directory, flake_settings, flake_settings_free,
-	flake_settings_new, init_bool, init_int, init_string, locked_flake_free,
-	locked_flake_get_output_attrs, set_err_msg, setting_set, state_free, value_decref,
-	value_incref,
+	flake_lock_flags_new, flake_reference_parse_flags, flake_reference_parse_flags_free,
+	flake_reference_parse_flags_new, flake_reference_parse_flags_set_base_directory,
+	flake_settings, flake_settings_free, flake_settings_new, get_string, init_bool, init_int,
+	init_string, locked_flake_free, locked_flake_get_output_attrs, set_err_msg, setting_set,
+	state_free, value_decref, value_incref,
 };
 
 // Contains macros helpers
@@ -226,11 +225,15 @@
 	fn new() -> Result<Self> {
 		let mut ctx = NixContext::new();
 		let store = ctx
-			.run_in_context(|c| unsafe { nix_raw::store_open(c, c"daemon".as_ptr(), null_mut()) })
+			.run_in_context(|c| unsafe { nix_raw::store_open(c, c"auto".as_ptr(), null_mut()) })
 			.map(Store)?;
 
 		let builder = ctx.run_in_context(|c| unsafe { eval_state_builder_new(c, store.0) })?;
 		ctx.run_in_context(|c| {
+			unsafe { nix_raw::eval_state_builder_load(c, builder) }
+			// eval_s
+		})?;
+		ctx.run_in_context(|c| {
 			unsafe {
 				nix_raw::eval_state_builder_set_eval_setting(
 					c,
@@ -363,12 +366,12 @@
 		}
 	}
 }
-struct FlakeLockFlags(*mut flake_lock_flags);
+pub struct FlakeLockFlags(*mut flake_lock_flags);
 impl FlakeLockFlags {
-	fn new(settings: &mut FlakeSettings) -> Result<Self> {
+	pub fn new(settings: &FlakeSettings) -> Result<Self> {
 		let o = with_default_context(|c, _| unsafe { flake_lock_flags_new(c, settings.0) })
 			.map(Self)?;
-		with_default_context(|c, _| unsafe { flake_lock_flags_set_mode_virtual(c, o.0) })?;
+		// with_default_context(|c, _| unsafe { flake_lock_flags_set_mode_virtual(c, o.0) })?;
 
 		Ok(o)
 	}
@@ -432,14 +435,15 @@
 
 		Ok((Self(out), fragment))
 	}
-	#[instrument(name = "lock-flake", skip(self, fetch))]
-	pub fn lock(&mut self, fetch: &FetchSettings) -> Result<LockedFlake> {
-		let mut settings = FlakeSettings::new()?;
-		let lock_flags = FlakeLockFlags::new(&mut settings)?;
-		with_default_context(|c, es| unsafe {
-			flake_lock(c, fetch.0, settings.0, es, lock_flags.0, self.0)
-		})
-		.map(LockedFlake)
+	#[instrument(name = "lock-flake", skip(self, fetch, flake, lock))]
+	pub fn lock(
+		&mut self,
+		fetch: &FetchSettings,
+		flake: &FlakeSettings,
+		lock: &FlakeLockFlags,
+	) -> Result<LockedFlake> {
+		with_default_context(|c, es| unsafe { flake_lock(c, fetch.0, flake.0, es, lock.0, self.0) })
+			.map(LockedFlake)
 	}
 }
 unsafe impl Send for FlakeReference {}
@@ -611,8 +615,17 @@
 			.expect("get_type should not fail");
 		NixType::from_int(ty)
 	}
+	fn builtin_to_string(&self) -> Result<Self> {
+		let builtin = Self::eval("builtins.toString")?;
+		builtin.call(self.clone())
+	}
 	pub fn to_string(&self) -> Result<String> {
-		Ok(self.to_realised_string()?.as_str().to_owned())
+		let mut str_out = String::new();
+		with_default_context(|c, _| unsafe {
+			get_string(c, self.0, Some(copy_nix_str), (&raw mut str_out).cast())
+		})?;
+
+		Ok(str_out)
 	}
 	pub fn to_realised_string(&self) -> Result<RealisedString> {
 		with_default_context(|c, es| unsafe { nix_raw::string_realise(c, es, self.0, false) })
@@ -751,10 +764,11 @@
 			self.clone()
 		};
 		// to_string here blocks until the path is built
-		let drv_path = tokio::task::spawn_blocking(move || v.get_field("outPath")?.to_string())
-			.await
-			.expect("should not fail")?;
-		Ok(PathBuf::from(drv_path))
+		let drv_path =
+			tokio::task::spawn_blocking(move || v.builtin_to_string()?.to_realised_string())
+				.await
+				.expect("spawn should not fail")?;
+		Ok(PathBuf::from(drv_path.as_str()))
 	}
 	pub fn as_json<T: DeserializeOwned>(&self) -> Result<T> {
 		let to_json = Self::eval("builtins.toJSON")?;
@@ -835,6 +849,9 @@
 
 pub fn init_libraries() {
 	unsafe { nix_raw::GC_allow_register_threads() };
+	unsafe {
+		nix_raw::GC_init();
+	};
 
 	let mut ctx = NixContext::new();
 	ctx.run_in_context(|c| unsafe { nix_raw::libutil_init(c) })
modifiedcrates/nix-eval/src/logging.ccdiffbeforeafterboth
--- a/crates/nix-eval/src/logging.cc
+++ b/crates/nix-eval/src/logging.cc
@@ -60,5 +60,6 @@
 extern "C" {
 void apply_tracing_logger() {
   logger = std::make_unique<TracingLogger>();
+  // verbosity = lvlVomit;
 }
 }
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
--- a/flake.lock
+++ b/flake.lock
@@ -104,10 +104,10 @@
         "nixpkgs-regression": "nixpkgs-regression"
       },
       "locked": {
-        "lastModified": 1757000273,
+        "lastModified": 1757031817,
         "owner": "deltarocks",
         "repo": "nix",
-        "rev": "eba1f549ec21208cf98343f1351a95e2e6eb3fbb",
+        "rev": "2261305161dc02496c8aedcdda14ace04b9b1dc1",
         "type": "github"
       },
       "original": {
modifiedlib/flakePart.nixdiffbeforeafterboth
--- a/lib/flakePart.nix
+++ b/lib/flakePart.nix
@@ -65,25 +65,28 @@
           normalEval = bootstrapNixpkgs.lib.evalModules {
             modules = (import ../modules/module-list.nix) ++ [
               module
-              ({inputs', ...}: {
-                config = {
-                  data = if isPath data then import data else data;
-                  nixpkgs.buildUsing = mkOptionDefault bootstrapNixpkgs;
-                  nixpkgs.overlays = [
-                    (final: prev: {
-                      inherit
-                        (import ../pkgs {
-                          inherit (prev) callPackage;
-                          inherit inputs';
-                          craneLib = crane.mkLib prev;
-                        })
-                        fleet-install-secrets
-                        fleet-generator-helper
-                        ;
-                    })
-                  ];
-                };
-              })
+              (
+                { inputs', ... }:
+                {
+                  config = {
+                    data = if isPath data then import data else data;
+                    nixpkgs.buildUsing = mkOptionDefault bootstrapNixpkgs;
+                    nixpkgs.overlays = [
+                      (final: prev: {
+                        inherit
+                          (import ../pkgs {
+                            inherit (prev) callPackage;
+                            inherit inputs';
+                            craneLib = crane.mkLib prev;
+                          })
+                          fleet-install-secrets
+                          fleet-generator-helper
+                          ;
+                      })
+                    ];
+                  };
+                }
+              )
             ];
             specialArgs = {
               inherit inputs self;