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

80 lines
1.7 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper
2019-08-16 09:17:14 +00:00
, which, nodejs, yarn2nix, python2 }:
yarn2nix.mkYarnPackage rec {
name = "codimd";
2019-08-16 09:17:14 +00:00
version = "1.5.0";
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
};
nativeBuildInputs = [ which makeWrapper ];
2019-08-16 09:17:14 +00:00
extraBuildInputs = [ python2 ];
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/CodiMD/node_modules
cp -R "$node_modules" deps/CodiMD
chmod -R u+w deps/CodiMD
'';
2018-08-19 15:54:46 +00:00
buildPhase = ''
runHook preBuild
2018-08-19 15:54:46 +00:00
cd deps/CodiMD
2018-08-19 15:54:46 +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
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
2018-08-19 15:54:46 +00:00
cat > $out/bin/codimd <<EOF
#!${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 \
--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
meta = with stdenv.lib; {
description = "Realtime collaborative markdown notes on all platforms";
license = licenses.agpl3;
homepage = "https://github.com/codimd/server";
maintainers = with maintainers; [ willibutz ma27 globin ];
2018-08-19 15:54:46 +00:00
platforms = platforms.linux;
};
}