diff options
Diffstat (limited to 'terranix/default.nix')
| -rw-r--r-- | terranix/default.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/terranix/default.nix b/terranix/default.nix new file mode 100644 index 0000000..aa499a3 --- /dev/null +++ b/terranix/default.nix @@ -0,0 +1,49 @@ +{inputs, ...}: { + perSystem = { + lib, + pkgs, + system, + self', + opentofu', + ... + }: let + terranixConfig = inputs.terranix.lib.terranixConfiguration { + inherit system; + modules = [ + ./cloudflare + ./tailscale + ./cloud.nix + ./vars.nix + ./versions.nix + ]; + }; + in { + _module.args.opentofu' = pkgs.opentofu.withPlugins (plugins: + with plugins; [ + cloudflare + tailscale + ]); + + apps.gen-terranix = { + type = "app"; + + program = pkgs.writeShellApplication { + name = "gen-tf"; + + text = '' + config_file="config.tf.json" + [ -e "$config_file" ] && rm -f "$config_file" + cp ${terranixConfig} "$config_file" + ''; + }; + }; + + devShells.terranix = pkgs.mkShell { + shellHook = '' + ${self'.apps.gen-terranix.program} + ''; + + packages = [pkgs.just opentofu']; + }; + }; +} |
