Skip to content

Commit 5c4cb3c

Browse files
author
nartsisss
committed
openobserve: add update script
1 parent dfecf34 commit 5c4cb3c

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/build.rs b/build.rs
2+
index 0f66ace..be74fad 100644
3+
--- a/build.rs
4+
+++ b/build.rs
5+
@@ -99,24 +99,5 @@ fn main() -> Result<()> {
6+
&["proto"],
7+
)?;
8+
9+
- // build information
10+
- let output = Command::new("git")
11+
- .args(["describe", "--tags", "--abbrev=0"])
12+
- .output()
13+
- .unwrap();
14+
- let git_tag = String::from_utf8(output.stdout).unwrap();
15+
- println!("cargo:rustc-env=GIT_VERSION={git_tag}");
16+
-
17+
- let output = Command::new("git")
18+
- .args(["rev-parse", "HEAD"])
19+
- .output()
20+
- .unwrap();
21+
- let git_commit = String::from_utf8(output.stdout).unwrap();
22+
- println!("cargo:rustc-env=GIT_COMMIT_HASH={git_commit}");
23+
-
24+
- let now: DateTime<Utc> = Utc::now();
25+
- let build_date = now.to_rfc3339_opts(SecondsFormat::Secs, true);
26+
- println!("cargo:rustc-env=GIT_BUILD_DATE={build_date}");
27+
-
28+
Ok(())
29+
}

pkgs/servers/monitoring/openobserve/default.nix renamed to pkgs/servers/monitoring/openobserve/openobserve/package.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
zlib,
1212
zstd,
1313
buildNpmPackage,
14+
nix-update-script,
1415
}:
1516

1617
let
@@ -97,6 +98,7 @@ rustPlatform.buildRustPackage {
9798
"--skip=tests::e2e_test"
9899
];
99100

101+
passthru.updateScript = nix-update-script { };
100102

101103
meta = {
102104
description = "Cloud-native observability platform built specifically for logs, metrics, traces, analytics & realtime user-monitoring";
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
lib,
3+
rustPlatform,
4+
fetchFromGitHub,
5+
pkg-config,
6+
protobuf,
7+
bzip2,
8+
oniguruma,
9+
sqlite,
10+
xz,
11+
zlib,
12+
zstd,
13+
buildNpmPackage,
14+
gitUpdater,
15+
}:
16+
17+
let
18+
version = "0.14.0";
19+
src = fetchFromGitHub {
20+
owner = "openobserve";
21+
repo = "openobserve";
22+
tag = "v${version}";
23+
hash = "sha256-rTp+DkADqYkJg1zJog1yURE082V5kCqgid/oUd81SN8=";
24+
};
25+
web = buildNpmPackage {
26+
inherit src version;
27+
pname = "openobserve-ui";
28+
29+
sourceRoot = "${src.name}/web";
30+
31+
npmDepsHash = "sha256-awfQR1wZBX3ggmD0uJE9Fur4voPydeygrviRijKnBTE=";
32+
33+
preBuild = ''
34+
# Patch vite config to not open the browser to visualize plugin composition
35+
substituteInPlace vite.config.ts \
36+
--replace "open: true" "open: false";
37+
'';
38+
39+
env = {
40+
NODE_OPTIONS = "--max-old-space-size=8192";
41+
# cypress tries to download binaries otherwise
42+
CYPRESS_INSTALL_BINARY = 0;
43+
};
44+
45+
installPhase = ''
46+
runHook preInstall
47+
mkdir -p $out/share
48+
mv dist $out/share/openobserve-ui
49+
runHook postInstall
50+
'';
51+
};
52+
in
53+
rustPlatform.buildRustPackage {
54+
pname = "openobserve";
55+
inherit version src;
56+
57+
patches = [
58+
# prevent using git to determine version info during build time
59+
./build.rs.patch
60+
];
61+
62+
preBuild = ''
63+
cp -r ${web}/share/openobserve-ui web/dist
64+
'';
65+
66+
useFetchCargoVendor = true;
67+
cargoHash = "sha256-FWMUPghx9CxuzP7jFZYSIwZsylApWzQsfx8DuwS4GTo=";
68+
69+
nativeBuildInputs = [
70+
pkg-config
71+
protobuf
72+
];
73+
74+
buildInputs = [
75+
bzip2
76+
oniguruma
77+
sqlite
78+
xz
79+
zlib
80+
zstd
81+
];
82+
83+
env = {
84+
RUSTONIG_SYSTEM_LIBONIG = true;
85+
ZSTD_SYS_USE_PKG_CONFIG = true;
86+
87+
RUSTC_BOOTSTRAP = 1; # uses experimental features
88+
89+
# the patched build.rs file sets these variables
90+
GIT_VERSION = src.tag;
91+
GIT_COMMIT_HASH = "builtByNix";
92+
GIT_BUILD_DATE = "1970-01-01T00:00:00Z";
93+
};
94+
95+
# requires network access or filesystem mutations
96+
checkFlags = [
97+
"--skip=handler::http::router::tests::test_get_proxy_routes"
98+
"--skip=tests::e2e_test"
99+
];
100+
101+
passthru.updateScript = gitUpdater {
102+
rev-prefix = "v";
103+
ignoredVersions = "rc";
104+
};
105+
106+
meta = {
107+
description = "Cloud-native observability platform built specifically for logs, metrics, traces, analytics & realtime user-monitoring";
108+
homepage = "https://github.com/openobserve/openobserve";
109+
changelog = "https://github.com/openobserve/openobserve/releases/tag/v${version}";
110+
license = lib.licenses.asl20;
111+
maintainers = with lib.maintainers; [ happysalada ];
112+
mainProgram = "openobserve";
113+
};
114+
}

0 commit comments

Comments
 (0)