-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathvicinae.nix
More file actions
212 lines (196 loc) · 6.26 KB
/
Copy pathvicinae.nix
File metadata and controls
212 lines (196 loc) · 6.26 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
{
cmake,
cmark-gfm,
fetchNpmDeps,
kdePackages,
lib,
libqalculate,
libx11,
libxcb,
libxcb-keysyms,
libxkbcommon,
llvmPackages_21,
ninja,
nodejs,
npmHooks,
openssl,
pkg-config,
qt6,
stdenv,
gcc15Stdenv,
udev,
wayland,
wayland-protocols,
wayland-scanner,
glaze,
swift ? null,
apple-sdk ? null,
}: let
inherit (stdenv.hostPlatform) isLinux isDarwin;
effectiveStdenv =
if isLinux
then gcc15Stdenv
else llvmPackages_21.libcxxStdenv;
# syntax-highlighting (and its extra-cmake-modules dep) is tagged Linux-only in
# nixpkgs but builds fine on macOS; lift the platform tag so we can link the
# system library instead of vendoring it. No-op on Linux.
addDarwinPlatform = drv:
drv.overrideAttrs (old: {
meta = old.meta // {platforms = old.meta.platforms ++ lib.platforms.darwin;};
});
kdeScope = kdePackages.overrideScope (_: prev: {
extra-cmake-modules = addDarwinPlatform prev.extra-cmake-modules;
});
syntax-highlighting = addDarwinPlatform kdeScope.syntax-highlighting;
manifestRaw = builtins.readFile ../manifest.yaml;
manifestGet = key: let
m = builtins.match ".*${key}:[[:space:]]*\"([^\"]+)\".*" manifestRaw;
in
if m == null
then throw "Key ${key} not found in manifest.yaml"
else builtins.elemAt m 0;
in
effectiveStdenv.mkDerivation (finalAttrs: {
pname = "vicinae";
version = lib.removePrefix "v" (manifestGet "tag");
src = ../.;
apiDeps = fetchNpmDeps {
src = "${finalAttrs.src}/src/typescript/api";
hash = "sha256-4FEaBDJK9abcgz+vptuL4wQ8zhp+wpLbbR4Y79BVhEg=";
};
extensionManagerDeps = fetchNpmDeps {
src = "${finalAttrs.src}/src/typescript/extension-manager";
hash = "sha256-pEgqFgvdz7Bcc+LznCI+KlD1XEfUuWFWjS24MJ7sx3k=";
};
cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
"VICINAE_GIT_TAG" = "v${finalAttrs.version}";
"VICINAE_GIT_COMMIT_HASH" = manifestGet "short_rev";
"VICINAE_PROVENANCE" = "nix";
"INSTALL_MODULES_LOAD_CONFIG" = "OFF";
"INSTALL_NODE_MODULES" = "OFF";
"USE_SYSTEM_CMARK_GFM" = "ON";
"USE_SYSTEM_GLAZE" = "ON";
"USE_SYSTEM_KF6" = "ON";
"USE_SYSTEM_QT_KEYCHAIN" = "ON";
"CMAKE_INSTALL_PREFIX" = placeholder "out";
"CMAKE_INSTALL_DATAROOTDIR" = "share";
"CMAKE_INSTALL_BINDIR" = "bin";
"CMAKE_INSTALL_LIBDIR" = "lib";
"AUTO_INSTALL_BROWSER_MANIFESTS" = "OFF";
"AUTO_ENABLE_AUTOSTART" = "OFF";
"ENABLE_ONBOARDING" = "OFF";
"BUNDLE_SOULVER_CORE" = "OFF";
};
strictDeps = true;
nativeBuildInputs =
[
cmake
ninja
nodejs
pkg-config
qt6.qttools
qt6.wrapQtAppsHook
]
++ lib.optionals isLinux [
wayland-scanner
]
++ lib.optionals isDarwin [
swift
];
buildInputs =
[
cmark-gfm
kdePackages.qtkeychain
kdePackages.qtshadertools
syntax-highlighting
libqalculate
nodejs
qt6.qtbase
qt6.qtdeclarative
qt6.qtimageformats
qt6.qtsvg
glaze
]
++ lib.optionals isLinux [
kdePackages.layer-shell-qt
libx11
libxcb
libxcb-keysyms
libxkbcommon
openssl
qt6.qtwayland
udev
wayland
wayland-protocols
]
++ lib.optionals isDarwin [
apple-sdk
];
postPatch = ''
local postPatchHooks=()
source ${npmHooks.npmConfigHook}/nix-support/setup-hook
npmRoot=src/typescript/api npmDeps=${finalAttrs.apiDeps} npmConfigHook
npmRoot=src/typescript/extension-manager npmDeps=${finalAttrs.extensionManagerDeps} npmConfigHook
'';
# On macOS CMake installs only the CLI; assemble a thin .app bundle for the
# GUI server. Both binaries go in the bundle so the CLI resolves the server
# as a sibling (findServerBinary); $out/bin/vicinae is re-added in postFixup.
postInstall =
lib.optionalString isDarwin ''
app=$out/Applications/Vicinae.app
install -Dm755 bin/vicinae-server "$app/Contents/MacOS/Vicinae"
install -Dm755 bin/vicinae "$app/Contents/MacOS/vicinae-cli"
install -Dm644 Info.plist "$app/Contents/Info.plist"
install -Dm644 ../extra/vicinae.icns "$app/Contents/Resources/vicinae.icns"
cp -r ../extra/themes "$app/Contents/Resources/themes"
rm -f "$out/bin/vicinae"
''
# Generate native host manifests for Firefox and Chromium, so the browser
# extension can communicate with the browser link
+ ''
install -d "$out/lib/mozilla/native-messaging-hosts"
cat > "$out/lib/mozilla/native-messaging-hosts/com.vicinae.vicinae.json" <<EOF
{
"name": "com.vicinae.vicinae",
"description": "Vicinae Native Messaging Host",
"path": "$out/libexec/vicinae/vicinae-browser-link",
"type": "stdio",
"allowed_extensions": ["firefox@vicinae.com"]
}
EOF
install -d "$out/etc/chromium/native-messaging-hosts"
cat > "$out/etc/chromium/native-messaging-hosts/com.vicinae.vicinae.json" <<EOF
{
"name": "com.vicinae.vicinae",
"description": "Vicinae Native Messaging Host",
"path": "$out/libexec/vicinae/vicinae-browser-link",
"type": "stdio",
"allowed_origins": ["chrome-extension://kcmipingpfbohfjckomimmahknoddnke/"]
}
EOF
'';
# Symlink the CLI onto PATH after wrapQtAppsHook runs, so the hook doesn't
# double-wrap it and the CLI still resolves from inside the bundle.
postFixup = lib.optionalString isDarwin ''
ln -s ../Applications/Vicinae.app/Contents/MacOS/vicinae-cli "$out/bin/vicinae"
'';
qtWrapperArgs =
[
"--prefix PATH : ${
lib.makeBinPath [
nodejs
(placeholder "out")
]
}"
]
++ lib.optionals isLinux [
"--set VICINAE_INPUT_SERVER_BIN /run/wrappers/bin/vicinae-input-server"
];
meta = {
description = "A focused launcher for your desktop — native, fast, extensible";
homepage = "https://github.com/vicinaehq/vicinae";
license = lib.licenses.gpl3Plus;
platforms = with lib.platforms; linux ++ darwin;
mainProgram = "vicinae";
};
})