hedgedoc: refactor to fix editor crashing, replace inactive maintainer with myself
This commit is contained in:
parent
9bbc053f1a
commit
1653d2e3e2
4 changed files with 24 additions and 11825 deletions
|
@ -1,7 +1,6 @@
|
||||||
{ lib
|
{ lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, fetchFromGitHub
|
, fetchzip
|
||||||
, fetchpatch
|
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, which
|
, which
|
||||||
, nodejs
|
, nodejs
|
||||||
|
@ -9,80 +8,44 @@
|
||||||
, fetchYarnDeps
|
, fetchYarnDeps
|
||||||
, python3
|
, python3
|
||||||
, nixosTests
|
, 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 {
|
mkYarnPackage rec {
|
||||||
pname = "hedgedoc";
|
pname = "hedgedoc";
|
||||||
inherit (pinData) version;
|
version = "1.9.4";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
# we use the upstream compiled js files because yarn2nix cannot handle different versions of dependencies
|
||||||
owner = "hedgedoc";
|
# in development and production and the web assets muts be compiled with js-yaml 3 while development
|
||||||
repo = "hedgedoc";
|
# uses js-yaml 4 which breaks the text editor
|
||||||
rev = version;
|
src = fetchzip {
|
||||||
sha256 = pinData.srcHash;
|
url = "https://github.com/hedgedoc/hedgedoc/releases/download/${version}/hedgedoc-${version}.tar.gz";
|
||||||
|
hash = "sha256-YBPxL1/2bj+8cemSBZSNqSlD/DYJRxSG5UuyUipf3R8=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ which makeWrapper ];
|
nativeBuildInputs = [ which makeWrapper ];
|
||||||
extraBuildInputs = [ python3 esbuild-hedgedoc ];
|
extraBuildInputs = [ python3 ];
|
||||||
|
|
||||||
|
packageJSON = ./package.json;
|
||||||
|
yarnFlags = [ "--production" ];
|
||||||
|
|
||||||
offlineCache = fetchYarnDeps {
|
offlineCache = fetchYarnDeps {
|
||||||
inherit yarnLock;
|
yarnLock = src + "/yarn.lock";
|
||||||
sha256 = pinData.yarnHash;
|
sha256 = "sha256-tnxubtu2lv5DKYY4rwQzNwvsFu3pD3NF4VUN/xieqpc=";
|
||||||
};
|
};
|
||||||
|
|
||||||
# FIXME(@Ma27) on the bump to 1.9.0 I had to patch this file manually:
|
configurePhase = ''
|
||||||
# I replaced `midi "https://github.com/paulrosen/MIDI.js.git#abcjs"` with
|
cp -r "$node_modules" node_modules
|
||||||
# `midi "git+https://github.com/paulrosen/MIDI.js.git#abcjs"` on all occurrences.
|
chmod -R u+w node_modules
|
||||||
#
|
|
||||||
# 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
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
cd deps/HedgeDoc
|
|
||||||
|
|
||||||
pushd node_modules/sqlite3
|
pushd node_modules/sqlite3
|
||||||
export CPPFLAGS="-I${nodejs}/include/node"
|
export CPPFLAGS="-I${nodejs}/include/node"
|
||||||
npm run install --build-from-source --nodedir=${nodejs}/include/node
|
npm run install --build-from-source --nodedir=${nodejs}/include/node
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd node_modules/esbuild
|
|
||||||
rm bin/esbuild
|
|
||||||
ln -s ${lib.getBin esbuild-hedgedoc}/bin/esbuild bin/
|
|
||||||
popd
|
|
||||||
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
patchShebangs bin/*
|
patchShebangs bin/*
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
|
@ -108,7 +71,6 @@ mkYarnPackage rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
updateScript = ./update.sh;
|
|
||||||
tests = { inherit (nixosTests) hedgedoc; };
|
tests = { inherit (nixosTests) hedgedoc; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,7 +78,7 @@ mkYarnPackage rec {
|
||||||
description = "Realtime collaborative markdown notes on all platforms";
|
description = "Realtime collaborative markdown notes on all platforms";
|
||||||
license = licenses.agpl3;
|
license = licenses.agpl3;
|
||||||
homepage = "https://hedgedoc.org";
|
homepage = "https://hedgedoc.org";
|
||||||
maintainers = with maintainers; [ willibutz globin ];
|
maintainers = with maintainers; [ willibutz SuperSandro2000 ];
|
||||||
platforms = platforms.linux;
|
platforms = platforms.linux;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"version": "1.9.4",
|
|
||||||
"srcHash": "0tOuSVz/b9qYNQppsxREY/emG1F3t5jeEhX4ek7Ktgg=",
|
|
||||||
"yarnHash": "15xakqcgy3amw52p63z9xlbfq2rp6c2ayf46551zx5mnvdp6wz5n"
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -I nixpkgs=../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
|
#!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
|
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
|
||||||
echo "Regenerates packaging data for the element packages."
|
echo "Regenerates packaging data for the element packages."
|
||||||
|
@ -9,24 +11,16 @@ fi
|
||||||
|
|
||||||
version="$1"
|
version="$1"
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
version="$(wget -O- "https://api.github.com/repos/hedgedoc/hedgedoc/releases?per_page=1" | jq -r '.[0].tag_name')"
|
version="$(wget -O- "https://api.github.com/repos/hedgedoc/hedgedoc/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
src="https://raw.githubusercontent.com/hedgedoc/hedgedoc/$version"
|
src="https://raw.githubusercontent.com/hedgedoc/hedgedoc/$version"
|
||||||
wget "$src/package.json" -O package.json
|
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)
|
yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||||
|
|
||||||
cat > pin.json << EOF
|
sed -i "s/version = \".*\"/version = \"$version\"/" default.nix
|
||||||
{
|
sed -i "s/hash = \".*\"/hash = \"$src_hash\"/" default.nix
|
||||||
"version": "$version",
|
sed -i "s/sha256 = \".*\"/sha256 = \"$yarn_hash\"/" default.nix
|
||||||
"srcHash": "$src_hash",
|
|
||||||
"yarnHash": "$yarn_hash"
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue