modules/cluster/deployment: add option extraShares

This commit is contained in:
Astro 2022-12-12 21:16:20 +01:00
parent 592d79a9e0
commit 49b6b5dc4d
2 changed files with 40 additions and 13 deletions

View File

@ -42,6 +42,22 @@
Which glusterfs volume to use for persistedShares Which glusterfs volume to use for persistedShares
''; '';
}; };
extraShares = mkOption {
type = with types; listOf (submodule {
options = {
source = mkOption {
type = str;
};
mountPoint = mkOption {
type = str;
};
};
});
default = [];
description = ''
Extra shares. THESE MUST BE AVAILABLE ON ALL MICROVM HOSTS!
'';
};
needForSpeed = mkOption { needForSpeed = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;

View File

@ -37,19 +37,30 @@ in
rm -f "${writableStoreOverlayImage}" rm -f "${writableStoreOverlayImage}"
''; '';
shares = [ { shares =
proto = "virtiofs"; [ {
tag = "ro-store"; proto = "virtiofs";
source = "/nix/store"; tag = "ro-store";
mountPoint = "/nix/.ro-store"; source = "/nix/store";
} ] ++ map (mountPoint: { mountPoint = "/nix/.ro-store";
proto = "virtiofs"; } ]
tag = builtins.replaceStrings [ "/" ] [ "-" ] ( ++
withoutLeadingSlash mountPoint map (mountPoint: {
); proto = "virtiofs";
source = "/glusterfs/${config.deployment.storage}/microvms/${user}/${repo}/${vmName}/${withoutLeadingSlash mountPoint}"; tag = builtins.replaceStrings [ "/" ] [ "-" ] (
inherit mountPoint; withoutLeadingSlash mountPoint
}) config.deployment.persistedShares; );
source = "/glusterfs/${config.deployment.storage}/microvms/${user}/${repo}/${vmName}/${withoutLeadingSlash mountPoint}";
inherit mountPoint;
}) config.deployment.persistedShares
++
map ({ source, mountPoint }: {
proto = "virtiofs";
tag = builtins.replaceStrings [ "/" ] [ "-" ] (
withoutLeadingSlash mountPoint
);
inherit mountPoint source;
}) config.deployment.extraShares;
volumes = [ { volumes = [ {
image = writableStoreOverlayImage; image = writableStoreOverlayImage;
mountPoint = config.microvm.writableStoreOverlay; mountPoint = config.microvm.writableStoreOverlay;