[run-vim] allow setting data share
All checks were successful
Check flake syntax / flake-check (push) Successful in 4m27s
All checks were successful
Check flake syntax / flake-check (push) Successful in 4m27s
This commit is contained in:
@@ -133,6 +133,13 @@ rec {
|
|||||||
mountPoint = "/var";
|
mountPoint = "/var";
|
||||||
tag = "var";
|
tag = "var";
|
||||||
}
|
}
|
||||||
|
] ++ pkgs.lib.optionals (options.dataPath != "") [
|
||||||
|
{
|
||||||
|
source = "${options.dataPath}";
|
||||||
|
securityModel = "mapped";
|
||||||
|
mountPoint = "/data";
|
||||||
|
tag = "data";
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
interfaces = pkgs.lib.mkIf (!options.withNetworking) (pkgs.lib.mkForce [{
|
interfaces = pkgs.lib.mkIf (!options.withNetworking) (pkgs.lib.mkForce [{
|
||||||
@@ -209,6 +216,7 @@ rec {
|
|||||||
(vmMicroVMOverwrites name {
|
(vmMicroVMOverwrites name {
|
||||||
withNetworking = true;
|
withNetworking = true;
|
||||||
varPath = "";
|
varPath = "";
|
||||||
|
dataPath = "";
|
||||||
writableStore = false; })
|
writableStore = false; })
|
||||||
(if sopsDummy then (vmSopsOverwrites name) else {})
|
(if sopsDummy then (vmSopsOverwrites name) else {})
|
||||||
]);
|
]);
|
||||||
@@ -218,11 +226,12 @@ rec {
|
|||||||
builtins.listToAttrs (map mapperFunc self.nixosConfigurations.${host}.config.services.malobeo.microvm.deployHosts));
|
builtins.listToAttrs (map mapperFunc self.nixosConfigurations.${host}.config.services.malobeo.microvm.deployHosts));
|
||||||
};
|
};
|
||||||
|
|
||||||
buildVM = host: networking: sopsDummy: disableDisko: varPath: writableStore: fwdPort: (self.nixosConfigurations.${host}.extendModules {
|
buildVM = host: networking: sopsDummy: disableDisko: varPath: dataPath: writableStore: fwdPort: (self.nixosConfigurations.${host}.extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
(vmMicroVMOverwrites host {
|
(vmMicroVMOverwrites host {
|
||||||
withNetworking = networking;
|
withNetworking = networking;
|
||||||
varPath = "${varPath}";
|
varPath = "${varPath}";
|
||||||
|
dataPath = "${dataPath}";
|
||||||
writableStore = writableStore;
|
writableStore = writableStore;
|
||||||
fwdPort = fwdPort; })
|
fwdPort = fwdPort; })
|
||||||
(if sopsDummy then (vmSopsOverwrites host) else {})
|
(if sopsDummy then (vmSopsOverwrites host) else {})
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ usage() {
|
|||||||
echo "--no-disko disable disko and initrd secrets. needed for real hosts like fanny"
|
echo "--no-disko disable disko and initrd secrets. needed for real hosts like fanny"
|
||||||
echo "--writable-store enables writable store. necessary for host with nested imperative microvms like fanny"
|
echo "--writable-store enables writable store. necessary for host with nested imperative microvms like fanny"
|
||||||
echo "--var path to directory that should be shared as /var. may require root otherwise some systemd units fail within vm. if dir is empty vm will populate"
|
echo "--var path to directory that should be shared as /var. may require root otherwise some systemd units fail within vm. if dir is empty vm will populate"
|
||||||
|
echo "--data path to directory that should be shared as /data"
|
||||||
echo "--fwd-port forwards the given port to port 80 on vm"
|
echo "--fwd-port forwards the given port to port 80 on vm"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -23,6 +24,7 @@ DUMMY_SECRETS=false
|
|||||||
NO_DISKO=false
|
NO_DISKO=false
|
||||||
RW_STORE=false
|
RW_STORE=false
|
||||||
VAR_PATH=""
|
VAR_PATH=""
|
||||||
|
DATA_PATH=""
|
||||||
FWD_PORT=0
|
FWD_PORT=0
|
||||||
|
|
||||||
# check argws
|
# check argws
|
||||||
@@ -42,6 +44,15 @@ while [[ "$#" -gt 0 ]]; do
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--data)
|
||||||
|
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||||
|
DATA_PATH="$2"
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
echo "Error: --data requires a non-empty string argument."
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
;;
|
||||||
--fwd-port)
|
--fwd-port)
|
||||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||||
FWD_PORT="$2"
|
FWD_PORT="$2"
|
||||||
@@ -64,4 +75,8 @@ if [ -n "$VAR_PATH" ]; then
|
|||||||
echo "sharing var directory: $VAR_PATH"
|
echo "sharing var directory: $VAR_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nix run --show-trace --impure --expr "((builtins.getFlake \"$(pwd)\").vmBuilder.x86_64-linux \"$HOSTNAME\" $NETWORK $DUMMY_SECRETS $NO_DISKO \"$VAR_PATH\" $RW_STORE $FWD_PORT).config.microvm.declaredRunner"
|
if [ -n "$DATA_PATH" ]; then
|
||||||
|
echo "sharing data directory: $DATA_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nix run --show-trace --impure --expr "((builtins.getFlake \"$(pwd)\").vmBuilder.x86_64-linux \"$HOSTNAME\" $NETWORK $DUMMY_SECRETS $NO_DISKO \"$VAR_PATH\" \"$DATA_PATH\" $RW_STORE $FWD_PORT).config.microvm.declaredRunner"
|
||||||
|
|||||||
Reference in New Issue
Block a user