we can now deploy the Blob module
This commit is contained in:
6
deploy
Normal file → Executable file
6
deploy
Normal file → Executable file
@@ -8,14 +8,16 @@ then
|
|||||||
echo doneeeeeeeeeeeeeee
|
echo doneeeeeeeeeeeeeee
|
||||||
echo path: $path
|
echo path: $path
|
||||||
|
|
||||||
scp -r acern:$path/* ocih:host/webserver/webfiles
|
#scp -r acern:$path/* ocih:host/webserver/webfiles
|
||||||
|
rsync -rv $path/* ocih:host/webserver/webfiles --rsync-path="sudo rsync"
|
||||||
else
|
else
|
||||||
path=$(nix build .#webfiles -L -v --print-out-paths $@)
|
path=$(nix build .#webfiles -L -v --print-out-paths $@)
|
||||||
|
|
||||||
echo doneeeeeeeeeeeeeee
|
echo doneeeeeeeeeeeeeee
|
||||||
echo path: $path
|
echo path: $path
|
||||||
|
|
||||||
scp -r $path/* ocih:host/webserver/webfiles
|
#scp -r $path/* ocih:host/webserver/webfiles
|
||||||
|
rsync -rv $path/* ocih:host/webserver/webfiles --rsync-path="sudo rsync"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
flake.lock
generated
17
flake.lock
generated
@@ -59,6 +59,22 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mize_modules": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1725110866,
|
||||||
|
"narHash": "sha256-pwbO+IPT6hxQ4orfVftqWnei6k5NvgdgXiLWC7E39zc=",
|
||||||
|
"owner": "c2vi",
|
||||||
|
"repo": "mize-modules",
|
||||||
|
"rev": "3fc5c4a1faba733790a22b22dc795238d569d508",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "c2vi",
|
||||||
|
"repo": "mize-modules",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1703637592,
|
"lastModified": 1703637592,
|
||||||
@@ -80,6 +96,7 @@
|
|||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
|
"mize_modules": "mize_modules",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
34
flake.nix
34
flake.nix
@@ -13,9 +13,14 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mize_modules = {
|
||||||
|
url = "github:c2vi/mize-modules";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
outputs = { self, flake-utils, nixpkgs, fenix, crane, ... }@inputs: flake-utils.lib.eachDefaultSystem (system:
|
outputs = { self, flake-utils, nixpkgs, fenix, crane, mize_modules, ... }@inputs: flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
|
||||||
############################## LET BINDINGS ##############################
|
############################## LET BINDINGS ##############################
|
||||||
let
|
let
|
||||||
@@ -34,17 +39,27 @@ let
|
|||||||
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defaultMizeConfig = {
|
||||||
|
config = {
|
||||||
|
namespace = "mize.buildtime.ns";
|
||||||
|
module_url = "c2vi.dev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
############################## PACKAGES ##############################
|
############################## PACKAGES ##############################
|
||||||
|
|
||||||
webfiles = pkgs.callPackage ./webfiles.nix { inherit inputs nixpkgs self; };
|
packages = {
|
||||||
|
|
||||||
packages.default = osCrane.buildPackage {
|
osCrane = osCrane;
|
||||||
src = "${self}";
|
|
||||||
cargoExtraArgs = "--bin mize --features os-binary";
|
webfiles = pkgs.callPackage ./webfiles.nix { inherit inputs nixpkgs self osCrane defaultMizeConfig mize_modules; };
|
||||||
};
|
|
||||||
|
default = osCrane.buildPackage {
|
||||||
|
src = "${self}";
|
||||||
|
cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
};
|
||||||
|
|
||||||
packages = rec {
|
|
||||||
wasm = wasmCrane.buildPackage {
|
wasm = wasmCrane.buildPackage {
|
||||||
src = "${self}";
|
src = "${self}";
|
||||||
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
||||||
@@ -94,6 +109,11 @@ in {
|
|||||||
lldb gdb
|
lldb gdb
|
||||||
];
|
];
|
||||||
|
|
||||||
|
MIZE_BUILD_CONFIG = pkgs.writeTextFile {
|
||||||
|
name = "vic-build-config";
|
||||||
|
text = builtins.toJSON defaultMizeConfig;
|
||||||
|
};
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ pub mod module;
|
|||||||
|
|
||||||
static MSG_CHANNEL_SIZE: usize = 200;
|
static MSG_CHANNEL_SIZE: usize = 200;
|
||||||
|
|
||||||
|
static BUILD_TIME_CONFIG: &str = include_str!(std::env!("MIZE_BUILD_CONFIG"));
|
||||||
|
|
||||||
/// The Instance type is the heart of the mize system
|
/// The Instance type is the heart of the mize system
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Instance {
|
pub struct Instance {
|
||||||
@@ -141,6 +143,10 @@ impl Instance {
|
|||||||
|
|
||||||
fn init(&mut self) -> MizeResult<()> {
|
fn init(&mut self) -> MizeResult<()> {
|
||||||
|
|
||||||
|
// load the config from build time
|
||||||
|
let config = ItemData::from_toml(BUILD_TIME_CONFIG)?;
|
||||||
|
self.set_blocking("0", config);
|
||||||
|
|
||||||
// platform specific init code
|
// platform specific init code
|
||||||
crate::platform::any::instance_init(self);
|
crate::platform::any::instance_init(self);
|
||||||
|
|
||||||
@@ -166,7 +172,7 @@ impl Instance {
|
|||||||
|
|
||||||
let mut instance = Instance::empty()?;
|
let mut instance = Instance::empty()?;
|
||||||
|
|
||||||
instance.set_blocking("0", config.clone());
|
instance.set_blocking("0", config);
|
||||||
|
|
||||||
instance.init()?;
|
instance.init()?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use tracing::{debug, error, info, instrument, trace, warn, Instrument};
|
use tracing::{debug, error, info, instrument, trace, warn, Instrument};
|
||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
@@ -148,6 +149,16 @@ impl ItemData {
|
|||||||
ItemData(CborValue::Null)
|
ItemData(CborValue::Null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_toml(toml_string: &str) -> MizeResult<ItemData> {
|
||||||
|
|
||||||
|
let toml_deserializer = toml::Deserializer::new(&toml_string);
|
||||||
|
|
||||||
|
let value = CborValue::deserialize(toml_deserializer)
|
||||||
|
.mize_result_msg(format!("Could not deserialize the toml string: {}", &toml_string))?;
|
||||||
|
|
||||||
|
return Ok(value.into_item_data());
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_string<S: Into<String>>(into_string: S) -> ItemData {
|
pub fn from_string<S: Into<String>>(into_string: S) -> ItemData {
|
||||||
let string = into_string.into();
|
let string = into_string.into();
|
||||||
let data = CborValue::Text(string);
|
let data = CborValue::Text(string);
|
||||||
|
|||||||
@@ -188,12 +188,9 @@ pub fn config_from_file(file_path: String) -> MizeResult<ItemData> {
|
|||||||
let toml_string = fs::read_to_string(&file_path)
|
let toml_string = fs::read_to_string(&file_path)
|
||||||
.mize_result_msg(format!("Could not read file {} as mize config", &file_path))?;
|
.mize_result_msg(format!("Could not read file {} as mize config", &file_path))?;
|
||||||
|
|
||||||
let toml_deserializer = toml::Deserializer::new(&toml_string.as_str());
|
let item_data = ItemData::from_toml(toml_string.as_str())?;
|
||||||
|
|
||||||
let config = CborValue::deserialize(toml_deserializer)
|
return Ok(item_data);
|
||||||
.mize_result_msg(format!("Could not deserialize the content of MIZE_CONFIG_FILE at {}", &file_path))?;
|
|
||||||
|
|
||||||
return Ok(config.into_item_data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_from_string(config_string: String) -> MizeResult<ItemData> {
|
fn config_from_string(config_string: String) -> MizeResult<ItemData> {
|
||||||
|
|||||||
87
webfiles.nix
87
webfiles.nix
@@ -1,9 +1,83 @@
|
|||||||
{ stdenv
|
{ stdenv
|
||||||
, pkgs
|
, pkgs
|
||||||
, ... }:
|
, osCrane
|
||||||
|
, self
|
||||||
|
, defaultMizeConfig
|
||||||
|
, mize_modules
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
in
|
# build all modules
|
||||||
|
module_list_drv = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "mize_module_list";
|
||||||
|
dontUnpack = true;
|
||||||
|
configurePhase = "";
|
||||||
|
buildPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
touch $out/modules_to_build
|
||||||
|
|
||||||
|
for d in ${mize_modules}/modules/*; do
|
||||||
|
[[ -f $d/mize_module.nix ]] && echo "$d/mize_module.nix" >> $out/modules_to_build
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
module_list_string = builtins.readFile "${module_list_drv}/modules_to_build";
|
||||||
|
module_list = pkgs.lib.lists.remove "" (pkgs.lib.strings.splitString "\n" module_list_string);
|
||||||
|
|
||||||
|
buildModule = path: (pkgs.callPackage path {
|
||||||
|
craneLib = osCrane;
|
||||||
|
toolchain_version = toolchain_version_string;
|
||||||
|
});
|
||||||
|
module_drv_list = map buildModule module_list;
|
||||||
|
|
||||||
|
test2 = builtins.trace "list: ${module_drv_list}" "hi";
|
||||||
|
test = builtins.trace "last: ${pkgs.lib.lists.last module_drv_list}" test2;
|
||||||
|
|
||||||
|
webfilesBuildPhase = module_drv: ''
|
||||||
|
echo got module: ${module_drv.name}
|
||||||
|
hash=$(echo ${module_drv.selector_string} | sha256sum | cut -c -32)
|
||||||
|
mkdir -p $out/mize/dist/$hash
|
||||||
|
cp -r ${module_drv}/* $out/mize/dist/$hash
|
||||||
|
echo '${module_drv.selector_string}' > $out/mize/dist/$hash/selector_string
|
||||||
|
'';
|
||||||
|
|
||||||
|
toolchain_version_drv = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "toolchain_version_drv";
|
||||||
|
dontUnpack = true;
|
||||||
|
configurePhase = "";
|
||||||
|
buildPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
touch $out/rustc-version
|
||||||
|
|
||||||
|
${osCrane.rustc}/bin/rustc --version > $out/rustc-version
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
toolchain_version_string = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile "${toolchain_version_drv}/rustc-version");
|
||||||
|
|
||||||
|
main = osCrane.buildPackage {
|
||||||
|
src = "${self}";
|
||||||
|
cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
|
||||||
|
MIZE_BUILD_CONFIG = pkgs.writeTextFile {
|
||||||
|
name = "mize-build-config";
|
||||||
|
text = builtins.toJSON (defaultMizeConfig // { toolchain_version = toolchain_version_string; });
|
||||||
|
};
|
||||||
|
|
||||||
|
# patch the interpreter to run on most linux-gnu distros
|
||||||
|
postBuild = ''
|
||||||
|
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /build/source/target/release/mize
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "mize-webfiles";
|
name = "mize-webfiles";
|
||||||
@@ -14,7 +88,14 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
'';
|
mkdir -p $out/mize
|
||||||
|
mkdir -p $out/mize/dist
|
||||||
|
|
||||||
|
mkdir -p $out/mize/x86_64-linux-gnu
|
||||||
|
cp -r ${main}/bin/mize $out/mize/x86_64-linux-gnu/mize
|
||||||
|
|
||||||
|
'' + pkgs.lib.concatStringsSep "\n" (map webfilesBuildPhase module_drv_list);
|
||||||
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user