3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/servers/web-apps/codimd/CodeMirror/default.nix
Maximilian Bosch 5feec424de
codimd: build with nodejs-8_x
This diff regenerates the package sets for `codimd` and `codemirror`
using NodeJS 8 to get rid of the deprecated[1] `nodejs-6_x`.

Additionally the following issues had to be fixed during the update:

* The package `js-sequence-diagram` has been removed from the NPM
  registry and was replaced by a security holding package[2]. The
  package was published by a third-party (upstream only supports bower
  builds), so it's unclear whether the package will re-appear[3].

  As the tarballs still exist (and the hash didn't change), the package
  will be loaded manually into the build env.

* For the babel-related packages, `dontNpmInstall` will be set for
  `node2nix` installs as some of those packages bundle a
  `package-lock.json` that triggers `ENOTCACHED` errors for optional
  dependencies[4].

For now it should be sufficient to use NodeJS 8 (`codimd` v1.2.x doesn't
support NodeJS 10), in the long term we probably want to use `yarn2nix`
here with NodeJS 10. This is much rather a fix to get rid of another
NodeJS 6 dependency.

[1] `nodejs-6_x` is about to be deprecated, see #58976
[2] https://www.npmjs.com/package/js-sequence-diagrams,
    https://github.com/npm/security-holder
[3] https://github.com/bramp/js-sequence-diagrams/issues/212
[4] https://github.com/svanderburg/node2nix/issues/134
2019-04-07 16:44:26 +02:00

47 lines
1.2 KiB
Nix

{ stdenv, pkgs, buildEnv, fetchFromGitHub, nodejs-8_x, phantomjs2, which }:
let
nodePackages = import ./node.nix {
inherit pkgs;
system = stdenv.system;
};
phantomjs-prebuilt = nodePackages."phantomjs-prebuilt-^2.1.12".override (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [ phantomjs2 ];
});
in
stdenv.mkDerivation {
name = "codemirror-hackmdio-05-07-2018";
src = fetchFromGitHub {
owner = "hackmdio";
repo = "CodeMirror";
rev = "df412731ed3923124f9a43f60e84bdf855eb843a";
sha256 = "02v2wccv9sjdda9x45ib8d08i1pc4b8kwg3p6qc314wqq89nhniw";
};
nativeBuildInputs = [ which ];
buildInputs = [ nodejs-8_x phantomjs-prebuilt ] ++ (stdenv.lib.attrVals [
"blint-^1"
"node-static-0.6.0"
"rollup-^0.41.0"
"rollup-plugin-buble-^0.15.0"
"rollup-watch-^3.2.0"
"uglify-js-^2.8.15"
] nodePackages);
buildPhase = ''
patchShebangs .
npm run build
node release
'';
installPhase = ''
mkdir -p $out/lib/node_modules/codemirror
cp -R {codemirror.min.js,addon,bin,keymap,lib,mode,theme} $out/lib/node_modules/codemirror/
ln -s ${nodePackages."url-loader-^0.5.7"}/lib/node_modules/url-loader \
$out/lib/node_modules
'';
}