-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdefault.nix
More file actions
162 lines (147 loc) · 3.8 KB
/
Copy pathdefault.nix
File metadata and controls
162 lines (147 loc) · 3.8 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
{
lib,
rustPlatform,
pkg-config,
wrapGAppsHook3,
nodejs,
npmHooks,
fetchNpmDeps,
copyDesktopItems,
makeDesktopItem,
atk,
cairo,
gdk-pixbuf,
git,
glib,
gtk3,
libgit2,
libsoup_3,
oniguruma,
openssl,
pango,
webkitgtk_4_1,
zlib,
# `desktop` and `web` are mutually exclusive cargo features (see
# diffcore-tauri/src/lib.rs), so diffcore-web needs its own derivation.
webMode ? false,
}:
rustPlatform.buildRustPackage {
pname = if webMode then "diffcore-web" else "diff-core";
version = (lib.importTOML ./Cargo.toml).workspace.package.version;
__structuredAttrs = true;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
npmDeps = fetchNpmDeps {
src = ./crates/diffcore-tauri/ui;
hash = "sha256-AQFay57TfO62s0m1UhFZFlNu5/l/k0zBwmnhhl7+5sw=";
};
npmRoot = "crates/diffcore-tauri/ui";
nativeBuildInputs = [
pkg-config
nodejs
npmHooks.npmConfigHook
]
++ lib.optionals (!webMode) [
wrapGAppsHook3
copyDesktopItems
];
# The web server is a plain axum binary; only the desktop app needs the
# gtk/webkit stack.
buildInputs = [
libgit2
oniguruma
openssl
zlib
]
++ lib.optionals (!webMode) [
atk
cairo
gdk-pixbuf
glib
gtk3
libsoup_3
pango
webkitgtk_4_1
];
env = {
OPENSSL_NO_VENDOR = true;
RUSTONIG_SYSTEM_LIBONIG = true;
};
preBuild = ''
npm --prefix crates/diffcore-tauri/ui run build
'';
# Desktop app + CLI (production webview assets), or the standalone web
# server. `--no-default-features` is scoped to diffcore-tauri via `-p` so it
# does not strip defaults from the rest of the workspace.
cargoBuildFlags =
if webMode then
[
"-p"
"diffcore-tauri"
"--no-default-features"
"--features"
"web"
]
else
[
"--features"
"diffcore-tauri/custom-protocol"
];
# Default cargoTestFlags would test the whole workspace with default
# features, pulling `desktop` back in without gtk/webkit present.
cargoTestFlags = lib.optionals webMode [
"-p"
"diffcore-tauri"
"--no-default-features"
"--features"
"web"
];
desktopItems = lib.optionals (!webMode) [
(makeDesktopItem {
name = "diffcore-tauri";
exec = "diffcore-tauri";
icon = "diffcore-tauri";
desktopName = "Diffcore";
genericName = "Semantic Diff Viewer";
comment = "Semantic diff layer for code review";
categories = [
"Development"
"RevisionControl"
];
startupWMClass = "diffcore-tauri";
})
];
# Both binaries resolve the UI from ../share/diffcore/ui relative to $out/bin.
postInstall = ''
mkdir -p $out/share/diffcore
cp -r crates/diffcore-tauri/ui/dist $out/share/diffcore/ui
''
+ lib.optionalString (!webMode) ''
for size in 32 64 128; do
install -Dm444 crates/diffcore-tauri/icons/''${size}x''${size}.png \
$out/share/icons/hicolor/''${size}x''${size}/apps/diffcore-tauri.png
done
install -Dm444 crates/diffcore-tauri/icons/128x128@2x.png \
$out/share/icons/hicolor/256x256/apps/diffcore-tauri.png
install -Dm444 crates/diffcore-tauri/icons/icon.png \
$out/share/icons/hicolor/512x512/apps/diffcore-tauri.png
'';
nativeCheckInputs = [ git ];
preCheck = ''
export HOME=$(mktemp -d)
export GIT_AUTHOR_NAME=nixbld
export GIT_AUTHOR_EMAIL=nixbld@localhost
export GIT_COMMITTER_NAME=nixbld
export GIT_COMMITTER_EMAIL=nixbld@localhost
'';
meta = {
description =
if webMode then
"Semantic diff layer for code review (web server)"
else
"Semantic diff layer for code review";
homepage = "https://github.com/jamesaphoenix/diff-core";
license = lib.licenses.mit;
mainProgram = if webMode then "diffcore-web" else "diffcore";
};
}