-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
158 lines (133 loc) · 4.77 KB
/
flake.nix
File metadata and controls
158 lines (133 loc) · 4.77 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
150
151
152
153
154
155
156
157
158
{
description = "flowctl - Control plane for data pipeline orchestration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Go version to use
go = pkgs.go_1_26;
# Build dependencies
buildInputs = with pkgs; [
# Go and build tools
go
gotools
go-tools
gopls
delve
# Protobuf compiler and plugins
protobuf
protoc-gen-go
protoc-gen-go-grpc
# Development tools
gnumake
git
# Optional: for documentation
mdbook
];
# flowctl package
flowctl = pkgs.buildGoModule rec {
pname = "flowctl";
version = "0.1.0";
src = ./.;
vendorHash = null; # Set to null for now, will need to be updated
nativeBuildInputs = [ pkgs.protobuf ];
preBuild = ''
# Generate protobuf files
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/*.proto
'';
ldflags = [
"-s"
"-w"
"-X main.version=${version}"
];
meta = with pkgs.lib; {
description = "Control plane for data pipeline orchestration";
homepage = "https://github.com/withObsrvr/flowctl";
license = licenses.mit;
maintainers = [ ];
};
};
# Development shell script for generating protobuf
generateScript = pkgs.writeScriptBin "generate-proto" ''
#!${pkgs.stdenv.shell}
echo "Generating protobuf files..."
${pkgs.protobuf}/bin/protoc \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/*.proto
echo "Done!"
'';
# Development shell script for running flowctl
runScript = pkgs.writeScriptBin "run-flowctl" ''
#!${pkgs.stdenv.shell}
go run ./cmd/flowctl "$@"
'';
in
{
# Package outputs
packages = {
default = flowctl;
flowctl = flowctl;
};
# App outputs
apps = {
default = flake-utils.lib.mkApp {
drv = flowctl;
};
flowctl = flake-utils.lib.mkApp {
drv = flowctl;
};
};
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = buildInputs ++ [
generateScript
runScript
];
shellHook = ''
export PS1="\[\033[1;34m\][nix-flowctl]\[\033[0m\] \[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ "
echo "flowctl development environment"
echo "Available commands:"
echo " generate-proto - Generate protobuf Go files"
echo " run-flowctl - Run flowctl using 'go run'"
echo " go test - Run tests"
echo " go build - Build flowctl binary"
echo ""
echo "Protoc version: $(protoc --version)"
echo "Go version: $(go version)"
# Set up Go environment
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"
# Install Go protobuf plugins if not already installed
if ! command -v protoc-gen-go &> /dev/null; then
echo "Installing protoc-gen-go..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
fi
if ! command -v protoc-gen-go-grpc &> /dev/null; then
echo "Installing protoc-gen-go-grpc..."
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
fi
'';
};
# Alternative minimal shell just for protobuf generation
devShells.proto = pkgs.mkShell {
buildInputs = with pkgs; [
protobuf
go
];
shellHook = ''
echo "Minimal shell for protobuf generation"
echo "Installing Go protobuf plugins..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
echo "Ready to generate protobuf files!"
'';
};
});
}