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
|
{ lib
, stdenv
, fetchFromGitHub
, fetchYarnDeps
, makeDesktopItem
, copyDesktopItems
, fixup-yarn-lock
, makeWrapper
, autoSignDarwinBinariesHook
, nodejs
, yarn
, electron
}:
stdenv.mkDerivation rec {
pname = "drawio";
version = "24.1.0";
src = fetchFromGitHub {
owner = "jgraph";
repo = "drawio-desktop";
rev = "v${version}";
fetchSubmodules = true;
hash = "sha256-vwytqlPv8LfOceuBs/MNPxzO1ZYv1hwjIRyBh/wuVEU=";
};
# `@electron/fuses` tries to run `codesign` and fails. Disable and use autoSignDarwinBinariesHook instead
postPatch = ''
sed -i -e 's/resetAdHocDarwinSignature:.*/resetAdHocDarwinSignature: false,/' build/fuses.js
'';
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-mRnGsfxrdfzk6+z07174zZ7pcS68Zut6inuBPZkLtWQ=";
};
nativeBuildInputs = [
fixup-yarn-lock
makeWrapper
nodejs
yarn
] ++ lib.optionals (!stdenv.isDarwin) [
copyDesktopItems
] ++ lib.optionals stdenv.isDarwin [
autoSignDarwinBinariesHook
];
ELECTRON_SKIP_BINARY_DOWNLOAD = true;
configurePhase = ''
runHook preConfigure
export HOME="$TMPDIR"
yarn config --offline set yarn-offline-mirror "$offlineCache"
fixup-yarn-lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
'' + lib.optionalString stdenv.isDarwin ''
cp -R ${electron}/Applications/Electron.app Electron.app
chmod -R u+w Electron.app
export CSC_IDENTITY_AUTO_DISCOVERY=false
sed -i "/afterSign/d" electron-builder-linux-mac.json
'' + ''
yarn --offline run electron-builder --dir \
${if stdenv.isDarwin then "--config electron-builder-linux-mac.json" else ""} \
-c.electronDist=${if stdenv.isDarwin then "." else "${electron}/libexec/electron"} \
-c.electronVersion=${electron.version}
runHook postBuild
'';
installPhase = ''
runHook preInstall
'' + lib.optionalString stdenv.isDarwin ''
mkdir -p $out/{Applications,bin}
mv dist/mac*/draw.io.app $out/Applications
# Symlinking `draw.io` doesn't work; seems to look for files in the wrong place.
makeWrapper $out/Applications/draw.io.app/Contents/MacOS/draw.io $out/bin/drawio
'' + lib.optionalString (!stdenv.isDarwin) ''
mkdir -p "$out/share/lib/drawio"
cp -r dist/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/drawio"
install -Dm644 build/icon.svg "$out/share/icons/hicolor/scalable/apps/drawio.svg"
makeWrapper '${electron}/bin/electron' "$out/bin/drawio" \
--add-flags "$out/share/lib/drawio/resources/app.asar" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--inherit-argv0
'' + ''
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = "drawio";
exec = "drawio %U";
icon = "drawio";
desktopName = "drawio";
comment = "draw.io desktop";
mimeTypes = [ "application/vnd.jgraph.mxfile" "application/vnd.visio" ];
categories = [ "Graphics" ];
startupWMClass = "draw.io";
})
];
meta = with lib; {
description = "A desktop application for creating diagrams";
homepage = "https://about.draw.io/";
license = licenses.asl20;
changelog = "https://github.com/jgraph/drawio-desktop/releases/tag/v${version}";
maintainers = with maintainers; [ qyliss darkonion0 ];
platforms = platforms.darwin ++ platforms.linux;
mainProgram = "drawio";
};
}
|