From 00d7c22d3432211b01525b8690363c8b6f8e4430 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Fri, 29 Oct 2021 14:01:14 -0400 Subject: [PATCH] morph: add livecd-deploy --- lib/morph.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/morph.nix b/lib/morph.nix index b24ce37..2e5bf7e 100644 --- a/lib/morph.nix +++ b/lib/morph.nix @@ -79,6 +79,19 @@ exec "${morph}/bin/morph" deploy ${morph-config} "$@" ''; + livecd-deploy = sh '' + config=".#nixosConfigurations.\"$1\".config" + nix build "$config.system.build.toplevel" --out-link "$(mktemp -d)/result" + sys="$(nix eval --raw "$config.system.build.toplevel")" + ip="$(nix eval --raw "$config.sconfig.morph.deployment.targetHost")" + nix copy --to ssh://root@$ip?remote-store=local?root=/mnt "$sys" + ssh root@$ip nix-env --store /mnt -p /mnt/nix/var/nix/profiles/system --set "$sys" + ssh root@$ip mkdir /mnt/etc + ssh root@$ip touch /mnt/etc/NIXOS + ssh root@$ip ln -sfn /proc/mounts /mnt/etc/mtab + ssh root@$ip NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root /mnt -- /run/current-system/bin/switch-to-configuration boot + ''; + push = sh '' exec "${morph}/bin/morph" push ${morph-config} "$@" '';