Properly update profile when not rebooting microvm

This commit is contained in:
Sandro - 2023-11-13 23:55:45 +01:00
parent a8bde144b3
commit 75fe718992
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
1 changed files with 10 additions and 0 deletions

View File

@ -232,6 +232,10 @@ lib.attrsets.mapAttrs
echo "hostname of ${target} was expected to be ${name} but is \$hostname. Aborting to be safe..."
exit 2
fi
# refresh nix db which is required for nix-env -p ... --set
${discardStringCtx hostConfig.nix.package}/bin/nix-store --load-db < ${discardStringCtx (pkgs.closureInfo { rootPaths = [ hostConfig.system.build.toplevel.outPath ]; })}
${discardStringCtx hostConfig.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
${toplevelOutPath}/bin/switch-to-configuration "''${@:-switch}"
END
# ^ yes, this is required to be like this
@ -253,6 +257,12 @@ lib.attrsets.mapAttrs
${hostConfig.system.build.runOnServer} bash -e <<END
set -eou pipefail
hostname=\$(cat /etc/hostname)
if [[ "\$hostname" != ${name} ]]; then
echo "hostname of ${target} was expected to be ${name} but is \$hostname. Aborting to be safe..."
exit 2
fi
${createDirsCopyCurrent name}
ln -sfT ${hostConfig.microvm.declaredRunner} current