diff options
Diffstat (limited to 'ext/terranix/default.nix')
| -rw-r--r-- | ext/terranix/default.nix | 50 |
1 files changed, 35 insertions, 15 deletions
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 + ]); }; } |
