summaryrefslogtreecommitdiff
path: root/tofu/default.nix
blob: fe0d3bd67918a4995d685cb9f2a6073388de2a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{inputs, ...}: {
  perSystem = {
    lib,
    pkgs,
    system,
    ...
  }: let
    tofuConfig = inputs.terranix.lib.terranixConfiguration {
      inherit system;
      modules = [
        ./cloudflare
        ./tailscale
        ./cloud.nix
        ./vars.nix
        ./versions.nix
      ];
    };
  in {
    apps.gen-tofu = {
      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 ${tofuConfig} "$config_file"
        '';
      };
    };
  };
}