2023-05-24 13:37:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchYarnDeps
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2024-04-21 15:54:59 +00:00
|
|
|
, fixup-yarn-lock
|
2023-05-24 13:37:59 +00:00
|
|
|
, makeWrapper
|
2024-04-21 15:54:59 +00:00
|
|
|
, autoSignDarwinBinariesHook
|
2023-05-24 13:37:59 +00:00
|
|
|
, nodejs
|
|
|
|
, yarn
|
|
|
|
, electron
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "drawio";
|
2024-06-24 18:47:55 +00:00
|
|
|
version = "24.6.1";
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jgraph";
|
|
|
|
repo = "drawio-desktop";
|
|
|
|
rev = "v${version}";
|
|
|
|
fetchSubmodules = true;
|
2024-06-24 18:47:55 +00:00
|
|
|
hash = "sha256-trBSNE5OBBNq18Dn/IwhHpD3ZQ7C5venwsBtyZxv+2k=";
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# `@electron/fuses` tries to run `codesign` and fails. Disable and use autoSignDarwinBinariesHook instead
|
|
|
|
postPatch = ''
|
2024-06-05 15:53:02 +00:00
|
|
|
sed -i -e 's/resetAdHocDarwinSignature:.*/resetAdHocDarwinSignature: false,/' build/fuses.cjs
|
2024-04-21 15:54:59 +00:00
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2024-06-24 18:47:55 +00:00
|
|
|
hash = "sha256-9Hq08DXEiOK0P+x89Gl3Y2+dN5r7aS7GNrCSVDGMpFs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-04-21 15:54:59 +00:00
|
|
|
fixup-yarn-lock
|
2023-05-24 13:37:59 +00:00
|
|
|
makeWrapper
|
|
|
|
nodejs
|
|
|
|
yarn
|
2023-11-16 04:20:00 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
|
|
copyDesktopItems
|
2024-04-21 15:54:59 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
autoSignDarwinBinariesHook
|
2023-11-16 04:20:00 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
export HOME="$TMPDIR"
|
|
|
|
yarn config --offline set yarn-offline-mirror "$offlineCache"
|
2024-01-02 11:29:13 +00:00
|
|
|
fixup-yarn-lock yarn.lock
|
2023-05-24 13:37:59 +00:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
patchShebangs node_modules/
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
runHook postConfigure
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00: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-05-24 13:37:59 +00:00
|
|
|
yarn --offline run electron-builder --dir \
|
2024-02-29 20:09:43 +00:00
|
|
|
${if stdenv.isDarwin then "--config electron-builder-linux-mac.json" else ""} \
|
2023-11-16 04:20:00 +00:00
|
|
|
-c.electronDist=${if stdenv.isDarwin then "." else "${electron}/libexec/electron"} \
|
2023-05-24 13:37:59 +00:00
|
|
|
-c.electronVersion=${electron.version}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00: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-05-24 13:37:59 +00:00
|
|
|
mkdir -p "$out/share/lib/drawio"
|
|
|
|
cp -r dist/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/drawio"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
install -Dm644 build/icon.svg "$out/share/icons/hicolor/scalable/apps/drawio.svg"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00: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-11-16 04:20:00 +00:00
|
|
|
'' + ''
|
2022-01-23 02:10:13 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
runHook postInstall
|
2022-01-23 02:10:13 +00:00
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00: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-09 19:29:22 +00:00
|
|
|
startupWMClass = "draw.io";
|
2023-05-24 13:37:59 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Desktop application for creating diagrams";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://about.draw.io/";
|
|
|
|
license = licenses.asl20;
|
2020-08-20 17:08:02 +00:00
|
|
|
changelog = "https://github.com/jgraph/drawio-desktop/releases/tag/v${version}";
|
2023-05-24 13:37:59 +00:00
|
|
|
maintainers = with maintainers; [ qyliss darkonion0 ];
|
|
|
|
platforms = platforms.darwin ++ platforms.linux;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "drawio";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|