2023-05-24 13:37:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchYarnDeps
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2024-01-02 11:29:13 +00:00
|
|
|
, prefetch-yarn-deps
|
2023-05-24 13:37:59 +00:00
|
|
|
, makeWrapper
|
|
|
|
, nodejs
|
|
|
|
, yarn
|
|
|
|
, electron
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "drawio";
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "22.1.18";
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jgraph";
|
|
|
|
repo = "drawio-desktop";
|
|
|
|
rev = "v${version}";
|
|
|
|
fetchSubmodules = true;
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-qOZm7XbF8QOx5rD5EJY0lJhaq2Yhp/nppOA4BIWheyE=";
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-TwI3NCIn5NnKXuwW5dBl4q6Ma5rZR7NVNb5hoKbmNLM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
prefetch-yarn-deps
|
2023-05-24 13:37:59 +00:00
|
|
|
makeWrapper
|
|
|
|
nodejs
|
|
|
|
yarn
|
2023-11-16 04:20:00 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
|
|
copyDesktopItems
|
|
|
|
];
|
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 \
|
|
|
|
--config electron-builder-linux-mac.json \
|
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; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A desktop application for creating diagrams";
|
|
|
|
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;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|