hedgedoc: refactor to fix editor crashing, replace inactive maintainer with myself

This commit is contained in:
Sandro Jäckel 2022-07-24 14:44:35 +02:00
parent 9bbc053f1a
commit 1653d2e3e2
No known key found for this signature in database
GPG key ID: 3AF5A43A3EECC2E5
4 changed files with 24 additions and 11825 deletions

View file

@ -1,7 +1,6 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, fetchzip
, makeWrapper
, which
, nodejs
@ -9,80 +8,44 @@
, fetchYarnDeps
, python3
, nixosTests
, buildGoModule
}:
let
pinData = lib.importJSON ./pin.json;
# we need a different version than the one already available in nixpkgs
esbuild-hedgedoc = buildGoModule rec {
pname = "esbuild";
version = "0.12.27";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
sha256 = "sha256-UclUTfm6fxoYEEdEEmO/j+WLZLe8SFzt7+Tej4bR0RU=";
};
vendorSha256 = "sha256-QPkBR+FscUc3jOvH7olcGUhM6OW4vxawmNJuRQxPuGs=";
};
in
mkYarnPackage rec {
pname = "hedgedoc";
inherit (pinData) version;
version = "1.9.4";
src = fetchFromGitHub {
owner = "hedgedoc";
repo = "hedgedoc";
rev = version;
sha256 = pinData.srcHash;
# we use the upstream compiled js files because yarn2nix cannot handle different versions of dependencies
# in development and production and the web assets muts be compiled with js-yaml 3 while development
# uses js-yaml 4 which breaks the text editor
src = fetchzip {
url = "https://github.com/hedgedoc/hedgedoc/releases/download/${version}/hedgedoc-${version}.tar.gz";
hash = "sha256-YBPxL1/2bj+8cemSBZSNqSlD/DYJRxSG5UuyUipf3R8=";
};
nativeBuildInputs = [ which makeWrapper ];
extraBuildInputs = [ python3 esbuild-hedgedoc ];
extraBuildInputs = [ python3 ];
packageJSON = ./package.json;
yarnFlags = [ "--production" ];
offlineCache = fetchYarnDeps {
inherit yarnLock;
sha256 = pinData.yarnHash;
yarnLock = src + "/yarn.lock";
sha256 = "sha256-tnxubtu2lv5DKYY4rwQzNwvsFu3pD3NF4VUN/xieqpc=";
};
# FIXME(@Ma27) on the bump to 1.9.0 I had to patch this file manually:
# I replaced `midi "https://github.com/paulrosen/MIDI.js.git#abcjs"` with
# `midi "git+https://github.com/paulrosen/MIDI.js.git#abcjs"` on all occurrences.
#
# Without this change `yarn` attempted to download the code directly from GitHub, with
# the `git+`-prefix it actually uses the `midi.js` version from the offline cache
# created by `yarn2nix`. On future bumps this may be necessary as well!
yarnLock = ./yarn.lock;
packageJSON = ./package.json;
postConfigure = ''
rm deps/HedgeDoc/node_modules
cp -R "$node_modules" deps/HedgeDoc
chmod -R u+w deps/HedgeDoc
configurePhase = ''
cp -r "$node_modules" node_modules
chmod -R u+w node_modules
'';
buildPhase = ''
runHook preBuild
cd deps/HedgeDoc
pushd node_modules/sqlite3
export CPPFLAGS="-I${nodejs}/include/node"
npm run install --build-from-source --nodedir=${nodejs}/include/node
popd
pushd node_modules/esbuild
rm bin/esbuild
ln -s ${lib.getBin esbuild-hedgedoc}/bin/esbuild bin/
popd
npm run build
patchShebangs bin/*
runHook postBuild
@ -108,7 +71,6 @@ mkYarnPackage rec {
'';
passthru = {
updateScript = ./update.sh;
tests = { inherit (nixosTests) hedgedoc; };
};
@ -116,7 +78,7 @@ mkYarnPackage rec {
description = "Realtime collaborative markdown notes on all platforms";
license = licenses.agpl3;
homepage = "https://hedgedoc.org";
maintainers = with maintainers; [ willibutz globin ];
maintainers = with maintainers; [ willibutz SuperSandro2000 ];
platforms = platforms.linux;
};
}

View file

@ -1,5 +0,0 @@
{
"version": "1.9.4",
"srcHash": "0tOuSVz/b9qYNQppsxREY/emG1F3t5jeEhX4ek7Ktgg=",
"yarnHash": "15xakqcgy3amw52p63z9xlbfq2rp6c2ayf46551zx5mnvdp6wz5n"
}

View file

@ -1,5 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
set -euo pipefail
cd "$(dirname "$0")"
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for the element packages."
@ -9,24 +11,16 @@ fi
version="$1"
set -euo pipefail
if [ -z "$version" ]; then
version="$(wget -O- "https://api.github.com/repos/hedgedoc/hedgedoc/releases?per_page=1" | jq -r '.[0].tag_name')"
fi
src="https://raw.githubusercontent.com/hedgedoc/hedgedoc/$version"
wget "$src/package.json" -O package.json
wget "$src/yarn.lock" -O yarn.lock
sed 's;midi "https://github\.com/paulrosen/MIDI\.js\.git;midi "git+https://github.com/paulrosen/MIDI.js.git;g' -i yarn.lock
src_hash=$(nix-prefetch-github hedgedoc hedgedoc --rev ${version} | jq -r .sha256)
src_hash=$(nix-prefetch-github hedgedoc hedgedoc --rev "${version}" | jq -r .sha256)
yarn_hash=$(prefetch-yarn-deps yarn.lock)
cat > pin.json << EOF
{
"version": "$version",
"srcHash": "$src_hash",
"yarnHash": "$yarn_hash"
}
EOF
sed -i "s/version = \".*\"/version = \"$version\"/" default.nix
sed -i "s/hash = \".*\"/hash = \"$src_hash\"/" default.nix
sed -i "s/sha256 = \".*\"/sha256 = \"$yarn_hash\"/" default.nix

File diff suppressed because it is too large Load diff