From 70b60bc55cf80e78ef63a6de59d53073aa21684f Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Wed, 11 Dec 2024 10:28:18 +0100 Subject: [PATCH] build(nix): add devshell to be able to launch a local dev shell from remote/local code --- flake.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/flake.nix b/flake.nix index 94bba4e5..9c9702be 100644 --- a/flake.nix +++ b/flake.nix @@ -25,13 +25,18 @@ }; in { + # Exposes the local plugin to be consumed as a package. packages = with pkgs.terraform-providers; { inherit sysdig; default = sysdig; }; + + # To be used with `nix run`. apps.terraform = flake-utils.lib.mkApp { drv = pkgs.terraform.withPlugins (tf: [ tf.sysdig ]); }; + + # Used for local development. Adds the required dependencies to work in this project. devShells.default = with pkgs; mkShell { @@ -41,6 +46,21 @@ ]; }; + # Used with `nix develop #terraform-with-plugin`. + # You can load terraform with the sysdig plugin from a commit, a branch or a tag. + # For instance: + # - `nix develop github:sysdiglabs/terraform-provider-sysdig#terraform-with-plugin` will create a local dev shell with the version from the main branch. + # - `nix develop github:sysdiglabs/terraform-provider-sysdig/branch-name#terraform-with-plugin` with create a local dev shell with the version from the `branch-name` branch code. + # - `nix develop github:sysdiglabs/terraform-provider-sysdig/v1.2.3#terraform-with-plugin` will create a local dev shell with the version from the tag `v1.2.3` code (note the provided version is just an example). + # - `nix develop .#terraform-with-plugin` will create a local dev shell with terraform with the local code. + devShells.terraform-with-plugin = + with pkgs; + mkShell { + packages = [ + (terraform.withPlugins (tf: [ tf.sysdig ])) + ]; + }; + formatter = pkgs.nixfmt-rfc-style; } );