Building docker image using nix for a nestjs project

I have mac m1 silicon,

./test-app // contains nestjs basic project

{ pkgs ? import <nixpkgs> {}, pkgsLinux ? import <nixpkgs> { system="x86_64-linux"; } }:

  nodePackages = pkgsLinux.nodejs_20;
  appDir = ./test-app;

pkgs.dockerTools.buildImage {
  name = "nestjs-docker";

  copyToRoot = [ appDir ];

  runAsRoot = ''
    ${nodePackages}/bin/npm install -g @nestjs/cli && 
    ${nodePackages}/bin/npm install && 
    ${nodePackages}/bin/npm run build

  config = {
    Cmd = [
      "${nodePackages}/bin/node" "dist/main.js"
    ExposedPorts = {
      "3000/tcp" = {};

now when i am trying to run nix-build docker.nix it throw error for unsupported system, it works without runAsRoot lines.
I need to install dependencies while building image so I have to use runAsRoot or may be in Cmd somehow want to do same step
but both have issue as runAsRoot doesn’t allow build
and cmd with scripts doesn’t run in container

 config = {
    Cmd = [
      "${nodePackages}/bin/npm" "install"
      "${nodePackages}/bin/npm" "run" "build" 
      "${nodePackages}/bin/node" "dist/main.js"

any way to do this?

requirement is : when I run nix build script it should copy /test-app (nestjs app) code and then install the depend. defiend in package.json and then build docker image that i can load and run.

I know can be done using Dockerfile but I have some other usecases so I want to avoid dockerfile
and I can’t use linux os or vm box