-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
143 lines (118 loc) · 4.38 KB
/
flake.nix
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
# Flake to build openobserve a service for metrics,logs and traces.
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
# https://github.com/nix-community/fenix?tab=readme-ov-file#toolchain
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
# https://crane.dev/index.html
crane = {
url = "github:ipetkov/crane";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
openobserve-src = {
url = "github:openobserve/openobserve/v0.8.1";
flake = false;
};
};
outputs = { self, nixpkgs, utils, fenix, crane, openobserve-src }:
utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
cargoToml = pkgs.lib.importTOML "${src}/Cargo.toml";
toolchain = (fenix.packages.${system}.fromToolchainName {
name = (pkgs.lib.importTOML "${src}/rust-toolchain.toml").toolchain.channel;
sha256 = "sha256-nxFSckxGqs0YAW3UeHBC4fTeE3fLJI+nC0IEPiF/bIw=";
}).toolchain;
craneLib = crane.lib.${system}.overrideToolchain toolchain;
src =
# filter out the web directory which gets built and linked in later
let f = name: type:
with builtins;
with pkgs.lib;
let baseName = baseNameOf (toString name);
in !(type == "directory" && baseName == "web");
in pkgs.lib.cleanSourceWith {filter = f; src = "${openobserve-src}";};
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
patches = [
# the presence of .cargo/config.toml apparently
# breaks nix builds on aarch64-linux
./nix/patches/remove-cargo-config-toml.patch
];
strictDeps = true;
nativeBuildInputs = [
pkgs.protobuf
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
openobserve = craneLib.buildPackage (commonArgs // {
pname = cargoToml.package.name;
version = cargoToml.package.version;
inherit cargoArtifacts;
nativeBuildInputs = [
pkgs.protobuf
pkgs.git
];
# test cases are failing at the moment so we disable them
doCheck = false;
preConfigurePhases = [ "buildWeb" ];
buildWeb = ''
ln -s ${web} web
'';
meta = with pkgs.lib; {
homepage = cargoToml.package.homepage;
changelog = "https://github.com/openobserve/openobserve/releases/tag/v${version}";
description = cargoToml.package.description;
longDescription = ''
OpenObserve (O2 for short) is a cloud-native observability platform built
specifically for logs, metrics, traces, analytics, RUM (Real User Monitoring -
Performance, Errors, Session Replay) designed to work at petabyte scale.
'';
license = licenses.agpl3;
mainProgram = "openobserve";
};
});
web = pkgs.buildNpmPackage {
name = "${cargoToml.package.name}-web";
src = "${openobserve-src}/web";
patches = [
# remove cyprus related packages used for testing and which causes installation issues
./nix/patches/web/package.json.diff
];
# run prefetch-npm-deps to update it
npmDepsHash = "sha256-RNUCR80ewFt9F/VHv7kXLa87h0fz0YBp+9gSOUhtrdU=";
# the output of this package is only the assets
# it is not a nodejs application
dontNpmInstall = true;
installPhase = ''
ls -alh
mkdir $out
cp -r dist $out/
'';
};
in
{
checks = {
inherit web openobserve;
};
packages.default = openobserve;
packages.openobserve = openobserve;
apps.default = utils.lib.mkApp { drv = openobserve; };
}
)
// {
overlays.default = final: prev: {
openobserve = self.packages.${prev.system}.openobserve;
};
};
}