diff options
| author | seth <[email protected]> | 2025-01-05 23:24:04 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-06 04:24:04 +0000 |
| commit | a0726ea66d1857eb2e1c9d7dfd2f10d30ac64706 (patch) | |
| tree | 585d4c7706ef52fc037419958b0af86e216a5d43 /modules/flake/terranix.nix | |
| parent | 85e702efc03b04cbb0ac5b1b2ef79c21602c8ed8 (diff) | |
treewide: back to flake parts (#539)
* treewide: back to flake parts
* treewide: drop extra docs
these are kind pointless
Diffstat (limited to 'modules/flake/terranix.nix')
| -rw-r--r-- | modules/flake/terranix.nix | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/modules/flake/terranix.nix b/modules/flake/terranix.nix new file mode 100644 index 0000000..cbf57b9 --- /dev/null +++ b/modules/flake/terranix.nix @@ -0,0 +1,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} "$@" + ''; + }; + }; + }; +} |
