summaryrefslogtreecommitdiff
path: root/modules/flake/terranix.nix
blob: 0d390436203042b67eac0cf51df58907a32188eb (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
{
  lib,
  flake-parts-lib,
  inputs,
  ...
}: let
  namespace = "terranix";

  inherit
    (lib)
    literalExpression
    mkOption
    mkPackageOption
    types
    ;

  inherit
    (flake-parts-lib)
    mkPerSystemOption
    ;
in {
  options = {
    perSystem = mkPerSystemOption ({
      config,
      pkgs,
      system,
      ...
    }: let
      cfg = config.${namespace};
    in {
      options.${namespace} = {
        modules = mkOption {
          type = types.listOf types.unspecified;
          default = [];
          example = literalExpression "[ ./terranix ]";
          description = ''
            Modules to use in this terranixConfiguration
          '';
        };

        package = mkPackageOption pkgs "opentofu" {
          default = ["opentofu"];
          example = literalExpression "pkgs.opentofu.withPlugins (plugins: [ plugins.tailscale ] )";
        };
      };

      config = {
        packages.terranix = inputs.terranix.lib.terranixConfiguration {
          inherit system;
          inherit (cfg) modules;
        };
      };
    });
  };
}