blob: b01ec11b70429ee17d1db73651dd55c2fe5cf412 (
plain)
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
|
{
self,
nixpkgs,
rust-overlay,
flake-utils,
flake-compat,
crate2nix,
}:
flake-utils.lib.eachSystem [
"aarch64-linux"
"aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
]
(system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};
pkgsMusl = import nixpkgs {
inherit system overlays;
crossSystem = {config = "x86_64-unknown-linux-musl";};
};
crate2nixPkgs = import nixpkgs {
inherit system;
overlays = [
(self: _: {
rustc = rustToolchainToml;
cargo = rustToolchainToml;
})
];
};
name = "zellij";
pname = name;
root = self;
ignoreSource = [".git" "target" "example"];
src = pkgs.nix-gitignore.gitignoreSource ignoreSource root;
rustToolchainToml = pkgs.rust-bin.fromRustupToolchainFile ../rust-toolchain;
cargoLock = {
lockFile = builtins.path {
path = ../Cargo.lock;
name = "Cargo.lock";
};
};
cargo = rustToolchainToml;
rustc = rustToolchainToml;
buildInputs = [
# in order to run tests
pkgs.openssl
];
nativeBuildInputs = [
rustToolchainToml
# for openssl/openssl-sys
pkgs.pkg-config
# generates manpages
pkgs.mandown
pkgs.installShellFiles
pkgs.copyDesktopItems
];
devInputs = [
pkgs.cargo-make
pkgs.rust-analyzer
# optimizes wasm binaries
pkgs.binaryen
# used for snapshotting the e2e tests
pkgs.cargo-insta
];
fmtInputs = [
pkgs.alejandra
pkgs.treefmt
];
postInstall = ''
mandown ./docs/MANPAGE.md > ./zellij.1
installManPage ./zellij.1
# explicit behavior
$out/bin/zellij setup --generate-completion bash > ./completions.bash
installShellCompletion --bash --name ${pname}.bash ./completions.bash
$out/bin/zellij setup --generate-completion fish > ./completions.fish
installShellCompletion --fish --name ${pname}.fish ./completions.fish
$out/bin/zellij setup --generate-completion zsh > ./completions.zsh
installShellCompletion --zsh --name _${pname} ./completions.zsh
install -Dm644 ./assets/logo.png $out/share/icons/hicolor/scalable/apps/zellij.png
copyDesktopItems
'';
desktopItems = [
(pkgs.makeDesktopItem {
type = "Application";
inherit name;
desktopName = "zellij";
terminal = true;
genericName = "Terminal multiplexer";
comment = "Manage your terminal applications";
exec = "zellij";
icon = "zellij";
categories = ["ConsoleOnly"];
})
];
meta = with pkgs.lib; {
homepage = "https://github.com/zellij-org/zellij/";
description = "A terminal workspace with batteries included";
license = [licenses.mit];
};
in rec {
# crate2nix - better incremental builds, but uses ifd
packages.zellij = crate2nixPkgs.callPackage ./crate2nix.nix {
inherit
name
src
nativeBuildInputs
crate2nix
desktopItems
postInstall
meta
;
};
# native nixpkgs support - keep supported
packages.zellij-native = (pkgs.makeRustPlatform {inherit cargo rustc;}).buildRustPackage {
inherit
src
name
cargoLock
buildInputs
nativeBuildInputs
postInstall
desktopItems
meta
;
};
# musl cross-compilation - static binary
packages.zellij-musl = (pkgsMusl.makeRustPlatform {inherit rustc cargo;}).buildRustPackage {
inherit
src
name
cargoLock
postInstall
buildInputs
nativeBuildInputs
desktopItems
meta
;
};
defaultPackage = packages.zellij;
# nix run
apps.zellij = flake-utils.lib.mkApp {drv = packages.zellij;};
defaultApp = apps.zellij;
devShells = {
zellij = pkgs.callPackage ./devShell.nix {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ devInputs ++ fmtInputs;
};
fmtShell = pkgs.mkShell {
name = "fmt-shell";
nativeBuildInputs = fmtInputs;
};
e2eShell = pkgs.pkgsMusl.mkShell {
name = "e2e-shell";
nativeBuildInputs = [
pkgs.cargo-make
pkgs.pkgsMusl.cargo
];
};
};
devShell = devShells.zellij;
})
// rec {
overlays = {
default = final: prev: rec {
zellij = self.packages.${prev.system}.zellij;
};
nightly = final: prev: rec {
zellij-nightly = self.packages.${prev.system}.zellij;
};
};
}
|