Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt nixos-anywhere to work with a remote running alpine #286

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ done
import_facts() {
local facts filtered_facts
if ! facts=$(
ssh_ -o ConnectTimeout=10 bash -- <<SSH
ssh_ -o ConnectTimeout=10 sh -- <<SSH
set -efu ${enable_debug}
has(){
command -v "\$1" >/dev/null && echo "y" || echo "n"
Expand All @@ -317,6 +317,7 @@ is_installer=\$(if [[ "\$is_nixos" == "y" ]] && grep -q VARIANT_ID=installer /et
is_container=\$(if [[ "\$(has systemd-detect-virt)" == "y" ]]; then systemd-detect-virt --container; else echo "none"; fi)
has_tar=\$(has tar)
has_sudo=\$(has sudo)
has_doas=\$(has doas)
has_wget=\$(has wget)
has_curl=\$(has curl)
has_setsid=\$(has setsid)
Expand Down Expand Up @@ -348,6 +349,8 @@ fi
maybe_sudo=""
if [[ ${has_sudo-n} == "y" ]]; then
maybe_sudo="sudo"
elif [[ ${has_doas-n} == "y" ]]; then
maybe_sudo="doas"
fi

if [[ ${is_os-n} != "Linux" ]]; then
Expand All @@ -371,7 +374,7 @@ if [[ ${is_kexec-n} == "n" ]] && [[ ${is_installer-n} == "n" ]]; then
fi

step Switching system into kexec
ssh_ bash <<SSH
ssh_ sh <<SSH
set -efu ${enable_debug}
$maybe_sudo rm -rf /root/kexec
$maybe_sudo mkdir -p /root/kexec
Expand Down Expand Up @@ -471,7 +474,7 @@ if [[ -n ${extra_files-} ]]; then
fi

step Installing NixOS
ssh_ bash <<SSH
ssh_ sh <<SSH
set -eu ${enable_debug}
# when running not in nixos we might miss this directory, but it's needed in the nixos chroot during installation
export PATH="\$PATH:/run/current-system/sw/bin"
Expand Down Expand Up @@ -499,7 +502,7 @@ if command -v zpool >/dev/null; then
fi
# We will reboot in background so we can cleanly finish the script before the hosts go down.
# This makes integration into scripts easier
nohup bash -c '${maybe_reboot}' >/dev/null &
nohup sh -c '${maybe_reboot}' >/dev/null &
SSH

if [[ -n ${maybe_reboot} ]]; then
Expand Down
Loading