diff options
| author | seth <[email protected]> | 2023-12-11 19:08:10 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2023-12-12 22:43:30 -0500 |
| commit | 03cea3ba8fea453fa5ca1611c7d8af152e2fcaaa (patch) | |
| tree | c3f8895328329485714a5e51d928af1bf9892d46 /tofu/default.nix | |
| parent | 988e00c510b1cc6b50e2211c4d0e8852463b1741 (diff) | |
start using opentofu
Diffstat (limited to 'tofu/default.nix')
| -rw-r--r-- | tofu/default.nix | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tofu/default.nix b/tofu/default.nix new file mode 100644 index 0000000..4e6a425 --- /dev/null +++ b/tofu/default.nix @@ -0,0 +1,54 @@ +{inputs, ...}: { + perSystem = { + lib, + pkgs, + system, + ... + }: let + config = inputs.terranix.lib.terranixConfiguration { + inherit system; + modules = [ + ./cloudflare + ./tailscale + ./cloud.nix + ./vars.nix + ./versions.nix + ]; + }; + in { + apps = + lib.genAttrs ["apply" "destroy" "plan"] (fn: { + type = "app"; + + program = pkgs.writeShellApplication { + name = fn; + + runtimeInputs = [pkgs.opentofu]; + + text = '' + config_file="config.tf.json" + [ -e "$config_file" ] && rm -f "$config_file" + cp ${config} "$config_file" + tofu init && tofu ${fn} + ''; + }; + }) + // { + tofu-config = { + type = "app"; + + program = pkgs.writeShellApplication { + name = "tofu-config"; + + runtimeInputs = [pkgs.opentofu]; + + text = '' + config_file="config.tf.json" + [ -e "$config_file" ] && rm -f "$config_file" + cp ${config} "$config_file" + ''; + }; + }; + }; + }; +} |
