depot/third_party/nixpkgs/pkgs/servers/web-apps/hedgedoc/default.nix
Default email 01ed8ef136 Project import generated by Copybara.
GitOrigin-RevId: 20fc948445a6c22d4e8d5178e9a6bc6e1f5417c8
2022-11-21 19:40:18 +02:00

84 lines
2 KiB
Nix

{ lib
, stdenv
, fetchzip
, makeWrapper
, which
, nodejs
, mkYarnPackage
, fetchYarnDeps
, python3
, nixosTests
}:
mkYarnPackage rec {
pname = "hedgedoc";
version = "1.9.6";
# 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-NoA4mv9LyvShr4fdfBSHgDoyxY59ubRC8YC6hvOimZc=";
};
nativeBuildInputs = [ which makeWrapper ];
extraBuildInputs = [ python3 ];
packageJSON = ./package.json;
yarnFlags = [ "--production" ];
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
sha256 = "1xxq02mgys3bp7ivgsr9hyafd866ygw2bp3rbld2500afvayz89v";
};
configurePhase = ''
cp -r "$node_modules" node_modules
chmod -R u+w node_modules
'';
buildPhase = ''
runHook preBuild
pushd node_modules/sqlite3
export CPPFLAGS="-I${nodejs}/include/node"
npm run install --build-from-source --nodedir=${nodejs}/include/node
popd
patchShebangs bin/*
runHook postBuild
'';
dontInstall = true;
distPhase = ''
runHook preDist
mkdir -p $out
cp -R {app.js,bin,lib,locales,node_modules,package.json,public} $out
cat > $out/bin/hedgedoc <<EOF
#!${stdenv.shell}/bin/sh
${nodejs}/bin/node $out/app.js
EOF
chmod +x $out/bin/hedgedoc
wrapProgram $out/bin/hedgedoc \
--set NODE_PATH "$out/lib/node_modules"
runHook postDist
'';
passthru = {
tests = { inherit (nixosTests) hedgedoc; };
};
meta = with lib; {
description = "Realtime collaborative markdown notes on all platforms";
license = licenses.agpl3;
homepage = "https://hedgedoc.org";
maintainers = with maintainers; [ willibutz SuperSandro2000 ];
platforms = platforms.linux;
};
}