Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
153 lines (137 loc) · 4.23 KB
/
Copy pathflake.nix
File metadata and controls
153 lines (137 loc) · 4.23 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
{
description = "Standalone GPUI build";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
fenix,
crane,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
toolchain = fenix.packages.${system}.combine [
(fenix.packages.${system}.latest.withComponents [
"cargo"
"rustc"
"rust-src"
"rustfmt"
"clippy"
])
fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.rust-std
];
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
src = lib.cleanSourceWith {
src = craneLib.path ./.;
filter =
path: type:
(craneLib.filterCargoSources path type)
|| (lib.hasSuffix ".metal" path)
|| (lib.hasSuffix ".wgsl" path)
|| (lib.hasSuffix ".hlsl" path)
|| (lib.hasSuffix ".glsl" path);
};
linuxLibs = with pkgs; [
alsa-lib
libdrm
mesa # provides libgbm
libxkbcommon
libva
vulkan-loader
wayland
xorg.libX11
xorg.libxcb
];
commonArgs = {
pname = "gpui-ce";
version = "0.3.3";
inherit src;
strictDeps = true;
nativeBuildInputs = with pkgs; [
cmake
pkg-config
rustPlatform.bindgenHook
];
buildInputs =
with pkgs;
[
fontconfig
freetype
openssl
zlib
]
++ lib.optionals stdenv.isLinux linuxLibs
++ lib.optionals stdenv.isDarwin [
apple-sdk_15
(darwinMinVersionHook "11.0")
];
env = lib.optionalAttrs pkgs.stdenv.isLinux {
LD_LIBRARY_PATH = lib.makeLibraryPath linuxLibs;
};
cargoExtraArgs = "--features runtime_shaders";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
gpui = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
in
{
packages.default = gpui;
devShells.default = pkgs.mkShell {
# Provide rustup's cargo/rustc proxy (so `cargo +toolchain` works for
# the MSRV and WASM-atomics CI checks) plus all the native build deps.
packages = [
pkgs.rustup
pkgs.cargo-machete
pkgs.taplo
pkgs.typos
pkgs.just
pkgs.nushell
pkgs.cmake
pkgs.pkg-config
pkgs.rustPlatform.bindgenHook
pkgs.fontconfig
pkgs.freetype
pkgs.openssl
pkgs.zlib
] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.apple-sdk_15
(pkgs.darwinMinVersionHook "11.0")
] ++ lib.optionals pkgs.stdenv.isLinux linuxLibs;
shellHook = ''
export RUST_BACKTRACE=1
${lib.optionalString pkgs.stdenv.isDarwin ''
# Use the real Xcode SDK (not the nix apple-sdk stub) so that
# `xcrun` can find the system Metal toolchain used by gpui_macos
# to compile its .metal shaders.
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
# The nix `apple-sdk`/xcbuild package installs a stub `xcrun`
# that doesn't know about the system Metal toolchain. Prefer the
# real /usr/bin/xcrun.
mkdir -p /tmp/gpui-ce-bin
ln -sf /usr/bin/xcrun /tmp/gpui-ce-bin/xcrun
export PATH="/tmp/gpui-ce-bin:$PATH"
''}
${lib.optionalString pkgs.stdenv.isLinux ''
export LD_LIBRARY_PATH="${lib.makeLibraryPath linuxLibs}:$LD_LIBRARY_PATH"
''}
'';
};
}
);
}