-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
119 lines (99 loc) · 3.15 KB
/
flake.nix
File metadata and controls
119 lines (99 loc) · 3.15 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
{
description = "Deployah - A CLI tool for deploying applications to Kubernetes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
lib = nixpkgs.lib;
packageName = "deployah";
clusterName = "deployah";
kubeConfigPath = "./.kubeconfig";
kindContext = "kind-${clusterName}";
go = pkgs.go_1_25;
# Ensure buildGoModule (including its go-modules fetcher) uses Go 1.25
buildGoModule125 = pkgs.buildGoModule.override { go = go; };
deployah = buildGoModule125 {
pname = packageName;
version = "0.1.0";
src = ./.;
vendorHash = "sha256-ZIVqNqjqQFpSYwAHIKTgf3MEea/0ggdF/eQ2sMSm0i4=";
subPackages = [ "cmd/deployah" ];
ldflags = [
"-s"
"-w"
"-X main.version=${"0.1.0"}"
];
# Disable tests during Nix build if they are not hermetic
doCheck = false;
# Improve reproducibility and avoid local workspace interference
env.CGO_ENABLED = "0";
GOWORK = "off";
meta = {
mainProgram = "deployah";
description = "Deployah - A CLI tool for deploying applications to Kubernetes";
homepage = "https://github.com/deployah-dev/deployah";
license = lib.licenses.asl20;
};
};
in {
formatter = pkgs.alejandra;
packages = {
default = deployah;
${packageName} = deployah;
};
apps = {
default = flake-utils.lib.mkApp {
drv = deployah;
exePath = "/bin/deployah";
};
};
devShells.default = pkgs.mkShell {
name = packageName;
buildInputs = with pkgs; [
go
kind
revive
kubectl
kubecolor
kubernetes-helm
golangci-lint
gopls
just
jq
yq-go
];
shellHook = ''
set -euo pipefail
echo "Welcome to ${packageName} development environment!"
alias kubectl="kubecolor"
# Check and create kind cluster if not exists
if ! kind get clusters | grep -q ${clusterName}; then
kind create cluster --name ${clusterName} --wait 60s --kubeconfig ${kubeConfigPath}
fi
export KUBECONFIG=${kubeConfigPath}
export HELM_KUBECONTEXT=${kindContext}
# Only prompt/cleanup if interactive
if [ -t 0 ]; then
cleanup() {
echo "Cleaning up ${packageName} development environment..."
read -p "Do you want to delete the kind cluster? (y/n): " choice
case $choice in
[Yy]*)
kind delete cluster --name ${clusterName} --kubeconfig ${kubeConfigPath}
rm -rf ${kubeConfigPath}
;;
esac
}
trap cleanup EXIT
fi
'';
};
});
}