moved from 0/config to self/config...

This commit is contained in:
Sebastian Moser
2025-04-01 23:45:58 +02:00
parent 673ab2235d
commit d9ee9b5be4
6 changed files with 34 additions and 15 deletions

12
lib.nix
View File

@@ -23,6 +23,7 @@ rec {
then "${crossSystem.cpu.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}" then "${crossSystem.cpu.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}"
else "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}"; else "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
nameFull = "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}"; nameFull = "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
nameRust = nameFull;
config = nameFull; config = nameFull;
}; };
in crossSystem; in crossSystem;
@@ -101,7 +102,7 @@ rec {
]) ])
else else
(crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default) (crane.mkLib pkgsCross).overrideToolchain (p: fenix.packages.${localSystem}.stable.toolchain)
; ;
toolchain_version_drv = pkgs.stdenv.mkDerivation { toolchain_version_drv = pkgs.stdenv.mkDerivation {
@@ -131,7 +132,7 @@ rec {
toolchain_version = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile "${toolchain_version_drv}/rustc-version"); toolchain_version = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile "${toolchain_version_drv}/rustc-version");
mkMizeModule = attrs: pkgsCross.stdenv.mkDerivation ( rec { mkMizeModule = attrs: (if builtins.hasAttr "drvFunc" attrs then attrs.drvFunc else pkgsCross.stdenv.mkDerivation) ( rec {
name = attrs.modName; name = attrs.modName;
inherit (attrs) modName; inherit (attrs) modName;
selector_string = mkSelString (attrs.select or {} // { selector_string = mkSelString (attrs.select or {} // {
@@ -145,11 +146,12 @@ rec {
########## build Rust Module ########## build Rust Module
mkMizeRustModule = attrs: craneLib.buildPackage (attrs // { mkMizeRustModule = attrs: craneLib.buildPackage (attrs // {
MIZE_BUILD_CONFIG = mizeBuildConfigStr; MIZE_BUILD_CONFIG = mizeBuildConfigStr;
mizeInstallPhase = '' mizeInstallPhase = attrs.mizeInstallPhase or ''
mkdir -p $out/lib/ mkdir -p $out/lib/
cp ./target/$debugOrRelease/libmize_module_${attrs.modName}.so $out/lib/ cp $build_dir/target/${crossSystem.nameRust}/$debugOrRelease/libmize_module_${attrs.modName}.so $out/lib/
''; '';
mizeBuildPhase = '' mizeBuildPhase = attrs.mizeBuildPhase or ''
cargo --color always build --target ${crossSystem.nameRust} --manifest-path $build_dir/Cargo.toml --lib
''; '';
selector_string = mkSelString (attrs.select or {} // { selector_string = mkSelString (attrs.select or {} // {
inherit (attrs) modName; inherit (attrs) modName;

View File

@@ -557,10 +557,14 @@ impl Instance {
threads_inner.push((*next_thread_id, name.to_owned())); threads_inner.push((*next_thread_id, name.to_owned()));
let runtime_inner = self.runtime.lock().unwrap(); let runtime_inner = self.runtime.lock().unwrap();
let handle = runtime_inner.handle().to_owned(); let handle = runtime_inner.handle().to_owned();
*next_thread_id += 1;
drop(runtime_inner); drop(runtime_inner);
drop(threads_inner);
drop(next_thread_id);
let result = handle.block_on(func); let result = handle.block_on(func);
*next_thread_id += 1;
return result; return result;
} }

View File

@@ -60,6 +60,8 @@ impl Item<'_> {
// the instance we are // the instance we are
if id.store_part() == "self" { if id.store_part() == "self" {
debug!("getting item '{}' from self", self.id());
match id.nth_part(1)? { match id.nth_part(1)? {
"con_by_id" => { return value_raw_con_by_id(&mut self.clone()); }, "con_by_id" => { return value_raw_con_by_id(&mut self.clone()); },
"namespace" => { "namespace" => {
@@ -70,6 +72,13 @@ impl Item<'_> {
let namespace_inner = self.instance.self_namespace.lock()?; let namespace_inner = self.instance.self_namespace.lock()?;
return Ok(ItemData::from_string(namespace_inner.as_real_string())); return Ok(ItemData::from_string(namespace_inner.as_real_string()));
}, },
"config" => {
let rest_path = id.path.into_iter().skip(2).map(|v| v.to_owned()).collect::<Vec<String>>().join("/");
let id_for_store = self.instance.new_id("0/config".to_owned() + "/" + rest_path.as_str())?;
let store = self.instance.store.lock()?;
let data = store.get_value_data_full(id_for_store)?;
return Ok(data);
}
_ => {}, _ => {},
} }
return Err(mize_err!("a /self path, but the next element in the path '{:?}' is not valid", id.nth_part(1))); return Err(mize_err!("a /self path, but the next element in the path '{:?}' is not valid", id.nth_part(1)));
@@ -78,7 +87,7 @@ impl Item<'_> {
let self_namespace_inner = self.instance.self_namespace.lock()?; let self_namespace_inner = self.instance.self_namespace.lock()?;
if self.id().namespace() == self_namespace_inner.to_owned() { if self.id().namespace() == self_namespace_inner.to_owned() {
debug!("getting item from store"); debug!("getting item '{}' from store", self.id());
if id.store_part() == "inst" { if id.store_part() == "inst" {
match id.nth_part(1)? { match id.nth_part(1)? {
@@ -101,6 +110,9 @@ impl Item<'_> {
} else { } else {
let mut connection = self.instance.get_connection_by_ns(self.id().namespace())?; let mut connection = self.instance.get_connection_by_ns(self.id().namespace())?;
debug!("getting item '{}' from connection '{}' from store", self.id(), connection.id);
let msg = MizeMessage::new_get(self.id(), connection.id); let msg = MizeMessage::new_get(self.id(), connection.id);
connection.send(msg); connection.send(msg);
let data = self.instance.give_msg_wait(self.id())?; let data = self.instance.give_msg_wait(self.id())?;
@@ -265,7 +277,7 @@ pub fn data_from_string(data_string: String) -> MizeResult<ItemData> {
} }
let path = option.split("=").nth(0) let path = option.split("=").nth(0)
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty path (thing beforee =)", option)))?; .ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty path (thing before =)", option)))?;
let value = option.split("=").nth(1) let value = option.split("=").nth(1)
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty value (thing after =)", option)))?; .ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty value (thing after =)", option)))?;
let mut path_vec = Vec::new(); let mut path_vec = Vec::new();

View File

@@ -89,8 +89,8 @@ pub fn init_logger(cli_matches: &ArgMatches) {
log_messages.push((Level::TRACE, format!("set log level from the verbose flags to {}", log_level))); log_messages.push((Level::TRACE, format!("set log level from the verbose flags to {}", log_level)));
// check --log-level arg // check --log-level arg
if let Some(log_level_arg_string) = cli_matches.get_one::<&str>("log-level") { if let Some(log_level_arg_string) = cli_matches.get_one::<String>("log-level") {
let log_level_from_arg = match log_level_arg_string.to_lowercase().as_str() { let log_level_from_arg = match log_level_arg_string.to_owned().to_lowercase().as_str() {
"none" => LevelFilter::OFF, "none" => LevelFilter::OFF,
"trace" => LevelFilter::TRACE, "trace" => LevelFilter::TRACE,
"debug" => LevelFilter::DEBUG, "debug" => LevelFilter::DEBUG,

View File

@@ -112,7 +112,7 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
{ {
warn!("CONNECTING... would connect, but that is not implemented on windows yet"); error!("CONNECTING... would connect, but that is not implemented on windows yet");
} }
} else { } else {
@@ -216,13 +216,13 @@ fn download_module(instance: &mut Instance, store_path: &str, module_url: &str,
pub fn fetch_module(instance: &mut Instance, module_name: &str) -> MizeResult<String> { pub fn fetch_module(instance: &mut Instance, module_name: &str) -> MizeResult<String> {
if let Ok(module_path) = instance.get(format!("0/config/module_dir/{}", module_name))?.value_string() { if let Ok(module_path) = instance.get(format!("self/config/module_dir/{}", module_name))?.value_string() {
return Ok(module_path); return Ok(module_path);
} else { } else {
// if null, load it from the url // if null, load it from the url
let module_url = instance.get("0/config/module_url")?.value_string()?; let module_url = instance.get("self/config/module_url")?.value_string()?;
let store_path = instance.get("0/config/store_path")?.value_string()?; let store_path = instance.get("self/config/store_path")?.value_string()?;
let (module_hash, module_selector) = get_module_hash(instance, module_name, ItemData::new())?; let (module_hash, module_selector) = get_module_hash(instance, module_name, ItemData::new())?;
@@ -237,7 +237,7 @@ pub fn fetch_module(instance: &mut Instance, module_name: &str) -> MizeResult<St
pub fn load_module(instance: &mut Instance, module_name: &str, path: Option<String>) -> MizeResult<()> { pub fn load_module(instance: &mut Instance, module_name: &str, path: Option<String>) -> MizeResult<()> {
let module_dir_from_config = instance.get(format!("0/config/module_dir/{}", module_name)); let module_dir_from_config = instance.get(format!("self/config/module_dir/{}", module_name));
let module_path = if path.is_some() { let module_path = if path.is_some() {
format!("{}/lib/libmize_module_{}.so", path.unwrap(), module_name) format!("{}/lib/libmize_module_{}.so", path.unwrap(), module_name)

View File

@@ -58,6 +58,7 @@ async fn connect_async(mut instance: Instance, store_path: PathBuf) -> MizeResul
Ok(()) Ok(())
}); });
let outgoing_cloned_instance = instance.clone(); let outgoing_cloned_instance = instance.clone();
instance.spawn("outgoing", move || { instance.spawn("outgoing", move || {
let result = unix_outgoing(unix_write, send_rx, outgoing_cloned_instance, conn_id); let result = unix_outgoing(unix_write, send_rx, outgoing_cloned_instance, conn_id);