-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflake.nix
More file actions
118 lines (110 loc) · 3.57 KB
/
Copy pathflake.nix
File metadata and controls
118 lines (110 loc) · 3.57 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
gengeommdb.url = "github:negrel/gengeommdb";
};
outputs =
{
self,
nixpkgs,
flake-utils,
gengeommdb,
...
}:
let
outputsWithoutSystem = { };
outputsWithSystem = flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
buildPrisme =
tags:
pkgs.buildGo125Module {
pname = "prisme";
version = "0.20.0";
vendorHash = "sha256-bYmuF80sPnr1pTJC8Uljyh6sBL9wACIevGryx7WjCLo=";
src = ./.;
# Skip go test.
doCheck = false;
tags = tags;
subPackages = "./cmd/prisme";
env = {
GOEXPERIMENT = "jsonv2";
};
};
dockerBuildPrisme =
prisme: extraEnv:
pkgs.dockerTools.buildImage {
name = "prismelabs/analytics";
tag = "dev";
copyToRoot = with pkgs; [
cacert
bash
coreutils
bunyan-rs
];
runAsRoot = ''
#!${pkgs.runtimeShell}
mkdir -p /app
cp -r ${self.packages."${system}".prisme-healthcheck}/bin/* /healthcheck
'';
config = {
Cmd = [ "${prisme}/bin/prisme" ];
WorkingDir = "/app";
Env = [
"PRISME_ADMIN_HOSTPORT=0.0.0.0:9090"
]
++ extraEnv;
};
};
in
{
pkgs = pkgs;
lib = lib;
devShells = {
default = pkgs.mkShell rec {
buildInputs =
(with pkgs; [
go_1_25
air # FS watcher / Live reload
gopls # Go LSP
golangci-lint # Go linter
go-migrate # Go SQL migration
bunyan-rs # Bunyan format pretty print
minify # JS minifier
clickhouse # clickhouse client
yq # Command-line YAML/XML/TOML processor
python313Packages.openapi-spec-validator # OpenAPI validator
deno # JS/TS runtime
])
++ (with gengeommdb.packages.${system}; [ default ])
++ (with self.packages.${system}; [ libchdb ]);
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
GOFLAGS = "-tags=chdb,test";
GOEXPERIMENT = "jsonv2";
CHDB_LIB_PATH = "${self.packages.${system}.libchdb}/lib/libchdb.so";
};
};
packages = rec {
default = prisme;
prisme = buildPrisme [ ];
prisme-chdb = buildPrisme [ "chdb" ];
docker = dockerBuildPrisme prisme [ ];
docker-chdb = dockerBuildPrisme prisme-chdb [
"CHDB_LIB_PATH=${libchdb}/lib/libchdb.so"
];
prisme-healthcheck = pkgs.writeShellApplication {
name = "prisme-healthcheck";
runtimeInputs = with pkgs; [ wget ];
text = ''
wget --no-verbose --tries=1 --spider "http://localhost:''${PRISME_PORT:-80}/api/v1/healthcheck" || exit 1
'';
};
libchdb = pkgs.callPackage ./nix/libchdb.nix { };
};
}
);
in
outputsWithSystem // outputsWithoutSystem;
}