successfully deployed mize for the first time

This commit is contained in:
Sebastian Moser
2024-09-23 12:27:21 +02:00
parent 1724e99f58
commit aa7f376262
6 changed files with 92 additions and 72 deletions

34
deploy
View File

@@ -1,23 +1,43 @@
set -e
if [[ "$1" == "a" ]] if [[ "$1" == "a" ]]
then then
ssh acern mkdir -p /tmp/victorinix ssh acern mkdir -p /tmp/mize-src
rsync -rv --exclude="target" --exclude="gitignore" ./* acern:/tmp/victorinix/ ssh acern mkdir -p ~/work/modules
path=$(ssh acern nix build /tmp/victorinix#webfiles -L --print-out-paths) rsync -rv --exclude="target" --exclude="gitignore" ./* acern:/tmp/mize-src/
rsync -rv --exclude="target" --exclude="gitignore" --exclude="node_modules" ~/work/modules acern:work/
path=$(ssh acern /home/me/out/nix/bin/nix build /tmp/mize-src#webfiles -L --print-out-paths)
echo doneeeeeeeeeeeeeee echo doneeeeeeeeeeeeeee building
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" tmp=$(mktemp -d)
[[ "$path" != "" ]] && rsync -rv -p --chmod=u+w acern:$path/* $tmp
[[ "$path" != "" ]] && rsync -rv $tmp/* ocih:host/webserver/webfiles/ --rsync-path="sudo rsync"
elif [[ "$1" == "c" ]] # only copy files to acern
then
ssh acern mkdir -p /tmp/mize-src
ssh acern mkdir -p ~/work/modules
rsync -rv --exclude="target" --exclude="gitignore" ./* acern:/tmp/mize-src/
rsync -rv --exclude="target" --exclude="gitignore" --exclude="node_modules" ~/work/modules acern:work/
else else
path=$(nix build .#webfiles -L -v --print-out-paths $@) path=$(nix build .#webfiles -L -v --print-out-paths $@)
echo doneeeeeeeeeeeeeee echo doneeeeeeeeeeeeeee building
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" [[ "$path" != "" ]] && rsync -rv $path/* ocih:host/webserver/webfiles --rsync-path="sudo rsync"
fi fi

2
flake.lock generated
View File

@@ -60,7 +60,7 @@
"dirtyRev": "fa3b462cbe3e63fc9ecada6c4445d366e58a6f86-dirty", "dirtyRev": "fa3b462cbe3e63fc9ecada6c4445d366e58a6f86-dirty",
"dirtyShortRev": "fa3b462-dirty", "dirtyShortRev": "fa3b462-dirty",
"lastModified": 1725362504, "lastModified": 1725362504,
"narHash": "sha256-uL7SRKxrCpS/9sXVOdClijqdxXNLIuiHZ54YYZck42E=", "narHash": "sha256-whgym05xZUVEtO6/F4id2XN7MBQTs7VUEhF8PEJV41E=",
"submodules": true, "submodules": true,
"type": "git", "type": "git",
"url": "file:///home/me/work/modules" "url": "file:///home/me/work/modules"

View File

@@ -71,6 +71,7 @@ let
inherit inputs nixpkgs pkgs self osCrane defaultMizeConfig mize_modules; inherit inputs nixpkgs pkgs self osCrane defaultMizeConfig mize_modules;
inherit rust-overlay crane fenix; inherit rust-overlay crane fenix;
localSystem = system; localSystem = system;
stdenv = pkgs.stdenv;
}; };
in { in {
@@ -110,10 +111,7 @@ in {
}; };
}; };
webfiles = pkgs.callPackage ./webfiles.nix { webfiles = mizeLib.webfiles systems;
inherit (mizeLib) buildMizeForSystem mkInstallPhase;
inherit systems;
};
default = osCrane.buildPackage { default = osCrane.buildPackage {
src = "${self}"; src = "${self}";

82
lib.nix
View File

@@ -8,6 +8,7 @@
, rust-overlay , rust-overlay
, crane , crane
, fenix , fenix
, stdenv
, ... , ...
}: }:
rec { rec {
@@ -65,9 +66,10 @@ rec {
if crossSystem.kernel.name == "windows" if crossSystem.kernel.name == "windows"
then then
(crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [ (crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [
fenix.packages.${localSystem}.minimal.rustc #fenix.packages.${localSystem}.minimal.rustc
fenix.packages.${localSystem}.minimal.cargo #fenix.packages.${localSystem}.minimal.cargo
fenix.packages.${localSystem}.targets."${crossSystem.cpu.name}-pc-windows-gnu".latest.rust-std fenix.packages.${localSystem}.stable.toolchain
fenix.packages.${localSystem}.targets."${crossSystem.cpu.name}-pc-windows-gnu".stable.toolchain
]) ])
else if crossSystem.cpu.name == "wasm32" else if crossSystem.cpu.name == "wasm32"
@@ -80,43 +82,51 @@ rec {
then then
builtins.trace "x86_64-linux-gnu hackfix...." builtins.trace "x86_64-linux-gnu hackfix...."
(crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [ (crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [
fenix.packages.${localSystem}.latest.toolchain fenix.packages.${localSystem}.stable.toolchain
]) ])
else else
(crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default) (crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default)
; ;
toolchain_version_drv = pkgs.stdenv.mkDerivation {
name = "toolchain_version_drv";
dontUnpack = true;
configurePhase = "";
buildPhase = ''
mkdir -p $out
touch $out/rustc-version
echo hiiiiiiiiiiiiiiiiiiiiiiii
#echo 'rustc 1.80.1 (3f5fd8dd4 2024-08-06)' > $out/rustc-version
${craneLib.cargo}/bin/rustc --version > $out/rustc-version
exit 0
'';
};
mkSelString = attrs: builtins.toJSON (attrs // { mkSelString = attrs: builtins.toJSON (attrs // {
inherit toolchain_version; inherit toolchain_version;
system = crossSystem.nameFull; system = crossSystem.nameFull;
mize_version = main-default.version; mize_version = main-default.version;
}); });
toolchain_version_drv = pkgs.stdenv.mkDerivation {
name = "toolchain_version_drv";
dontUnpack = true;
configurePhase = "";
buildPhase = ''
mkdir -p $out
touch $out/rustc-version
echo hiiiiiiiiiiiiiiiiiiiiiiii
echo 'rustc 1.80.1 (3f5fd8dd4 2024-08-06)' > $out/rustc-version
${craneLib.cargo}/bin/rustc --version > $out/rustc-version
exit 0
'';
};
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 (attrs // { mkMizeModule = attrs: pkgsCross.stdenv.mkDerivation (attrs // {
selector_string = mkSelString attrs.select; selector_string = mkSelString (attrs.select or {} // {
inherit (attrs) modName;
});
}); });
########## build Rust Module
mkMizeRustModule = attrs: craneLib.buildPackage (attrs // { mkMizeRustModule = attrs: craneLib.buildPackage (attrs // {
MIZE_BUILD_CONFIG = mizeBildConfig; MIZE_BUILD_CONFIG = mizeBildConfig;
selector_string = mkSelString (attrs.select or {} // { selector_string = mkSelString (attrs.select or {} // {
inherit (attrs) modName;
}); });
} }
@@ -175,6 +185,7 @@ rec {
}); });
}; };
####### build mize
main-default = craneLib.buildPackage ({ main-default = craneLib.buildPackage ({
src = "${self}"; src = "${self}";
cargoExtraArgs = "--bin mize --features os-target"; cargoExtraArgs = "--bin mize --features os-target";
@@ -230,8 +241,15 @@ rec {
src = "${self}"; src = "${self}";
CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
doCheck = false; doCheck = false;
cargoExtraArgs = "--features wasm-target"; cargoExtraArgs = "--features wasm-target --no-default-features";
MIZE_BUILD_CONFIG = mizeBildConfig; MIZE_BUILD_CONFIG = mizeBildConfig;
# env vars
#CC = "${stdenv.cc.nativePrefix}cc";
#AR = "${stdenv.cc.nativePrefix}ar";
#CC_wasm32_unknown_unknown = "${pkgs.llvmPackages_14.clang-unwrapped}/bin/clang-14";
#CFLAGS_wasm32_unknown_unknown = "-I ${pkgs.llvmPackages_14.libclang.lib}/lib/clang/14.0.6/include/";
#AR_wasm32_unknown_unknown = "${pkgs.llvmPackages_14.llvm}/bin/llvm-ar";
}; };
in rec { in rec {
@@ -274,13 +292,33 @@ rec {
mkModuleInstallPhase = module: '' mkModuleInstallPhase = module: ''
echo got module: ${module.name} echo got module: ${module.name}
echo out: $out
hash=$(echo ${module.selector_string} | sha256sum | cut -c -32) hash=$(echo ${module.selector_string} | sha256sum | cut -c -32)
mkdir -p $out/mize/dist/$hash cp --no-preserve=mode,ownership -r ${module}/* $out/mize/dist/$hash
cp -r ${module}/* $out/mize/dist/$hash
echo '${module.selector_string}' > $out/mize/dist/$hash/selector echo '${module.selector_string}' > $out/mize/dist/$hash/selector
''; '';
webfiles = systems: stdenv.mkDerivation {
name = "mize-webfiles";
dontUnpack = true;
# so that those binaries run on average linux-gnu systems
dontPatchShebangs = true;
buildPhase = ''
'';
installPhase = ''
mkdir -p $out
mkdir -p $out/mize
mkdir -p $out/mize/dist
'' + pkgs.lib.concatStringsSep "\n" (map mkInstallPhase (map buildMizeForSystem systems));
nativeBuildInputs = [
];
};
} }

View File

@@ -1,5 +1,6 @@
[config] [config]
namespace = "test.c2vi.dev" namespace = "test.c2vi.dev"
module_dir = "/home/me/work/mize/modules"
test = "hello from test item" test = "hello from test item"
[config.module_dir]

View File

@@ -1,37 +0,0 @@
{ stdenv
, pkgs
, mkInstallPhase
, buildMizeForSystem
, systems
, ...
}: let
# list of systems, we build mize for for webfiles
#systems = [ "x86_64-linux" "aarch64-linux" "wasm32" ];
#systems = [ "x86_64-linux" "aarch64-linux" ];
list_of_mizes = map buildMizeForSystem systems;
in
stdenv.mkDerivation {
name = "mize-webfiles";
dontUnpack = true;
# so that /bin/sh does not get patched to a nix store path in victorinix-s
dontPatchShebangs = true;
buildPhase = ''
'';
installPhase = ''
mkdir -p $out
mkdir -p $out/mize
mkdir -p $out/mize/dist
'' + pkgs.lib.concatStringsSep "\n" (map mkInstallPhase list_of_mizes);
nativeBuildInputs = [
];
}