diff --git a/src/default.nix b/src/default.nix index caf1d72..eb4010b 100644 --- a/src/default.nix +++ b/src/default.nix @@ -10,6 +10,7 @@ , gawk , findutils , gnused +, terraform-docs , lib , makeWrapper , mkShellNoCC @@ -44,7 +45,7 @@ stdenv.mkDerivation { # Dependencies for our devshell passthru.devShell = mkShellNoCC { - packages = runtimeDeps ++ [ openssh ]; + packages = runtimeDeps ++ [ openssh terraform-docs ]; }; meta = with lib; { diff --git a/terraform/README.md b/terraform/README.md new file mode 100644 index 0000000..3c080d3 --- /dev/null +++ b/terraform/README.md @@ -0,0 +1,6 @@ +# List of terraform modules + +- [all-in-one](all-in-one.md) +- [install](install.md) +- [nix-build](nix-build.md) +- [nixos-rebuild](nixos-rebuild.md) diff --git a/terraform/all-in-one.md b/terraform/all-in-one.md new file mode 100644 index 0000000..51d496d --- /dev/null +++ b/terraform/all-in-one.md @@ -0,0 +1,50 @@ + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +| -------------------------------------------------------------------------------------- | ---------------- | ------- | +| [install](#module_install) | ../install | n/a | +| [nixos-rebuild](#module_nixos-rebuild) | ../nixos-rebuild | n/a | +| [partitioner-build](#module_partitioner-build) | ../nix-build | n/a | +| [system-build](#module_system-build) | ../nix-build | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | -------- | :------: | +| [debug\_logging](#input_debug_logging) | Enable debug logging | `bool` | `false` | no | +| [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 | +| [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 |
list(object({| `[]` | no | +| [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 | +| [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 | +| [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 | +| [install\_ssh\_key](#input_install_ssh_key) | Content of private key used to connect to the target\_host during initial installation | `string` | `null` | no | +| [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 | +| [instance\_id](#input_instance_id) | The instance id of the target\_host, used to track when to reinstall the machine | `string` | `null` | no | +| [kexec\_tarball\_url](#input_kexec_tarball_url) | NixOS kexec installer tarball url | `string` | `null` | no | +| [nixos\_partitioner\_attr](#input_nixos_partitioner_attr) | Nixos partitioner and mount script i.e. your-flake#nixosConfigurations.your-evaluated-nixos.config.system.build.diskoNoDeps or just your-evaluated.config.system.build.diskNoDeps. `config.system.build.diskNoDeps` is provided by the disko nixos module | `string` | n/a | yes | +| [nixos\_system\_attr](#input_nixos_system_attr) | The nixos system to deploy i.e. your-flake#nixosConfigurations.your-evaluated-nixos.config.system.build.toplevel or just your-evaluated-nixos.config.system.build.toplevel if you are not using flakes | `string` | n/a | yes | +| [no\_reboot](#input_no_reboot) | Do not reboot after installation | `bool` | `false` | no | +| [stop\_after\_disko](#input_stop_after_disko) | Exit after disko formatting | `bool` | `false` | no | +| [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes | +| [target\_port](#input_target_port) | SSH port used to connect to the target\_host, before installing NixOS | `number` | `22` | no | +| [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 | + +## Outputs + +No outputs. + + diff --git a/terraform/install.md b/terraform/install.md new file mode 100644 index 0000000..1388501 --- /dev/null +++ b/terraform/install.md @@ -0,0 +1,46 @@ + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +| --------------------------------------------------- | ------- | +| [null](#provider_null) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +| ------------------------------------------------------------------------------------------------------------------- | -------- | +| [null_resource.nixos-remote](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | -------- | :------: | +| [debug\_logging](#input_debug_logging) | Enable debug logging | `bool` | `false` | no | +| [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 |
path = string
script = string
}))
list(object({| `[]` | no | +| [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 | +| [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 | +| [instance\_id](#input_instance_id) | The instance id of the target\_host, used to track when to reinstall the machine | `string` | `null` | no | +| [kexec\_tarball\_url](#input_kexec_tarball_url) | NixOS kexec installer tarball url | `string` | `null` | no | +| [nixos\_partitioner](#input_nixos_partitioner) | nixos partitioner and mount script | `string` | n/a | yes | +| [nixos\_system](#input_nixos_system) | The nixos system to deploy | `string` | n/a | yes | +| [no\_reboot](#input_no_reboot) | Do not reboot the machine after installation | `bool` | `false` | no | +| [ssh\_private\_key](#input_ssh_private_key) | Content of private key used to connect to the target\_host | `string` | `""` | no | +| [stop\_after\_disko](#input_stop_after_disko) | Exit after disko formatting | `bool` | `false` | no | +| [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes | +| [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no | +| [target\_user](#input_target_user) | SSH user used to connect to the target\_host | `string` | `"root"` | no | + +## Outputs + +No outputs. + + diff --git a/terraform/nix-build.md b/terraform/nix-build.md new file mode 100644 index 0000000..6a27a79 --- /dev/null +++ b/terraform/nix-build.md @@ -0,0 +1,36 @@ + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +| --------------------------------------------------------------- | ------- | +| [external](#provider_external) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +| --------------------------------------------------------------------------------------------------------------------------- | ----------- | +| [external_external.nix-build](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +| ------------------------------------------------------------ | -------------------------------------------------- | -------- | ------- | :------: | +| [attribute](#input_attribute) | the attribute to build, can also be a flake | `string` | n/a | yes | +| [file](#input_file) | the nix file to evaluate, if not run in flake mode | `string` | `null` | no | + +## Outputs + +| Name | Description | +| ----------------------------------------------------- | ----------- | +| [result](#output_result) | n/a | + + diff --git a/terraform/nixos-rebuild.md b/terraform/nixos-rebuild.md new file mode 100644 index 0000000..23b90f9 --- /dev/null +++ b/terraform/nixos-rebuild.md @@ -0,0 +1,38 @@ + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +| --------------------------------------------------- | ------- | +| [null](#provider_null) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +| -------------------------------------------------------------------------------------------------------------------- | -------- | +| [null_resource.nixos-rebuild](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +| -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | :------: | +| [ignore\_systemd\_errors](#input_ignore_systemd_errors) | Ignore systemd errors happening during deploy | `bool` | `false` | no | +| [nixos\_system](#input_nixos_system) | The nixos system to deploy | `string` | n/a | yes | +| [ssh\_private\_key](#input_ssh_private_key) | Content of private key used to connect to the target\_host. If set to - no key is passed to openssh and ssh will back to its own configuration | `string` | `"-"` | no | +| [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes | +| [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no | +| [target\_user](#input_target_user) | User to deploy as | `string` | `"root"` | no | + +## Outputs + +No outputs. + + diff --git a/terraform/update-docs.sh b/terraform/update-docs.sh new file mode 100755 index 0000000..eafcaed --- /dev/null +++ b/terraform/update-docs.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +files=() +find "${SCRIPT_DIR}"/* -type d | while read -r i; do + module_name=$(basename "$i") + markdown_file="${SCRIPT_DIR}/${module_name}.md" + terraform-docs markdown table --output-file "${markdown_file}" --output-mode inject "${module_name}" + files+=("${markdown_file}") +done +nix fmt -- "${files[@]}"
path = string
script = string
}))