nix-community / yarn2nix

Generate nix expressions from a yarn.lock file [maintainer=???]
GNU General Public License v3.0
123 stars 61 forks source link

Wrong packages being used when running yarn #150

Open purefn opened 4 years ago

purefn commented 4 years ago

I've got an SPA that I'm trying to build and can't quite get things worked out right. tslint and tsc fail when run with nix but are fine when I run yarn directly. After a bit of investigating, it appears to be a problem with the wrong versions of packages being used in the nix build.

It's a small subset of dependencies: date-fns, query-string, and a few others. I can't determine why these specifically are being singled out. I did some experimenting and found that, during the yarn install to create the yarn modules derivation, there is a /build/node_modules directory that is populated and a /build/deps/${pname}/node_modules directory that is created.

/build/node_modules contains all the dependencies of my package, with incorrect versions of date-fns, query-string and others.

/build/deps/${pname}/node_modules contains only subset of packages that have incorrect versions in build/node_modules, but has the correct versions of those packages.

I'm not doing anything out of the ordinary in my derivation

   client = mkYarnPackage {
      name = "portal-client";
      src = ../client;
      packageJSON = ../client/package.json;
      yarnLock = ../client/yarn.lock;

      postConfigure = ''
        substituteInPlace deps/$pname/tslint.json \
          --replace './node_modules/fp-ts/rules' "$node_modules/fp-ts/rules"
      '';

      buildPhase = ''
        yarn run build_qa
      '';
    };

Is there something different I should be doing?

purefn commented 4 years ago

The problem seems to be with the package.json that is put in /build. If I replace it with my actual package.json things work correctly. Possibly because there is also a workspace defined in mine and nested workspaces aren't supported?