Skip to content

Commit 227cfbd

Browse files
committed
deploy_nixos: support concurrency when copying closures
1 parent 8c2cdd6 commit 227cfbd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

deploy_nixos/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ see also:
107107
| config\_pwd | Directory to evaluate the configuration in. This argument is required if 'config' is given | `string` | `""` | no |
108108
| extra\_build\_args | List of arguments to pass to the nix builder | `list(string)` | `[]` | no |
109109
| extra\_eval\_args | List of arguments to pass to the nix evaluation | `list(string)` | `[]` | no |
110+
| closure\_copy\_concurrency | Concurrency used when transferring derivations to the remote host | `number` | `1` | no |
110111
| 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 |
111112
| 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 |
112113
| keys | A map of filename to content to upload as secrets in /var/keys | `map(string)` | `{}` | no |

deploy_nixos/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ variable "extra_build_args" {
6969
default = []
7070
}
7171

72+
variable "closure_copy_concurrency" {
73+
type = number
74+
description = "Concurrency to apply when copying derivations to the target_host"
75+
default = 1
76+
}
77+
7278
variable "build_on_target" {
7379
type = string
7480
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" {
198204
local.ssh_private_key == "" ? "-" : local.ssh_private_key,
199205
"switch",
200206
var.delete_older_than,
207+
var.closure_copy_concurrency,
201208
],
202209
local.extra_build_args
203210
)

deploy_nixos/nixos-deploy.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# nixos-deploy deploys a nixos-instantiate-generated drvPath to a target host
33
#
4-
# Usage: nixos-deploy.sh <drvPath> <host> <switch-action> <deleteOlderThan> [<build-opts>] ignoreme
4+
# Usage: nixos-deploy.sh <drvPath> <host> <switch-action> <deleteOlderThan> <copyConcurrency> [<build-opts>] ignoreme
55
set -euo pipefail
66

77
### Defaults ###
@@ -34,7 +34,8 @@ buildOnTarget="$5"
3434
sshPrivateKey="$6"
3535
action="$7"
3636
deleteOlderThan="$8"
37-
shift 8
37+
copyConcurrency="$9"
38+
shift 9
3839

3940
# remove the last argument
4041
set -- "${@:1:$(($# - 1))}"
@@ -59,7 +60,7 @@ log() {
5960
}
6061

6162
copyToTarget() {
62-
NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$targetHost" "$@"
63+
NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --max-jobs "$copyConcurrency" --to "$targetHost" "$@"
6364
}
6465

6566
# assumes that passwordless sudo is enabled on the server

0 commit comments

Comments
 (0)