From 7f55664079f99883f910b672fe5ede77e0284277 Mon Sep 17 00:00:00 2001 From: piegames Date: Fri, 9 Jul 2021 00:42:03 +0200 Subject: [PATCH] nodePackages.node2nix: Remove `node_` prefix in buildNodePackage Fixes #127137 This greatly improves compatibility with repology.org. As a side effect, more packages will be supported by automatic update tools --- pkgs/development/node-packages/default.nix | 27 ++++++++++++++++++++- pkgs/development/node-packages/node-env.nix | 10 ++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pkgs/development/node-packages/default.nix b/pkgs/development/node-packages/default.nix index 19fff0c71f78..270574257e85 100644 --- a/pkgs/development/node-packages/default.nix +++ b/pkgs/development/node-packages/default.nix @@ -1,4 +1,4 @@ -{ pkgs, nodejs, stdenv, fetchFromGitHub }: +{ pkgs, nodejs, stdenv, applyPatches, fetchFromGitHub, fetchpatch }: let since = (version: pkgs.lib.versionAtLeast nodejs.version version); @@ -160,6 +160,31 @@ let node2nix = super.node2nix.override { buildInputs = [ pkgs.makeWrapper ]; + # We need to apply a patch to the source, but buildNodePackage doesn't allow patches. + # So we pin the patched commit instead. The commit actually contains two other newer commits + # since the last (1.9.0) release, but actually this is a good thing since one of them is a + # Hydra-specific fix. + src = applyPatches { + src = fetchFromGitHub { + owner = "svanderburg"; + repo = "node2nix"; + rev = "node2nix-1.9.0"; + sha256 = "0l4wp1131nhl9c14cn8bwawb8f77h1nfbnswgi5lp5m3kzkb27jn"; + }; + + patches = [ + # remove node_ name prefix + (fetchpatch { + url = "https://github.com/svanderburg/node2nix/commit/b54d45207427ff46e90f16f2f32771fdc8bff5a4.patch"; + sha256 = "03cg2xwryvdlvg299dg91qxicrw2r43grja80an9zkb875ps8jxh"; + }) + # set meta platform + (fetchpatch { + url = "https://github.com/svanderburg/node2nix/commit/58736093161f2d237c17e75a96529b018cd0ac64.patch"; + sha256 = "1c91qfqa6p4hzyafv5pq6rpgnny2805n007b1443gbqwrz5awz6n"; + }) + ]; + }; postInstall = '' wrapProgram "$out/bin/node2nix" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nix ]} ''; diff --git a/pkgs/development/node-packages/node-env.nix b/pkgs/development/node-packages/node-env.nix index c2b723195b77..21089c4d5459 100644 --- a/pkgs/development/node-packages/node-env.nix +++ b/pkgs/development/node-packages/node-env.nix @@ -391,13 +391,14 @@ let , dontStrip ? true , unpackPhase ? "true" , buildPhase ? "true" + , meta ? {} , ... }@args: let - extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ]; + extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ]; in stdenv.mkDerivation ({ - name = "node_${name}-${version}"; + name = "${name}-${version}"; buildInputs = [ tarWrapper python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ lib.optional (stdenv.isDarwin) libtool @@ -446,6 +447,11 @@ let # Run post install hook, if provided runHook postInstall ''; + + meta = { + # default to Node.js' platforms + platforms = nodejs.meta.platforms; + } // meta; } // extraArgs); # Builds a node environment (a node_modules folder and a set of binaries)