blob: cbf57b9e0c97590a4237a531a8f5a2967ee8c0e5 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
{
config,
lib,
pkgs,
flake-parts-lib,
inputs,
...
}:
let
inherit (flake-parts-lib) mkSubmoduleOptions;
namespace = "terranix";
cfg = config.${namespace};
in
{
options.terranix = mkSubmoduleOptions {
package = lib.mkOption {
type = lib.types.functionTo lib.types.package;
default = pkgs: pkgs.opentofu;
defaultText = lib.literalExpression "pkgs: pkgs.opentofu";
apply = fn: fn pkgs;
description = "The Terraform-compatible implementation to use.";
example = lib.literalExpression "pkgs: pkgs.terraform";
};
modules = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = [ ];
};
};
config = {
perSystem =
{
lib,
pkgs,
system,
...
}:
let
terranixConfiguration = inputs.terranix.lib.terranixConfiguration {
inherit system;
inherit (cfg) modules;
};
in
{
apps.tf = {
program = pkgs.writeShellScriptBin "tf" ''
ln -sf ${terranixConfiguration} config.tf.json
exec ${lib.getExe cfg.package} "$@"
'';
};
};
};
}
|