2019-07-13 13:09:39 +00:00
|
|
|
{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper
|
2019-08-16 09:17:14 +00:00
|
|
|
, which, nodejs, yarn2nix, python2 }:
|
2019-07-13 13:09:39 +00:00
|
|
|
|
|
|
|
yarn2nix.mkYarnPackage rec {
|
|
|
|
name = "codimd";
|
2019-08-16 09:17:14 +00:00
|
|
|
version = "1.5.0";
|
2019-07-13 13:09:39 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "codimd";
|
|
|
|
repo = "server";
|
|
|
|
rev = version;
|
2019-08-16 09:17:14 +00:00
|
|
|
sha256 = "1sd7r5ws1k7dxmr57m67c1k23pzbkn25k2wvcnbrqn7gza6mhlf0";
|
2018-08-19 15:54:46 +00:00
|
|
|
};
|
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
nativeBuildInputs = [ which makeWrapper ];
|
2019-08-16 09:17:14 +00:00
|
|
|
extraBuildInputs = [ python2 ];
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
yarnNix = ./yarn.nix;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
packageJSON = ./package.json;
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
postConfigure = ''
|
|
|
|
rm deps/CodiMD/node_modules
|
|
|
|
cp -R "$node_modules" deps/CodiMD
|
|
|
|
chmod -R u+w deps/CodiMD
|
|
|
|
'';
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
cd deps/CodiMD
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
pushd node_modules/codemirror
|
|
|
|
npm run install
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd node_modules/sqlite3
|
|
|
|
export OLD_HOME="$HOME"
|
|
|
|
export HOME="$PWD"
|
|
|
|
mkdir -p .node-gyp/${nodejs.version}
|
|
|
|
echo 9 > .node-gyp/${nodejs.version}/installVersion
|
|
|
|
ln -s ${nodejs}/include .node-gyp/${nodejs.version}
|
|
|
|
npm run install
|
|
|
|
export HOME="$OLD_HOME"
|
|
|
|
unset OLD_HOME
|
|
|
|
popd
|
|
|
|
|
2018-08-19 15:54:46 +00:00
|
|
|
npm run build
|
2019-07-13 13:09:39 +00:00
|
|
|
|
|
|
|
runHook postBuild
|
2018-08-19 15:54:46 +00:00
|
|
|
'';
|
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
dontInstall = true;
|
|
|
|
|
|
|
|
distPhase = ''
|
|
|
|
runHook preDist
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R {app.js,bin,lib,locales,node_modules,package.json,public} $out
|
|
|
|
|
2018-08-19 15:54:46 +00:00
|
|
|
cat > $out/bin/codimd <<EOF
|
2019-07-13 13:09:39 +00:00
|
|
|
#!${stdenv.shell}/bin/sh
|
|
|
|
${nodejs}/bin/node $out/app.js
|
2018-08-19 15:54:46 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/codimd
|
|
|
|
wrapProgram $out/bin/codimd \
|
2019-07-13 13:09:39 +00:00
|
|
|
--set NODE_PATH "$out/lib/node_modules"
|
2018-08-19 15:54:46 +00:00
|
|
|
|
2019-07-13 13:09:39 +00:00
|
|
|
runHook postDist
|
|
|
|
'';
|
2018-08-19 15:54:46 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Realtime collaborative markdown notes on all platforms";
|
|
|
|
license = licenses.agpl3;
|
2019-07-13 13:09:39 +00:00
|
|
|
homepage = "https://github.com/codimd/server";
|
2019-08-20 17:36:05 +00:00
|
|
|
maintainers = with maintainers; [ willibutz ma27 globin ];
|
2018-08-19 15:54:46 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|