Hey, there is one npm package that causes trouble for me when running nix build using buildNpmPackage in my flake.nix file. This package is called sharp, and here is the error message:
error: builder for '/nix/store/59qj7rbv5k376i6f1yhcfqk8pgsw4s4d-build-website.drv' failed with exit code 1;
last 10 log lines:
> npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
> npm ERR! sharp: Are you trying to install as a root or sudo user?
> npm ERR! sharp: - For npm <= v6, try again with the "--unsafe-perm" flag
> npm ERR! sharp: - For npm >= v8, the user must own the directory "npm install" is run in
> npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
> npm ERR! sharp: Installation error: EACCES: permission denied, mkdir '/nix/store/077qgrp572ck9m32q7r8dcd42rcd7hzr-build-website-npm-deps/_libvips'
I think this error is quite helpful, but unfortunately I do not know how I would overcome this issue.
I will post my flake.nix contents below, it would be much appreciated if you could show me how I have to adjust the flake for this scenario ![]()
{
description = "JavaScript development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = { self, nixpkgs }:
let
# Systems supported
allSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = nixpkgs.legacyPackages.${system};
});
in
{
packages = forAllSystems ({ pkgs }: {
default = pkgs.buildNpmPackage {
name = "build-website";
buildInputs = with pkgs; [
nodejs_20
];
src = ./.;
npmDepsHash = "sha256-2AV40Q7Fqfc/rjC2tc5sm7ss4hZ8dV+zaSpgVUANNNg=";
npmBuild = "npm run build";
installPhase = ''
mkdir $out
cp -r dist/* $out
'';
};
});
};
}