deploy-local: Use custom implementation
Using nixos-rebuild for this, while being easy, often was difficult.
This commit is contained in:
parent
0bbacae3d0
commit
89855c41cc
21
flake.nix
21
flake.nix
|
@ -108,12 +108,21 @@
|
|||
|
||||
deploy-local = lib.recurseIntoAttrs (lib.mapAttrs
|
||||
(hostname: machine: pkgs.writeShellScript "deploy-local-${hostname}" ''
|
||||
${pkgs.nixos-rebuild}/bin/nixos-rebuild \
|
||||
switch \
|
||||
--flake .#${hostname} \
|
||||
--build-host localhost \
|
||||
--target-host root@${machine.config.deployment.targetHost} \
|
||||
--use-substitutes
|
||||
set -euo pipefail
|
||||
|
||||
closure="$(nix build -L --print-out-paths .#nixosConfigurations.${hostname}.config.system.build.toplevel)"
|
||||
nix copy \
|
||||
-s \
|
||||
-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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue