-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathflake.nix
More file actions
318 lines (292 loc) · 11 KB
/
flake.nix
File metadata and controls
318 lines (292 loc) · 11 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
{
description = "Warp is an agentic development environment, born out of the terminal (Experimental Nix Support, Linux-only).";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
crane,
rust-overlay,
...
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
packages = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
lib = pkgs.lib;
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
appCargoToml = builtins.fromTOML (builtins.readFile ./app/Cargo.toml);
version = "${appCargoToml.package.version}+${self.shortRev or "dirty"}";
src = self;
cargoLock = ./Cargo.lock;
# Match Zed's approach: derive the main app vendor directory from
# Cargo.lock instead of maintaining a top-level cargoVendorHash.
cargoVendorDir =
let
craneVendorDir = craneLib.vendorCargoDeps {
inherit src cargoLock;
overrideVendorGitCheckout =
crates: drv:
let
hasCrate = crateName: builtins.any (crate: crate.name == crateName) crates;
in
drv.overrideAttrs (old: {
postPatch = (old.postPatch or "") + ''
find . -name 'Cargo.toml.orig' -delete
${lib.optionalString (hasCrate "warp_multi_agent_api") ''
mkdir -p apis/multi_agent/v1/gen/rust/nix-vendored-protos
cp apis/multi_agent/v1/*.proto \
apis/multi_agent/v1/gen/rust/nix-vendored-protos/
substituteInPlace apis/multi_agent/v1/gen/rust/build.rs \
--replace-fail \
'let proto_path = manifest_dir.parent().unwrap().parent().unwrap();' \
'let proto_path = manifest_dir.join("nix-vendored-protos");'
''}
${lib.optionalString (hasCrate "warp-workflows") ''
mkdir -p workflows/nix-vendored-specs
cp -R specs/. workflows/nix-vendored-specs/
substituteInPlace workflows/build.rs \
--replace-fail \
'println!("cargo:rerun-if-changed=../specs");' \
'println!("cargo:rerun-if-changed=nix-vendored-specs");' \
--replace-fail \
'for entry in WalkDir::new("../specs") {' \
'for entry in WalkDir::new("nix-vendored-specs") {'
''}
'';
});
};
in
# crane writes a root config.toml; buildRustPackage expects the
# cargoDeps layout to include .cargo/config.toml and Cargo.lock.
pkgs.runCommand "warp-terminal-experimental-${version}-cargo-vendor" { } ''
cp -R ${craneVendorDir}/. "$out"
chmod u+w "$out"
mkdir -p "$out/.cargo"
sed 's|${craneVendorDir}|@vendor@|g' \
"$out/config.toml" > "$out/.cargo/config.toml"
rm "$out/config.toml"
cp ${cargoLock} "$out/Cargo.lock"
'';
linuxRuntimeLibraries = with pkgs; [
alsa-lib
curl
dbus
expat
fontconfig
freetype
libGL
libgit2
libxkbcommon
openssl
stdenv.cc.cc.lib
udev
vulkan-loader
wayland
libx11
libxscrnsaver
libxcursor
libxext
libxfixes
libxi
libxrandr
libxrender
libxcb
zlib
];
buildFeatures = [
"release_bundle"
"gui"
"nld_improvements"
];
warp-terminal-experimental = rustPlatform.buildRustPackage {
pname = "warp-terminal-experimental";
inherit version;
inherit src;
cargoDeps = cargoVendorDir;
nativeBuildInputs = with pkgs; [
brotli
cargo-about
clang
cmake
jq
makeWrapper
patchelf
pkg-config
protobuf
python3
];
buildInputs = linuxRuntimeLibraries;
cargoBuildFlags = [
"-p"
"warp"
"--bin"
"warp-oss"
"--bin"
"generate_settings_schema"
];
inherit buildFeatures;
# The application test suite is large and GUI/integration-heavy; this
# flake's package check is the Nix build plus a launch smoke test.
doCheck = false;
env = {
APPIMAGE_NAME = "WarpOss-${pkgs.stdenv.hostPlatform.parsed.cpu.name}.AppImage";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";
CARGO_PROFILE_RELEASE_DEBUG = "false";
};
postInstall =
let
installDir = "$out/opt/warpdotdev/warp-terminal-experimental";
resourcesDir = "${installDir}/resources";
releaseChannel = "stable";
libraryPath = lib.makeLibraryPath linuxRuntimeLibraries;
executablePath = lib.makeBinPath (with pkgs; [ xdg-utils ]);
in
''
install -Dm755 "$out/bin/warp-oss" "${installDir}/warp-oss"
rm -f "$out/bin/warp-oss"
patchShebangs \
./script/prepare_bundled_resources \
./script/copy_conditional_skills
SKIP_SETTINGS_SCHEMA=1 ./script/prepare_bundled_resources \
"${resourcesDir}" \
"${releaseChannel}" \
release
"$out/bin/generate_settings_schema" \
--channel "${releaseChannel}" \
"${resourcesDir}/settings_schema.json"
rm -f "$out/bin/generate_settings_schema"
install -Dm644 \
"${resourcesDir}/THIRD_PARTY_LICENSES.txt" \
"$out/share/licenses/warp-terminal-experimental/THIRD_PARTY_LICENSES.txt"
install -Dm644 LICENSE-AGPL "$out/share/licenses/warp-terminal-experimental/LICENSE-AGPL"
install -Dm644 LICENSE-MIT "$out/share/licenses/warp-terminal-experimental/LICENSE-MIT"
install -Dm644 app/channels/oss/dev.warp.WarpOss.desktop \
"$out/share/applications/dev.warp.WarpOss.desktop"
substituteInPlace "$out/share/applications/dev.warp.WarpOss.desktop" \
--replace-fail "Exec=warp-terminal-oss %U" "Exec=warp-terminal-experimental %U"
for size in 16x16 32x32 64x64 128x128 256x256 512x512; do
icon="app/channels/oss/icon/no-padding/$size.png"
if [ -f "$icon" ]; then
install -Dm644 "$icon" \
"$out/share/icons/hicolor/$size/apps/dev.warp.WarpOss.png"
fi
done
wrapProgram "${installDir}/warp-oss" \
--prefix LD_LIBRARY_PATH : "${libraryPath}" \
--prefix PATH : "${executablePath}"
mkdir -p "$out/bin"
ln -s "${installDir}/warp-oss" "$out/bin/warp-oss"
ln -s "${installDir}/warp-oss" "$out/bin/warp-terminal-experimental"
'';
postFixup = lib.optionalString pkgs.stdenv.isLinux ''
wrapped="/opt/warpdotdev/warp-terminal-experimental/.warp-oss-wrapped"
if [ -e "$out$wrapped" ] && ! patchelf --print-needed "$out$wrapped" | grep -q '^libfontconfig\.so\.1$'; then
patchelf --add-needed libfontconfig.so.1 "$out$wrapped"
fi
'';
meta = {
description = "Warp is an agentic development environment, born out of the terminal (Experimental Nix Support, Linux-only).";
homepage = "https://www.warp.dev";
license = lib.licenses.agpl3Only;
mainProgram = "warp-terminal-experimental";
platforms = systems;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
};
};
in
{
inherit warp-terminal-experimental;
}
);
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
lib = pkgs.lib;
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
nativeBuildInputs = with pkgs; [
brotli
cargo-about
cargo-nextest
clang
cmake
jq
lld
makeWrapper
patchelf
pkg-config
protobuf
python3
rustToolchain
rust-analyzer
];
buildInputs = with pkgs; [
alsa-lib
curl
dbus
expat
fontconfig
freetype
libGL
libgit2
libxkbcommon
openssl
stdenv.cc.cc.lib
udev
vulkan-loader
wayland
libx11
libxscrnsaver
libxcursor
libxext
libxfixes
libxi
libxrandr
libxrender
libxcb
zlib
];
in
{
default = pkgs.mkShell {
inherit nativeBuildInputs buildInputs;
APPIMAGE_NAME = "WarpOss-${pkgs.stdenv.hostPlatform.parsed.cpu.name}.AppImage";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
};
}
);
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt);
};
}