From dd72904bf12f9630b9920f62aba44b230ccd27b1 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 7 Jul 2024 19:17:11 +0200 Subject: [PATCH] flake: replace tf wrappers with a single '.#tf' command --- flake.nix | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index a9b2ea3..12917a6 100644 --- a/flake.nix +++ b/flake.nix @@ -41,38 +41,16 @@ in { apps.${system} = { - apply = { + tf = { 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 + ln -snf ${terraformCfg} config.tf.json + exec ${lib.getExe terraform} "$@" ''); - }; - 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 - ln -snf ${terraformCfg} config.tf.json - ${lib.getExe terraform} init - ${lib.getExe terraform} destroy - ''); - }; + }; - default = self.apps.${system}.apply; + default = self.apps.${system}.tf; }; devShells.${system}.default = pkgs.mkShell {