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

feat: expose --generate-hardware-config nixos-facter thru TF #408

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions terraform/all-in-one.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ No resources.
| <a name="input_target_host"></a> [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes |
| <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 |
| <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 |
| <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 |
| <a name="input_nixos_facter_path"></a> [nixos\_facter\_path](#input_nixos_facter_path) | Path to which to write a `hardware-configuration.nix` generated by `nixos-facter`. | `string` | `""` | no |

## Outputs

Expand Down
2 changes: 2 additions & 0 deletions terraform/all-in-one/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module "install" {
extra_environment = var.extra_environment
instance_id = var.instance_id
phases = var.phases
nixos_generate_config_path = var.nixos_generate_config_path
nixos_facter_path = var.nixos_facter_path
# deprecated attributes
stop_after_disko = var.stop_after_disko
no_reboot = var.no_reboot
Expand Down
12 changes: 12 additions & 0 deletions terraform/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ variable "nix_options" {
description = "the options of nix"
default = {}
}

variable "nixos_generate_config_path" {
type = string
description = "Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`."
default = ""
}

variable "nixos_facter_path" {
type = string
description = "Path to which to write a `facter.json` generated by `nixos-facter`."
default = ""
}
2 changes: 2 additions & 0 deletions terraform/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ No modules.
| <a name="input_target_pass"></a> [target\_pass](#input_target_pass) | Password used to connect to the target\_host | `string` | `null` | no |
| <a name="input_target_port"></a> [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no |
| <a name="input_target_user"></a> [target\_user](#input_target_user) | SSH user used to connect to the target\_host | `string` | `"root"` | no |
| <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 |
| <a name="input_nixos_facter_path"></a> [nixos\_facter\_path](#input_nixos_facter_path) | Path to which to write a `hardware-configuration.nix` generated by `nixos-facter`. | `string` | `""` | no |

## Outputs

Expand Down
2 changes: 2 additions & 0 deletions terraform/install/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ locals {
build_on_remote = var.build_on_remote
flake = var.flake
phases = join(",", local.phases)
nixos_generate_config_path = var.nixos_generate_config_path
nixos_facter_path = var.nixos_facter_path
})
}

Expand Down
9 changes: 9 additions & 0 deletions terraform/install/run-nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ if [[ -n ${input[flake]} ]]; then
else
args+=("--store-paths" "${input[nixos_partitioner]}" "${input[nixos_system]}")
fi
if [[ -n ${input[nixos_generate_config_path]} ]]; then
if [[ -n ${input[nixos_facter_path]} ]]; then
echo "cannot set both variables 'nixos_generate_config_path' and 'nixos_facter_path'!" >&2
exit 1
fi
args+=("--generate-hardware-config" "nixos-generate-config" "${input[nixos_generate_config_path]}")
KiaraGrouwstra marked this conversation as resolved.
Show resolved Hide resolved
elif [[ -n ${input[nixos_facter_path]} ]]; then
args+=("--generate-hardware-config" "nixos-facter" "${input[nixos_facter_path]}")
fi
args+=(--phases "${input[phases]}")
if [[ ${input[ssh_private_key]} != null ]]; then
export SSH_PRIVATE_KEY="${input[ssh_private_key]}"
Expand Down
12 changes: 12 additions & 0 deletions terraform/install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ variable "flake" {
description = "The flake to install the system from"
default = ""
}

variable "nixos_generate_config_path" {
KiaraGrouwstra marked this conversation as resolved.
Show resolved Hide resolved
type = string
description = "Path to which to write a `hardware-configuration.nix` generated by `nixos-generate-config`."
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
default = ""
}

variable "nixos_facter_path" {
type = string
description = "Path to which to write a `facter.json` generated by `nixos-facter`."
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
default = ""
}