-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtf.nix
More file actions
49 lines (46 loc) · 1.12 KB
/
Copy pathtf.nix
File metadata and controls
49 lines (46 loc) · 1.12 KB
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
41
42
43
44
45
46
47
48
49
{ inputs, ... }:
{
perSystem =
{
lib,
pkgs,
system,
self',
...
}:
let
opentofu = lib.getExe pkgs.opentofu;
tfConfiguration = inputs.terranix.lib.terranixConfiguration {
inherit system;
modules = [ ./tf/dns.nix ];
};
in
{
packages.default = tfConfiguration;
apps = {
default = self'.apps.apply;
apply = {
type = "app";
program = toString (
pkgs.writers.writeBash "apply" ''
if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi
cp ${tfConfiguration} config.tf.json \
&& ${opentofu} init \
&& ${opentofu} apply
''
);
};
destroy = {
type = "app";
program = toString (
pkgs.writers.writeBash "destroy" ''
if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi
cp ${tfConfiguration} config.tf.json \
&& ${opentofu} init \
&& ${opentofu} destroy
''
);
};
};
};
}