24 stdenv.mkDerivation (finalAttrs: {
26 version = "0.17.1-unstable-2024-06-10";
28 src = fetchFromGitHub {
31 rev = "cd8452979bf2441f8064968ab1f9ae28302c9d75";
32 hash = "sha256-6oD9Bp0XonhNHWA8JajyWdNkAXpX4GoKPpdLzpvr+jM=";
35 patch -p1 < ${./0001-update-electron.patch}
36 ''; # Need for offlineCache
39 offlineCache = fetchYarnDeps {
40 yarnLock = "${finalAttrs.src}/yarn.lock";
41 hash = "sha256-mr79FV/LHkoY3vX9B5yv95IQIJQ9akwfslKndKYmwCo=";
50 (python3.withPackages (ps: with ps; [ packaging ]))
53 nodePackages.node-gyp-build
55 ++ lib.optionals stdenv.hostPlatform.isDarwin [
69 substituteInPlace src/common/filesystem/paths.js \
70 --replace-fail "process.resourcesPath" "'$out/opt/marktext/resources'"
72 substituteInPlace src/main/cli/index.js \
73 --replace-fail "process.argv.slice(1)" "process.argv.slice(2)"
79 export HOME=$(mktemp -d)
80 yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
81 fixup-yarn-lock yarn.lock
83 # set nodedir to prevent node-gyp from downloading headers
84 # taken from https://nixos.org/manual/nixpkgs/stable/#javascript-tool-specific
85 mkdir -p $HOME/.node-gyp/${nodejs.version}
86 echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
87 ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version}
88 export npm_config_nodedir=${nodejs}
90 yarn --offline --frozen-lockfile install --ignore-scripts --no-progress --non-interactive
92 patchShebangs node_modules
94 substituteInPlace node_modules/node-gyp/gyp/pylib/gyp/input.py \
95 --replace-fail "from distutils.version import StrictVersion" "from packaging.version import Version as StrictVersion"
97 ./node_modules/.bin/electron-rebuild -f
99 substituteInPlace package.json \
100 --replace-fail "electron-rebuild -f" "echo 0" \
101 --replace-fail "&& yarn run lint:fix" ""
103 mkdir -p node_modules/vscode-ripgrep/bin
105 yarn --offline --frozen-lockfile install --no-progress
106 patchShebangs node_modules
108 substituteInPlace node_modules/node-gyp/gyp/pylib/gyp/input.py \
109 --replace-fail "from distutils.version import StrictVersion" "from packaging.version import Version as StrictVersion"
111 sed -i -e 's|path.join(.*);|"${lib.getExe ripgrep}";|' \
112 node_modules/vscode-ripgrep/lib/index.js
114 runHook postConfigure
117 yarnBuildScript = "electron-builder";
121 "-c.electronDist=${electron.dist}"
122 "-c.electronVersion=${electron.version}"
126 ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
127 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
131 node .electron-vue/build.js
132 ''; # From package.json
137 mkdir -p $out/opt/marktext $out/bin
139 install -Dm644 resources/linux/marktext.desktop $out/share/application/marktext.desktop
141 pushd resources/icons/
143 find -maxdepth 1 -mindepth 1 -type d -exec install -DT {}/marktext.png $out/share/icons/hicolor/{}/apps/marktext.png \;
145 find -maxdepth 1 -mindepth 1 -type d -exec install -DT {}/md.png $out/share/icons/hicolor/{}/apps/md.png \;
149 cp -r build/*-unpacked/{locales,resources{,.pak}} $out/opt/marktext
151 makeWrapper ${lib.getExe electron} $out/bin/marktext \
152 --add-flags $out/opt/marktext/resources/app.asar \
153 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
158 passthru.updateScript = unstableGitUpdater {
164 description = "Simple and elegant markdown editor, available for Linux, macOS and Windows";
165 homepage = "https://www.marktext.cc";
166 license = lib.licenses.mit;
167 maintainers = with lib.maintainers; [
176 platforms = lib.platforms.unix;
177 mainProgram = "marktext";