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

Default to ssh-ng and and builders-use-substituters #167

Closed
wants to merge 2 commits into from
Closed
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
22 changes: 16 additions & 6 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Options:
URL of the source Nix store to copy the nixos and disko closure from
* --build-on-remote
build the closure on the remote machine instead of locally and copy-closuring it
* --legacy-ssh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

Suggested change
* --legacy-ssh
* --builder-protocol

Than we can also support other protocols in future?

use nix "ssh://" protocol instead of "ssh-ng://"
* --vm-test
build the system and test the disk configuration inside a VM without installing it to the target.
USAGE
Expand All @@ -68,8 +70,13 @@ nix_options=(
--extra-experimental-features 'nix-command flakes'
"--no-write-lock-file"
)
nix_build_options=(
--print-out-paths
--no-link
)
substitute_on_destination=y
ssh_private_key_file=
ssh_store_protocol="ssh-ng"
ssh_tty_param="-T"
post_kexec_ssh_port=22

Expand Down Expand Up @@ -157,6 +164,9 @@ while [[ $# -gt 0 ]]; do
--build-on-remote)
build_on_remote=y
;;
--legacy_ssh)
ssh_store_protocol="ssh"
;;
--vm-test)
vm_test=y
;;
Expand All @@ -178,6 +188,7 @@ fi

if [[ ${substitute_on_destination-n} == "y" ]]; then
nix_copy_options+=("--substitute-on-destination")
nix_build_options+=("--builders-use-substitutes")
fi

# ssh wrapper
Expand All @@ -196,9 +207,8 @@ nix_copy() {
}
nix_build() {
NIX_SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ssh_key_dir/nixos-anywhere" nix build \
--print-out-paths \
--no-link \
"${nix_options[@]}" \
"${nix_build_options[@]}" \
"$@"
}

Expand Down Expand Up @@ -394,11 +404,11 @@ if [[ -z ${disko_script-} ]] && [[ ${build_on_remote-n} == "y" ]]; then
step Building disko script
disko_script=$(
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
--builders "ssh://$ssh_connection $is_arch-linux $ssh_key_dir/nixos-anywhere - - - - $pubkey "
--builders "$ssh_store_protocol://$ssh_connection $is_arch-linux $ssh_key_dir/nixos-anywhere - - - - $pubkey "
)
fi
step Formatting hard drive with disko
nix_copy --to "ssh://$ssh_connection" "$disko_script"
nix_copy --to "$ssh_store_protocol://$ssh_connection" "$disko_script"
ssh_ "$disko_script"

if [[ ${stop_after_disko-n} == "y" ]]; then
Expand All @@ -412,11 +422,11 @@ if [[ -z ${nixos_system-} ]] && [[ ${build_on_remote-n} == "y" ]]; then
step Building the system closure
nixos_system=$(
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
--builders "ssh://$ssh_connection?remote-store=local?root=/mnt $is_arch-linux $ssh_key_dir/nixos-anywhere - - - - $pubkey "
--builders "$ssh_store_protocol://$ssh_connection?remote-store=local?root=/mnt $is_arch-linux $ssh_key_dir/nixos-anywhere - - - - $pubkey "
)
fi
step Uploading the system closure
nix_copy --to "ssh://$ssh_connection?remote-store=local?root=/mnt" "$nixos_system"
nix_copy --to "$ssh_store_protocol://$ssh_connection?remote-store=local?root=/mnt" "$nixos_system"

if [[ -n ${extra_files-} ]]; then
if [[ -d $extra_files ]]; then
Expand Down