diff --git a/deploy_nixos/README.md b/deploy_nixos/README.md index a91f7af..4aab51c 100644 --- a/deploy_nixos/README.md +++ b/deploy_nixos/README.md @@ -107,6 +107,7 @@ see also: | config\_pwd | Directory to evaluate the configuration in. This argument is required if 'config' is given | `string` | `""` | no | | extra\_build\_args | List of arguments to pass to the nix builder | `list(string)` | `[]` | no | | extra\_eval\_args | List of arguments to pass to the nix evaluation | `list(string)` | `[]` | no | +| closure\_copy\_concurrency | Concurrency used when transferring derivations to the remote host | `number` | `1` | no | | hermetic | Treat the provided nixos configuration as a hermetic expression and do not evaluate using the ambient system nixpkgs. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no | | flake | Treat the provided nixos_config as the name of the NixOS configuration to use in the flake located in the current directory. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no | | keys | A map of filename to content to upload as secrets in /var/keys | `map(string)` | `{}` | no | diff --git a/deploy_nixos/main.tf b/deploy_nixos/main.tf index 862cb4f..8eb51ba 100644 --- a/deploy_nixos/main.tf +++ b/deploy_nixos/main.tf @@ -69,6 +69,12 @@ variable "extra_build_args" { default = [] } +variable "closure_copy_concurrency" { + type = number + description = "Concurrency to apply when copying derivations to the target_host" + default = 1 +} + variable "build_on_target" { type = string description = "Avoid building on the deployer. Must be true or false. Has no effect when deploying from an incompatible system. Unlike remote builders, this does not require the deploying user to be trusted by its host." @@ -198,6 +204,7 @@ resource "null_resource" "deploy_nixos" { local.ssh_private_key == "" ? "-" : local.ssh_private_key, "switch", var.delete_older_than, + var.closure_copy_concurrency, ], local.extra_build_args ) diff --git a/deploy_nixos/nixos-deploy.sh b/deploy_nixos/nixos-deploy.sh index 6946122..a6c309b 100755 --- a/deploy_nixos/nixos-deploy.sh +++ b/deploy_nixos/nixos-deploy.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # nixos-deploy deploys a nixos-instantiate-generated drvPath to a target host # -# Usage: nixos-deploy.sh [] ignoreme +# Usage: nixos-deploy.sh [] ignoreme set -euo pipefail ### Defaults ### @@ -34,7 +34,8 @@ buildOnTarget="$5" sshPrivateKey="$6" action="$7" deleteOlderThan="$8" -shift 8 +copyConcurrency="$9" +shift 9 # remove the last argument set -- "${@:1:$(($# - 1))}" @@ -59,7 +60,7 @@ log() { } copyToTarget() { - NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$targetHost" "$@" + NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --max-jobs "$copyConcurrency" --to "$targetHost" "$@" } # assumes that passwordless sudo is enabled on the server