-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdevenv.nix
More file actions
149 lines (128 loc) · 3.88 KB
/
devenv.nix
File metadata and controls
149 lines (128 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{ pkgs, lib, config, inputs, ... }:
let
kubectl-volsync = pkgs.buildGoModule rec {
pname = "kubectl-volsync";
version = "0.14.0";
src = pkgs.fetchFromGitHub {
owner = "backube";
repo = "volsync";
rev = "v${version}";
hash = "sha256-vtJlrqbuZ01wo3HRwfSY4RzR5uEKOmNKAmiHIj0CDIU=";
};
vendorHash = "sha256-0pU8TruOugV6e+4hKtnJWJ7jGy2Df3Z1bnm6k0XD3tk=";
subPackages = [ "kubectl-volsync" ];
ldflags = [
"-s"
"-w"
"-X github.com/backube/volsync/kubectl-volsync/cmd.volsyncVersion=${version}"
];
postInstall = ''
# Generate shell completions
mkdir -p $out/share/bash-completion/completions
mkdir -p $out/share/zsh/site-functions
mkdir -p $out/share/fish/vendor_completions.d
$out/bin/kubectl-volsync completion bash > $out/share/bash-completion/completions/kubectl-volsync
$out/bin/kubectl-volsync completion zsh > $out/share/zsh/site-functions/_kubectl-volsync
$out/bin/kubectl-volsync completion fish > $out/share/fish/vendor_completions.d/kubectl-volsync.fish
'';
meta = with lib; {
description = "kubectl plugin for VolSync";
homepage = "https://github.com/backube/volsync";
license = licenses.agpl3Plus;
};
};
in
{
# https://devenv.sh/basics/
env.GREET = "Infra Development Environment";
dotenv.enable = true;
# https://devenv.sh/packages/
packages = with pkgs; [
cilium-cli
kubectl
kustomize
kubernetes-helm
fluxcd
google-cloud-sdk
sops
age
just
cilium-cli
kns
kubectl-view-secret
kubectl-volsync
];
# https://devenv.sh/processes/
# processes.cargo-watch.exec = "cargo-watch";
# https://devenv.sh/services/
# services.postgres.enable = true;
# https://devenv.sh/scripts/
scripts.setup-infra.exec = ''
echo "🚀 Setting up infrastructure development environment..."
echo ""
echo "💡 Use 'just --list' to see available automation tasks"
echo "📚 Check docs/ directory for setup instructions"
'';
enterShell = ''
setup-infra
'';
# https://devenv.sh/tasks/
# tasks = {
# "myproj:setup".exec = "mytool build";
# "devenv:enterShell".after = [ "myproj:setup" ];
# };
# https://devenv.sh/tests/
enterTest = ''
echo "🧪 Running infrastructure environment tests..."
# Test essential tools
terraform version
kubectl version --client
flux version --client
helm version
sops --version
just --version
# Test cloud CLI tools
gcloud version
echo "✅ All tools are working correctly"
'';
# https://devenv.sh/git-hooks/
git-hooks.hooks = {
shellcheck.enable = true;
terraform-format.enable = true;
terraform-validate.enable = true;
yamllint = {
enable = true;
settings.configPath = ".github/lint/.yamllint.yaml";
};
trim-trailing-whitespace.enable = true;
end-of-file-fixer.enable = true;
# SOPS secret detection
forbid-secrets = {
enable = true;
name = "forbid-secrets";
entry = "${pkgs.writeShellScript "forbid-secrets" ''
#!/usr/bin/env bash
if grep -r "sops:" "$@" 2>/dev/null | grep -v "\.sops\." | grep -qv "\.sops\.yaml"; then
exit 0
fi
for file in "$@"; do
if [[ "$file" == *.sops.* ]]; then
continue
fi
if grep -q "ENC\[AES256_GCM" "$file" 2>/dev/null; then
echo "ERROR: Found encrypted SOPS data in non-.sops file: $file"
exit 1
fi
if grep -qE "(PRIVATE KEY|password|secret|api[_-]?key)" "$file" 2>/dev/null; then
if [[ ! "$file" == *.sops.* ]]; then
echo "WARNING: Potential secret in $file - verify this is intentional"
fi
fi
done
''}";
types = [ "text" ];
pass_filenames = true;
};
};
# See full reference at https://devenv.sh/reference/options/
}