flake: replace tf wrappers with a single '.#tf' command

This commit is contained in:
Pierre Bourdon 2024-07-07 19:17:11 +02:00
parent 2e9483936e
commit dd72904bf1
Signed by: delroth
GPG key ID: 6FB80DCD84DA0F1C

View file

@ -41,38 +41,16 @@
in in
{ {
apps.${system} = { apps.${system} = {
apply = { tf = {
type = "app"; type = "app";
program = toString (pkgs.writers.writeBash "apply" '' program = toString (pkgs.writers.writeBash "tf" ''
set -eo pipefail
rm -f config.tf.json
cp ${terraformCfg} config.tf.json
${lib.getExe terraform} init
${lib.getExe terraform} apply
'');
};
plan = {
type = "app";
program = toString (pkgs.writers.writeBash "plan" ''
set -eo pipefail
rm -f config.tf.json
cp ${terraformCfg} config.tf.json
${lib.getExe terraform} init
${lib.getExe terraform} plan
'');
};
# nix run ".#destroy"
destroy = {
type = "app";
program = toString (pkgs.writers.writeBash "destroy" ''
set -eo pipefail set -eo pipefail
ln -snf ${terraformCfg} config.tf.json ln -snf ${terraformCfg} config.tf.json
${lib.getExe terraform} init exec ${lib.getExe terraform} "$@"
${lib.getExe terraform} destroy
''); '');
}; };
default = self.apps.${system}.apply; default = self.apps.${system}.tf;
}; };
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {