fediversity/deployment/run/tf-single-host/main.tf
Kiara Grouwstra 03a22b1cb8
All checks were successful
deploy-infra / deploy (push) Successful in 2m14s
/ check-data-model (push) Successful in 31s
Nix flake checks / _complete (push) Successful in 35s
Nix flake checks / deployment-basic (push) Successful in 35s
Nix flake checks / deployment-cli (push) Successful in 46s
Nix flake checks / deployment-model-nixops4 (push) Successful in 35s
Nix flake checks / deployment-model-ssh (push) Successful in 24s
Nix flake checks / deployment-model-tf (push) Successful in 26s
Nix flake checks / deployment-panel (push) Successful in 1m50s
Nix flake checks / nixops-deployment-providers-default (push) Successful in 12s
Nix flake checks / nixops-deployment-providers-fedi200 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-fedi201 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-forgejo-ci (push) Successful in 13s
Nix flake checks / nixops-deployment-providers-test (push) Successful in 12s
Nix flake checks / nixops-deployment-providers-vm02116 (push) Successful in 12s
Nix flake checks / nixops-deployment-providers-vm02187 (push) Successful in 11s
Nix flake checks / nixosConfigurations-fedi200 (push) Successful in 17s
Nix flake checks / nixosConfigurations-fedi201 (push) Successful in 33s
Nix flake checks / nixosConfigurations-forgejo-ci (push) Successful in 20s
Nix flake checks / nixosConfigurations-test01 (push) Successful in 18s
Nix flake checks / nixosConfigurations-test02 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test03 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test04 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test05 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test06 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test11 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test12 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test13 (push) Successful in 18s
Nix flake checks / nixosConfigurations-test14 (push) Successful in 17s
Nix flake checks / nixosConfigurations-vm02116 (push) Successful in 19s
Nix flake checks / nixosConfigurations-vm02187 (push) Successful in 18s
Nix flake checks / panel (push) Successful in 29s
Nix flake checks / pre-commit (push) Successful in 11s
Nix flake checks / proxmox-basic (push) Successful in 35s
Nix flake checks / test-mastodon-service (push) Successful in 23s
Nix flake checks / test-peertube-service (push) Successful in 22s
Nix flake checks / vmOptions-fedi200 (push) Successful in 5s
Nix flake checks / vmOptions-fedi201 (push) Successful in 5s
Nix flake checks / vmOptions-test01 (push) Successful in 5s
Nix flake checks / vmOptions-test02 (push) Successful in 5s
Nix flake checks / vmOptions-test03 (push) Successful in 5s
Nix flake checks / vmOptions-test04 (push) Successful in 5s
Nix flake checks / vmOptions-test05 (push) Successful in 7s
Nix flake checks / vmOptions-test06 (push) Successful in 5s
Nix flake checks / vmOptions-test11 (push) Successful in 5s
Nix flake checks / vmOptions-test12 (push) Successful in 5s
Nix flake checks / vmOptions-test13 (push) Successful in 4s
Nix flake checks / vmOptions-test14 (push) Successful in 5s
Nix flake checks / _checks (push) Successful in 0s
factor out nixos conf (#526)
Reviewed-on: Fediversity/Fediversity#526
2025-09-18 20:06:23 +02:00

43 lines
1.8 KiB
HCL

# hash of our code directory, used to trigger re-deploy
# FIXME calculate separately to reduce false positives
data "external" "hash" {
program = ["sh", "-c", "echo \"{\\\"hash\\\":\\\"$(nix-hash ../../..)\\\"}\""]
}
# TF resource to build and deploy NixOS instances.
resource "terraform_data" "nixos" {
# trigger rebuild/deploy if (FIXME?) any potentially used config/code changed,
# preventing these (20+s, build being bottleneck) when nothing changed.
# terraform-nixos separates these to only deploy if instantiate changed,
# yet building even then - which may be not as bad using deploy on remote.
# having build/deploy one resource reflects wanting to prevent no-op rebuilds
# over preventing (with less false positives) no-op deployments,
# as i could not find a way to do prevent no-op rebuilds without merging them:
# - generic resources cannot have outputs, while we want info from the instantiation (unless built on host?).
# - `data` always runs, which is slow for deploy and especially build.
triggers_replace = [
data.external.hash.result,
var.nixos_conf,
var.host,
]
provisioner "local-exec" {
# directory to run the script from. we use the TF project root dir,
# here as a path relative from where TF is run from,
# matching calling modules' expectations on config_nix locations.
# note that absolute paths can cause false positives in triggers,
# so are generally discouraged in TF.
working_dir = path.root
environment = {
nixos_conf = var.nixos_conf
username = var.username
host = var.host
key_file = var.key_file
ssh_opts = var.ssh_opts
}
# TODO: refactor back to command="ignoreme" interpreter=concat([]) to protect sensitive data from error logs?
# TODO: build on target?
command = "sh ../ssh-single-host/run.sh"
}
}