forked from BloopAI/bloop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
206 lines (180 loc) · 6.41 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
description = "bloop";
# nixConfig = {
# extra-substituters = "https://bloopai.cachix.org";
# extra-trusted-public-keys =
# "bloopai.cachix.org-1:uSHFor+Jd3znikUnLc58xnHBXTcuIBSjdJxV5rLIMJU=";
# };
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs2305.url = "github:nixos/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs2305, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
pkgsStable = import nixpkgs2305 { inherit system; };
pkgsStatic = pkgs.pkgsStatic;
lib = pkgs.lib;
llvm = pkgs.llvmPackages_14;
clang = llvm.clang;
libclang = llvm.libclang;
stdenv =
if pkgs.stdenv.isLinux then
pkgs.stdenvAdapters.useMoldLinker llvm.stdenv
else
llvm.stdenv;
mkShell =
if stdenv.isLinux then
pkgs.mkShell.override { inherit stdenv; }
else
pkgs.mkShell;
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.cargo;
rustc = pkgs.rustc;
};
runtimeDeps = with pkgs;
([ openssl.out rocksdb git zlib nsync ]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Foundation
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
]);
buildDeps = with pkgs;
([
stdenv.cc.cc.lib
glib.dev
pkg-config
openssl.out
openssl.dev
llvm.bintools
protobuf
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Foundation
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
]);
guiDeps = with pkgs;
[ nodePackages.npm nodejs ] ++ (lib.optionals stdenv.isLinux [
gdk-pixbuf
gdk-pixbuf.dev
zlib.dev
dbus.dev
libsoup.dev
gtk3.dev
webkitgtk
dmidecode
appimage-run
appimagekit
gdk-pixbuf
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.MetalKit
darwin.apple_sdk.frameworks.MetalPerformanceShaders
darwin.apple_sdk.frameworks.Carbon
darwin.apple_sdk.frameworks.WebKit
darwin.apple_sdk.frameworks.AppKit
]);
envVars = {
LIBCLANG_PATH = "${libclang.lib}/lib";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb}/include";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
OPENSSL_NO_VENDOR = "1";
} // lib.optionalAttrs stdenv.isLinux {
RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
};
bleep =
(rustPlatform.buildRustPackage.override { inherit stdenv; } rec {
meta = with pkgs.lib; {
description = "Search code. Fast.";
homepage = "https://bloop.ai";
license = licenses.asl20;
platforms = platforms.all;
};
name = "bleep";
pname = name;
src = pkgs.lib.sources.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hyperpolyglot-0.1.7" =
"sha256-JY75NB6sPxN0p/hksnBbat4S2EYFi2nExYoVHpYoib8=";
"tree-sitter-cpp-0.20.0" =
"sha256-h6mJdmQzJlxYIcY+d5IiaFghraUgBGZwqFPKwB3E4pQ=";
"tree-sitter-go-0.19.1" =
"sha256-f885YTswEDH/QfRPUxcLp/1E2zXLKl25R9IyTGKb1eM=";
"tree-sitter-java-0.20.0" =
"sha256-gQzoWGV9wYiLibMFkLoY2sdEJg+ae9NnHt/GFfFzP8U=";
"ort-1.14.8" =
"sha256-6YAhbrgI95WwRV0ngS0yaYlxfDGUFXYU0/oGf6vs68M=";
"comrak-0.18.0" =
"sha256-UWY00jF2aKAG3Oz0P1UWF/7TiTIrCUGHwfjW+O1ok7Q=";
"tree-sitter-php-0.19.1" =
"sha256-oHUfcuqtFFl+70/uJjE74J1JVV93G9++UaEIntOH5tM=";
"esaxx-rs-0.1.8" =
"sha256-rPNNSn829eOo/glgmHPqnoylZmDLlaI5vKMRtfTikGs=";
};
};
buildNoDefaultFeatures = true;
checkNoDefaultFeatures = true;
cargoTestFlags = "-p ${name}";
cargoBuildFlags = "-p ${name}";
nativeCheckInputs = buildDeps;
nativeBuildInputs = buildDeps;
checkInputs = runtimeDeps;
buildInputs = runtimeDeps;
}).overrideAttrs (old: envVars);
frontend = (pkgs.buildNpmPackage rec {
meta = with pkgs.lib; {
description = "Search code. Fast.";
homepage = "https://bloop.ai";
license = licenses.asl20;
platforms = platforms.all;
};
name = "bleep-frontend";
pname = name;
src = pkgs.lib.sources.cleanSource ./.;
# The prepack script runs the build script, which we'd rather do in the build phase.
npmPackFlags = [ "--ignore-scripts" ];
npmDepsHash = "sha256-YvmdThbqlmQ9MXL+a7eyXJ33sQNStQah9MUW2zhc/Uc=";
makeCacheWritable = true;
npmBuildScript = "build-web";
installPhase = ''
mkdir -p $out
cp -r client/dist $out/dist
'';
});
in
{
packages = {
default = bleep;
frontend = frontend;
bleep = bleep;
docker = pkgs.dockerTools.buildImage {
name = "bleep";
config = { Cmd = [ "${bleep}/bin/bleep" ]; };
extraCommands = ''
ln -s ${bleep}/bin/bleep /bleep
'';
};
};
devShells = {
default = (mkShell {
buildInputs = buildDeps ++ runtimeDeps ++ guiDeps ++ (with pkgs; [
git-lfs
rustfmt
clippy
rust-analyzer
cargo
rustc
cargo-watch
]);
src = pkgs.lib.sources.cleanSource ./.;
BLOOP_LOG = "bleep=debug";
}).overrideAttrs (old: envVars);
};
formatter = pkgs.nixfmt;
});
}