Skip to content

Commit

Permalink
add kexec support for linux-aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Aug 5, 2023
1 parent e71ef00 commit efeb9cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions docs/howtos.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ By default, `nixos-anywhere` downloads the kexec image from the

However, you can provide your own `kexec` image file if you need to use a
different one. This is particularly useful for architectures other than
`x86_64`, since they don't have a pre-build image.
`x86_64` and `aarch64`, since they don't have a pre-build image.

To do this, use the `--kexec` command line switch followed by the path to your
image file. The image will be uploaded prior to execution.

Here's an example command that demonstrates how to use a custom kexec image with
`nixos-anywhere` for aarch64 instead of the default `x86_64` architecture:
Here's an example command that demonstrates how to use a custom kexec image with `nixos-anywhere`:

```
nix run github:numtide/nixos-anywhere -- \
Expand Down
14 changes: 10 additions & 4 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ step() {
echo "### $* ###"
}

default_kexec_url=https://github.com/nix-community/nixos-images/releases/download/nixos-23.05/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz
kexec_url="$default_kexec_url"
kexec_url=""
enable_debug=""
maybe_reboot="sleep 6 && reboot"
nix_options=(
Expand Down Expand Up @@ -337,8 +336,15 @@ if [[ ${is_os-n} != "Linux" ]]; then
fi

if [[ ${is_kexec-n} == "n" ]] && [[ ${is_installer-n} == "n" ]]; then
if [[ ${is_arch-n} != "x86_64" ]] && [[ $kexec_url == "$default_kexec_url" ]]; then
abort "The default kexec image only support x86_64 cpus. Checkout https://github.com/numtide/nixos-anywhere/#using-your-own-kexec-image for more information."
if [[ $kexec_url == "" ]]; then
case "${is_arch-unknown}" in
x86_64 | aarch64)
kexec_url="https://github.com/nix-community/nixos-images/releases/download/nixos-23.05/nixos-kexec-installer-noninteractive-${is_arch}-linux.tar.gz"
;;
*)
abort "Unsupported architecture: ${is_arch}. Our default kexec images only support x86_64 and aarch64 cpus. Checkout https://github.com/numtide/nixos-anywhere/#using-your-own-kexec-image for more information."
;;
esac
fi

step Switching system into kexec
Expand Down

0 comments on commit efeb9cf

Please sign in to comment.