packages: fix nix-env not being in PATH; check if we nuke the microvm host on accident

This commit is contained in:
Sandro - 2023-11-13 02:54:21 +01:00
parent 27930ce873
commit 6c5830b591
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
1 changed files with 8 additions and 3 deletions

View File

@ -116,7 +116,7 @@ lib.attrsets.mapAttrs
''}
if [[ $(ssh ${target} cat /etc/hostname) != ${name} ]]; then
echo "hostname of the target machine does not match, please manually investiagte!"
echo "hostname of the target machine does not match, please manually investigate!"
echo " $(ssh ${target} cat /etc/hostname) != ${name}"
exit 1
fi
@ -126,7 +126,7 @@ lib.attrsets.mapAttrs
# use nixos-rebuild from target config
ssh ${target} bash -e <<END
nix build ${toplevelDrvPath}
nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
${discardStringCtx hostConfig.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
${toplevelOutPath}/bin/switch-to-configuration "''${@:-switch}"
END
'';
@ -219,8 +219,13 @@ lib.attrsets.mapAttrs
ssh ${target} bash -e <<END
set -eou pipefail
if [[ $(cat /etc/hostname) != ${name} ]]; then
echo "hostname of the target machine does not match, please manually investigate!"
echo " $(ssh ${target} cat /etc/hostname) != ${name}"
exit 1
fi
${discardStringCtx hostConfig.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
${toplevelOutPath}/bin/switch-to-configuration "''${@:-switch}"
nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
END
# ^ yes, this is required to be like this