-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
226 lines (210 loc) · 6.53 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{
description = "Zellij Nix Environment";
inputs = {
multitask.url = "github:imsnif/multitask";
multitask.flake = false;
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-utils.url = "github:numtide/flake-utils";
zellij.url = "github:zellij-org/zellij";
zellij.flake = false;
};
outputs =
{
self,
nixpkgs,
zellij,
multitask,
rust-overlay,
flake-utils,
...
}:
let
src = zellij;
cargoTOML = builtins.fromTOML (builtins.readFile (src + "/Cargo.toml"));
inherit (cargoTOML.package) version name;
cargoLock = {
lockFile = builtins.path {
path = src + "/Cargo.lock";
name = "Cargo.lock";
};
allowBuiltinFetchGit = true;
};
make-zellij =
{
makeRustPlatform,
lib,
stdenv,
pkg-config,
protobuf,
openssl,
perl,
rust-bin,
darwin,
patchPlugins ? true,
}:
let
rustToolchainTOML = rust-bin.fromRustupToolchainFile (src + /rust-toolchain.toml);
rustc = rustToolchainTOML;
cargo = rustToolchainTOML;
in
(makeRustPlatform { inherit cargo rustc; }).buildRustPackage {
inherit
cargoLock
name
src
stdenv
version
;
nativeBuildInputs = [
pkg-config
protobuf
perl
];
buildInputs =
[
openssl
protobuf
]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
DiskArbitration
Foundation
]
);
patchPhase =
if patchPlugins then
''
cp ${
self.outputs.plugins.${stdenv.system}.configuration
}/bin/configuration.wasm zellij-utils/assets/plugins/configuration.wasm
cp ${
self.outputs.plugins.${stdenv.system}.tab-bar
}/bin/tab-bar.wasm zellij-utils/assets/plugins/tab-bar.wasm
cp ${
self.outputs.plugins.${stdenv.system}.status-bar
}/bin/status-bar.wasm zellij-utils/assets/plugins/status-bar.wasm
cp ${
self.outputs.plugins.${stdenv.system}.strider
}/bin/strider.wasm zellij-utils/assets/plugins/strider.wasm
cp ${
self.outputs.plugins.${stdenv.system}.compact-bar
}/bin/compact-bar.wasm zellij-utils/assets/plugins/compact-bar.wasm
cp ${
self.outputs.plugins.${stdenv.system}.session-manager
}/bin/session-manager.wasm zellij-utils/assets/plugins/session-manager.wasm
''
else
":";
meta = {
description = "A terminal workspace with batteries included";
homepage = "https://zellij.dev/";
license = [ lib.licenses.mit ];
mainProgram = "zellij";
};
};
in
# flake outputs
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchainTOML = pkgs.rust-bin.fromRustupToolchainFile (src + /rust-toolchain.toml);
rustWasmToolchainTOML = rustToolchainTOML.override {
extensions = [ ];
targets = [ "wasm32-wasi" ];
};
devInputs = [
rustToolchainTOML
pkgs.binaryen
pkgs.mkdocs
pkgs.just
pkgs.protobuf
];
fmtInputs = [
pkgs.nixfmt-rfc-style
pkgs.treefmt
];
defaultPlugins = pkgs.callPackage ./default-plugins.nix {
inherit cargoLock src;
rustc = rustWasmToolchainTOML;
cargo = rustWasmToolchainTOML;
};
externalPlugins = pkgs.callPackage ./external-plugins.nix rec {
src = multitask;
cargoLock = {
lockFile = builtins.path {
path = src + "/Cargo.lock";
name = "Cargo.lock";
};
allowBuiltinFetchGit = true;
};
rustc = rustWasmToolchainTOML;
cargo = rustWasmToolchainTOML;
};
in
rec {
packages = rec {
# The default build compiles the plugins from src
default = zellij;
zellij = pkgs.callPackage make-zellij { };
# The upstream build relies on precompiled binary plugins that are included in the upstream src
zellij-upstream = pkgs.callPackage make-zellij { patchPlugins = false; };
};
plugins = {
inherit (defaultPlugins)
compact-bar
configuration
session-manager
status-bar
strider
tab-bar
;
inherit (externalPlugins) multitask;
};
apps = {
default = flake-utils.lib.mkApp { drv = packages.default; };
zellij-upstream = flake-utils.lib.mkApp { drv = packages.zellij-upstream; };
};
devShells = {
default = pkgs.mkShell {
inherit name;
nativeBuildInputs = devInputs;
RUST_BACKTRACE = 1;
};
fmtShell = pkgs.mkShell { buildInputs = fmtInputs; };
actionlintShell = pkgs.mkShell { buildInputs = [ pkgs.actionlint ]; };
};
checks = {
inherit (self.outputs.packages.${system}) default zellij-upstream;
inherit (self.outputs.plugins.${system})
compact-bar
configuration
session-manager
status-bar
strider
tab-bar
multitask
;
};
formatter = pkgs.nixfmt-rfc-style;
}
)
// {
overlays = {
default = final: _: {
zellij = final.callPackage make-zellij { };
zellij-upstream = final.callPackage make-zellij { patchPlugins = false; };
};
nightly = final: _: {
zellij-nightly = final.callPackage make-zellij { };
zellij-upstream-nightly = final.callPackage make-zellij { patchPlugins = false; };
};
};
};
}