aboutsummaryrefslogtreecommitdiff
path: root/flake/terraform.nix
blob: 23cc6d337ff26a89be9550ec6d3223a6602baa78 (plain) (blame)
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
36
37
38
39
40
{ lib, ... }:
{
  perSystem =
    { pkgs, ... }:
    let
      mkTfWrapper =
        {
          tfPlugins,
          cfg,
        }:
        let
          pkg = pkgs.opentofu.withPlugins tfPlugins;
        in
        {
          type = "app";
          program = toString (
            pkgs.writers.writeBash "tf" ''
              set -xeuo pipefail
              ln -snf ${cfg} config.tf.json
              exec ${lib.getExe pkg} "$@"
            ''
          );
        };
    in
    {
      apps = {
        tf = mkTfWrapper {
          cfg = pkgs.adminTerraformCfg;
          tfPlugins = p: [
            p.cloudflare
            p.digitalocean
            p.external
            p.google
            p.null
            p.random
          ];
        };
      };
    };
}