Building python package with node dependencies


I am trying to build beancount-import, which is a python package with node dependencies. Unfortunately, I am not super familiar with how to accomplish this. I did see panel, which seems to have a similar node dependency, so I tried to model after that.

This is my current buildPythonPackage:

        beancount_import = with pkgs;
          python38Packages.buildPythonPackage rec {
            pname = "beancount-import";
            version = "v1.3.3";

            src = fetchFromGitHub {
              owner = "jbms";
              repo = pname;
              rev = "master";
              sha256 = "sha256-7Ct5yYv7GB341t7SkJAAVmTE4PAdZpJEYGgrfjicZIY=";

            preBuild = ''
              pushd beancount_import
              mkdir frontend
              ln -s ${beancount_import-node.nodeDependencies}/lib/node_modules frontend/node_modules
              export PATH="${beancount_import-node.nodeDependencies}/bin:$PATH"

            # pipInstallFlags = [ "--install-option='--skip_npm_reinstall'" ];

            nativeBuildInputs = [ nodejs ];

            propagatedBuildInputs = with python38Packages; [

There also seems to be a user option to skip-npm-reinstall, although, I am not quite sure how to add that option to the command.

Any help would be appreciated, thanks!

repo: GitHub - wangkev/beancount-import-flake

Made some progress on this. Hitting a dependency issue:

> esbuild --bundle app.tsx --sourcemap --minify --outdir=../beancount_import/frontend_dist --define:global=window "--define:process.env.NODE_ENV='production'"

 > ../../../../../nix/store/mjw9awn9qhwkbjcg9hvwgpl8pmy2c1d7-node-dependencies-beancount-import-0.0.1/lib/node_modules/styled-components/dist/styled-components.browser.esm.js:1:62: error: Could not resolve "react-is" (mark i
    1 │ ...isValidElementType as n}from"react-is";import r,{useState as o,use...
      ╵                                ~~~~~~~~~~

1 error
npm ERR! errno 1
npm ERR! beancount-import@0.0.1 build: `esbuild --bundle app.tsx --sourcemap --minify --outdir=../beancount_import/frontend_dist --define:global=window "--define:process.env.NODE_ENV='production'"`
npm ERR! Exit status 1

There were other reports of this issue, and it seems it may be an issue with nodejs and npm versions (works with nodejs v15.14.0 and npm 7.9.0).

However, seems like nodejs 15 is not yet supported on node2nix.

Is there a way to properly install this dependency? I saw zigbee2mqtt in nixpkgs has a similar react-is dependency, which seems to be using nodejs 12, so I am not quite sure what might be the issue.