Error when running nixos-rebuild for a microvm

This commit is contained in:
Sandro - 2023-01-07 00:55:45 +01:00
parent 9d9cc81671
commit 6f98aedfa0
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
1 changed files with 8 additions and 1 deletions

View File

@ -111,9 +111,16 @@ lib.attrsets.mapAttrs
# remote machine and bulding and switching there.
# Can be run with `nix run c3d2#…-nixos-rebuild switch`
"${name}-nixos-rebuild" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
#!${pkgs.runtimeShell} -ex
#!${pkgs.runtimeShell} -e
if nix eval .#nixosConfigurations.${name}.config.c3d2.deployment.server &>/dev/null; then
echo "microvms cannot be updated with nixos-rebuild. Use nix run .#microvm-update-${name}"
exit 2
fi
[[ $(ssh ${target} cat /etc/hostname) == ${name} ]]
nix copy --no-check-sigs --to ssh-ng://${target} ${inputPaths}
# use nixos-rebuild from target config
nixosRebuild=$(nix build ${self}#nixosConfigurations.${name}.config.system.build.nixos-rebuild --no-link --json | ${pkgs.jq}/bin/jq -r '.[0].outputs.out')
nix copy --no-check-sigs --to ssh-ng://${target} $nixosRebuild