1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-14 16:46:09 +00:00
nixpkgs/pkgs/applications/version-management/sourcehut/fetchNodeModules.nix

27 lines
728 B
Nix
Raw Normal View History

2021-01-15 13:21:58 +00:00
{ lib, stdenv, jq }: { src, nodejs, sha256 }:
2020-02-17 17:36:48 +00:00
# Only npm >= 5.4.2 is deterministic, see:
# https://github.com/npm/npm/issues/17979#issuecomment-332701215
2021-01-15 13:21:58 +00:00
assert lib.versionAtLeast nodejs.version "8.9.0";
2020-02-17 17:36:48 +00:00
stdenv.mkDerivation {
name = "node_modules";
outputHashAlgo = "sha256";
outputHash = sha256;
outputHashMode = "recursive";
nativeBuildInputs = [ jq nodejs ];
buildCommand = ''
cp -r ${src}/* .
HOME=. npm install --force --ignore-scripts --only=production
for f in $(find node_modules -name package.json); do
# https://github.com/npm/npm/issues/10393
jq -S 'delpaths(keys | map(select(startswith("_")) | [.]))' $f > $f.tmp
mv $f.tmp $f
done
mv node_modules $out
'';
}