| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- { lib
- , stdenv
- , fetchFromGitHub
- , python3
- , fetchYarnDeps
- , yarn
- , nodejs
- , prefetch-yarn-deps
- , fixup-yarn-lock
- , makeWrapper
- , gitUpdater
- , pkg-config
- , sqlite
- , apple-sdk
- , cctools
- , cacert
- , gvisor
- ,
- }:
- stdenv.mkDerivation rec {
- pname = "grist-core";
- version = "1.7.8";
- src = fetchFromGitHub {
- owner = "gristlabs";
- repo = "grist-core";
- tag = "v${version}";
- hash = "sha256-e68PtWdlgKdjCj97fp+Rh3WwwwIcvKSXlx4Ry1qUeLg=";
- };
- offlineCache = fetchYarnDeps {
- yarnLock = "${src}/yarn.lock";
- hash = "sha256-7zyuBxheftgCXGjjJ+rdwSslIro9IEd/uvmo4xp6I+Q=";
- };
- nativeBuildInputs = [
- yarn
- nodejs
- prefetch-yarn-deps
- fixup-yarn-lock
- makeWrapper
- pkg-config
- python3
- ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
- cctools
- ];
- buildInputs = [
- sqlite
- ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
- apple-sdk
- ] ++ lib.optionals stdenv.hostPlatform.isLinux [
- gvisor
- ];
- passthru = {
- updateScript = gitUpdater { rev-prefix = "v"; };
- tests = { };
- };
- configurePhase = ''
- runHook preConfigure
- export HOME=$(mktemp -d)
- rm .yarnrc
- yarn config --offline set yarn-offline-mirror ${offlineCache}
- fixup-yarn-lock yarn.lock
- mkdir -p "$HOME/.node-gyp/${nodejs.version}"
- echo 9 >"$HOME/.node-gyp/${nodejs.version}/installVersion"
- ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}"
- export npm_config_nodedir=${nodejs}
- # Set SSL certificates for node-pre-gyp
- export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
- export NODE_EXTRA_CA_CERTS="${cacert}/etc/ssl/certs/ca-bundle.crt"
- # Ensure cctools' libtool comes before any other libtool
- ${lib.optionalString stdenv.hostPlatform.isDarwin ''
- export PATH="${cctools}/bin:$PATH"
- ''}
- yarn --offline --frozen-lockfile --ignore-platform --ignore-engines --ignore-optional --no-progress --non-interactive install
- yarn install:python
- patchShebangs node_modules
- patchShebangs buildtools
- runHook postConfigure
- '';
- buildPhase = ''
- runHook preBuild
- yarn --offline run build:prod
- runHook postBuild
- '';
- installPhase = ''
- runHook preInstall
- mkdir -p "$out/libexec" "$out/bin"
- # Copy runtime files + the sandbox venv
- cp -r _build node_modules plugins sandbox static bower_components package.json sandbox_venv3 $out/libexec/
- makeWrapper ${lib.getExe nodejs} $out/bin/grist-core \
- --add-flags "$out/libexec/_build/stubs/app/server/server.js" \
- --set "GRIST_PYTHON_VIRTUALENV" "$out/libexec/sandbox_venv3" \
- --set "NODE_PATH" "$out/libexec/_build:$out/libexec/_build/stubs:$out/libexec/_build/ext" \
- --chdir "$out/libexec"
- runHook postInstall
- '';
- postInstall = ''
- # Remove test/dev files that might not exist
- rm -f $out/libexec/static/mocha.js
- rm -f $out/libexec/static/sinon.js
- rm -f $out/libexec/static/mocha.css
-
- # Fix or remove broken symlinks
- find $out/libexec/bower_components -type l ! -exec test -e {} \; -delete
-
- # Remove problematic .bin directories
- find $out/libexec/node_modules -name '.bin' -type d -print0 | xargs -0 rm -rf 2>/dev/null || true
- '';
- meta = {
- description = "Grist is the evolution of spreadsheets";
- homepage = "https://github.com/gristlabs/grist-core";
- license = lib.licenses.asl20;
- maintainers = with lib.maintainers; [ scandiravian ];
- mainProgram = "grist-core";
- platforms = lib.platforms.unix;
- };
- }
|