From c20ed35827d4abed986c3a8340cabfd2aad751f3 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 11:09:41 -0400 Subject: terranix: add apply script --- ext/terranix/default.nix | 50 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'ext') diff --git a/ext/terranix/default.nix b/ext/terranix/default.nix index 44ede51..1af9002 100644 --- a/ext/terranix/default.nix +++ b/ext/terranix/default.nix @@ -1,24 +1,44 @@ { inputs, ... }: { perSystem = - { pkgs, system, ... }: { - packages = { - opentofu = pkgs.opentofu.withPlugins (plugins: [ - plugins.cloudflare - plugins.tailscale - ]); + lib, + pkgs, + self', + system, + ... + }: + let + inherit (self'.packages) opentofu; - terranix = inputs.terranix.lib.terranixConfiguration { - inherit system; - modules = [ - ./cloudflare - ./tailscale - ./cloud.nix - ./vars.nix - ./versions.nix - ]; + terranix = inputs.terranix.lib.terranixConfiguration { + inherit system; + modules = [ + ./cloudflare + ./tailscale + ./cloud.nix + ./vars.nix + ./versions.nix + ]; + }; + in + { + apps = { + apply-tf = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellScriptBin "apply" '' + cp --force ${terranix} config.tf.json \ + && ${lib.getExe opentofu} init \ + && ${lib.getExe opentofu} apply + '' + ); }; }; + + packages.opentofu = pkgs.opentofu.withPlugins (plugins: [ + plugins.cloudflare + plugins.tailscale + ]); }; } -- cgit v1.2.3