Override crossSystem for single derivation within a Flake

I have a Flake that builds two NPM projects and a Cargo project which are eventually merged into a single derivation. This works fine when we have pkgs.crossPlatform.config set to x86_64-unknown-linux-gnu but Node.JS will fail to compile when we set this to x86_64-unknown-linux-musl.

As these NPM dependencies are actually just client-side TS being transpiled to JS, the host platform can match the build platform as the output should always be the same anyway. Is it possible to set crossPlatform to the same value as the build platform within the buildNpmPackage function?

Create a second pkgs block without crossSystem set:

pkgs = import nixpkgs {
  inherit system;

  crossSystem = {
    config = "x86_64-unknown-linux-musl"
  };
};

npmPkgs = import nixpkgs {
  inherit system;
};

then call npmPkgs.buildNpmPackage instead of pkgs.buildNpmPackage.

There’s probably a more efficient way, but this works.