Skip to content

Commit

Permalink
chore: add nix flake based local dev workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRudolph committed Jun 10, 2024
1 parent 6a16bee commit d3767c0
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,22 @@ In order to run the full suite of Acceptance tests, run `make testacc`.
```shell
make testacc
```

## Tips for Local Testing

```shellsession
# start a nix development shell which has go an all dependencies required to build
nix develop -c zsh

# build and install the provider
go install

# link the provider into the terraform plugins dir so terraform can pick it up as a "Implied Local Mirror"
# https://developer.hashicorp.com/terraform/cli/config/config-file#implied-local-mirror-directories

$registry=registry.terraform.io # alternatively use 'registry.opentofu.org'
$platform=darwin_arm64 # replace with your platform

mkdir -p "~/.terraform.d/plugins/$registry/meshcloud/meshstack/0.1.0/$platform/"
ln -s ~/go/bin/terraform-provider-meshstack "~/.terraform.d/plugins/$registry/meshcloud/meshstack/0.1.0/$platform/terraform-provider-meshstack_v0.1.0"
```
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "meshStack Terraform Provider";

inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};


outputs = { self, nixpkgs }:
let
goVersion = 22; # Change this to update the whole stack

# use an overlay to pin default go version
overlays = [ (final: prev: { go = prev."go_1_${toString goVersion}"; }) ];

supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
# go 1.22 (specified by overlay)
go_1_22

# goimports, godoc, etc.
gotools

# https://github.com/golangci/golangci-lint
golangci-lint
];
};
});
};
}

0 comments on commit d3767c0

Please sign in to comment.