summaryrefslogtreecommitdiff
path: root/terranix/default.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-12-27 04:49:26 -0500
committerseth <[email protected]>2023-12-27 05:09:07 -0500
commit773d59f2606c924de218d8d5bdfadcc875084047 (patch)
tree10bd52f58715adb47dcf87993885d2b3989d85c5 /terranix/default.nix
parent6f2a3fc6e3e20e719a4d570d883d64023db00653 (diff)
terranix: better handle deployments
Diffstat (limited to 'terranix/default.nix')
-rw-r--r--terranix/default.nix49
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'];
+ };
+ };
+}