deploy-local: Use custom implementation

Using nixos-rebuild for this, while being easy, often was difficult.
This commit is contained in:
Simon Bruder 2023-05-31 17:50:51 +02:00
parent 0bbacae3d0
commit 89855c41cc
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -108,12 +108,21 @@
deploy-local = lib.recurseIntoAttrs (lib.mapAttrs deploy-local = lib.recurseIntoAttrs (lib.mapAttrs
(hostname: machine: pkgs.writeShellScript "deploy-local-${hostname}" '' (hostname: machine: pkgs.writeShellScript "deploy-local-${hostname}" ''
${pkgs.nixos-rebuild}/bin/nixos-rebuild \ set -euo pipefail
switch \
--flake .#${hostname} \ closure="$(nix build -L --print-out-paths .#nixosConfigurations.${hostname}.config.system.build.toplevel)"
--build-host localhost \ nix copy \
--target-host root@${machine.config.deployment.targetHost} \ -s \
--use-substitutes -L \
--to ssh://root@${machine.config.deployment.targetHost} \
"$closure"
ssh root@${machine.config.deployment.targetHost} nix-env -p /nix/var/nix/profiles/system --set ''${closure}
ssh root@${machine.config.deployment.targetHost} ''${closure}/bin/switch-to-configuration switch
return="$?"
if [ "$return" != 0 ]; then
echo "Error(s) occurred while Switching configuration"
exit "$retuen"
fi
'') '')
self.nixosConfigurations); self.nixosConfigurations);