Skip to content

Commit 2e62d1f

Browse files
authored
chore: add nix flake for reproducible dev environment (#695)
- Add Nix flake configuration for reproducible development environment - Include all required tools: go, terraform, goreleaser, golangci-lint, gofumpt, pre-commit, etc. - Update `.envrc` to automatically use the flake when nix is available - Remove `testacc` from pre-commit hooks (too slow for local commits)
1 parent 93d03a8 commit 2e62d1f

File tree

4 files changed

+108
-7
lines changed

4 files changed

+108
-7
lines changed

.envrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
export TF_ACC=true
2-
export TF_LOG=DEBUG
1+
has nix && use flake
32
dotenv_if_exists .env # You can create a .env file with your env vars for this project. You can also use .secrets if you are using act. See the line below.
43
dotenv_if_exists .secrets # Used by [act](https://nektosact.com/) to load secrets into the pipelines
54
strict_env
65
env_vars_required SYSDIG_SECURE_API_TOKEN SYSDIG_MONITOR_API_TOKEN
6+
export TF_ACC=true
7+
export TF_LOG=DEBUG

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,4 @@ repos:
2626
pass_filenames: false
2727
entry: make test
2828
language: system
29-
- id: testacc
30-
name: testacc
31-
pass_filenames: false
32-
entry: make testacc
33-
language: system
3429

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
outputs =
7+
{
8+
self,
9+
nixpkgs,
10+
flake-utils,
11+
}:
12+
flake-utils.lib.eachDefaultSystem (
13+
system:
14+
let
15+
pkgs = import nixpkgs {
16+
inherit system;
17+
config.allowUnfree = true;
18+
};
19+
in
20+
{
21+
devShells.default =
22+
with pkgs;
23+
mkShell {
24+
packages = [
25+
go
26+
terraform
27+
goreleaser
28+
gnupg
29+
golangci-lint
30+
gofumpt
31+
jq
32+
gnumake
33+
pre-commit
34+
];
35+
36+
shellHook = ''
37+
pre-commit install
38+
'';
39+
};
40+
41+
formatter = pkgs.nixfmt-tree;
42+
}
43+
);
44+
}

0 commit comments

Comments
 (0)