Repository navigation
Expand file tree
/
Copy pathpackage.nix
More file actions
184 lines (162 loc) · 5.42 KB
/
Copy pathpackage.nix
File metadata and controls
184 lines (162 loc) · 5.42 KB
1
2
3
4
5
6
7
8
8000
div>
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
{
lib,
stdenv,
callPackage,
gobject-introspection,
blueprint-compiler,
libxml2,
gettext,
wrapGAppsHook4,
git,
ncurses,
pkg-config,
zig_0_17,
pandoc,
systemd,
revision ? "dirty",
optimize ? "debug",
enableX11 ? true,
enableWayland ? true,
wayland-protocols,
wayland-scanner,
pkgs,
}: let
gi_typelib_path = import ./build-support/gi-typelib-path.nix {
inherit pkgs lib stdenv;
};
buildInputs = import ./build-support/build-inputs.nix {
inherit pkgs lib stdenv enableX11 enableWayland;
};
strip = optimize != "debug" && optimize != "safe";
in
stdenv.mkDerivation (finalAttrs: {
pname = "ghostty";
version = "1.3.2-dev+${revision}-nix";
# We limit source like this to try and reduce the amount of rebuilds as possible
# thus we only provide the source that is needed for the build
#
# NOTE: as of the current moment only linux files are provided,
# since darwin support is not finished
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
lib.fileset.unions [
../dist/linux
../images
../include
../po
../pkg
../src
../vendor
../build.zig
../build.zig.zon
../build.zig.zon.nix
]
);
};
deps = callPackage ../build.zig.zon.nix {name = "ghostty-cache-${finalAttrs.version}";};
nativeBuildInputs =
[
git
ncurses
pandoc
pkg-config
zig_0_17
gobject-introspection
wrapGAppsHook4
blueprint-compiler
libxml2 # for xmllint
gettext
]
++ lib.optionals enableWayland [
wayland-scanner
wayland-protocols
];
buildInputs = buildInputs;
dontStrip = !strip;
GI_TYPELIB_PATH = gi_typelib_path;
dontSetZigDefaultFlags = true;
zigBuildFlags = [
"--system"
"${finalAttrs.deps}"
"-Dversion-string=${finalAttrs.version}"
"-Dgtk-x11=${lib.boolToString enableX11}"
"-Dgtk-wayland=${lib.boolToString enableWayland}"
"-Dcpu=baseline"
"-Doptimize=${optimize}"
"-Dstrip=${lib.boolToString strip}"
"-Dinstalled-exe-path=${placeholder "out"}/bin/ghostty"
];
outputs = [
"out"
"terminfo"
"shell_integration"
"vim"
];
postInstall = ''
terminfo_src=${
if stdenv.hostPlatform.isDarwin
then ''"$out/Applications/Ghostty.app/Contents/Resources/terminfo"''
else "$out/share/terminfo"
}
mkdir -p "$out/nix-support"
mkdir -p "$terminfo/share"
mv "$terminfo_src" "$terminfo/share/terminfo"
ln -sf "$terminfo/share/terminfo" "$terminfo_src"
echo "$terminfo" >> "$out/nix-support/propagated-user-env-packages"
mkdir -p "$shell_integration"
mv "$out/share/ghostty/shell-integration" "$shell_integration/shell-integration"
ln -sf "$shell_integration/shell-integration" "$out/share/ghostty/shell-integration"
echo "$shell_integration" >> "$out/nix-support/propagated-user-env-packages"
mv $out/share/vim/vimfiles "$vim"
ln -sf "$vim" "$out/share/vim/vimfiles"
echo "$vim" >> "$out/nix-support/propagated-user-env-packages"
echo "gst_all_1.gstreamer" >> "$out/nix-support/propagated-user-env-packages"
echo "gst_all_1.gst-plugins-base" >> "$out/nix-support/propagated-user-env-packages"
echo "gst_all_1.gst-plugins-good" >> "$out/nix-support/propagated-user-env-packages"
'';
# The systemd, D-Bus and desktop files launch Ghostty by the path given
# in -Dinstalled-exe-path. systemd only searches its own directory for a
# bare name on NixOS, so check that every one of them names an
# executable that exists.
doInstallCheck = stdenv.hostPlatform.isLinux;
nativeInstallCheckInputs = [systemd];
installCheckPhase = ''
runHook preInstallCheck
# The verifier starts a user manager, which needs somewhere to keep
# its runtime state; the sandbox gives it no /run. dbus.socket and
# graphical-session.target aren't in the sandbox either, so only the
# unit itself is checked, including its ExecStart.
export XDG_RUNTIME_DIR="$TMPDIR/run" HOME="$TMPDIR/home"
mkdir -p -m 0700 "$XDG_RUNTIME_DIR" "$HOME"
for unit in "$out"/share/systemd/user/*.service; do
# Its messages are colored and end in a carriage return, which
# `nix build -L` shows as a blank line, so strip both.
status=0
output=$(SYSTEMD_COLORS=0 systemd-analyze --user verify --man=no --recursive-errors=no "$unit" 2>&1) || status=$?
[[ -z "$output" ]] || echo "''${output//$'\r'/}" >&2
if ((status != 0)); then
exit "$status"
fi
done
for file in "$out"/share/dbus-1/services/*.service "$out"/share/applications/com.mitchellh.ghostty*.desktop; do
while IFS='=' read -r key value; do
exe=''${value%% *}
if [[ "$exe" != /* || ! -x "$exe" ]]; then
echo "$file: $key does not name an executable: $exe" >&2
exit 1
fi
done < <(grep -E '^(TryExec|Exec)=' "$file")
done
runHook postInstallCheck
'';
meta = {
homepage = "https://ghostty.org";
license = lib.licenses.mit;
platforms = [
"x86_64-linux"
"aarch64-linux"
];
mainProgram = "ghostty";
};
})