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

Use tar and ssh instead of rsync #325

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions src/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ stdenv
, openssh
, gitMinimal
, rsync
, nixVersions
, nix
, coreutils
Expand All @@ -28,7 +27,6 @@ let
findutils
gnused # needed by ssh-copy-id
sshpass # used to provide password for ssh-copy-id
rsync # used to upload extra-files
];
in
stdenv.mkDerivation {
Expand All @@ -41,8 +39,6 @@ stdenv.mkDerivation {

# We prefer the system's openssh over our own, since it might come with features not present in ours:
# https://github.com/nix-community/nixos-anywhere/issues/62
#
# We also prefer system rsync to prevent crashes between rsync and ssh.
makeShellWrapper $out/libexec/nixos-anywhere/nixos-anywhere.sh $out/bin/nixos-anywhere \
--prefix PATH : ${lib.makeBinPath runtimeDeps} --suffix PATH : ${lib.makeBinPath [ openssh ]}
'';
Expand Down
7 changes: 2 additions & 5 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,8 @@ if [[ -n ${extra_files-} ]]; then
extra_files="$extra_files/"
fi
step Copying extra files
rsync -rlpv -FF \
-e "ssh -i \"$ssh_key_dir\"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${ssh_args[*]}" \
"$extra_files" \
"${ssh_connection}:/mnt/"
ssh_ "chmod 755 /mnt" # rsync also changes permissions of /mnt
tar -C "$extra_files" -cpf- . | ssh_ "${maybe_sudo} tar -C /mnt -xf-"
ssh_ "chmod 755 /mnt" # tar also changes permissions of /mnt
fi

step Installing NixOS
Expand Down
2 changes: 1 addition & 1 deletion terraform/all-in-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ No resources.
| <a name="input_deployment_ssh_key"></a> [deployment\_ssh\_key](#input_deployment_ssh_key) | Content of private key used to deploy to the target\_host after initial installation. To ensure maximum security, it is advisable to connect to your host using ssh-agent instead of relying on this variable | `string` | `null` | no |
| <a name="input_disk_encryption_key_scripts"></a> [disk\_encryption\_key\_scripts](#input_disk_encryption_key_scripts) | Each of these script files will be executed locally and the output of each of them will be made present at the given path to disko during installation. The keys will be not copied to the final system | <pre>list(object({<br> path = string<br> script = string<br> }))</pre> | `[]` | no |
| <a name="input_extra_environment"></a> [extra\_environment](#input_extra_environment) | Extra environment variables to be set during installation. This can be usefull to set extra variables for the extra\_files\_script or disk\_encryption\_key\_scripts | `map(string)` | `{}` | no |
| <a name="input_extra_files_script"></a> [extra\_files\_script](#input_extra_files_script) | A script file that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is rsynced to the target host during installation to the / directory. | `string` | `null` | no |
| <a name="input_extra_files_script"></a> [extra\_files\_script](#input_extra_files_script) | A script file that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is copied to the target host during installation to the / directory. | `string` | `null` | no |
| <a name="input_file"></a> [file](#input_file) | Nix file containing the nixos\_system\_attr and nixos\_partitioner\_attr. Use this if you are not using flake | `string` | `null` | no |
| <a name="input_install_ssh_key"></a> [install\_ssh\_key](#input_install_ssh_key) | Content of private key used to connect to the target\_host during initial installation | `string` | `null` | no |
| <a name="input_install_user"></a> [install\_user](#input_install_user) | SSH user used to connect to the target\_host, before installing NixOS. If null than the value of `target_host` is used | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion terraform/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ variable "stop_after_disko" {

variable "extra_files_script" {
type = string
description = "A script file that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is rsynced to the target host during installation to the / directory."
description = "A script file that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is copied to the target host during installation to the / directory."
default = null
}

Expand Down
Loading
Loading