Unverified Commit 24a76db0 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

Merge pull request #334377 from dotlambda/node-gyp

node-gyp: init at 10.2.0
parents c1704d98 000f83e1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
  nodejs,
  pnpm,
  python3,
  nodePackages,
  node-gyp,
  cacert,
  xcbuild,
  libkrb5,
@@ -34,7 +34,7 @@ stdenv.mkDerivation (finalAttrs: {
  nativeBuildInputs = [
    pnpm.configHook
    python3 # required to build sqlite3 bindings
    nodePackages.node-gyp # required to build sqlite3 bindings
    node-gyp # required to build sqlite3 bindings
    cacert # required for rustls-native-certs (dependency of turbo build tool)
    makeWrapper
  ] ++ lib.optional stdenv.isDarwin [ xcbuild ];
+5034 −0

File added.

Preview size limit exceeded, changes collapsed.

+41 −0
Original line number Diff line number Diff line
{
  buildNpmPackage,
  fetchFromGitHub,
  lib,
  nodejs,
}:

(buildNpmPackage.override { inherit nodejs; }) rec {
  pname = "node-gyp";
  version = "10.2.0";

  src = fetchFromGitHub {
    owner = "nodejs";
    repo = "node-gyp";
    rev = "refs/tags/v${version}";
    hash = "sha256-AxyGE86nuU9VkbLLR/8GKM6bcTgayYodQ0mWiQhQtA0=";
  };

  npmDepsHash = "sha256-LCm1gF7GfjT13k3fe1A+DNNwP48OtFVbYgwCCLH3eHA=";

  postPatch = ''
    ln -s ${./package-lock.json} package-lock.json
  '';

  dontNpmBuild = true;

  # Teach node-gyp to use nodejs headers locally rather that download them form https://nodejs.org.
  # This is important when build nodejs packages in sandbox.
  makeWrapperArgs = [ "--set npm_config_nodedir ${nodejs}" ];

  passthru.updateScript = ./update.sh;

  meta = {
    changelog = "https://github.com/nodejs/node-gyp/blob/${src.rev}/CHANGELOG.md";
    description = "Node.js native addon build tool";
    homepage = "https://github.com/nodejs/node-gyp";
    license = lib.licenses.mit;
    mainProgram = "node-gyp";
    maintainers = with lib.maintainers; [ dotlambda ];
  };
}
+26 −0
Original line number Diff line number Diff line
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p gnused jq nix-prefetch-github nodejs prefetch-npm-deps wget

set -euo pipefail
pushd "$(dirname "${BASH_SOURCE[0]}")"

version=$(npm view node-gyp version)

if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
    echo "Already up to date!"
    exit 0
fi

sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix

src_hash=$(nix-prefetch-github nodejs node-gyp --rev "v$version" | jq --raw-output .hash)
sed -i 's#hash = "[^"]*"#hash = "'"$src_hash"'"#' package.nix

rm -f package-lock.json package.json
wget "https://github.com/nodejs/node-gyp/raw/v$version/package.json"
npm i --package-lock-only --ignore-scripts
npm_hash=$(prefetch-npm-deps package-lock.json)
sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' package.nix
rm package.json

popd
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
, Security
, AppKit
, pkg-config
, nodePackages
, node-gyp
, runCommand
, vscode-js-debug
, nix-update-script
@@ -29,7 +29,7 @@ buildNpmPackage rec {

  nativeBuildInputs = [
    pkg-config
    nodePackages.node-gyp
    node-gyp
  ] ++ lib.optionals stdenv.isDarwin [ xcbuild ];

  buildInputs =
Loading