Skip to content

Commit

Permalink
feat: add option --ssh-store-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aabccd021 committed Aug 13, 2024
1 parent b3d6481 commit 3e1944d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Options:
use another kexec tarball to bootstrap NixOS
* --kexec-extra-flags
extra flags to add into the call to kexec, e.g. "--no-sync"
* --ssh-store-settings
extra ssh store settings appended to the store URI e.g. "compress=true&max-connections=10"
* --post-kexec-ssh-port <ssh_port>
after kexec is executed, use a custom ssh port to connect. Defaults to 22
* --copy-host-keys
Expand Down
19 changes: 13 additions & 6 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Options:
use another kexec tarball to bootstrap NixOS
* --kexec-extra-flags
extra flags to add into the call to kexec, e.g. "--no-sync"
* --ssh-store-settings
extra ssh store settings appended to the store URI e.g. "compress=true&max-connections=10"
* --post-kexec-ssh-port <ssh_port>
after kexec is executed, use a custom ssh port to connect. Defaults to 22
* --copy-host-keys
Expand Down Expand Up @@ -68,6 +70,7 @@ step() {
here=$(dirname "${BASH_SOURCE[0]}")
kexec_url=""
kexec_extra_flags=""
ssh_store_settings=""
enable_debug=""
maybe_reboot="sleep 6 && reboot"
nix_options=(
Expand Down Expand Up @@ -130,6 +133,10 @@ while [[ $# -gt 0 ]]; do
kexec_extra_flags=$2
shift
;;
--ssh-store-settings)
ssh_store_settings=$2
shift
;;
--post-kexec-ssh-port)
post_kexec_ssh_port=$2
shift
Expand Down Expand Up @@ -446,15 +453,15 @@ if [[ ${build_on_remote-n} == "y" ]]; then
fi

if [[ -n ${disko_script-} ]]; then
nix_copy --to "ssh://$ssh_connection" "$disko_script"
nix_copy --to "ssh://$ssh_connection?$ssh_store_settings" "$disko_script"
elif [[ ${build_on_remote-n} == "y" ]]; then
step Building disko script
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
nix_copy --to "ssh-ng://$ssh_connection" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
nix_copy --to "ssh-ng://$ssh_connection?$ssh_store_settings" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
--derivation --no-check-sigs
disko_script=$(
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.diskoScript" \
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir%2Fnixos-anywhere"
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir%2Fnixos-anywhere&$ssh_store_settings"
)
fi

Expand All @@ -470,15 +477,15 @@ fi

if [[ -n ${nixos_system-} ]]; then
step Uploading the system closure
nix_copy --to "ssh://$ssh_connection?remote-store=local%3Froot=%2Fmnt" "$nixos_system"
nix_copy --to "ssh://$ssh_connection?remote-store=local%3Froot=%2Fmnt&$ssh_store_settings" "$nixos_system"
elif [[ ${build_on_remote-n} == "y" ]]; then
step Building the system closure
# We need to do a nix copy first because nix build doesn't have --no-check-sigs
nix_copy --to "ssh-ng://$ssh_connection?remote-store=local%3Froot=%2Fmnt" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
nix_copy --to "ssh-ng://$ssh_connection?remote-store=local%3Froot=%2Fmnt&$ssh_store_settings" "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
--derivation --no-check-sigs
nixos_system=$(
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir%2Fnixos-anywhere&remote-store=local%3Froot=%2Fmnt"
--eval-store auto --store "ssh-ng://$ssh_connection?ssh-key=$ssh_key_dir%2Fnixos-anywhere&remote-store=local%3Froot=%2Fmnt&$ssh_store_settings"
)
fi

Expand Down

0 comments on commit 3e1944d

Please sign in to comment.