npmlock2nix
npmlock2nix copied to clipboard
Different behavior on Linux vs Darwin
I am trying to create a devShell and am getting different behavior on Linux vs Darwin. Specifically the prepare
script is causing issues on Linux. See this commit hash for reference.
In the package.json file there is a line "prepare": "husky install"
. On Darwin, this executes without issue. On Linux, the following error occurs.
% nix develop .\#astro
trace: warning: [npmlock2nix] You are using the new v2 beta api. The interface isn't stable yet. Please report any issues at https://github.com/nix-community/npmlock2nix/issues
error: builder for '/nix/store/n1vxcbl6vrrr8acghhccvbf798nk0nni-astro-paper-2.3.0.drv' failed with exit code 127;
last 10 log lines:
>
> sh: line 1: /build/node_modules/.bin/husky: cannot execute: required file not found
> npm ERR! code 127
> npm ERR! path /build
> npm ERR! command failed
> npm ERR! command sh -c husky install
>
> npm ERR! A complete log of this run can be found in:
> npm ERR! /build/.npm/_logs/2023-05-17T06_31_45_382Z-debug-0.log
>
For full logs, run 'nix log /nix/store/n1vxcbl6vrrr8acghhccvbf798nk0nni-astro-paper-2.3.0.drv'.
error: 1 dependencies of derivation '/nix/store/hkl7lm8ha8jsgpsihxxyx073r93xxb2q-nix-shell-env.drv' failed to build
bakerdn@bahamut djacu.dev % nix log /nix/store/n1vxcbl6vrrr8acghhccvbf798nk0nni-astro-paper-2.3.0.drv
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
[#########.........] / reify: timing npm-ci:rm Completed in 0ms^M[#########.........] - reify:@esbuild/a>
npm WARN deprecated @types/[email protected]: This is a stub types definition. sharp provides its own type de>
[############......] / reify:flat-cache: timing reifyNode:node_modules/is-buffe^M[#############.....] | >
added 853 packages in 9s
257 packages are looking for funding
run `npm fund` for details
patching script interpreter paths in node_modules/.bin
rebuilt dependencies successfully
[#########.........] - idealTree: timing idealTree Completed in 545ms^M[#########.........] \ idealTree:>
> [email protected] prepare
> husky install
sh: line 1: /build/node_modules/.bin/husky: cannot execute: required file not found
npm ERR! code 127
npm ERR! path /build
npm ERR! command failed
npm ERR! command sh -c husky install
npm ERR! A complete log of this run can be found in:
npm ERR! /build/.npm/_logs/2023-05-17T06_31_45_382Z-debug-0.log
In fact, the Darwin environment can seemingly execute any code. We switched it to "prepare": "astro --version"
and it showed up in the build logs. Is the prepare script supposed to work differently on Darwin vs Linux or is there some other more general issue?
For reference, this is the flake file.
{
description = "djacu's personal site";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.npmlock2nix.url = "github:nix-community/npmlock2nix";
inputs.npmlock2nix.flake = false;
outputs = {
self,
nixpkgs,
flake-utils,
npmlock2nix,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(self: super: {
npmlock2nix = pkgs.callPackage npmlock2nix {};
})
];
};
astro-shell = pkgs.npmlock2nix.v2.shell {
src = ./.;
nodejs = pkgs.nodejs;
node_modules_mode = "copy";
};
in {
devShells.astro = astro-shell;
}
);
}