packages: let microvm-update-* bail out with elaborative exception

This commit is contained in:
Astro 2022-12-12 01:45:17 +01:00
parent 3d276740a2
commit af7b75df9e
1 changed files with 25 additions and 26 deletions

View File

@ -160,14 +160,11 @@ lib.attrsets.mapAttrs
ssh ${target} "time nix-collect-garbage -d && time nix-store --optimise"
'';
"microvm-update-${name}" = pkgs.writeScriptBin "microvm-update-${name}" ''
"microvm-update-${name}" = pkgs.writeScriptBin "microvm-update-${name}" (
if builtins.elem (hostConfig.c3d2.deployment.server or null) [ "server9" "server10" ]
then ''
#!${pkgs.runtimeShell} -e
${lib.optionalString (! builtins.elem (hostConfig.c3d2.deployment.server or null) [ "server9" "server10" ]) ''
echo "MicroVM must be configured to proper server" >&2
exit 1
''}
${hostConfig.system.build.copyToServer} ${inputPaths}
${hostConfig.system.build.runOnServer} bash -e <<END
@ -191,7 +188,9 @@ lib.attrsets.mapAttrs
systemctl restart microvm@${name}.service
END
'';
''
else throw "${name} is not configured to run on microvm.nix. Is it a physical host or is it deployed in Skyflake?"
);
"microvm-update-${name}-local" = pkgs.writeScriptBin "microvm-update-${name}" ''
#!${pkgs.runtimeShell} -e