diff --git a/hosts/containers/leon/default.nix b/hosts/containers/leon/default.nix index 06c9dee4..a6b817d4 100644 --- a/hosts/containers/leon/default.nix +++ b/hosts/containers/leon/default.nix @@ -9,6 +9,7 @@ in }; c3d2.deployment = { + server = "nomad"; mounts = [ "etc" "home" "var"]; mountBase = "/glusterfs/fast/microvms/${config.networking.hostName}"; }; diff --git a/hosts/containers/mucbot/default.nix b/hosts/containers/mucbot/default.nix index 65669ca6..e9a9494c 100644 --- a/hosts/containers/mucbot/default.nix +++ b/hosts/containers/mucbot/default.nix @@ -2,7 +2,7 @@ { c3d2.deployment = { - server = "server10"; + server = "nomad"; mounts = []; mountBase = "/glusterfs/fast/microvms/${config.networking.hostName}"; }; diff --git a/modules/microvm.nix b/modules/microvm.nix index da1a8e4f..3e0fa0c6 100644 --- a/modules/microvm.nix +++ b/modules/microvm.nix @@ -29,9 +29,12 @@ in { options.c3d2.deployment = with lib; { server = mkOption { - type = with types; nullOr (enum [ "server9" "server10" ]); + type = types.enum [ "server9" "server10" "nomad" ]; default = null; - description = "Server that is supposed to host this MicroVM."; + description = '' + Server that is supposed to host this MicroVM, + or \"nomad\" for HA clustering. + ''; }; autoNetSetup = mkOption { @@ -58,6 +61,17 @@ in }; }; + config.assertions = [ { + assertion = + config.c3d2.deployment.server == "nomad" -> + config.c3d2.deployment.mounts == [] || + lib.hasPrefix "/glusterfs" config.c3d2.deployment.mountBase; + message = '' + Host \"${config.networking.hostName}\" is to be run on nomad + but its mountBase is not located on /glusterfs/...! + ''; + } ]; + config.system.build = with pkgs; { copyToServer = writeScript "copy-to-${server}" '' #! ${runtimeShell} -e