|
| 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