How to build a Node project using Nix and Flake?

538 Views Asked by At

I'm trying to build a web application using React and using Nix with Flake to build it, for that I am using this tutorial as an example, but I have this error:

error: builder for '/nix/store/my-app.drv' failed with exit code 1;
       last 10 log lines:
       > is not maintianed anymore. It is thus unlikely that this bug will
       > ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
       > your devDependencies to work around this error. This will make this message
       > go away.
       >
       > Failed to compile.
       > 
       > [eslint] EACCES: permission denied, mkdir '/build/auth/node_modules/.cache'
       >
       >
       For full logs, run '/nix/store/my-app.drv'.

I'm using this project struct:

├── default.nix
├── flake.nix
└── site
    └── client
        └── auth
            ├── default.nix
            ├── nix
            │   ├── default.nix
            │   ├── node-env.nix
            │   └── node-packages.nix
            ├── ... # React app
            └── node_modules               

The problem is in ./site/client/auth/default.nix when it tries to build the React project:

static = stdenv.mkDerivation {
    name = "my-client";
    src = ./.;
    buildInputs = [ nodejs ];
    buildPhase = ''
      ln -s ${generated.nodeDependencies}/lib/node_modules ./node_modules
      export PATH="${generated.nodeDependencies}/bin:$PATH"
      npm run build
    '';
    installPhase = ''
      cp -r dist $out/
    '';
  };

How can I grant it permissions to do the .cache/?

0

There are 0 best solutions below