2023-04-29 13:46:11 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchYarnDeps
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2024-04-17 19:34:05 +02:00
|
|
|
, fixup-yarn-lock
|
2023-04-29 13:46:11 +02:00
|
|
|
, makeWrapper
|
2024-03-19 03:44:27 +01:00
|
|
|
, autoSignDarwinBinariesHook
|
2023-04-29 13:46:11 +02:00
|
|
|
, nodejs
|
|
|
|
, yarn
|
|
|
|
, electron
|
2019-07-02 08:38:54 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "drawio";
|
2024-04-17 20:04:29 +02:00
|
|
|
version = "24.2.5";
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jgraph";
|
|
|
|
repo = "drawio-desktop";
|
|
|
|
rev = "v${version}";
|
|
|
|
fetchSubmodules = true;
|
2024-04-17 20:04:29 +02:00
|
|
|
hash = "sha256-8Cs+uME6uXWIWeuS9cgKnlYJG/m13l2BIVNDG0bqEmc=";
|
2023-04-29 13:46:11 +02:00
|
|
|
};
|
|
|
|
|
2024-03-19 03:44:27 +01:00
|
|
|
# `@electron/fuses` tries to run `codesign` and fails. Disable and use autoSignDarwinBinariesHook instead
|
|
|
|
postPatch = ''
|
|
|
|
sed -i -e 's/resetAdHocDarwinSignature:.*/resetAdHocDarwinSignature: false,/' build/fuses.js
|
|
|
|
'';
|
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2024-04-17 20:04:29 +02:00
|
|
|
hash = "sha256-tQFcdZc+4N6TYY6MDAwUgpaIvqYkU681DbuYCQhvJ1c=";
|
2019-07-02 08:38:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-04-17 19:34:05 +02:00
|
|
|
fixup-yarn-lock
|
2023-04-29 13:46:11 +02:00
|
|
|
makeWrapper
|
|
|
|
nodejs
|
|
|
|
yarn
|
2023-10-19 16:25:31 +02:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
|
|
copyDesktopItems
|
2024-03-19 03:44:27 +01:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
autoSignDarwinBinariesHook
|
2023-10-19 16:25:31 +02:00
|
|
|
];
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD = true;
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
export HOME="$TMPDIR"
|
|
|
|
yarn config --offline set yarn-offline-mirror "$offlineCache"
|
2023-11-22 23:28:51 +01:00
|
|
|
fixup-yarn-lock yarn.lock
|
2023-04-29 13:46:11 +02:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
patchShebangs node_modules/
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
runHook postConfigure
|
|
|
|
'';
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-10-19 16:25:31 +02:00
|
|
|
'' + 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
|
|
|
|
'' + ''
|
2023-04-29 13:46:11 +02:00
|
|
|
yarn --offline run electron-builder --dir \
|
2024-02-18 12:35:36 +01:00
|
|
|
${if stdenv.isDarwin then "--config electron-builder-linux-mac.json" else ""} \
|
2023-10-19 16:25:31 +02:00
|
|
|
-c.electronDist=${if stdenv.isDarwin then "." else "${electron}/libexec/electron"} \
|
2023-04-29 13:46:11 +02:00
|
|
|
-c.electronVersion=${electron.version}
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-10-19 16:25:31 +02:00
|
|
|
'' + 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) ''
|
2023-04-29 13:46:11 +02:00
|
|
|
mkdir -p "$out/share/lib/drawio"
|
|
|
|
cp -r dist/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/drawio"
|
2019-07-02 08:38:54 +02:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
install -Dm644 build/icon.svg "$out/share/icons/hicolor/scalable/apps/drawio.svg"
|
2022-01-22 17:58:41 +01:00
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
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
|
2023-10-19 16:25:31 +02:00
|
|
|
'' + ''
|
2023-04-29 13:46:11 +02:00
|
|
|
|
|
|
|
runHook postInstall
|
2022-01-22 17:58:41 +01:00
|
|
|
'';
|
|
|
|
|
2023-04-29 13:46:11 +02:00
|
|
|
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" ];
|
2023-10-08 19:54:27 +02:00
|
|
|
startupWMClass = "draw.io";
|
2023-04-29 13:46:11 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-07-02 08:38:54 +02:00
|
|
|
description = "A desktop application for creating diagrams";
|
2020-03-29 04:18:40 +02:00
|
|
|
homepage = "https://about.draw.io/";
|
2019-07-02 08:38:54 +02:00
|
|
|
license = licenses.asl20;
|
2020-07-25 08:25:19 +02:00
|
|
|
changelog = "https://github.com/jgraph/drawio-desktop/releases/tag/v${version}";
|
2023-04-29 13:46:11 +02:00
|
|
|
maintainers = with maintainers; [ qyliss darkonion0 ];
|
|
|
|
platforms = platforms.darwin ++ platforms.linux;
|
2024-02-11 03:19:15 +01:00
|
|
|
mainProgram = "drawio";
|
2019-07-02 08:38:54 +02:00
|
|
|
};
|
|
|
|
}
|