Serve sites from nginx with additional build step

I use the following in my NixOS configuration to serve the websites that are just static HTML, CSS and JS files from GitHub:

nginx = {
  enable = true;
  virtualHosts = {
    "shaniag.com" = {
      enableACME = true;
      forceSSL = true;
      root = inputs.website;
    };
  };
};

This works totally fine, but I have the problem that I now want to host another website, but this time there is one step required before the static files are there and thus ready for nginx to serve, called npm run build to turn the framework code into plain HTML, CSS and JS files.

Could you show me how I do that in a good way with Nix?

Maybe something like

nginx = {
  enable = true;
  virtualHosts = {
    "shaniag.com" = {
      enableACME = true;
      forceSSL = true;
      root = pkgs.buildNpmPackage {
        src = inputs.website;
        npmDepsHash = "";
        installPhase = "cp -r . $out";
      };
    };
  };
};