Skip to content

Commit 3a11c17

Browse files
KiaraGrouwstramergify[bot]
authored andcommitted
feat: expose --generate-hardware-config nixos-generate-config flag in TF as var.nixos_generate_config_path
1 parent 3fb834d commit 3a11c17

File tree

7 files changed

+19
-0
lines changed

7 files changed

+19
-0
lines changed

terraform/all-in-one.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ No resources.
127127
| <a name="input_target_host"></a> [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes |
128128
| <a name="input_target_port"></a> [target\_port](#input_target_port) | SSH port used to connect to the target\_host after installing NixOS. If install\_port is not set than this port is also used before installing. | `number` | `22` | no |
129129
| <a name="input_target_user"></a> [target\_user](#input_target_user) | SSH user used to connect to the target\_host after installing NixOS. If install\_user is not set than this user is also used before installing. | `string` | `"root"` | no |
130+
| <a name="input_nixos_generate_config_path"></a> [nixos\_generate\_config\_path](#input_nixos_generate_config_path) | Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`. | `string` | `""` | no |
130131

131132
## Outputs
132133

terraform/all-in-one/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module "install" {
3232
extra_environment = var.extra_environment
3333
instance_id = var.instance_id
3434
phases = var.phases
35+
nixos_generate_config_path = var.nixos_generate_config_path
3536
# deprecated attributes
3637
stop_after_disko = var.stop_after_disko
3738
no_reboot = var.no_reboot

terraform/all-in-one/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,9 @@ variable "nix_options" {
119119
description = "the options of nix"
120120
default = {}
121121
}
122+
123+
variable "nixos_generate_config_path" {
124+
type = string
125+
description = "Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`."
126+
default = ""
127+
}

terraform/install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ No modules.
8181
| <a name="input_target_pass"></a> [target\_pass](#input_target_pass) | Password used to connect to the target\_host | `string` | `null` | no |
8282
| <a name="input_target_port"></a> [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no |
8383
| <a name="input_target_user"></a> [target\_user](#input_target_user) | SSH user used to connect to the target\_host | `string` | `"root"` | no |
84+
| <a name="input_nixos_generate_config_path"></a> [nixos\_generate\_config\_path](#input_nixos_generate_config_path) | Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`. | `string` | `""` | no |
8485

8586
## Outputs
8687

terraform/install/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ locals {
1616
build_on_remote = var.build_on_remote
1717
flake = var.flake
1818
phases = join(",", local.phases)
19+
nixos_generate_config_path = var.nixos_generate_config_path
1920
})
2021
}
2122

terraform/install/run-nixos-anywhere.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ if [[ -n ${input[flake]} ]]; then
2727
else
2828
args+=("--store-paths" "${input[nixos_partitioner]}" "${input[nixos_system]}")
2929
fi
30+
if [[ -n ${input[nixos_generate_config_path]} ]]; then
31+
args+=("--generate-hardware-config" "nixos-generate-config" "${input[nixos_generate_config_path]}")
32+
fi
3033
args+=(--phases "${input[phases]}")
3134
if [[ ${input[ssh_private_key]} != null ]]; then
3235
export SSH_PRIVATE_KEY="${input[ssh_private_key]}"

terraform/install/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ variable "flake" {
109109
description = "The flake to install the system from"
110110
default = ""
111111
}
112+
113+
variable "nixos_generate_config_path" {
114+
type = string
115+
description = "Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`."
116+
default = ""
117+
}

0 commit comments

Comments
 (0)