nixpkgs/pkgs/servers/web-apps/hedgedoc/default.nix

106 lines
2.2 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, makeWrapper
, which
, nodejs
, mkYarnPackage
, python2
, nixosTests
, buildGoModule
}:
let
# we need a different version than the one already available in nixpkgs
esbuild-hedgedoc = buildGoModule rec {
pname = "esbuild";
version = "0.11.20";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
sha256 = "009f2mfgzkzgxjh3034mzdkcvm5vz17sgy1cs604f0425i22z8qm";
};
vendorSha256 = "1n5538yik72x94vzfq31qaqrkpxds5xys1wlibw2gn2am0z5c06q";
};
in
mkYarnPackage rec {
pname = "hedgedoc";
version = "1.8.2";
src = fetchFromGitHub {
owner = "hedgedoc";
repo = "hedgedoc";
rev = version;
sha256 = "1h2wyhap264iqm2jh0i05w0hb2j86jsq1plyl7k3an90w7wngyg1";
2018-08-19 15:54:46 +00:00
};
nativeBuildInputs = [ which makeWrapper ];
extraBuildInputs = [ python2 esbuild-hedgedoc ];
2018-08-19 15:54:46 +00:00
yarnNix = ./yarn.nix;
yarnLock = ./yarn.lock;
packageJSON = ./package.json;
2018-08-19 15:54:46 +00:00
postConfigure = ''
rm deps/HedgeDoc/node_modules
cp -R "$node_modules" deps/HedgeDoc
chmod -R u+w deps/HedgeDoc
'';
2018-08-19 15:54:46 +00:00
buildPhase = ''
runHook preBuild
2018-08-19 15:54:46 +00:00
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
2018-08-19 15:54:46 +00:00
npm run build
patchShebangs bin/*
runHook postBuild
2018-08-19 15:54:46 +00:00
'';
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
2018-08-19 15:54:46 +00:00
EOF
chmod +x $out/bin/hedgedoc
wrapProgram $out/bin/hedgedoc \
--set NODE_PATH "$out/lib/node_modules"
2018-08-19 15:54:46 +00:00
runHook postDist
'';
2018-08-19 15:54:46 +00:00
passthru.tests = { inherit (nixosTests) hedgedoc; };
meta = with lib; {
2018-08-19 15:54:46 +00:00
description = "Realtime collaborative markdown notes on all platforms";
license = licenses.agpl3;
homepage = "https://hedgedoc.org";
maintainers = with maintainers; [ willibutz ma27 globin ];
2018-08-19 15:54:46 +00:00
platforms = platforms.linux;
};
}